@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * Establishes a connection to the LDAP server and sets the protocol version |
30 | 30 | * |
31 | - * @return resource ldap link identifier or false |
|
31 | + * @return boolean ldap link identifier or false |
|
32 | 32 | * @author ndiechburg <[email protected]> |
33 | 33 | * */ |
34 | 34 | function extldap_connect() |
@@ -77,6 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * Authenticate user on external ldap server and return user ldap entry if that succeeds |
79 | 79 | * |
80 | + * @param string $password |
|
80 | 81 | * @return mixed false if user cannot authenticate on ldap, user ldap entry if tha succeeds |
81 | 82 | * @author ndiechburg <[email protected]> |
82 | 83 | * Modified by [email protected] |
@@ -237,7 +238,7 @@ discard block |
||
237 | 238 | |
238 | 239 | /** |
239 | 240 | * Imports all LDAP users into Chamilo |
240 | - * @return bool false on error, true otherwise |
|
241 | + * @return false|null false on error, true otherwise |
|
241 | 242 | */ |
242 | 243 | function extldap_import_all_users() |
243 | 244 | { |
@@ -303,7 +303,7 @@ |
||
303 | 303 | |
304 | 304 | // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that. |
305 | 305 | $passwordKey = isset($extldap_user_correspondance['password']) ? $extldap_user_correspondance['password'] : 'userPassword'; |
306 | - $password = $data[$passwordKey][0]; |
|
306 | + $password = $data[$passwordKey][0]; |
|
307 | 307 | |
308 | 308 | // To ease management, we add the step-year (etape-annee) code |
309 | 309 | //$official_code = $etape."-".$annee; |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * Creates the 'shibb_unique_id' field in the table 'user' of the main Chamilo database if it doesn't exist yet |
36 | 36 | * |
37 | 37 | * @author Nicolas Rod |
38 | - * @return void |
|
38 | + * @return false|null |
|
39 | 39 | */ |
40 | 40 | public static function create_shibb_unique_id_field_if_missing() |
41 | 41 | { |
@@ -346,6 +346,9 @@ |
||
346 | 346 | return $result; |
347 | 347 | } |
348 | 348 | |
349 | + /** |
|
350 | + * @param string $sql |
|
351 | + */ |
|
349 | 352 | protected function execute($sql) |
350 | 353 | { |
351 | 354 | return Database::query($sql, null, __FILE__); |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | |
247 | 247 | $db_name = $this->get_db_name($object); |
248 | 248 | $sql = "INSERT INTO `{$db_name}`.`{$this->table_name}` "; |
249 | - $sql .= ' (' . join(', ', $keys) . ') '; |
|
249 | + $sql .= ' ('.join(', ', $keys).') '; |
|
250 | 250 | $sql .= 'VALUES'; |
251 | - $sql .= ' (' . join(', ', $values) . ') '; |
|
251 | + $sql .= ' ('.join(', ', $values).') '; |
|
252 | 252 | |
253 | 253 | $result = $this->execute($sql); |
254 | 254 | if ($result) |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $items = array(); |
296 | 296 | foreach ($args as $key => $val) |
297 | 297 | { |
298 | - $items[] = $key . ' = ' . $this->format_value($val); |
|
298 | + $items[] = $key.' = '.$this->format_value($val); |
|
299 | 299 | } |
300 | 300 | return implode(' AND ', $items); |
301 | 301 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Validates the received active connection data with the database |
93 | - * @return bool Return the loginFailed variable value to local.inc.php |
|
93 | + * @return null|false Return the loginFailed variable value to local.inc.php |
|
94 | 94 | */ |
95 | 95 | public function check_user() |
96 | 96 | { |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class ssoDrupal |
24 | 24 | { |
25 | - public $protocol; // 'http://', |
|
26 | - public $domain; // 'localhost/project/drupal', |
|
27 | - public $auth_uri; // '/?q=user', |
|
25 | + public $protocol; // 'http://', |
|
26 | + public $domain; // 'localhost/project/drupal', |
|
27 | + public $auth_uri; // '/?q=user', |
|
28 | 28 | public $deauth_uri; // '/?q=logout', |
29 | - public $referer; // http://my.chamilo.com/main/auth/profile.php |
|
29 | + public $referer; // http://my.chamilo.com/main/auth/profile.php |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Instanciates the object, initializing all relevant URL strings |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | && ($sso['username'] == $uData['username'])) { |
124 | 124 | |
125 | 125 | //Check if the account is active (not locked) |
126 | - if ($uData['active']=='1') { |
|
126 | + if ($uData['active'] == '1') { |
|
127 | 127 | // check if the expiration date has not been reached |
128 | - if (empty($uData['expiration_date']) OR $uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') { |
|
128 | + if (empty($uData['expiration_date']) OR $uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date'] == '0000-00-00 00:00:00') { |
|
129 | 129 | |
130 | 130 | //If Multiple URL is enabled |
131 | 131 | if (api_get_multiple_access_url()) { |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | // the user credentials are OK, which |
159 | 159 | // should be protection enough |
160 | 160 | // against evil URL spoofing... |
161 | - $sso_target = api_get_path(WEB_PATH) . base64_decode($sso['ruri']); |
|
161 | + $sso_target = api_get_path(WEB_PATH).base64_decode($sso['ruri']); |
|
162 | 162 | } else { |
163 | - $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) . 'index.php'; |
|
163 | + $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH).'index.php'; |
|
164 | 164 | } |
165 | - header('Location: '. $sso_target); |
|
165 | + header('Location: '.$sso_target); |
|
166 | 166 | exit; |
167 | 167 | } else { |
168 | 168 | // user does not have permission for this site |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | // If this is an administrator, allow him to make some changes in |
280 | 280 | // the Chamilo profile |
281 | 281 | if ($asAdmin && api_is_platform_admin(true)) { |
282 | - return api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=$userId"; |
|
282 | + return api_get_path(WEB_CODE_PATH)."admin/user_edit.php?user_id=$userId"; |
|
283 | 283 | } |
284 | 284 | // If the user doesn't match a Drupal user, give the normal profile |
285 | 285 | // link |
286 | 286 | if ($drupalUserIdData === false) { |
287 | - return api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; |
|
287 | + return api_get_path(WEB_CODE_PATH).'auth/profile.php'; |
|
288 | 288 | } |
289 | 289 | // In all other cases, generate a link to the Drupal profile edition |
290 | 290 | $drupalUserId = $drupalUserIdData['value']; |
@@ -327,6 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Serialize the course with the best serializer available |
330 | + * @return string |
|
330 | 331 | */ |
331 | 332 | public static function serialize($course) |
332 | 333 | { |
@@ -339,6 +340,7 @@ discard block |
||
339 | 340 | |
340 | 341 | /** |
341 | 342 | * Unserialize the course with the best serializer available |
343 | + * @param string $course |
|
342 | 344 | */ |
343 | 345 | public static function unserialize($course) |
344 | 346 | { |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | if (is_array($resources)) { |
41 | 41 | foreach ($resources as $resource) { |
42 | 42 | Coursecopy\Resource::setClassType($resource); |
43 | - if ($resource->links_to($resource_to_check) ) { |
|
43 | + if ($resource->links_to($resource_to_check)) { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | - if ($type == RESOURCE_LEARNPATH && get_class($resource)=='CourseCopyLearnpath') { |
|
46 | + if ($type == RESOURCE_LEARNPATH && get_class($resource) == 'CourseCopyLearnpath') { |
|
47 | 47 | if ($resource->has_item($resource_to_check)) { |
48 | 48 | return true; |
49 | 49 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function has_resources($resource_type = null) |
72 | 72 | { |
73 | - if( $resource_type != null) { |
|
73 | + if ($resource_type != null) { |
|
74 | 74 | return isset($this->resources[$resource_type]) && is_array($this->resources[$resource_type]) && (count( |
75 | 75 | $this->resources[$resource_type] |
76 | 76 | ) > 0); |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | $description = $resource->content; |
178 | 178 | break; |
179 | 179 | case RESOURCE_THEMATIC: |
180 | - $title = $resource->title; |
|
181 | - $description = $resource->content; |
|
180 | + $title = $resource->title; |
|
181 | + $description = $resource->content; |
|
182 | 182 | break; |
183 | 183 | case RESOURCE_ATTENDANCE: |
184 | - $title = $resource->params['name']; |
|
185 | - $description = $resource->params['description']; |
|
184 | + $title = $resource->params['name']; |
|
185 | + $description = $resource->params['description']; |
|
186 | 186 | break; |
187 | 187 | case RESOURCE_WORK: |
188 | 188 | $title = $resource->title; |
@@ -173,7 +173,7 @@ |
||
173 | 173 | |
174 | 174 | /** |
175 | 175 | * @param array $file |
176 | - * @return bool|string |
|
176 | + * @return string|false |
|
177 | 177 | */ |
178 | 178 | public static function import_uploaded_file($file) |
179 | 179 | { |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | while (($file = readdir($handle)) !== false) { |
24 | 24 | if ($file != "." && $file != ".." && |
25 | 25 | strpos($file, 'CourseArchiver_') === 0 && |
26 | - is_dir($dir . '/' . $file) |
|
26 | + is_dir($dir.'/'.$file) |
|
27 | 27 | ) { |
28 | - rmdirr($dir . '/' . $file); |
|
28 | + rmdirr($dir.'/'.$file); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | closedir($handle); |
@@ -43,48 +43,48 @@ discard block |
||
43 | 43 | CourseArchiver::clean_backup_dir(); |
44 | 44 | |
45 | 45 | // Create a temp directory |
46 | - $tmp_dir_name = 'CourseArchiver_' . api_get_unique_id(); |
|
47 | - $backup_dir = api_get_path(SYS_ARCHIVE_PATH) . $tmp_dir_name . '/'; |
|
46 | + $tmp_dir_name = 'CourseArchiver_'.api_get_unique_id(); |
|
47 | + $backup_dir = api_get_path(SYS_ARCHIVE_PATH).$tmp_dir_name.'/'; |
|
48 | 48 | |
49 | 49 | // All course-information will be stored in course_info.dat |
50 | - $course_info_file = $backup_dir . 'course_info.dat'; |
|
50 | + $course_info_file = $backup_dir.'course_info.dat'; |
|
51 | 51 | $zip_dir = api_get_path(SYS_ARCHIVE_PATH); |
52 | 52 | $user = api_get_user_info(); |
53 | 53 | $date = new DateTime(api_get_local_time()); |
54 | - $zip_file = $user['user_id'] . '_' . $course->code . '_' . $date->format('Ymd-His') . '.zip'; |
|
54 | + $zip_file = $user['user_id'].'_'.$course->code.'_'.$date->format('Ymd-His').'.zip'; |
|
55 | 55 | $php_errormsg = ''; |
56 | 56 | $res = @mkdir($backup_dir, $perm_dirs); |
57 | 57 | if ($res === false) { |
58 | 58 | //TODO set and handle an error message telling the user to review the permissions on the archive directory |
59 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini') . ' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0); |
|
59 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0); |
|
60 | 60 | } |
61 | 61 | // Write the course-object to the file |
62 | 62 | $fp = @fopen($course_info_file, 'w'); |
63 | 63 | if ($fp === false) { |
64 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
64 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $res = @fwrite($fp, base64_encode(serialize($course))); |
68 | 68 | if ($res === false) { |
69 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
69 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $res = @fclose($fp); |
73 | 73 | if ($res === false) { |
74 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
74 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Copy all documents to the temp-dir |
78 | 78 | if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) { |
79 | 79 | foreach ($course->resources[RESOURCE_DOCUMENT] as $document) { |
80 | 80 | if ($document->file_type == DOCUMENT) { |
81 | - $doc_dir = $backup_dir . $document->path; |
|
81 | + $doc_dir = $backup_dir.$document->path; |
|
82 | 82 | @mkdir(dirname($doc_dir), $perm_dirs, true); |
83 | - if (file_exists($course->path . $document->path)) { |
|
84 | - copy($course->path . $document->path, $doc_dir); |
|
83 | + if (file_exists($course->path.$document->path)) { |
|
84 | + copy($course->path.$document->path, $doc_dir); |
|
85 | 85 | } |
86 | 86 | } else { |
87 | - @mkdir($backup_dir . $document->path, $perm_dirs, true); |
|
87 | + @mkdir($backup_dir.$document->path, $perm_dirs, true); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
@@ -92,49 +92,49 @@ discard block |
||
92 | 92 | // Copy all scorm documents to the temp-dir |
93 | 93 | if (isset($course->resources[RESOURCE_SCORM]) && is_array($course->resources[RESOURCE_SCORM])) { |
94 | 94 | foreach ($course->resources[RESOURCE_SCORM] as $document) { |
95 | - $doc_dir = dirname($backup_dir . $document->path); |
|
95 | + $doc_dir = dirname($backup_dir.$document->path); |
|
96 | 96 | @mkdir($doc_dir, $perm_dirs, true); |
97 | - copyDirTo($course->path . $document->path, $doc_dir, false); |
|
97 | + copyDirTo($course->path.$document->path, $doc_dir, false); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | // Copy calendar attachments. |
102 | 102 | |
103 | 103 | if (isset($course->resources[RESOURCE_EVENT]) && is_array($course->resources[RESOURCE_EVENT])) { |
104 | - $doc_dir = dirname($backup_dir . '/upload/calendar/'); |
|
104 | + $doc_dir = dirname($backup_dir.'/upload/calendar/'); |
|
105 | 105 | @mkdir($doc_dir, $perm_dirs, true); |
106 | - copyDirTo($course->path . 'upload/calendar/', $doc_dir, false); |
|
106 | + copyDirTo($course->path.'upload/calendar/', $doc_dir, false); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Copy Learning path author image. |
110 | 110 | if (isset($course->resources[RESOURCE_LEARNPATH]) && is_array($course->resources[RESOURCE_LEARNPATH])) { |
111 | - $doc_dir = dirname($backup_dir . '/upload/learning_path/'); |
|
111 | + $doc_dir = dirname($backup_dir.'/upload/learning_path/'); |
|
112 | 112 | @mkdir($doc_dir, $perm_dirs, true); |
113 | - copyDirTo($course->path . 'upload/learning_path/', $doc_dir, false); |
|
113 | + copyDirTo($course->path.'upload/learning_path/', $doc_dir, false); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // Copy announcements attachments. |
117 | 117 | if (isset($course->resources[RESOURCE_ANNOUNCEMENT]) && is_array($course->resources[RESOURCE_ANNOUNCEMENT])) { |
118 | - $doc_dir = dirname($backup_dir . '/upload/announcements/'); |
|
118 | + $doc_dir = dirname($backup_dir.'/upload/announcements/'); |
|
119 | 119 | @mkdir($doc_dir, $perm_dirs, true); |
120 | - copyDirTo($course->path . 'upload/announcements/', $doc_dir, false); |
|
120 | + copyDirTo($course->path.'upload/announcements/', $doc_dir, false); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Copy work folders (only folders) |
124 | 124 | if (isset($course->resources[RESOURCE_WORK]) && is_array($course->resources[RESOURCE_WORK])) { |
125 | - $doc_dir = dirname($backup_dir . '/upload/work/'); |
|
125 | + $doc_dir = dirname($backup_dir.'/upload/work/'); |
|
126 | 126 | @mkdir($doc_dir, $perm_dirs, true); |
127 | 127 | // @todo: adjust to only create subdirs, but not copy files |
128 | - copyDirTo($course->path . 'upload/work/', $doc_dir, false); |
|
128 | + copyDirTo($course->path.'upload/work/', $doc_dir, false); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Zip the course-contents |
132 | - $zip = new PclZip($zip_dir . $zip_file); |
|
133 | - $zip->create($zip_dir . $tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir . $tmp_dir_name . '/'); |
|
132 | + $zip = new PclZip($zip_dir.$zip_file); |
|
133 | + $zip->create($zip_dir.$tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir.$tmp_dir_name.'/'); |
|
134 | 134 | //$zip->deleteByIndex(0); |
135 | 135 | // Remove the temp-dir. |
136 | 136 | rmdirr($backup_dir); |
137 | - return '' . $zip_file; |
|
137 | + return ''.$zip_file; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | global $dateTimeFormatLong; |
147 | 147 | $backup_files = array(); |
148 | - $dirname = api_get_path(SYS_ARCHIVE_PATH) . ''; |
|
148 | + $dirname = api_get_path(SYS_ARCHIVE_PATH).''; |
|
149 | 149 | if ($dir = opendir($dirname)) { |
150 | 150 | while (($file = readdir($dir)) !== false) { |
151 | 151 | $file_parts = explode('_', $file); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $date = $file_parts[0]; |
157 | 157 | $ext = isset($file_parts[1]) ? $file_parts[1] : null; |
158 | 158 | if ($ext == 'zip' && ($user_id != null && $owner_id == $user_id || $user_id == null)) { |
159 | - $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 9, 2) . ':' . substr($date, 11, 2) . ':' . substr($date, 13, 2); |
|
159 | + $date = substr($date, 0, 4).'-'.substr($date, 4, 2).'-'.substr($date, 6, 2).' '.substr($date, 9, 2).':'.substr($date, 11, 2).':'.substr($date, 13, 2); |
|
160 | 160 | $backup_files[] = array( |
161 | 161 | 'file' => $file, |
162 | 162 | 'date' => $date, |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public static function import_uploaded_file($file) |
179 | 179 | { |
180 | - $new_filename = uniqid('') . '.zip'; |
|
180 | + $new_filename = uniqid('').'.zip'; |
|
181 | 181 | $new_dir = api_get_path(SYS_ARCHIVE_PATH); |
182 | 182 | if (is_dir($new_dir) && is_writable($new_dir)) { |
183 | 183 | move_uploaded_file($file, api_get_path(SYS_ARCHIVE_PATH).$new_filename); |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | { |
201 | 201 | CourseArchiver::clean_backup_dir(); |
202 | 202 | // Create a temp directory |
203 | - $tmp_dir_name = 'CourseArchiver_' . uniqid(''); |
|
204 | - $unzip_dir = api_get_path(SYS_ARCHIVE_PATH) . '' . $tmp_dir_name; |
|
203 | + $tmp_dir_name = 'CourseArchiver_'.uniqid(''); |
|
204 | + $unzip_dir = api_get_path(SYS_ARCHIVE_PATH).''.$tmp_dir_name; |
|
205 | 205 | @mkdir($unzip_dir, api_get_permissions_for_new_directories(), true); |
206 | - @copy(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename, $unzip_dir . '/backup.zip'); |
|
206 | + @copy(api_get_path(SYS_ARCHIVE_PATH).''.$filename, $unzip_dir.'/backup.zip'); |
|
207 | 207 | // unzip the archive |
208 | - $zip = new PclZip($unzip_dir . '/backup.zip'); |
|
208 | + $zip = new PclZip($unzip_dir.'/backup.zip'); |
|
209 | 209 | @chdir($unzip_dir); |
210 | 210 | $zip->extract(PCLZIP_OPT_TEMP_FILE_ON); |
211 | 211 | // remove the archive-file |
212 | 212 | if ($delete) { |
213 | - @unlink(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename); |
|
213 | + @unlink(api_get_path(SYS_ARCHIVE_PATH).''.$filename); |
|
214 | 214 | } |
215 | 215 | // read the course |
216 | 216 | if (!is_file('course_info.dat')) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * @param array $array |
|
94 | + * @param string[] $array |
|
95 | 95 | */ |
96 | 96 | public function set_tools_to_build($array) |
97 | 97 | { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string $courseCode |
124 | 124 | * @param bool true if you want to get the elements that exists in the course and |
125 | 125 | * in the session, (session_id = 0 or session_id = X) |
126 | - * @return object The course object structure |
|
126 | + * @return Course The course object structure |
|
127 | 127 | */ |
128 | 128 | public function build( |
129 | 129 | $session_id = 0, |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | $table_doc = Database:: get_course_table(TABLE_DOCUMENT); |
596 | 596 | |
597 | 597 | if (!empty($courseId) && !empty($session_id)) { |
598 | - $session_id = intval($session_id); |
|
598 | + $session_id = intval($session_id); |
|
599 | 599 | if ($with_base_content) { |
600 | 600 | $session_condition = api_get_session_condition( |
601 | 601 | $session_id, |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | 'title' => get_lang('OrphanQuestions', ''), |
805 | 805 | 'type' => 2 |
806 | 806 | ); |
807 | - $newQuiz = new Quiz((object)$obj); |
|
807 | + $newQuiz = new Quiz((object) $obj); |
|
808 | 808 | if (!empty($orphanQuestionIds)) { |
809 | 809 | foreach ($orphanQuestionIds as $index => $orphanId) { |
810 | 810 | $order = $index + 1; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | /** |
15 | 15 | * Display the form |
16 | - * @param array $hidden_fiels Hidden fields to add to the form. |
|
16 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
17 | 17 | * @param boolean the document array will be serialize. This is used in the course_copy.php file |
18 | 18 | */ |
19 | 19 | static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | |
571 | 571 | /** |
572 | 572 | * Display the form session export |
573 | - * @param array $hidden_fiels Hidden fields to add to the form. |
|
573 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
574 | 574 | * @param boolean the document array will be serialize. This is used in the course_copy.php file |
575 | 575 | */ |
576 | 576 | public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | |
137 | 137 | //get destination course title |
138 | 138 | if (!empty($hidden_fields['destination_course'])) { |
139 | - $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name( |
|
139 | + $sessionTitle = !empty($hidden_fields['destination_session']) ? ' ('.api_get_session_name( |
|
140 | 140 | $hidden_fields['destination_session'] |
141 | - ) . ')' : null; |
|
141 | + ).')' : null; |
|
142 | 142 | |
143 | 143 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
144 | 144 | echo '<h3>'; |
145 | - echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
145 | + echo get_lang('DestinationCourse').' : '.$course_infos['title'].' ('.$course_infos['code'].') '.$sessionTitle; |
|
146 | 146 | echo '</h3>'; |
147 | 147 | } |
148 | 148 | echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
299 | 299 | (when there are directories with hundred/thousand of files) */ |
300 | 300 | // this is a known issue of serialize |
301 | - $course->resources['document']= null; |
|
301 | + $course->resources['document'] = null; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | Display::display_warning_message(get_lang('NoDataAvailable')); |
316 | 316 | } else { |
317 | 317 | if (!empty($hidden_fields['destination_session'])) { |
318 | - echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
318 | + echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
319 | 319 | get_lang('Ok').'</button>'; |
320 | 320 | } else { |
321 | 321 | if ($recycleOption) { |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | static function display_hidden_quiz_questions($course) |
341 | 341 | { |
342 | - if(is_array($course->resources)){ |
|
342 | + if (is_array($course->resources)) { |
|
343 | 343 | foreach ($course->resources as $type => $resources) { |
344 | 344 | if (count($resources) > 0) { |
345 | 345 | switch ($type) { |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | */ |
360 | 360 | static function display_hidden_scorm_directories($course) |
361 | 361 | { |
362 | - if (is_array($course->resources)){ |
|
362 | + if (is_array($course->resources)) { |
|
363 | 363 | foreach ($course->resources as $type => $resources) { |
364 | 364 | if (count($resources) > 0) { |
365 | - switch($type) { |
|
365 | + switch ($type) { |
|
366 | 366 | case RESOURCE_SCORM: |
367 | 367 | foreach ($resources as $id => $resource) { |
368 | 368 | echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | if (is_array($resource)) { |
409 | 409 | $resource = array_keys($resource); |
410 | 410 | |
411 | - foreach ($resource as $resource_item) { |
|
411 | + foreach ($resource as $resource_item) { |
|
412 | 412 | |
413 | 413 | $condition_session = ''; |
414 | 414 | if (!empty($session_id)) { |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | tool = '".RESOURCE_DOCUMENT."' AND |
445 | 445 | ref = $resource_item "; |
446 | 446 | $res = Database::query($sql); |
447 | - $all_properties = array (); |
|
448 | - while ($item_property = Database::fetch_array($res,'ASSOC')) { |
|
447 | + $all_properties = array(); |
|
448 | + while ($item_property = Database::fetch_array($res, 'ASSOC')) { |
|
449 | 449 | $all_properties[] = $item_property; |
450 | 450 | } |
451 | 451 | $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | |
461 | 461 | switch ($type) { |
462 | 462 | case RESOURCE_SURVEYQUESTION: |
463 | - foreach($resources as $id => $obj) { |
|
463 | + foreach ($resources as $id => $obj) { |
|
464 | 464 | if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
465 | 465 | is_array($_POST['resource'][RESOURCE_SURVEY]) && |
466 | 466 | !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY])) |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | ) { |
536 | 536 | foreach ($documents as $id_to_check => $post_value) { |
537 | 537 | $obj_to_check = $resources[$id_to_check]; |
538 | - $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
538 | + $shared_path_part = substr($obj_to_check->path, 0, strlen($obj->path)); |
|
539 | 539 | if ($id_to_check != $id && $obj->path == $shared_path_part) { |
540 | 540 | $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
541 | 541 | break; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
550 | 550 | // check if document is in a quiz (audio/video) |
551 | 551 | if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
552 | - foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
552 | + foreach ($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
553 | 553 | $quiz = $quiz->obj; |
554 | 554 | if (isset($quiz->media) && $quiz->media == $id) { |
555 | 555 | $resource_is_used_elsewhere = true; |
@@ -618,15 +618,15 @@ discard block |
||
618 | 618 | <?php |
619 | 619 | |
620 | 620 | //get destination course title |
621 | - if(!empty($hidden_fields['destination_course'])) { |
|
621 | + if (!empty($hidden_fields['destination_course'])) { |
|
622 | 622 | if (!empty($hidden_fields['destination_session'])) { |
623 | - $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
623 | + $sessionTitle = ' ('.api_get_session_name($hidden_fields['destination_session']).')'; |
|
624 | 624 | } else { |
625 | 625 | $sessionTitle = null; |
626 | 626 | } |
627 | 627 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
628 | 628 | echo '<h3>'; |
629 | - echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
629 | + echo get_lang('DestinationCourse').' : '.$course_infos['title'].$sessionTitle; |
|
630 | 630 | echo '</h3>'; |
631 | 631 | } |
632 | 632 | |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
635 | 635 | echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
636 | 636 | echo '<input type="hidden" name="action" value="course_select_form"/>'; |
637 | - foreach ($list_course as $course){ |
|
637 | + foreach ($list_course as $course) { |
|
638 | 638 | foreach ($course->resources as $type => $resources) { |
639 | 639 | if (count($resources) > 0) { |
640 | 640 | echo '<img id="img_'.$course->code.'" src="../img/1.gif" onclick="javascript:exp('."'$course->code'".');" />'; |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | if ($avoid_serialize) { |
663 | 663 | //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
664 | 664 | // this is a known issue of serialize |
665 | - $course->resources['document']= null; |
|
665 | + $course->resources['document'] = null; |
|
666 | 666 | } |
667 | 667 | echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
668 | 668 | if (is_array($hidden_fields)) { |
@@ -280,6 +280,7 @@ |
||
280 | 280 | } |
281 | 281 | /** |
282 | 282 | * Get dummy titles, descriptions and texts |
283 | + * @param string $type |
|
283 | 284 | */ |
284 | 285 | function get_dummy_content($type) |
285 | 286 | { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $this->default_property['to_user_id'] = null; |
43 | 43 | $this->default_property['visibility'] = '1'; |
44 | 44 | $this->default_property['start_visible'] = '0000-00-00 00:00:00'; |
45 | - $this->default_property['end_visible'] = '0000-00-00 00:00:00'; |
|
45 | + $this->default_property['end_visible'] = '0000-00-00 00:00:00'; |
|
46 | 46 | |
47 | 47 | $course = api_get_course_info($course_code); |
48 | 48 | $this->course = new Course(); |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | $course = api_get_course_info(); |
69 | 69 | $course_doc_path = $this->course->backup_path.'/document/'; |
70 | 70 | $number_of_documents = rand(10, 30); |
71 | - $extensions = array ('html', 'doc'); |
|
71 | + $extensions = array('html', 'doc'); |
|
72 | 72 | $directories = array(); |
73 | 73 | $property = $this->default_property; |
74 | 74 | $property['lastedit_type'] = 'DocumentAdded'; |
75 | 75 | $property['tool'] = TOOL_DOCUMENT; |
76 | 76 | $doc_id = 0; |
77 | - for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++) |
|
77 | + for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id++) |
|
78 | 78 | { |
79 | 79 | $path = ''; |
80 | 80 | $doc_type = rand(0, count($extensions) - 1); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension; |
83 | 83 | $content = $this->get_dummy_content('text'); |
84 | 84 | $dirs = rand(0, 3); |
85 | - for ($i = 0; $i < $dirs; $i ++) |
|
85 | + for ($i = 0; $i < $dirs; $i++) |
|
86 | 86 | { |
87 | 87 | $path .= 'directory/'; |
88 | 88 | $directories[$path] = 1; |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | fwrite($fp, $content); |
98 | 98 | fclose($fp); |
99 | 99 | $size = filesize($file); |
100 | - $document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size); |
|
100 | + $document = new Document($doc_id, '/'.$path.$filename, $this->get_dummy_content('description'), $this->get_dummy_content('title'), 'file', $size); |
|
101 | 101 | $document->item_properties[] = $property; |
102 | 102 | $this->course->add_resource($document); |
103 | 103 | } |
104 | - foreach($directories as $path => $flag) |
|
104 | + foreach ($directories as $path => $flag) |
|
105 | 105 | { |
106 | - $path = substr($path,0,strlen($path)-1); |
|
107 | - $document = new Document($doc_id++,'/'.$path, $this->get_dummy_content('description'),$this->get_dummy_content('title'),'folder',0); |
|
106 | + $path = substr($path, 0, strlen($path) - 1); |
|
107 | + $document = new Document($doc_id++, '/'.$path, $this->get_dummy_content('description'), $this->get_dummy_content('title'), 'folder', 0); |
|
108 | 108 | $property['lastedit_type'] = 'FolderCreated'; |
109 | 109 | $document->item_properties[] = $property; |
110 | 110 | $this->course->add_resource($document); |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | $property['lastedit_type'] = 'AnnouncementAdded'; |
120 | 120 | $property['tool'] = TOOL_ANNOUNCEMENT; |
121 | 121 | $number_of_announcements = rand(10, 30); |
122 | - for ($i = 0; $i < $number_of_announcements; $i ++) |
|
122 | + for ($i = 0; $i < $number_of_announcements; $i++) |
|
123 | 123 | { |
124 | 124 | $time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y'))); |
125 | 125 | $date = date('Y-m-d', $time); |
126 | - $announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0); |
|
126 | + $announcement = new Announcement($i, $this->get_dummy_content('title'), $this->get_dummy_content('text'), $date, 0); |
|
127 | 127 | $announcement->item_properties[] = $property; |
128 | 128 | $this->course->add_resource($announcement); |
129 | 129 | } |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | $property = $this->default_property; |
138 | 138 | $property['lastedit_type'] = 'AgendaAdded'; |
139 | 139 | $property['tool'] = TOOL_CALENDAR_EVENT; |
140 | - for ($i = 0; $i < $number_of_events; $i ++) |
|
140 | + for ($i = 0; $i < $number_of_events; $i++) |
|
141 | 141 | { |
142 | - $hour = rand(1,24); |
|
143 | - $minute = rand(1,60); |
|
144 | - $second = rand(1,60); |
|
145 | - $day = rand(1,28); |
|
146 | - $month = rand(1,12); |
|
142 | + $hour = rand(1, 24); |
|
143 | + $minute = rand(1, 60); |
|
144 | + $second = rand(1, 60); |
|
145 | + $day = rand(1, 28); |
|
146 | + $month = rand(1, 12); |
|
147 | 147 | $year = intval(date('Y')); |
148 | - $time = mktime($hour,$minute,$second,$month,$day,$year); |
|
148 | + $time = mktime($hour, $minute, $second, $month, $day, $year); |
|
149 | 149 | $start_date = date('Y-m-d H:m:s', $time); |
150 | - $hour = rand($hour,24); |
|
151 | - $minute = rand($minute,60); |
|
152 | - $second = rand($second,60); |
|
153 | - $day = rand($day,28); |
|
154 | - $month = rand($month,12); |
|
150 | + $hour = rand($hour, 24); |
|
151 | + $minute = rand($minute, 60); |
|
152 | + $second = rand($second, 60); |
|
153 | + $day = rand($day, 28); |
|
154 | + $month = rand($month, 12); |
|
155 | 155 | $year = intval(date('Y')); |
156 | - $time = mktime($hour,$minute,$second,$month,$day,$year); |
|
156 | + $time = mktime($hour, $minute, $second, $month, $day, $year); |
|
157 | 157 | $end_date = date('Y-m-d H:m:s', $time); |
158 | 158 | $event = new CalendarEvent( |
159 | 159 | $i, |
@@ -173,20 +173,20 @@ discard block |
||
173 | 173 | { |
174 | 174 | // create categorys |
175 | 175 | $number_of_categories = rand(5, 10); |
176 | - for ($i = 0; $i < $number_of_categories; $i ++) |
|
176 | + for ($i = 0; $i < $number_of_categories; $i++) |
|
177 | 177 | { |
178 | - $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i); |
|
178 | + $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $i); |
|
179 | 179 | $this->course->add_resource($linkcat); |
180 | 180 | } |
181 | 181 | // create links |
182 | 182 | $number_of_links = rand(5, 50); |
183 | - $on_homepage = rand(0,20) == 0 ? 1 : 0; |
|
183 | + $on_homepage = rand(0, 20) == 0 ? 1 : 0; |
|
184 | 184 | $property = $this->default_property; |
185 | 185 | $property['lastedit_type'] = 'LinkAdded'; |
186 | 186 | $property['tool'] = TOOL_LINK; |
187 | - for ($i = 0; $i < $number_of_links; $i ++) |
|
187 | + for ($i = 0; $i < $number_of_links; $i++) |
|
188 | 188 | { |
189 | - $link = new Link($i, $this->get_dummy_content('title'), 'http://www.google.com/search?q='.$this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(0, $number_of_categories -1),$on_homepage); |
|
189 | + $link = new Link($i, $this->get_dummy_content('title'), 'http://www.google.com/search?q='.$this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(0, $number_of_categories - 1), $on_homepage); |
|
190 | 190 | $link->item_properties[] = $property; |
191 | 191 | $this->course->add_resource($link); |
192 | 192 | } |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | $number_of_forums = rand(5, 50); |
201 | 201 | $number_of_topics = rand(30, 100); |
202 | 202 | $number_of_posts = rand(100, 1000); |
203 | - $last_forum_post = array (); |
|
204 | - $last_topic_post = array (); |
|
203 | + $last_forum_post = array(); |
|
204 | + $last_topic_post = array(); |
|
205 | 205 | // create categorys |
206 | 206 | $order = 1; |
207 | - for ($i = 1; $i <= $number_of_categories; $i ++) |
|
207 | + for ($i = 1; $i <= $number_of_categories; $i++) |
|
208 | 208 | { |
209 | 209 | $forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0); |
210 | 210 | $this->course->add_resource($forumcat); |
211 | 211 | $order++; |
212 | 212 | } |
213 | 213 | // create posts |
214 | - for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++) |
|
214 | + for ($post_id = 1; $post_id <= $number_of_posts; $post_id++) |
|
215 | 215 | { |
216 | 216 | $topic_id = rand(1, $number_of_topics); |
217 | 217 | $last_topic_post[$topic_id] = $post_id; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $this->course->add_resource($post); |
220 | 220 | } |
221 | 221 | // create topics |
222 | - for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++) |
|
222 | + for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id++) |
|
223 | 223 | { |
224 | 224 | $forum_id = rand(1, $number_of_forums); |
225 | 225 | $last_forum_post[$forum_id] = $last_topic_post[$topic_id]; |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | $this->course->add_resource($topic); |
228 | 228 | } |
229 | 229 | // create forums |
230 | - for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++) |
|
230 | + for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id++) |
|
231 | 231 | { |
232 | - $forum = new Forum($forum_id, $this->get_dummy_content('title'),$this->get_dummy_content('description'), rand(1, $number_of_categories), $last_forum_post[$forum_id]); |
|
232 | + $forum = new Forum($forum_id, $this->get_dummy_content('title'), $this->get_dummy_content('description'), rand(1, $number_of_categories), $last_forum_post[$forum_id]); |
|
233 | 233 | $this->course->add_resource($forum); |
234 | 234 | } |
235 | 235 | } |
@@ -238,25 +238,25 @@ discard block |
||
238 | 238 | */ |
239 | 239 | function create_dummy_learnpaths() |
240 | 240 | { |
241 | - $number_of_learnpaths = rand(3,5); |
|
241 | + $number_of_learnpaths = rand(3, 5); |
|
242 | 242 | $global_item_id = 1; |
243 | - for($i=1; $i<=$number_of_learnpaths;$i++) |
|
243 | + for ($i = 1; $i <= $number_of_learnpaths; $i++) |
|
244 | 244 | { |
245 | 245 | $chapters = array(); |
246 | - $number_of_chapters = rand(1,6); |
|
247 | - for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++) |
|
246 | + $number_of_chapters = rand(1, 6); |
|
247 | + for ($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++) |
|
248 | 248 | { |
249 | 249 | $chapter['name'] = $this->get_dummy_content('title'); |
250 | 250 | $chapter['description'] = $this->get_dummy_content('description'); |
251 | 251 | $chapter['display_order'] = $chapter_id; |
252 | 252 | $chapter['items'] = array(); |
253 | - $number_of_items = rand(5,20); |
|
254 | - for( $item_id = 1; $item_id<$number_of_items; $item_id++) |
|
253 | + $number_of_items = rand(5, 20); |
|
254 | + for ($item_id = 1; $item_id < $number_of_items; $item_id++) |
|
255 | 255 | { |
256 | - $types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT,RESOURCE_LINK,RESOURCE_FORUM,RESOURCE_FORUMPOST,RESOURCE_FORUMTOPIC); |
|
257 | - $type = $types[rand(0,count($types)-1)]; |
|
256 | + $types = array(RESOURCE_ANNOUNCEMENT, RESOURCE_EVENT, RESOURCE_DOCUMENT, RESOURCE_LINK, RESOURCE_FORUM, RESOURCE_FORUMPOST, RESOURCE_FORUMTOPIC); |
|
257 | + $type = $types[rand(0, count($types) - 1)]; |
|
258 | 258 | $resources = $this->course->resources[$type]; |
259 | - $resource = $resources[rand(0,count($resources)-1)]; |
|
259 | + $resource = $resources[rand(0, count($resources) - 1)]; |
|
260 | 260 | $item = array(); |
261 | 261 | $item['type'] = $resource->type; |
262 | 262 | $item['id'] = $resource->source_id; |
@@ -264,17 +264,17 @@ discard block |
||
264 | 264 | $item['title'] = $this->get_dummy_content('title'); |
265 | 265 | $item['description'] = $this->get_dummy_content('description'); |
266 | 266 | $item['ref_id'] = $global_item_id; |
267 | - if( rand(0,5) == 1 && $item_id > 1) |
|
267 | + if (rand(0, 5) == 1 && $item_id > 1) |
|
268 | 268 | { |
269 | 269 | $item['prereq_type'] = 'i'; |
270 | - $item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1); |
|
270 | + $item['prereq'] = rand($global_item_id - $item_id, $global_item_id - 1); |
|
271 | 271 | } |
272 | 272 | $chapter['items'][] = $item; |
273 | 273 | $global_item_id++; |
274 | 274 | } |
275 | 275 | $chapters[] = $chapter; |
276 | 276 | } |
277 | - $lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters); |
|
277 | + $lp = new CourseCopyLearnpath($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), 1, $chapters); |
|
278 | 278 | $this->course->add_resource($lp); |
279 | 279 | } |
280 | 280 | } |
@@ -288,20 +288,20 @@ discard block |
||
288 | 288 | Aenean ac wisi non enim aliquam scelerisque. Praesent eget mi. Vestibulum volutpat pulvinar justo. Phasellus sapien ante, pharetra id, bibendum sed, porta non, purus. Maecenas leo velit, luctus quis, porta non, feugiat sit amet, sapien. Proin vitae augue ut massa adipiscing placerat. Morbi ac risus. Proin dapibus eros egestas quam. Fusce fermentum lobortis elit. Duis lectus tellus, convallis nec, lobortis vel, accumsan ut, nunc. Nunc est. Donec ullamcorper laoreet quam. |
289 | 289 | Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse potenti. Mauris mi. Vivamus risus lacus, faucibus sit amet, sollicitudin a, blandit et, justo. In hendrerit. Sed imperdiet, eros at fringilla tempor, turpis augue semper enim, quis rhoncus nibh enim quis dui. Sed massa sapien, mattis et, laoreet sit amet, dignissim nec, urna. Integer laoreet quam quis lectus. Curabitur convallis gravida dui. Nam metus. Ut sit amet augue in nibh interdum scelerisque. Donec venenatis, lacus et pulvinar euismod, libero massa condimentum pede, commodo tristique nunc massa eu quam. Donec vulputate. Aenean in nibh. Phasellus porttitor. Donec molestie, sem ac porttitor vulputate, mauris dui egestas libero, ac lobortis dolor sem vel ligula. Nam vulputate pretium libero. Cras accumsan. Vivamus lacinia sapien sit amet elit. |
290 | 290 | Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.'; |
291 | - switch($type) |
|
291 | + switch ($type) |
|
292 | 292 | { |
293 | 293 | case 'description': |
294 | - $descriptions = explode(".",$dummy_text); |
|
295 | - return $descriptions[rand(0,count($descriptions)-1)]; |
|
294 | + $descriptions = explode(".", $dummy_text); |
|
295 | + return $descriptions[rand(0, count($descriptions) - 1)]; |
|
296 | 296 | break; |
297 | 297 | case 'title': |
298 | - $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text); |
|
299 | - $titles = explode(" ",$dummy_text); |
|
300 | - return trim($titles[rand(0,count($titles)-1)]); |
|
298 | + $dummy_text = str_replace(array("\n", '.', ',', "\t"), array(' ', '', '', ' '), $dummy_text); |
|
299 | + $titles = explode(" ", $dummy_text); |
|
300 | + return trim($titles[rand(0, count($titles) - 1)]); |
|
301 | 301 | break; |
302 | 302 | case 'text': |
303 | - $texts = explode("\n",$dummy_text); |
|
304 | - return $texts[rand(0,count($texts)-1)]; |
|
303 | + $texts = explode("\n", $dummy_text); |
|
304 | + return $texts[rand(0, count($texts) - 1)]; |
|
305 | 305 | break; |
306 | 306 | } |
307 | 307 | } |