@@ -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')) { |
@@ -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 | { |
@@ -20,289 +20,289 @@ |
||
20 | 20 | */ |
21 | 21 | class DummyCourseCreator |
22 | 22 | { |
23 | - /** |
|
24 | - * The dummy course |
|
25 | - */ |
|
26 | - public $course; |
|
27 | - /** |
|
28 | - * |
|
29 | - */ |
|
30 | - public $default_property = array(); |
|
23 | + /** |
|
24 | + * The dummy course |
|
25 | + */ |
|
26 | + public $course; |
|
27 | + /** |
|
28 | + * |
|
29 | + */ |
|
30 | + public $default_property = array(); |
|
31 | 31 | |
32 | - /** |
|
33 | - * Create the dummy course |
|
34 | - */ |
|
35 | - public function create_dummy_course($course_code) |
|
36 | - { |
|
37 | - $this->default_property['insert_user_id'] = '1'; |
|
38 | - $this->default_property['insert_date'] = date('Y-m-d H:i:s'); |
|
39 | - $this->default_property['lastedit_date'] = date('Y-m-d H:i:s'); |
|
40 | - $this->default_property['lastedit_user_id'] = '1'; |
|
41 | - $this->default_property['to_group_id'] = '0'; |
|
42 | - $this->default_property['to_user_id'] = null; |
|
43 | - $this->default_property['visibility'] = '1'; |
|
44 | - $this->default_property['start_visible'] = '0000-00-00 00:00:00'; |
|
45 | - $this->default_property['end_visible'] = '0000-00-00 00:00:00'; |
|
32 | + /** |
|
33 | + * Create the dummy course |
|
34 | + */ |
|
35 | + public function create_dummy_course($course_code) |
|
36 | + { |
|
37 | + $this->default_property['insert_user_id'] = '1'; |
|
38 | + $this->default_property['insert_date'] = date('Y-m-d H:i:s'); |
|
39 | + $this->default_property['lastedit_date'] = date('Y-m-d H:i:s'); |
|
40 | + $this->default_property['lastedit_user_id'] = '1'; |
|
41 | + $this->default_property['to_group_id'] = '0'; |
|
42 | + $this->default_property['to_user_id'] = null; |
|
43 | + $this->default_property['visibility'] = '1'; |
|
44 | + $this->default_property['start_visible'] = '0000-00-00 00:00:00'; |
|
45 | + $this->default_property['end_visible'] = '0000-00-00 00:00:00'; |
|
46 | 46 | |
47 | - $course = api_get_course_info($course_code); |
|
48 | - $this->course = new Course(); |
|
49 | - $tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid(''); |
|
50 | - @mkdir($tmp_path, api_get_permissions_for_new_directories(), true); |
|
51 | - $this->course->backup_path = $tmp_path; |
|
52 | - $this->create_dummy_links(); |
|
53 | - $this->create_dummy_events(); |
|
54 | - $this->create_dummy_forums(); |
|
55 | - $this->create_dummy_announcements(); |
|
56 | - $this->create_dummy_documents(); |
|
57 | - $this->create_dummy_learnpaths(); |
|
58 | - $cr = new CourseRestorer($this->course); |
|
59 | - $cr->set_file_option(FILE_OVERWRITE); |
|
60 | - $cr->restore($course_code); |
|
61 | - rmdirr($tmp_path); |
|
62 | - } |
|
63 | - /** |
|
64 | - * Create dummy documents |
|
65 | - */ |
|
66 | - function create_dummy_documents() |
|
67 | - { |
|
68 | - $course = api_get_course_info(); |
|
69 | - $course_doc_path = $this->course->backup_path.'/document/'; |
|
70 | - $number_of_documents = rand(10, 30); |
|
71 | - $extensions = array ('html', 'doc'); |
|
72 | - $directories = array(); |
|
73 | - $property = $this->default_property; |
|
74 | - $property['lastedit_type'] = 'DocumentAdded'; |
|
75 | - $property['tool'] = TOOL_DOCUMENT; |
|
76 | - $doc_id = 0; |
|
77 | - for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++) |
|
78 | - { |
|
79 | - $path = ''; |
|
80 | - $doc_type = rand(0, count($extensions) - 1); |
|
81 | - $extension = $extensions[$doc_type]; |
|
82 | - $filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension; |
|
83 | - $content = $this->get_dummy_content('text'); |
|
84 | - $dirs = rand(0, 3); |
|
85 | - for ($i = 0; $i < $dirs; $i ++) |
|
86 | - { |
|
87 | - $path .= 'directory/'; |
|
88 | - $directories[$path] = 1; |
|
89 | - } |
|
90 | - $dir_to_make = $course_doc_path.$path; |
|
91 | - if (!is_dir($dir_to_make)) |
|
92 | - { |
|
93 | - @mkdir($dir_to_make, api_get_permissions_for_new_directories(), true); |
|
94 | - } |
|
95 | - $file = $course_doc_path.$path.$filename; |
|
96 | - $fp = fopen($file, 'w'); |
|
97 | - fwrite($fp, $content); |
|
98 | - fclose($fp); |
|
99 | - $size = filesize($file); |
|
100 | - $document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size); |
|
101 | - $document->item_properties[] = $property; |
|
102 | - $this->course->add_resource($document); |
|
103 | - } |
|
104 | - foreach($directories as $path => $flag) |
|
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); |
|
108 | - $property['lastedit_type'] = 'FolderCreated'; |
|
109 | - $document->item_properties[] = $property; |
|
110 | - $this->course->add_resource($document); |
|
111 | - } |
|
112 | - } |
|
113 | - /** |
|
114 | - * Create dummy announcements |
|
115 | - */ |
|
116 | - function create_dummy_announcements() |
|
117 | - { |
|
118 | - $property = $this->default_property; |
|
119 | - $property['lastedit_type'] = 'AnnouncementAdded'; |
|
120 | - $property['tool'] = TOOL_ANNOUNCEMENT; |
|
121 | - $number_of_announcements = rand(10, 30); |
|
122 | - for ($i = 0; $i < $number_of_announcements; $i ++) |
|
123 | - { |
|
124 | - $time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y'))); |
|
125 | - $date = date('Y-m-d', $time); |
|
126 | - $announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0); |
|
127 | - $announcement->item_properties[] = $property; |
|
128 | - $this->course->add_resource($announcement); |
|
129 | - } |
|
130 | - } |
|
131 | - /** |
|
132 | - * Create dummy events |
|
133 | - */ |
|
134 | - function create_dummy_events() |
|
135 | - { |
|
136 | - $number_of_events = rand(10, 30); |
|
137 | - $property = $this->default_property; |
|
138 | - $property['lastedit_type'] = 'AgendaAdded'; |
|
139 | - $property['tool'] = TOOL_CALENDAR_EVENT; |
|
140 | - for ($i = 0; $i < $number_of_events; $i ++) |
|
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); |
|
147 | - $year = intval(date('Y')); |
|
148 | - $time = mktime($hour,$minute,$second,$month,$day,$year); |
|
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); |
|
155 | - $year = intval(date('Y')); |
|
156 | - $time = mktime($hour,$minute,$second,$month,$day,$year); |
|
157 | - $end_date = date('Y-m-d H:m:s', $time); |
|
158 | - $event = new CalendarEvent( |
|
159 | - $i, |
|
160 | - $this->get_dummy_content('title'), |
|
161 | - $this->get_dummy_content('text'), |
|
162 | - $start_date, |
|
163 | - $end_date |
|
164 | - ); |
|
165 | - $event->item_properties[] = $property; |
|
166 | - $this->course->add_resource($event); |
|
167 | - } |
|
168 | - } |
|
169 | - /** |
|
170 | - * Create dummy links |
|
171 | - */ |
|
172 | - function create_dummy_links() |
|
173 | - { |
|
174 | - // create categorys |
|
175 | - $number_of_categories = rand(5, 10); |
|
176 | - for ($i = 0; $i < $number_of_categories; $i ++) |
|
177 | - { |
|
178 | - $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i); |
|
179 | - $this->course->add_resource($linkcat); |
|
180 | - } |
|
181 | - // create links |
|
182 | - $number_of_links = rand(5, 50); |
|
183 | - $on_homepage = rand(0,20) == 0 ? 1 : 0; |
|
184 | - $property = $this->default_property; |
|
185 | - $property['lastedit_type'] = 'LinkAdded'; |
|
186 | - $property['tool'] = TOOL_LINK; |
|
187 | - for ($i = 0; $i < $number_of_links; $i ++) |
|
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); |
|
190 | - $link->item_properties[] = $property; |
|
191 | - $this->course->add_resource($link); |
|
192 | - } |
|
193 | - } |
|
194 | - /** |
|
195 | - * Create dummy forums |
|
196 | - */ |
|
197 | - function create_dummy_forums() |
|
198 | - { |
|
199 | - $number_of_categories = rand(2, 6); |
|
200 | - $number_of_forums = rand(5, 50); |
|
201 | - $number_of_topics = rand(30, 100); |
|
202 | - $number_of_posts = rand(100, 1000); |
|
203 | - $last_forum_post = array (); |
|
204 | - $last_topic_post = array (); |
|
205 | - // create categorys |
|
206 | - $order = 1; |
|
207 | - for ($i = 1; $i <= $number_of_categories; $i ++) |
|
208 | - { |
|
209 | - $forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0); |
|
210 | - $this->course->add_resource($forumcat); |
|
211 | - $order++; |
|
212 | - } |
|
213 | - // create posts |
|
214 | - for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++) |
|
215 | - { |
|
216 | - $topic_id = rand(1, $number_of_topics); |
|
217 | - $last_topic_post[$topic_id] = $post_id; |
|
218 | - $post = new ForumPost($post_id, $this->get_dummy_content('title'), $this->get_dummy_content('text'), date('Y-m-d H:i:s'), 1, 'Portal Administrator', 0, 0, $topic_id, 0, 1); |
|
219 | - $this->course->add_resource($post); |
|
220 | - } |
|
221 | - // create topics |
|
222 | - for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++) |
|
223 | - { |
|
224 | - $forum_id = rand(1, $number_of_forums); |
|
225 | - $last_forum_post[$forum_id] = $last_topic_post[$topic_id]; |
|
226 | - $topic = new ForumTopic($topic_id, $this->get_dummy_content('title'), '2011-03-31 12:10:00', 'Chamilo', 'Administrator', 0, $forum_id, $last_topic_post[$topic_id]); |
|
227 | - $this->course->add_resource($topic); |
|
228 | - } |
|
229 | - // create forums |
|
230 | - for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++) |
|
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]); |
|
233 | - $this->course->add_resource($forum); |
|
234 | - } |
|
235 | - } |
|
236 | - /** |
|
237 | - * Create dummy learnpaths |
|
238 | - */ |
|
239 | - function create_dummy_learnpaths() |
|
240 | - { |
|
241 | - $number_of_learnpaths = rand(3,5); |
|
242 | - $global_item_id = 1; |
|
243 | - for($i=1; $i<=$number_of_learnpaths;$i++) |
|
244 | - { |
|
245 | - $chapters = array(); |
|
246 | - $number_of_chapters = rand(1,6); |
|
247 | - for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++) |
|
248 | - { |
|
249 | - $chapter['name'] = $this->get_dummy_content('title'); |
|
250 | - $chapter['description'] = $this->get_dummy_content('description'); |
|
251 | - $chapter['display_order'] = $chapter_id; |
|
252 | - $chapter['items'] = array(); |
|
253 | - $number_of_items = rand(5,20); |
|
254 | - for( $item_id = 1; $item_id<$number_of_items; $item_id++) |
|
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)]; |
|
258 | - $resources = $this->course->resources[$type]; |
|
259 | - $resource = $resources[rand(0,count($resources)-1)]; |
|
260 | - $item = array(); |
|
261 | - $item['type'] = $resource->type; |
|
262 | - $item['id'] = $resource->source_id; |
|
263 | - $item['display_order'] = $item_id; |
|
264 | - $item['title'] = $this->get_dummy_content('title'); |
|
265 | - $item['description'] = $this->get_dummy_content('description'); |
|
266 | - $item['ref_id'] = $global_item_id; |
|
267 | - if( rand(0,5) == 1 && $item_id > 1) |
|
268 | - { |
|
269 | - $item['prereq_type'] = 'i'; |
|
270 | - $item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1); |
|
271 | - } |
|
272 | - $chapter['items'][] = $item; |
|
273 | - $global_item_id++; |
|
274 | - } |
|
275 | - $chapters[] = $chapter; |
|
276 | - } |
|
277 | - $lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters); |
|
278 | - $this->course->add_resource($lp); |
|
279 | - } |
|
280 | - } |
|
281 | - /** |
|
282 | - * Get dummy titles, descriptions and texts |
|
283 | - */ |
|
284 | - function get_dummy_content($type) |
|
285 | - { |
|
286 | - $dummy_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque lectus. Duis sodales. Vivamus et nunc. Phasellus interdum est a lorem. Fusce venenatis luctus lectus. Mauris quis turpis ac erat rhoncus suscipit. Phasellus elit dui, semper at, porta ut, egestas ac, enim. Quisque pellentesque, nisl nec consequat mollis, ipsum justo pellentesque nibh, non faucibus odio ante at lorem. Donec vitae pede ut felis ultricies semper. Suspendisse velit nibh, interdum quis, gravida nec, dapibus ac, leo. Cras id sem ut tellus tincidunt scelerisque. Aenean ac magna feugiat dolor accumsan dignissim. Integer eget nisl. |
|
47 | + $course = api_get_course_info($course_code); |
|
48 | + $this->course = new Course(); |
|
49 | + $tmp_path = api_get_path(SYS_COURSE_PATH).$course['directory'].'/document/tmp_'.uniqid(''); |
|
50 | + @mkdir($tmp_path, api_get_permissions_for_new_directories(), true); |
|
51 | + $this->course->backup_path = $tmp_path; |
|
52 | + $this->create_dummy_links(); |
|
53 | + $this->create_dummy_events(); |
|
54 | + $this->create_dummy_forums(); |
|
55 | + $this->create_dummy_announcements(); |
|
56 | + $this->create_dummy_documents(); |
|
57 | + $this->create_dummy_learnpaths(); |
|
58 | + $cr = new CourseRestorer($this->course); |
|
59 | + $cr->set_file_option(FILE_OVERWRITE); |
|
60 | + $cr->restore($course_code); |
|
61 | + rmdirr($tmp_path); |
|
62 | + } |
|
63 | + /** |
|
64 | + * Create dummy documents |
|
65 | + */ |
|
66 | + function create_dummy_documents() |
|
67 | + { |
|
68 | + $course = api_get_course_info(); |
|
69 | + $course_doc_path = $this->course->backup_path.'/document/'; |
|
70 | + $number_of_documents = rand(10, 30); |
|
71 | + $extensions = array ('html', 'doc'); |
|
72 | + $directories = array(); |
|
73 | + $property = $this->default_property; |
|
74 | + $property['lastedit_type'] = 'DocumentAdded'; |
|
75 | + $property['tool'] = TOOL_DOCUMENT; |
|
76 | + $doc_id = 0; |
|
77 | + for ($doc_id = 1; $doc_id < $number_of_documents; $doc_id ++) |
|
78 | + { |
|
79 | + $path = ''; |
|
80 | + $doc_type = rand(0, count($extensions) - 1); |
|
81 | + $extension = $extensions[$doc_type]; |
|
82 | + $filename = $this->get_dummy_content('title').'_'.$doc_id.'.'.$extension; |
|
83 | + $content = $this->get_dummy_content('text'); |
|
84 | + $dirs = rand(0, 3); |
|
85 | + for ($i = 0; $i < $dirs; $i ++) |
|
86 | + { |
|
87 | + $path .= 'directory/'; |
|
88 | + $directories[$path] = 1; |
|
89 | + } |
|
90 | + $dir_to_make = $course_doc_path.$path; |
|
91 | + if (!is_dir($dir_to_make)) |
|
92 | + { |
|
93 | + @mkdir($dir_to_make, api_get_permissions_for_new_directories(), true); |
|
94 | + } |
|
95 | + $file = $course_doc_path.$path.$filename; |
|
96 | + $fp = fopen($file, 'w'); |
|
97 | + fwrite($fp, $content); |
|
98 | + fclose($fp); |
|
99 | + $size = filesize($file); |
|
100 | + $document = new Document($doc_id, '/'.$path.$filename,$this->get_dummy_content('description'),$this->get_dummy_content('title'), 'file', $size); |
|
101 | + $document->item_properties[] = $property; |
|
102 | + $this->course->add_resource($document); |
|
103 | + } |
|
104 | + foreach($directories as $path => $flag) |
|
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); |
|
108 | + $property['lastedit_type'] = 'FolderCreated'; |
|
109 | + $document->item_properties[] = $property; |
|
110 | + $this->course->add_resource($document); |
|
111 | + } |
|
112 | + } |
|
113 | + /** |
|
114 | + * Create dummy announcements |
|
115 | + */ |
|
116 | + function create_dummy_announcements() |
|
117 | + { |
|
118 | + $property = $this->default_property; |
|
119 | + $property['lastedit_type'] = 'AnnouncementAdded'; |
|
120 | + $property['tool'] = TOOL_ANNOUNCEMENT; |
|
121 | + $number_of_announcements = rand(10, 30); |
|
122 | + for ($i = 0; $i < $number_of_announcements; $i ++) |
|
123 | + { |
|
124 | + $time = mktime(rand(1, 24), rand(1, 60), 0, rand(1, 12), rand(1, 28), intval(date('Y'))); |
|
125 | + $date = date('Y-m-d', $time); |
|
126 | + $announcement = new Announcement($i,$this->get_dummy_content('title'),$this->get_dummy_content('text'), $date,0); |
|
127 | + $announcement->item_properties[] = $property; |
|
128 | + $this->course->add_resource($announcement); |
|
129 | + } |
|
130 | + } |
|
131 | + /** |
|
132 | + * Create dummy events |
|
133 | + */ |
|
134 | + function create_dummy_events() |
|
135 | + { |
|
136 | + $number_of_events = rand(10, 30); |
|
137 | + $property = $this->default_property; |
|
138 | + $property['lastedit_type'] = 'AgendaAdded'; |
|
139 | + $property['tool'] = TOOL_CALENDAR_EVENT; |
|
140 | + for ($i = 0; $i < $number_of_events; $i ++) |
|
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); |
|
147 | + $year = intval(date('Y')); |
|
148 | + $time = mktime($hour,$minute,$second,$month,$day,$year); |
|
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); |
|
155 | + $year = intval(date('Y')); |
|
156 | + $time = mktime($hour,$minute,$second,$month,$day,$year); |
|
157 | + $end_date = date('Y-m-d H:m:s', $time); |
|
158 | + $event = new CalendarEvent( |
|
159 | + $i, |
|
160 | + $this->get_dummy_content('title'), |
|
161 | + $this->get_dummy_content('text'), |
|
162 | + $start_date, |
|
163 | + $end_date |
|
164 | + ); |
|
165 | + $event->item_properties[] = $property; |
|
166 | + $this->course->add_resource($event); |
|
167 | + } |
|
168 | + } |
|
169 | + /** |
|
170 | + * Create dummy links |
|
171 | + */ |
|
172 | + function create_dummy_links() |
|
173 | + { |
|
174 | + // create categorys |
|
175 | + $number_of_categories = rand(5, 10); |
|
176 | + for ($i = 0; $i < $number_of_categories; $i ++) |
|
177 | + { |
|
178 | + $linkcat = new LinkCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'),$i); |
|
179 | + $this->course->add_resource($linkcat); |
|
180 | + } |
|
181 | + // create links |
|
182 | + $number_of_links = rand(5, 50); |
|
183 | + $on_homepage = rand(0,20) == 0 ? 1 : 0; |
|
184 | + $property = $this->default_property; |
|
185 | + $property['lastedit_type'] = 'LinkAdded'; |
|
186 | + $property['tool'] = TOOL_LINK; |
|
187 | + for ($i = 0; $i < $number_of_links; $i ++) |
|
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); |
|
190 | + $link->item_properties[] = $property; |
|
191 | + $this->course->add_resource($link); |
|
192 | + } |
|
193 | + } |
|
194 | + /** |
|
195 | + * Create dummy forums |
|
196 | + */ |
|
197 | + function create_dummy_forums() |
|
198 | + { |
|
199 | + $number_of_categories = rand(2, 6); |
|
200 | + $number_of_forums = rand(5, 50); |
|
201 | + $number_of_topics = rand(30, 100); |
|
202 | + $number_of_posts = rand(100, 1000); |
|
203 | + $last_forum_post = array (); |
|
204 | + $last_topic_post = array (); |
|
205 | + // create categorys |
|
206 | + $order = 1; |
|
207 | + for ($i = 1; $i <= $number_of_categories; $i ++) |
|
208 | + { |
|
209 | + $forumcat = new ForumCategory($i, $this->get_dummy_content('title'), $this->get_dummy_content('description'), $order, 0, 0); |
|
210 | + $this->course->add_resource($forumcat); |
|
211 | + $order++; |
|
212 | + } |
|
213 | + // create posts |
|
214 | + for ($post_id = 1; $post_id <= $number_of_posts; $post_id ++) |
|
215 | + { |
|
216 | + $topic_id = rand(1, $number_of_topics); |
|
217 | + $last_topic_post[$topic_id] = $post_id; |
|
218 | + $post = new ForumPost($post_id, $this->get_dummy_content('title'), $this->get_dummy_content('text'), date('Y-m-d H:i:s'), 1, 'Portal Administrator', 0, 0, $topic_id, 0, 1); |
|
219 | + $this->course->add_resource($post); |
|
220 | + } |
|
221 | + // create topics |
|
222 | + for ($topic_id = 1; $topic_id <= $number_of_topics; $topic_id ++) |
|
223 | + { |
|
224 | + $forum_id = rand(1, $number_of_forums); |
|
225 | + $last_forum_post[$forum_id] = $last_topic_post[$topic_id]; |
|
226 | + $topic = new ForumTopic($topic_id, $this->get_dummy_content('title'), '2011-03-31 12:10:00', 'Chamilo', 'Administrator', 0, $forum_id, $last_topic_post[$topic_id]); |
|
227 | + $this->course->add_resource($topic); |
|
228 | + } |
|
229 | + // create forums |
|
230 | + for ($forum_id = 1; $forum_id <= $number_of_forums; $forum_id ++) |
|
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]); |
|
233 | + $this->course->add_resource($forum); |
|
234 | + } |
|
235 | + } |
|
236 | + /** |
|
237 | + * Create dummy learnpaths |
|
238 | + */ |
|
239 | + function create_dummy_learnpaths() |
|
240 | + { |
|
241 | + $number_of_learnpaths = rand(3,5); |
|
242 | + $global_item_id = 1; |
|
243 | + for($i=1; $i<=$number_of_learnpaths;$i++) |
|
244 | + { |
|
245 | + $chapters = array(); |
|
246 | + $number_of_chapters = rand(1,6); |
|
247 | + for($chapter_id = 1; $chapter_id <= $number_of_chapters; $chapter_id++) |
|
248 | + { |
|
249 | + $chapter['name'] = $this->get_dummy_content('title'); |
|
250 | + $chapter['description'] = $this->get_dummy_content('description'); |
|
251 | + $chapter['display_order'] = $chapter_id; |
|
252 | + $chapter['items'] = array(); |
|
253 | + $number_of_items = rand(5,20); |
|
254 | + for( $item_id = 1; $item_id<$number_of_items; $item_id++) |
|
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)]; |
|
258 | + $resources = $this->course->resources[$type]; |
|
259 | + $resource = $resources[rand(0,count($resources)-1)]; |
|
260 | + $item = array(); |
|
261 | + $item['type'] = $resource->type; |
|
262 | + $item['id'] = $resource->source_id; |
|
263 | + $item['display_order'] = $item_id; |
|
264 | + $item['title'] = $this->get_dummy_content('title'); |
|
265 | + $item['description'] = $this->get_dummy_content('description'); |
|
266 | + $item['ref_id'] = $global_item_id; |
|
267 | + if( rand(0,5) == 1 && $item_id > 1) |
|
268 | + { |
|
269 | + $item['prereq_type'] = 'i'; |
|
270 | + $item['prereq'] = rand($global_item_id - $item_id,$global_item_id-1); |
|
271 | + } |
|
272 | + $chapter['items'][] = $item; |
|
273 | + $global_item_id++; |
|
274 | + } |
|
275 | + $chapters[] = $chapter; |
|
276 | + } |
|
277 | + $lp = new CourseCopyLearnpath($i,$this->get_dummy_content('title'),$this->get_dummy_content('description'),1,$chapters); |
|
278 | + $this->course->add_resource($lp); |
|
279 | + } |
|
280 | + } |
|
281 | + /** |
|
282 | + * Get dummy titles, descriptions and texts |
|
283 | + */ |
|
284 | + function get_dummy_content($type) |
|
285 | + { |
|
286 | + $dummy_text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque lectus. Duis sodales. Vivamus et nunc. Phasellus interdum est a lorem. Fusce venenatis luctus lectus. Mauris quis turpis ac erat rhoncus suscipit. Phasellus elit dui, semper at, porta ut, egestas ac, enim. Quisque pellentesque, nisl nec consequat mollis, ipsum justo pellentesque nibh, non faucibus odio ante at lorem. Donec vitae pede ut felis ultricies semper. Suspendisse velit nibh, interdum quis, gravida nec, dapibus ac, leo. Cras id sem ut tellus tincidunt scelerisque. Aenean ac magna feugiat dolor accumsan dignissim. Integer eget nisl. |
|
287 | 287 | Ut sit amet nulla. Vestibulum venenatis posuere mauris. Nullam magna leo, blandit luctus, consequat quis, gravida nec, justo. Nam pede. Etiam ut nisl. In at quam scelerisque sapien faucibus commodo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Proin mattis lorem quis nunc. Praesent placerat ligula id elit. Aenean blandit, purus sit amet pharetra auctor, libero orci rutrum felis, sit amet sodales mauris ipsum ultricies sapien. Vivamus wisi. Cras elit elit, ullamcorper ac, interdum nec, pulvinar nec, lacus. In lacus. Vivamus auctor, arcu vitae tincidunt porta, eros lacus tristique justo, vitae semper risus neque eget massa. Vivamus turpis. |
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) |
|
292 | - { |
|
293 | - case 'description': |
|
294 | - $descriptions = explode(".",$dummy_text); |
|
295 | - return $descriptions[rand(0,count($descriptions)-1)]; |
|
296 | - break; |
|
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)]); |
|
301 | - break; |
|
302 | - case 'text': |
|
303 | - $texts = explode("\n",$dummy_text); |
|
304 | - return $texts[rand(0,count($texts)-1)]; |
|
305 | - break; |
|
306 | - } |
|
307 | - } |
|
291 | + switch($type) |
|
292 | + { |
|
293 | + case 'description': |
|
294 | + $descriptions = explode(".",$dummy_text); |
|
295 | + return $descriptions[rand(0,count($descriptions)-1)]; |
|
296 | + break; |
|
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)]); |
|
301 | + break; |
|
302 | + case 'text': |
|
303 | + $texts = explode("\n",$dummy_text); |
|
304 | + return $texts[rand(0,count($texts)-1)]; |
|
305 | + break; |
|
306 | + } |
|
307 | + } |
|
308 | 308 | } |
@@ -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 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | * @param null $feedback_type |
59 | 59 | * @param null $counter |
60 | 60 | * @param null $score |
61 | - * @return null|string |
|
61 | + * @return string |
|
62 | 62 | */ |
63 | 63 | function return_header($feedback_type = null, $counter = null, $score = null) |
64 | 64 | { |
@@ -31,7 +31,7 @@ |
||
31 | 31 | function createAnswersForm($form) |
32 | 32 | { |
33 | 33 | |
34 | - $form -> addElement('text','weighting', get_lang('Weighting'), array('class' => 'span1')); |
|
34 | + $form -> addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1')); |
|
35 | 35 | global $text, $class; |
36 | 36 | // setting the save button here and not in the question class.php |
37 | 37 | $form->addButtonSave($text, 'submitQuestion'); |
@@ -95,7 +95,7 @@ |
||
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Get the progress of this learnpath. Only the last attempt are taken into account. |
98 | - * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
98 | + * @param integer $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | 99 | * @return array (score, max) if student is given |
100 | 100 | * array (sum of scores, number of scores) otherwise |
101 | 101 | * or null if no scores available |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | |
44 | 44 | $result = Database::query($sql); |
45 | 45 | |
46 | - $cats=array(); |
|
47 | - while ($data=Database::fetch_array($result)) { |
|
48 | - $cats[] = array ($data['id'], $data['name']); |
|
46 | + $cats = array(); |
|
47 | + while ($data = Database::fetch_array($result)) { |
|
48 | + $cats[] = array($data['id'], $data['name']); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $cats; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | $result = Database::query($sql); |
73 | 73 | |
74 | 74 | $cats = array(); |
75 | - while ($data=Database::fetch_array($result)) { |
|
76 | - $cats[] = array ($data['id'], $data['name']); |
|
75 | + while ($data = Database::fetch_array($result)) { |
|
76 | + $cats[] = array($data['id'], $data['name']); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $cats; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $sql = "SELECT count(id) AS number FROM $tbl_stats |
90 | 90 | WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id(); |
91 | 91 | $result = Database::query($sql); |
92 | - $number = Database::fetch_array($result,'NUM'); |
|
92 | + $number = Database::fetch_array($result, 'NUM'); |
|
93 | 93 | return ($number[0] != 0); |
94 | 94 | } |
95 | 95 | |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | // for 1 student |
122 | 122 | if (isset($stud_id)) { |
123 | 123 | if ($data = Database::fetch_array($scores)) { |
124 | - return array ($data['progress'], 100); |
|
124 | + return array($data['progress'], 100); |
|
125 | 125 | } else |
126 | 126 | return null; |
127 | 127 | } else { |
128 | 128 | // all students -> get average |
129 | - $students = array(); // user list, needed to make sure we only |
|
129 | + $students = array(); // user list, needed to make sure we only |
|
130 | 130 | // take first attempts into account |
131 | 131 | $rescount = 0; |
132 | 132 | $sum = 0; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | return array($bestResult, 100); |
155 | 155 | break; |
156 | 156 | case 'average': |
157 | - return array($sumResult/$rescount, 100); |
|
157 | + return array($sumResult / $rescount, 100); |
|
158 | 158 | break; |
159 | 159 | case 'ranking': |
160 | 160 | return AbstractLink::getCurrentUserRanking($stud_id, $students); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
208 | 208 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
209 | 209 | $result = Database::query($sql); |
210 | - $number = Database::fetch_row($result,'NUM'); |
|
210 | + $number = Database::fetch_row($result, 'NUM'); |
|
211 | 211 | return ($number[0] != 0); |
212 | 212 | } |
213 | 213 |
@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | public function get_not_created_links() |
30 | 30 | { |
31 | 31 | return false; |
32 | - if (empty($this->course_code)) |
|
33 | - die('Error in get_not_created_links() : course code not set'); |
|
32 | + if (empty($this->course_code)) { |
|
33 | + die('Error in get_not_created_links() : course code not set'); |
|
34 | + } |
|
34 | 35 | |
35 | 36 | $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
36 | 37 | |
@@ -57,8 +58,9 @@ discard block |
||
57 | 58 | */ |
58 | 59 | public function get_all_links() |
59 | 60 | { |
60 | - if (empty($this->course_code)) |
|
61 | - die('Error in get_not_created_links() : course code not set'); |
|
61 | + if (empty($this->course_code)) { |
|
62 | + die('Error in get_not_created_links() : course code not set'); |
|
63 | + } |
|
62 | 64 | |
63 | 65 | $session_id = api_get_session_id(); |
64 | 66 | if (empty($session_id)) { |
@@ -111,8 +113,9 @@ discard block |
||
111 | 113 | lp_id = ".$this->get_ref_id()." AND |
112 | 114 | session_id = $session_id "; |
113 | 115 | |
114 | - if (isset($stud_id)) |
|
115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | + if (isset($stud_id)) { |
|
117 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
118 | + } |
|
116 | 119 | |
117 | 120 | // order by id, that way the student's first attempt is accessed first |
118 | 121 | $sql .= ' ORDER BY view_count DESC'; |
@@ -122,8 +125,9 @@ discard block |
||
122 | 125 | if (isset($stud_id)) { |
123 | 126 | if ($data = Database::fetch_array($scores)) { |
124 | 127 | return array ($data['progress'], 100); |
125 | - } else |
|
126 | - return null; |
|
128 | + } else { |
|
129 | + return null; |
|
130 | + } |
|
127 | 131 | } else { |
128 | 132 | // all students -> get average |
129 | 133 | $students = array(); // user list, needed to make sure we only |
@@ -9,260 +9,260 @@ |
||
9 | 9 | */ |
10 | 10 | class LearnpathLink extends AbstractLink |
11 | 11 | { |
12 | - private $course_info = null; |
|
13 | - private $learnpath_table = null; |
|
14 | - private $learnpath_data = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct(); |
|
22 | - $this->set_type(LINK_LEARNPATH); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | - */ |
|
29 | - public function get_not_created_links() |
|
30 | - { |
|
31 | - return false; |
|
32 | - if (empty($this->course_code)) |
|
33 | - die('Error in get_not_created_links() : course code not set'); |
|
34 | - |
|
35 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | - |
|
37 | - $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
12 | + private $course_info = null; |
|
13 | + private $learnpath_table = null; |
|
14 | + private $learnpath_data = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct(); |
|
22 | + $this->set_type(LINK_LEARNPATH); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | + */ |
|
29 | + public function get_not_created_links() |
|
30 | + { |
|
31 | + return false; |
|
32 | + if (empty($this->course_code)) |
|
33 | + die('Error in get_not_created_links() : course code not set'); |
|
34 | + |
|
35 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | + |
|
37 | + $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
38 | 38 | WHERE c_id = '.$this->course_id.' AND id NOT IN ' |
39 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | - .' WHERE type = '.LINK_LEARNPATH |
|
41 | - ." AND course_code = '".$this->get_course_code()."'" |
|
42 | - .') AND lp.session_id='.api_get_session_id().''; |
|
43 | - |
|
44 | - $result = Database::query($sql); |
|
45 | - |
|
46 | - $cats=array(); |
|
47 | - while ($data=Database::fetch_array($result)) { |
|
48 | - $cats[] = array ($data['id'], $data['name']); |
|
49 | - } |
|
50 | - |
|
51 | - return $cats; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Generate an array of all learnpaths available. |
|
56 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | - */ |
|
58 | - public function get_all_links() |
|
59 | - { |
|
60 | - if (empty($this->course_code)) |
|
61 | - die('Error in get_not_created_links() : course code not set'); |
|
62 | - |
|
63 | - $session_id = api_get_session_id(); |
|
64 | - if (empty($session_id)) { |
|
65 | - $session_condition = api_get_session_condition(0, true); |
|
66 | - } else { |
|
67 | - $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | - } |
|
69 | - |
|
70 | - $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
39 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | + .' WHERE type = '.LINK_LEARNPATH |
|
41 | + ." AND course_code = '".$this->get_course_code()."'" |
|
42 | + .') AND lp.session_id='.api_get_session_id().''; |
|
43 | + |
|
44 | + $result = Database::query($sql); |
|
45 | + |
|
46 | + $cats=array(); |
|
47 | + while ($data=Database::fetch_array($result)) { |
|
48 | + $cats[] = array ($data['id'], $data['name']); |
|
49 | + } |
|
50 | + |
|
51 | + return $cats; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Generate an array of all learnpaths available. |
|
56 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | + */ |
|
58 | + public function get_all_links() |
|
59 | + { |
|
60 | + if (empty($this->course_code)) |
|
61 | + die('Error in get_not_created_links() : course code not set'); |
|
62 | + |
|
63 | + $session_id = api_get_session_id(); |
|
64 | + if (empty($session_id)) { |
|
65 | + $session_condition = api_get_session_condition(0, true); |
|
66 | + } else { |
|
67 | + $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | + } |
|
69 | + |
|
70 | + $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
71 | 71 | WHERE c_id = '.$this->course_id.' '.$session_condition.' '; |
72 | - $result = Database::query($sql); |
|
72 | + $result = Database::query($sql); |
|
73 | 73 | |
74 | - $cats = array(); |
|
75 | - while ($data=Database::fetch_array($result)) { |
|
76 | - $cats[] = array ($data['id'], $data['name']); |
|
77 | - } |
|
74 | + $cats = array(); |
|
75 | + while ($data=Database::fetch_array($result)) { |
|
76 | + $cats[] = array ($data['id'], $data['name']); |
|
77 | + } |
|
78 | 78 | |
79 | - return $cats; |
|
80 | - } |
|
79 | + return $cats; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Has anyone used this learnpath yet ? |
|
85 | - */ |
|
86 | - public function has_results() |
|
87 | - { |
|
88 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | - $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
83 | + /** |
|
84 | + * Has anyone used this learnpath yet ? |
|
85 | + */ |
|
86 | + public function has_results() |
|
87 | + { |
|
88 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | + $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
90 | 90 | WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id(); |
91 | - $result = Database::query($sql); |
|
92 | - $number = Database::fetch_array($result,'NUM'); |
|
93 | - return ($number[0] != 0); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | - * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | - * @return array (score, max) if student is given |
|
100 | - * array (sum of scores, number of scores) otherwise |
|
101 | - * or null if no scores available |
|
102 | - */ |
|
103 | - public function calc_score($stud_id = null, $type = null) |
|
104 | - { |
|
105 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | - $session_id = api_get_session_id(); |
|
107 | - |
|
108 | - $sql = "SELECT * FROM $tbl_stats |
|
91 | + $result = Database::query($sql); |
|
92 | + $number = Database::fetch_array($result,'NUM'); |
|
93 | + return ($number[0] != 0); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | + * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | + * @return array (score, max) if student is given |
|
100 | + * array (sum of scores, number of scores) otherwise |
|
101 | + * or null if no scores available |
|
102 | + */ |
|
103 | + public function calc_score($stud_id = null, $type = null) |
|
104 | + { |
|
105 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | + $session_id = api_get_session_id(); |
|
107 | + |
|
108 | + $sql = "SELECT * FROM $tbl_stats |
|
109 | 109 | WHERE |
110 | 110 | c_id = ".$this->course_id." AND |
111 | 111 | lp_id = ".$this->get_ref_id()." AND |
112 | 112 | session_id = $session_id "; |
113 | 113 | |
114 | - if (isset($stud_id)) |
|
115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | - |
|
117 | - // order by id, that way the student's first attempt is accessed first |
|
118 | - $sql .= ' ORDER BY view_count DESC'; |
|
119 | - |
|
120 | - $scores = Database::query($sql); |
|
121 | - // for 1 student |
|
122 | - if (isset($stud_id)) { |
|
123 | - if ($data = Database::fetch_assoc($scores)) { |
|
124 | - return array ($data['progress'], 100); |
|
125 | - } else |
|
126 | - return null; |
|
127 | - } else { |
|
128 | - // all students -> get average |
|
129 | - $students = array(); // user list, needed to make sure we only |
|
130 | - // take first attempts into account |
|
131 | - $rescount = 0; |
|
132 | - $sum = 0; |
|
133 | - $bestResult = 0; |
|
134 | - $sumResult = 0; |
|
135 | - while ($data = Database::fetch_array($scores)) { |
|
136 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | - $students[$data['user_id']] = $data['progress']; |
|
138 | - $rescount++; |
|
139 | - $sum += $data['progress'] / 100; |
|
140 | - $sumResult += $data['progress']; |
|
141 | - |
|
142 | - if ($data['progress'] > $bestResult) { |
|
143 | - $bestResult = $data['progress']; |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - if ($rescount == 0) { |
|
149 | - return null; |
|
150 | - } else { |
|
151 | - |
|
152 | - switch ($type) { |
|
153 | - case 'best': |
|
154 | - return array($bestResult, 100); |
|
155 | - break; |
|
156 | - case 'average': |
|
157 | - return array($sumResult/$rescount, 100); |
|
158 | - break; |
|
159 | - case 'ranking': |
|
160 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | - break; |
|
162 | - default: |
|
163 | - return array($sum, $rescount); |
|
164 | - break; |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Get URL where to go to if the user clicks on the link. |
|
172 | - */ |
|
173 | - public function get_link() |
|
174 | - { |
|
175 | - $url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view'; |
|
176 | - $session_id = api_get_session_id(); |
|
177 | - if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
178 | - $url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
179 | - } else { |
|
180 | - $url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
181 | - } |
|
182 | - return $url; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Get name to display: same as learnpath title |
|
187 | - */ |
|
188 | - public function get_name() |
|
189 | - { |
|
190 | - $data = $this->get_learnpath_data(); |
|
191 | - return $data['name']; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Get description to display: same as learnpath description |
|
196 | - */ |
|
197 | - public function get_description() |
|
198 | - { |
|
199 | - $data = $this->get_learnpath_data(); |
|
200 | - return $data['description']; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Check if this still links to a learnpath |
|
205 | - */ |
|
206 | - public function is_valid_link() { |
|
207 | - $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
114 | + if (isset($stud_id)) |
|
115 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | + |
|
117 | + // order by id, that way the student's first attempt is accessed first |
|
118 | + $sql .= ' ORDER BY view_count DESC'; |
|
119 | + |
|
120 | + $scores = Database::query($sql); |
|
121 | + // for 1 student |
|
122 | + if (isset($stud_id)) { |
|
123 | + if ($data = Database::fetch_assoc($scores)) { |
|
124 | + return array ($data['progress'], 100); |
|
125 | + } else |
|
126 | + return null; |
|
127 | + } else { |
|
128 | + // all students -> get average |
|
129 | + $students = array(); // user list, needed to make sure we only |
|
130 | + // take first attempts into account |
|
131 | + $rescount = 0; |
|
132 | + $sum = 0; |
|
133 | + $bestResult = 0; |
|
134 | + $sumResult = 0; |
|
135 | + while ($data = Database::fetch_array($scores)) { |
|
136 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | + $students[$data['user_id']] = $data['progress']; |
|
138 | + $rescount++; |
|
139 | + $sum += $data['progress'] / 100; |
|
140 | + $sumResult += $data['progress']; |
|
141 | + |
|
142 | + if ($data['progress'] > $bestResult) { |
|
143 | + $bestResult = $data['progress']; |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + if ($rescount == 0) { |
|
149 | + return null; |
|
150 | + } else { |
|
151 | + |
|
152 | + switch ($type) { |
|
153 | + case 'best': |
|
154 | + return array($bestResult, 100); |
|
155 | + break; |
|
156 | + case 'average': |
|
157 | + return array($sumResult/$rescount, 100); |
|
158 | + break; |
|
159 | + case 'ranking': |
|
160 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | + break; |
|
162 | + default: |
|
163 | + return array($sum, $rescount); |
|
164 | + break; |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Get URL where to go to if the user clicks on the link. |
|
172 | + */ |
|
173 | + public function get_link() |
|
174 | + { |
|
175 | + $url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view'; |
|
176 | + $session_id = api_get_session_id(); |
|
177 | + if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
178 | + $url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
179 | + } else { |
|
180 | + $url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
181 | + } |
|
182 | + return $url; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Get name to display: same as learnpath title |
|
187 | + */ |
|
188 | + public function get_name() |
|
189 | + { |
|
190 | + $data = $this->get_learnpath_data(); |
|
191 | + return $data['name']; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Get description to display: same as learnpath description |
|
196 | + */ |
|
197 | + public function get_description() |
|
198 | + { |
|
199 | + $data = $this->get_learnpath_data(); |
|
200 | + return $data['description']; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Check if this still links to a learnpath |
|
205 | + */ |
|
206 | + public function is_valid_link() { |
|
207 | + $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
208 | 208 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
209 | - $result = Database::query($sql); |
|
210 | - $number = Database::fetch_row($result,'NUM'); |
|
211 | - return ($number[0] != 0); |
|
212 | - } |
|
213 | - |
|
214 | - public function get_type_name() |
|
215 | - { |
|
216 | - return get_lang('LearningPaths'); |
|
217 | - } |
|
218 | - |
|
219 | - public function needs_name_and_description() |
|
220 | - { |
|
221 | - return false; |
|
222 | - } |
|
223 | - |
|
224 | - public function needs_max() |
|
225 | - { |
|
226 | - return false; |
|
227 | - } |
|
228 | - |
|
229 | - public function needs_results() |
|
230 | - { |
|
231 | - return false; |
|
232 | - } |
|
233 | - |
|
234 | - public function is_allowed_to_change_name() |
|
235 | - { |
|
236 | - return false; |
|
237 | - } |
|
238 | - |
|
239 | - // INTERNAL FUNCTIONS |
|
240 | - |
|
241 | - /** |
|
242 | - * Lazy load function to get the database table of the learnpath |
|
243 | - */ |
|
244 | - private function get_learnpath_table() |
|
245 | - { |
|
246 | - $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
247 | - return $this->learnpath_table; |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Lazy load function to get the database contents of this learnpath |
|
252 | - */ |
|
253 | - private function get_learnpath_data() |
|
254 | - { |
|
255 | - if (!isset($this->learnpath_data)) { |
|
256 | - $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
209 | + $result = Database::query($sql); |
|
210 | + $number = Database::fetch_row($result,'NUM'); |
|
211 | + return ($number[0] != 0); |
|
212 | + } |
|
213 | + |
|
214 | + public function get_type_name() |
|
215 | + { |
|
216 | + return get_lang('LearningPaths'); |
|
217 | + } |
|
218 | + |
|
219 | + public function needs_name_and_description() |
|
220 | + { |
|
221 | + return false; |
|
222 | + } |
|
223 | + |
|
224 | + public function needs_max() |
|
225 | + { |
|
226 | + return false; |
|
227 | + } |
|
228 | + |
|
229 | + public function needs_results() |
|
230 | + { |
|
231 | + return false; |
|
232 | + } |
|
233 | + |
|
234 | + public function is_allowed_to_change_name() |
|
235 | + { |
|
236 | + return false; |
|
237 | + } |
|
238 | + |
|
239 | + // INTERNAL FUNCTIONS |
|
240 | + |
|
241 | + /** |
|
242 | + * Lazy load function to get the database table of the learnpath |
|
243 | + */ |
|
244 | + private function get_learnpath_table() |
|
245 | + { |
|
246 | + $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
247 | + return $this->learnpath_table; |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Lazy load function to get the database contents of this learnpath |
|
252 | + */ |
|
253 | + private function get_learnpath_data() |
|
254 | + { |
|
255 | + if (!isset($this->learnpath_data)) { |
|
256 | + $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
257 | 257 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
258 | - $result = Database::query($sql); |
|
259 | - $this->learnpath_data = Database::fetch_array($result); |
|
260 | - } |
|
261 | - return $this->learnpath_data; |
|
262 | - } |
|
263 | - |
|
264 | - public function get_icon_name() |
|
265 | - { |
|
266 | - return 'learnpath'; |
|
267 | - } |
|
258 | + $result = Database::query($sql); |
|
259 | + $this->learnpath_data = Database::fetch_array($result); |
|
260 | + } |
|
261 | + return $this->learnpath_data; |
|
262 | + } |
|
263 | + |
|
264 | + public function get_icon_name() |
|
265 | + { |
|
266 | + return 'learnpath'; |
|
267 | + } |
|
268 | 268 | } |
@@ -32,6 +32,8 @@ discard block |
||
32 | 32 | * @param array $evals |
33 | 33 | * @param array $links |
34 | 34 | * @param null $addparams |
35 | + * @param boolean $showTeacherView |
|
36 | + * @param integer $userId |
|
35 | 37 | */ |
36 | 38 | public function __construct( |
37 | 39 | $currentcat, |
@@ -895,7 +897,7 @@ discard block |
||
895 | 897 | |
896 | 898 | /** |
897 | 899 | * @param $item |
898 | - * @return mixed |
|
900 | + * @return string|null |
|
899 | 901 | */ |
900 | 902 | private function build_course_code($item) |
901 | 903 | { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->set_additional_parameters($addparams); |
72 | 72 | } |
73 | 73 | |
74 | - $column= 0; |
|
74 | + $column = 0; |
|
75 | 75 | if ($this->teacherView) { |
76 | 76 | if ($this->exportToPdf == false) { |
77 | 77 | $this->set_header($column++, '', '', 'width="25px"'); |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | $main_categories[$item->get_id()]['name'] = $item->get_name(); |
284 | 284 | } else { |
285 | 285 | $name = $this->build_name_link($item, $type); |
286 | - $row[] = $invisibility_span_open.$name. $invisibility_span_close; |
|
286 | + $row[] = $invisibility_span_open.$name.$invisibility_span_close; |
|
287 | 287 | $main_categories[$item->get_id()]['name'] = $name; |
288 | 288 | } |
289 | 289 | |
290 | 290 | $this->dataForGraph['categories'][] = $item->get_name(); |
291 | 291 | |
292 | - $main_categories[$item->get_id()]['weight']= $item->get_weight(); |
|
292 | + $main_categories[$item->get_id()]['weight'] = $item->get_weight(); |
|
293 | 293 | $total_categories_weight += $item->get_weight(); |
294 | 294 | |
295 | 295 | // Description. |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | ); |
310 | 310 | |
311 | 311 | if ($this->teacherView) { |
312 | - $row[] = $invisibility_span_open .Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close; |
|
312 | + $row[] = $invisibility_span_open.Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close; |
|
313 | 313 | } else { |
314 | - $row[] = $invisibility_span_open .$weight.$invisibility_span_close; |
|
314 | + $row[] = $invisibility_span_open.$weight.$invisibility_span_close; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | $category_weight = $item->get_weight(); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | if (!empty($score[1])) { |
339 | 339 | $completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); |
340 | - $score = $score[0]/$score[1]*$item->get_weight(); |
|
340 | + $score = $score[0] / $score[1] * $item->get_weight(); |
|
341 | 341 | $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE); |
342 | 342 | $scoreToDisplay = Display::tip($score, $completeScore); |
343 | 343 | } else { |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, SCORE_AVERAGE)); |
374 | 374 | $this->dataForGraph['my_result'][] = (float) str_replace('%', '', $totalResultAverageValue); |
375 | 375 | $totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE)); |
376 | - $this->dataForGraph['average'][] = (float) str_replace('%', '', $totalAverageValue); |
|
376 | + $this->dataForGraph['average'][] = (float) str_replace('%', '', $totalAverageValue); |
|
377 | 377 | // Ranking |
378 | 378 | $row[] = $ranking; |
379 | 379 | // Best |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); |
457 | 457 | |
458 | 458 | // Name. |
459 | - $row[] = $invisibility_span_open." ".$this->build_name_link($item, $type) . $invisibility_span_close; |
|
459 | + $row[] = $invisibility_span_open." ".$this->build_name_link($item, $type).$invisibility_span_close; |
|
460 | 460 | |
461 | 461 | // Description. |
462 | 462 | if ($this->exportToPdf == false) { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // Students get the results and certificates columns |
495 | 495 | $eval_n_links = array_merge($alleval, $alllink); |
496 | 496 | |
497 | - if (count($eval_n_links)> 0) { |
|
497 | + if (count($eval_n_links) > 0) { |
|
498 | 498 | $value_data = isset($data[4]) ? $data[4] : null; |
499 | 499 | |
500 | 500 | if (!is_null($value_data)) { |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | $row = array( |
594 | 594 | null, |
595 | 595 | null, |
596 | - '<strong>' . get_lang('Total') . '</strong>', |
|
596 | + '<strong>'.get_lang('Total').'</strong>', |
|
597 | 597 | null, |
598 | 598 | $total |
599 | 599 | ); |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | if ($this->exportToPdf) { |
664 | 664 | $row = array( |
665 | 665 | null, |
666 | - '<h3>' . get_lang('Total') . '</h3>', |
|
666 | + '<h3>'.get_lang('Total').'</h3>', |
|
667 | 667 | $main_weight, |
668 | 668 | $totalResult, |
669 | 669 | $totalRanking, |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | } else { |
674 | 674 | $row = array( |
675 | 675 | null, |
676 | - '<h3>' . get_lang('Total') . '</h3>', |
|
676 | + '<h3>'.get_lang('Total').'</h3>', |
|
677 | 677 | null, |
678 | 678 | $main_weight, |
679 | 679 | $totalResult, |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | } |
689 | 689 | |
690 | 690 | // Warning messages |
691 | - $view = isset($_GET['view']) ? $_GET['view']: null; |
|
691 | + $view = isset($_GET['view']) ? $_GET['view'] : null; |
|
692 | 692 | |
693 | 693 | if ($this->teacherView) { |
694 | 694 | if (isset($_GET['selectcat']) && |
@@ -701,14 +701,14 @@ discard block |
||
701 | 701 | $weight_category = intval($this->build_weight($category[0])); |
702 | 702 | |
703 | 703 | $course_code = $this->build_course_code($category[0]); |
704 | - $weight_total_links = round($weight_total_links); |
|
704 | + $weight_total_links = round($weight_total_links); |
|
705 | 705 | |
706 | 706 | if ($weight_total_links > $weight_category || |
707 | 707 | $weight_total_links < $weight_category || |
708 | 708 | $weight_total_links > $weight_category |
709 | 709 | ) { |
710 | 710 | $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); |
711 | - $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
711 | + $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
712 | 712 | Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>'; |
713 | 713 | $warning_message .= $modify_icons; |
714 | 714 | Display::display_warning_message($warning_message, false); |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | ); |
722 | 722 | |
723 | 723 | if (!empty($content_html)) { |
724 | - $new_content = explode('</head>',$content_html['content']); |
|
724 | + $new_content = explode('</head>', $content_html['content']); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | if (empty($new_content[0])) { |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | is_array($course_codes) |
756 | 756 | ) { |
757 | 757 | $warning_message = ''; |
758 | - for ($x = 0; $x<count($weight_categories);$x++) { |
|
758 | + for ($x = 0; $x < count($weight_categories); $x++) { |
|
759 | 759 | $weight_category = intval($weight_categories[$x]); |
760 | 760 | $certificate_min_score = intval($certificate_min_scores[$x]); |
761 | 761 | $course_code = $course_codes[$x]; |
@@ -763,12 +763,12 @@ discard block |
||
763 | 763 | if (empty($certificate_min_score) || |
764 | 764 | ($certificate_min_score > $weight_category) |
765 | 765 | ) { |
766 | - $warning_message .= $course_code .' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
|
766 | + $warning_message .= $course_code.' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
|
767 | 767 | } |
768 | 768 | } |
769 | 769 | |
770 | 770 | if (!empty($warning_message)) { |
771 | - Display::display_warning_message($warning_message,false); |
|
771 | + Display::display_warning_message($warning_message, false); |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | } |
@@ -812,15 +812,15 @@ discard block |
||
812 | 812 | $pChart->Antialias = FALSE; |
813 | 813 | |
814 | 814 | /* Add a border to the picture */ |
815 | - $pChart->drawRectangle(0,0,$xSize-10,$ySize-10,array("R"=>0,"G"=>0,"B"=>0)); |
|
815 | + $pChart->drawRectangle(0, 0, $xSize - 10, $ySize - 10, array("R"=>0, "G"=>0, "B"=>0)); |
|
816 | 816 | |
817 | - $pChart->drawText(10,16,get_lang('Results'),array("FontSize"=>11,"Align"=>TEXT_ALIGN_BOTTOMLEFT)); |
|
817 | + $pChart->drawText(10, 16, get_lang('Results'), array("FontSize"=>11, "Align"=>TEXT_ALIGN_BOTTOMLEFT)); |
|
818 | 818 | |
819 | - $pChart->setGraphArea(50, 30, $xSize-50, $ySize-50); |
|
819 | + $pChart->setGraphArea(50, 30, $xSize - 50, $ySize - 50); |
|
820 | 820 | |
821 | 821 | $pChart->setFontProperties( |
822 | 822 | array( |
823 | - 'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
823 | + 'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
824 | 824 | 'FontSize' => 10, |
825 | 825 | ) |
826 | 826 | ); |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | |
841 | 841 | /* Draw the line chart */ |
842 | 842 | $pChart->drawLineChart(); |
843 | - $pChart->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80)); |
|
843 | + $pChart->drawPlotChart(array("DisplayValues"=>TRUE, "PlotBorder"=>TRUE, "BorderSize"=>2, "Surrounding"=>-60, "BorderAlpha"=>80)); |
|
844 | 844 | |
845 | 845 | /* Write the chart legend */ |
846 | 846 | $pChart->drawLegend( |
@@ -860,13 +860,13 @@ discard block |
||
860 | 860 | $chartHash = $myCache->getHash($dataSet); |
861 | 861 | |
862 | 862 | $myCache->writeToCache($chartHash, $pChart); |
863 | - $imgSysPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; |
|
863 | + $imgSysPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash; |
|
864 | 864 | $myCache->saveFromCache($chartHash, $imgSysPath); |
865 | - $imgWebPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
|
865 | + $imgWebPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; |
|
866 | 866 | |
867 | 867 | if (file_exists($imgSysPath)) { |
868 | 868 | $result = '<div id="contentArea" style="text-align: center;" >'; |
869 | - $result .= '<img src="' . $imgWebPath.'" >'; |
|
869 | + $result .= '<img src="'.$imgWebPath.'" >'; |
|
870 | 870 | $result .= '</div>'; |
871 | 871 | return $result; |
872 | 872 | } |
@@ -911,13 +911,13 @@ discard block |
||
911 | 911 | switch ($item->get_item_type()) { |
912 | 912 | // category |
913 | 913 | case 'C' : |
914 | - return 'CATE' . $item->get_id(); |
|
914 | + return 'CATE'.$item->get_id(); |
|
915 | 915 | // evaluation |
916 | 916 | case 'E' : |
917 | - return 'EVAL' . $item->get_id(); |
|
917 | + return 'EVAL'.$item->get_id(); |
|
918 | 918 | // link |
919 | 919 | case 'L' : |
920 | - return 'LINK' . $item->get_id(); |
|
920 | + return 'LINK'.$item->get_id(); |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | |
@@ -945,20 +945,20 @@ discard block |
||
945 | 945 | switch ($item->get_item_type()) { |
946 | 946 | // category |
947 | 947 | case 'C' : |
948 | - $prms_uri='?selectcat=' . $item->get_id() . '&view='.$view; |
|
948 | + $prms_uri = '?selectcat='.$item->get_id().'&view='.$view; |
|
949 | 949 | |
950 | 950 | if (isset($_GET['isStudentView'])) { |
951 | - if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) { |
|
952 | - $prms_uri=$prms_uri.'&isStudentView='.Security::remove_XSS($_GET['isStudentView']); |
|
951 | + if (isset($is_student) || (isset($_SESSION['studentview']) && $_SESSION['studentview'] == 'studentview')) { |
|
952 | + $prms_uri = $prms_uri.'&isStudentView='.Security::remove_XSS($_GET['isStudentView']); |
|
953 | 953 | } |
954 | 954 | } |
955 | 955 | |
956 | 956 | $cat = new Category(); |
957 | - $show_message=$cat->show_message_resource_delete($item->get_course_code()); |
|
957 | + $show_message = $cat->show_message_resource_delete($item->get_course_code()); |
|
958 | 958 | return ' <a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">' |
959 | 959 | . $item->get_name() |
960 | 960 | . '</a>' |
961 | - . ($item->is_course() ? ' [' . $item->get_course_code() . ']'.$show_message : ''); |
|
961 | + . ($item->is_course() ? ' ['.$item->get_course_code().']'.$show_message : ''); |
|
962 | 962 | // evaluation |
963 | 963 | case 'E' : |
964 | 964 | $cat = new Category(); |
@@ -966,10 +966,10 @@ discard block |
||
966 | 966 | $show_message = $cat->show_message_resource_delete($course_id); |
967 | 967 | |
968 | 968 | // course/platform admin can go to the view_results page |
969 | - if (api_is_allowed_to_edit() && $show_message===false) { |
|
969 | + if (api_is_allowed_to_edit() && $show_message === false) { |
|
970 | 970 | if ($item->get_type() == 'presence') { |
971 | 971 | return ' ' |
972 | - . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&selecteval=' . $item->get_id() . '">' |
|
972 | + . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&selecteval='.$item->get_id().'">' |
|
973 | 973 | . $item->get_name() |
974 | 974 | . '</a>'; |
975 | 975 | } else { |
@@ -978,20 +978,20 @@ discard block |
||
978 | 978 | $extra = ''; |
979 | 979 | } |
980 | 980 | return ' ' |
981 | - . '<a href="gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
981 | + . '<a href="gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
982 | 982 | . $item->get_name() |
983 | 983 | . '</a> '.$extra; |
984 | 984 | } |
985 | - } elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) { |
|
985 | + } elseif (ScoreDisplay :: instance()->is_custom() && $show_message === false) { |
|
986 | 986 | // students can go to the statistics page (if custom display enabled) |
987 | 987 | return ' ' |
988 | - . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
988 | + . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
989 | 989 | . $item->get_name() |
990 | 990 | . '</a>'; |
991 | 991 | |
992 | 992 | } elseif ($show_message === false && !api_is_allowed_to_edit() && !ScoreDisplay :: instance()->is_custom()) { |
993 | 993 | return ' ' |
994 | - . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
994 | + . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
995 | 995 | . $item->get_name() |
996 | 996 | . '</a>'; |
997 | 997 | } else { |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | $url = $item->get_link(); |
1007 | 1007 | |
1008 | 1008 | if (isset($url) && $show_message === false) { |
1009 | - $text = ' <a href="' . $item->get_link() . '">' |
|
1009 | + $text = ' <a href="'.$item->get_link().'">' |
|
1010 | 1010 | . $item->get_name() |
1011 | 1011 | . '</a>'; |
1012 | 1012 | } else { |
@@ -256,10 +256,11 @@ |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | // Categories. |
259 | - if (!empty($data_array)) |
|
260 | - foreach ($data_array as $data) { |
|
259 | + if (!empty($data_array)) { |
|
260 | + foreach ($data_array as $data) { |
|
261 | 261 | // list of items inside the gradebook (exercises, lps, forums, etc) |
262 | 262 | $row = array(); |
263 | + } |
|
263 | 264 | /** @var AbstractLink $item */ |
264 | 265 | $item = $mainCategory = $data[0]; |
265 | 266 |
@@ -72,6 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Get actual array data |
75 | + * @param integer $count |
|
75 | 76 | * @return array 2-dimensional array - each array contains the elements: |
76 | 77 | * 0: eval/link object |
77 | 78 | * 1: item name |
@@ -285,7 +286,7 @@ discard block |
||
285 | 286 | |
286 | 287 | /** |
287 | 288 | * @param $item |
288 | - * @param $ignore_score_color |
|
289 | + * @param boolean $ignore_score_color |
|
289 | 290 | * @return string |
290 | 291 | */ |
291 | 292 | private function build_average_column($item, $ignore_score_color) |
@@ -306,7 +307,7 @@ discard block |
||
306 | 307 | |
307 | 308 | /** |
308 | 309 | * @param $item |
309 | - * @param $ignore_score_color |
|
310 | + * @param boolean $ignore_score_color |
|
310 | 311 | * @return string |
311 | 312 | */ |
312 | 313 | private function build_result_column($item, $ignore_score_color) |
@@ -323,7 +324,7 @@ discard block |
||
323 | 324 | |
324 | 325 | /** |
325 | 326 | * @param $item |
326 | - * @param $ignore_score_color |
|
327 | + * @param boolean $ignore_score_color |
|
327 | 328 | * @return string |
328 | 329 | */ |
329 | 330 | private function build_mask_column($item, $ignore_score_color) |
@@ -339,7 +340,7 @@ discard block |
||
339 | 340 | |
340 | 341 | /** |
341 | 342 | * @param $coursecode |
342 | - * @return mixed |
|
343 | + * @return string |
|
343 | 344 | */ |
344 | 345 | private function get_course_name_from_code_cached($coursecode) |
345 | 346 | { |
@@ -10,28 +10,28 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class UserDataGenerator |
12 | 12 | { |
13 | - // Sorting types constants |
|
14 | - const UDG_SORT_TYPE = 1; |
|
15 | - const UDG_SORT_NAME = 2; |
|
16 | - const UDG_SORT_COURSE = 4; |
|
17 | - const UDG_SORT_CATEGORY = 8; |
|
18 | - const UDG_SORT_AVERAGE = 16; |
|
19 | - const UDG_SORT_SCORE = 32; |
|
20 | - const UDG_SORT_MASK = 64; |
|
21 | - |
|
22 | - const UDG_SORT_ASC = 128; |
|
23 | - const UDG_SORT_DESC = 256; |
|
24 | - |
|
25 | - private $items; |
|
26 | - private $userid; |
|
27 | - |
|
28 | - private $coursecodecache; |
|
29 | - private $categorycache; |
|
30 | - private $scorecache; |
|
31 | - private $avgcache; |
|
32 | - |
|
33 | - public function UserDataGenerator($userid, $evals = array(), $links = array()) |
|
34 | - { |
|
13 | + // Sorting types constants |
|
14 | + const UDG_SORT_TYPE = 1; |
|
15 | + const UDG_SORT_NAME = 2; |
|
16 | + const UDG_SORT_COURSE = 4; |
|
17 | + const UDG_SORT_CATEGORY = 8; |
|
18 | + const UDG_SORT_AVERAGE = 16; |
|
19 | + const UDG_SORT_SCORE = 32; |
|
20 | + const UDG_SORT_MASK = 64; |
|
21 | + |
|
22 | + const UDG_SORT_ASC = 128; |
|
23 | + const UDG_SORT_DESC = 256; |
|
24 | + |
|
25 | + private $items; |
|
26 | + private $userid; |
|
27 | + |
|
28 | + private $coursecodecache; |
|
29 | + private $categorycache; |
|
30 | + private $scorecache; |
|
31 | + private $avgcache; |
|
32 | + |
|
33 | + public function UserDataGenerator($userid, $evals = array(), $links = array()) |
|
34 | + { |
|
35 | 35 | $this->userid = $userid; |
36 | 36 | $evals_filtered = array(); |
37 | 37 | $result = array(); |
@@ -62,330 +62,330 @@ discard block |
||
62 | 62 | $this->avgcache = null; |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Get total number of items (rows) |
|
67 | - */ |
|
68 | - public function get_total_items_count() |
|
69 | - { |
|
70 | - return count($this->items); |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Get actual array data |
|
75 | - * @return array 2-dimensional array - each array contains the elements: |
|
76 | - * 0: eval/link object |
|
77 | - * 1: item name |
|
78 | - * 2: course name |
|
79 | - * 3: category name |
|
80 | - * 4: average score |
|
81 | - * 5: student's score |
|
82 | - * 6: student's score as custom display (only if custom scoring enabled) |
|
83 | - */ |
|
84 | - public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false) |
|
85 | - { |
|
86 | - // do some checks on count, redefine if invalid value |
|
87 | - if (!isset($count)) { |
|
88 | - $count = count ($this->items) - $start; |
|
89 | - } |
|
90 | - if ($count < 0) { |
|
91 | - $count = 0; |
|
92 | - } |
|
93 | - $allitems = $this->items; |
|
94 | - |
|
95 | - // sort users array |
|
96 | - if ($sorting & self :: UDG_SORT_TYPE) { |
|
97 | - usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
|
98 | - }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
99 | - usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
|
100 | - } elseif ($sorting & self :: UDG_SORT_COURSE) { |
|
101 | - usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
|
102 | - } elseif ($sorting & self :: UDG_SORT_CATEGORY) { |
|
103 | - usort($allitems, array('UserDataGenerator', 'sort_by_category')); |
|
104 | - } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
|
105 | - // if user sorts on average scores, first calculate them and cache them |
|
106 | - foreach ($allitems as $item) { |
|
107 | - $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
108 | - } |
|
109 | - usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
|
110 | - } elseif ($sorting & self :: UDG_SORT_SCORE) { |
|
111 | - // if user sorts on student's scores, first calculate them and cache them |
|
112 | - foreach ($allitems as $item) { |
|
113 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
114 | - = $item->calc_score($this->userid); |
|
115 | - } |
|
116 | - usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
|
117 | - } elseif ($sorting & self :: UDG_SORT_MASK) { |
|
118 | - // if user sorts on student's masks, first calculate scores and cache them |
|
119 | - foreach ($allitems as $item) { |
|
120 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
121 | - = $item->calc_score($this->userid); |
|
122 | - } |
|
123 | - usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
|
124 | - } |
|
125 | - |
|
126 | - if ($sorting & self :: UDG_SORT_DESC) { |
|
127 | - $allitems = array_reverse($allitems); |
|
128 | - } |
|
129 | - // select the items we have to display |
|
130 | - $visibleitems = array_slice($allitems, $start, $count); |
|
131 | - |
|
132 | - // fill score cache if not done yet |
|
133 | - if (!isset ($this->scorecache)) { |
|
134 | - foreach ($visibleitems as $item) { |
|
135 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
136 | - = $item->calc_score($this->userid); |
|
137 | - } |
|
138 | - |
|
139 | - } |
|
140 | - // generate the data to display |
|
141 | - $scoredisplay = ScoreDisplay :: instance(); |
|
142 | - $data = array(); |
|
143 | - foreach ($visibleitems as $item) { |
|
144 | - $row = array (); |
|
145 | - $row[] = $item; |
|
146 | - $row[] = $item->get_name(); |
|
147 | - $row[] = $this->build_course_name($item); |
|
148 | - $row[] = $this->build_category_name($item); |
|
149 | - $row[] = $this->build_average_column($item, $ignore_score_color); |
|
150 | - $row[] = $this->build_result_column($item, $ignore_score_color); |
|
151 | - if ($scoredisplay->is_custom()) |
|
152 | - $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
153 | - $data[] = $row; |
|
154 | - } |
|
155 | - return $data; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @param $item1 |
|
160 | - * @param $item2 |
|
161 | - * @return int |
|
162 | - */ |
|
163 | - function sort_by_type($item1, $item2) |
|
164 | - { |
|
165 | - if ($item1->get_item_type() == $item2->get_item_type()) { |
|
166 | - return $this->sort_by_name($item1,$item2); |
|
167 | - } else { |
|
168 | - return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
|
169 | - } |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @param $item1 |
|
174 | - * @param $item2 |
|
175 | - * @return int |
|
176 | - */ |
|
177 | - function sort_by_course($item1, $item2) |
|
178 | - { |
|
179 | - $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code())); |
|
180 | - $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code())); |
|
181 | - return api_strnatcmp($name1, $name2); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @param $item1 |
|
186 | - * @param $item2 |
|
187 | - * @return int |
|
188 | - */ |
|
189 | - function sort_by_category($item1, $item2) |
|
190 | - { |
|
191 | - $cat1 = $this->get_category_cached($item1->get_category_id()); |
|
192 | - $cat2 = $this->get_category_cached($item2->get_category_id()); |
|
193 | - $name1 = api_strtolower($this->get_category_name_to_display($cat1)); |
|
194 | - $name2 = api_strtolower($this->get_category_name_to_display($cat2)); |
|
195 | - |
|
196 | - return api_strnatcmp($name1, $name2); |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * @param $item1 |
|
201 | - * @param $item2 |
|
202 | - * @return int |
|
203 | - */ |
|
204 | - function sort_by_name($item1, $item2) |
|
205 | - { |
|
206 | - return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * @param $item1 |
|
211 | - * @param $item2 |
|
212 | - * @return int |
|
213 | - */ |
|
214 | - function sort_by_average($item1, $item2) |
|
215 | - { |
|
216 | - $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
217 | - $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
218 | - |
|
219 | - return $this->compare_scores($score1, $score2); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * @param $item1 |
|
224 | - * @param $item2 |
|
225 | - * @return int |
|
226 | - */ |
|
227 | - function sort_by_score($item1, $item2) |
|
228 | - { |
|
229 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
230 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
231 | - |
|
232 | - return $this->compare_scores($score1, $score2); |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * @param $item1 |
|
237 | - * @param $item2 |
|
238 | - * @return int |
|
239 | - */ |
|
240 | - function sort_by_mask($item1, $item2) |
|
241 | - { |
|
242 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
243 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
244 | - |
|
245 | - return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * @param $score1 |
|
250 | - * @param $score2 |
|
251 | - * @return int |
|
252 | - */ |
|
253 | - function compare_scores($score1, $score2) |
|
254 | - { |
|
255 | - if (!isset($score1)) { |
|
256 | - return (isset($score2) ? 1 : 0); |
|
257 | - } elseif (!isset($score2)) { |
|
258 | - return -1; |
|
259 | - } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
260 | - return 0; |
|
261 | - } else { |
|
262 | - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
263 | - } |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * @param $item |
|
268 | - * @return mixed |
|
269 | - */ |
|
270 | - private function build_course_name($item) |
|
271 | - { |
|
272 | - return $this->get_course_name_from_code_cached($item->get_course_code()); |
|
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * @param $item |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - private function build_category_name($item) |
|
280 | - { |
|
281 | - $cat = $this->get_category_cached($item->get_category_id()); |
|
282 | - |
|
283 | - return $this->get_category_name_to_display($cat); |
|
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * @param $item |
|
288 | - * @param $ignore_score_color |
|
289 | - * @return string |
|
290 | - */ |
|
291 | - private function build_average_column($item, $ignore_score_color) |
|
292 | - { |
|
293 | - if (isset($this->avgcache)) { |
|
294 | - $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
295 | - } else { |
|
296 | - $avgscore = $item->calc_score(); |
|
297 | - } |
|
298 | - |
|
299 | - $scoredisplay = ScoreDisplay :: instance(); |
|
300 | - $displaytype = SCORE_AVERAGE; |
|
301 | - /*if ($ignore_score_color) |
|
65 | + /** |
|
66 | + * Get total number of items (rows) |
|
67 | + */ |
|
68 | + public function get_total_items_count() |
|
69 | + { |
|
70 | + return count($this->items); |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Get actual array data |
|
75 | + * @return array 2-dimensional array - each array contains the elements: |
|
76 | + * 0: eval/link object |
|
77 | + * 1: item name |
|
78 | + * 2: course name |
|
79 | + * 3: category name |
|
80 | + * 4: average score |
|
81 | + * 5: student's score |
|
82 | + * 6: student's score as custom display (only if custom scoring enabled) |
|
83 | + */ |
|
84 | + public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false) |
|
85 | + { |
|
86 | + // do some checks on count, redefine if invalid value |
|
87 | + if (!isset($count)) { |
|
88 | + $count = count ($this->items) - $start; |
|
89 | + } |
|
90 | + if ($count < 0) { |
|
91 | + $count = 0; |
|
92 | + } |
|
93 | + $allitems = $this->items; |
|
94 | + |
|
95 | + // sort users array |
|
96 | + if ($sorting & self :: UDG_SORT_TYPE) { |
|
97 | + usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
|
98 | + }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
99 | + usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
|
100 | + } elseif ($sorting & self :: UDG_SORT_COURSE) { |
|
101 | + usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
|
102 | + } elseif ($sorting & self :: UDG_SORT_CATEGORY) { |
|
103 | + usort($allitems, array('UserDataGenerator', 'sort_by_category')); |
|
104 | + } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
|
105 | + // if user sorts on average scores, first calculate them and cache them |
|
106 | + foreach ($allitems as $item) { |
|
107 | + $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
108 | + } |
|
109 | + usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
|
110 | + } elseif ($sorting & self :: UDG_SORT_SCORE) { |
|
111 | + // if user sorts on student's scores, first calculate them and cache them |
|
112 | + foreach ($allitems as $item) { |
|
113 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
114 | + = $item->calc_score($this->userid); |
|
115 | + } |
|
116 | + usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
|
117 | + } elseif ($sorting & self :: UDG_SORT_MASK) { |
|
118 | + // if user sorts on student's masks, first calculate scores and cache them |
|
119 | + foreach ($allitems as $item) { |
|
120 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
121 | + = $item->calc_score($this->userid); |
|
122 | + } |
|
123 | + usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
|
124 | + } |
|
125 | + |
|
126 | + if ($sorting & self :: UDG_SORT_DESC) { |
|
127 | + $allitems = array_reverse($allitems); |
|
128 | + } |
|
129 | + // select the items we have to display |
|
130 | + $visibleitems = array_slice($allitems, $start, $count); |
|
131 | + |
|
132 | + // fill score cache if not done yet |
|
133 | + if (!isset ($this->scorecache)) { |
|
134 | + foreach ($visibleitems as $item) { |
|
135 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
136 | + = $item->calc_score($this->userid); |
|
137 | + } |
|
138 | + |
|
139 | + } |
|
140 | + // generate the data to display |
|
141 | + $scoredisplay = ScoreDisplay :: instance(); |
|
142 | + $data = array(); |
|
143 | + foreach ($visibleitems as $item) { |
|
144 | + $row = array (); |
|
145 | + $row[] = $item; |
|
146 | + $row[] = $item->get_name(); |
|
147 | + $row[] = $this->build_course_name($item); |
|
148 | + $row[] = $this->build_category_name($item); |
|
149 | + $row[] = $this->build_average_column($item, $ignore_score_color); |
|
150 | + $row[] = $this->build_result_column($item, $ignore_score_color); |
|
151 | + if ($scoredisplay->is_custom()) |
|
152 | + $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
153 | + $data[] = $row; |
|
154 | + } |
|
155 | + return $data; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @param $item1 |
|
160 | + * @param $item2 |
|
161 | + * @return int |
|
162 | + */ |
|
163 | + function sort_by_type($item1, $item2) |
|
164 | + { |
|
165 | + if ($item1->get_item_type() == $item2->get_item_type()) { |
|
166 | + return $this->sort_by_name($item1,$item2); |
|
167 | + } else { |
|
168 | + return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @param $item1 |
|
174 | + * @param $item2 |
|
175 | + * @return int |
|
176 | + */ |
|
177 | + function sort_by_course($item1, $item2) |
|
178 | + { |
|
179 | + $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code())); |
|
180 | + $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code())); |
|
181 | + return api_strnatcmp($name1, $name2); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * @param $item1 |
|
186 | + * @param $item2 |
|
187 | + * @return int |
|
188 | + */ |
|
189 | + function sort_by_category($item1, $item2) |
|
190 | + { |
|
191 | + $cat1 = $this->get_category_cached($item1->get_category_id()); |
|
192 | + $cat2 = $this->get_category_cached($item2->get_category_id()); |
|
193 | + $name1 = api_strtolower($this->get_category_name_to_display($cat1)); |
|
194 | + $name2 = api_strtolower($this->get_category_name_to_display($cat2)); |
|
195 | + |
|
196 | + return api_strnatcmp($name1, $name2); |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * @param $item1 |
|
201 | + * @param $item2 |
|
202 | + * @return int |
|
203 | + */ |
|
204 | + function sort_by_name($item1, $item2) |
|
205 | + { |
|
206 | + return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * @param $item1 |
|
211 | + * @param $item2 |
|
212 | + * @return int |
|
213 | + */ |
|
214 | + function sort_by_average($item1, $item2) |
|
215 | + { |
|
216 | + $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
217 | + $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
218 | + |
|
219 | + return $this->compare_scores($score1, $score2); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * @param $item1 |
|
224 | + * @param $item2 |
|
225 | + * @return int |
|
226 | + */ |
|
227 | + function sort_by_score($item1, $item2) |
|
228 | + { |
|
229 | + $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
230 | + $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
231 | + |
|
232 | + return $this->compare_scores($score1, $score2); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * @param $item1 |
|
237 | + * @param $item2 |
|
238 | + * @return int |
|
239 | + */ |
|
240 | + function sort_by_mask($item1, $item2) |
|
241 | + { |
|
242 | + $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
243 | + $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
244 | + |
|
245 | + return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * @param $score1 |
|
250 | + * @param $score2 |
|
251 | + * @return int |
|
252 | + */ |
|
253 | + function compare_scores($score1, $score2) |
|
254 | + { |
|
255 | + if (!isset($score1)) { |
|
256 | + return (isset($score2) ? 1 : 0); |
|
257 | + } elseif (!isset($score2)) { |
|
258 | + return -1; |
|
259 | + } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
260 | + return 0; |
|
261 | + } else { |
|
262 | + return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
263 | + } |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * @param $item |
|
268 | + * @return mixed |
|
269 | + */ |
|
270 | + private function build_course_name($item) |
|
271 | + { |
|
272 | + return $this->get_course_name_from_code_cached($item->get_course_code()); |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * @param $item |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + private function build_category_name($item) |
|
280 | + { |
|
281 | + $cat = $this->get_category_cached($item->get_category_id()); |
|
282 | + |
|
283 | + return $this->get_category_name_to_display($cat); |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * @param $item |
|
288 | + * @param $ignore_score_color |
|
289 | + * @return string |
|
290 | + */ |
|
291 | + private function build_average_column($item, $ignore_score_color) |
|
292 | + { |
|
293 | + if (isset($this->avgcache)) { |
|
294 | + $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
295 | + } else { |
|
296 | + $avgscore = $item->calc_score(); |
|
297 | + } |
|
298 | + |
|
299 | + $scoredisplay = ScoreDisplay :: instance(); |
|
300 | + $displaytype = SCORE_AVERAGE; |
|
301 | + /*if ($ignore_score_color) |
|
302 | 302 | $displaytype |= SCORE_IGNORE_SPLIT; |
303 | 303 | */ |
304 | - return $scoredisplay->display_score($avgscore, $displaytype); |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * @param $item |
|
309 | - * @param $ignore_score_color |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - private function build_result_column($item, $ignore_score_color) |
|
313 | - { |
|
314 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
315 | - $scoredisplay = ScoreDisplay :: instance(); |
|
316 | - $displaytype = SCORE_DIV_PERCENT; |
|
317 | - if ($ignore_score_color) { |
|
318 | - $displaytype |= SCORE_IGNORE_SPLIT; |
|
319 | - } |
|
320 | - |
|
321 | - return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT); |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * @param $item |
|
326 | - * @param $ignore_score_color |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - private function build_mask_column($item, $ignore_score_color) |
|
330 | - { |
|
331 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
332 | - $scoredisplay = ScoreDisplay :: instance(); |
|
333 | - $displaytype = SCORE_DIV_PERCENT; |
|
334 | - if ($ignore_score_color) { |
|
335 | - $displaytype |= SCORE_IGNORE_SPLIT; |
|
336 | - } |
|
337 | - return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM); |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * @param $coursecode |
|
342 | - * @return mixed |
|
343 | - */ |
|
344 | - private function get_course_name_from_code_cached($coursecode) |
|
345 | - { |
|
346 | - if (isset ($this->coursecodecache) |
|
347 | - && isset ($this->coursecodecache[$coursecode])) { |
|
348 | - return $this->coursecodecache[$coursecode]; |
|
349 | - } else { |
|
350 | - $name = CourseManager::getCourseNameFromCode($coursecode); |
|
351 | - $this->coursecodecache[$coursecode] = $name; |
|
352 | - return $name; |
|
353 | - } |
|
354 | - } |
|
355 | - |
|
356 | - /** |
|
357 | - * @param $category_id |
|
358 | - * @return null |
|
359 | - */ |
|
360 | - private function get_category_cached($category_id) |
|
361 | - { |
|
362 | - if (isset ($this->categorycache) |
|
363 | - && isset ($this->categorycache[$category_id])) { |
|
364 | - return $this->categorycache[$category_id]; |
|
365 | - }else { |
|
366 | - $cat = Category::load($category_id); |
|
367 | - if (isset($cat)){ |
|
368 | - $this->categorycache[$category_id] = $cat[0]; |
|
369 | - return $cat[0]; |
|
370 | - }else |
|
371 | - return null; |
|
372 | - } |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * @param $cat |
|
377 | - * @return string |
|
378 | - */ |
|
379 | - private function get_category_name_to_display($cat) |
|
380 | - { |
|
381 | - if (isset($cat)) { |
|
382 | - if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
383 | - return ''; |
|
384 | - } else { |
|
385 | - return $cat->get_name(); |
|
386 | - } |
|
387 | - } else { |
|
388 | - return ''; |
|
389 | - } |
|
390 | - } |
|
304 | + return $scoredisplay->display_score($avgscore, $displaytype); |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * @param $item |
|
309 | + * @param $ignore_score_color |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + private function build_result_column($item, $ignore_score_color) |
|
313 | + { |
|
314 | + $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
315 | + $scoredisplay = ScoreDisplay :: instance(); |
|
316 | + $displaytype = SCORE_DIV_PERCENT; |
|
317 | + if ($ignore_score_color) { |
|
318 | + $displaytype |= SCORE_IGNORE_SPLIT; |
|
319 | + } |
|
320 | + |
|
321 | + return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT); |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * @param $item |
|
326 | + * @param $ignore_score_color |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + private function build_mask_column($item, $ignore_score_color) |
|
330 | + { |
|
331 | + $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
332 | + $scoredisplay = ScoreDisplay :: instance(); |
|
333 | + $displaytype = SCORE_DIV_PERCENT; |
|
334 | + if ($ignore_score_color) { |
|
335 | + $displaytype |= SCORE_IGNORE_SPLIT; |
|
336 | + } |
|
337 | + return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM); |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * @param $coursecode |
|
342 | + * @return mixed |
|
343 | + */ |
|
344 | + private function get_course_name_from_code_cached($coursecode) |
|
345 | + { |
|
346 | + if (isset ($this->coursecodecache) |
|
347 | + && isset ($this->coursecodecache[$coursecode])) { |
|
348 | + return $this->coursecodecache[$coursecode]; |
|
349 | + } else { |
|
350 | + $name = CourseManager::getCourseNameFromCode($coursecode); |
|
351 | + $this->coursecodecache[$coursecode] = $name; |
|
352 | + return $name; |
|
353 | + } |
|
354 | + } |
|
355 | + |
|
356 | + /** |
|
357 | + * @param $category_id |
|
358 | + * @return null |
|
359 | + */ |
|
360 | + private function get_category_cached($category_id) |
|
361 | + { |
|
362 | + if (isset ($this->categorycache) |
|
363 | + && isset ($this->categorycache[$category_id])) { |
|
364 | + return $this->categorycache[$category_id]; |
|
365 | + }else { |
|
366 | + $cat = Category::load($category_id); |
|
367 | + if (isset($cat)){ |
|
368 | + $this->categorycache[$category_id] = $cat[0]; |
|
369 | + return $cat[0]; |
|
370 | + }else |
|
371 | + return null; |
|
372 | + } |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * @param $cat |
|
377 | + * @return string |
|
378 | + */ |
|
379 | + private function get_category_name_to_display($cat) |
|
380 | + { |
|
381 | + if (isset($cat)) { |
|
382 | + if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
383 | + return ''; |
|
384 | + } else { |
|
385 | + return $cat->get_name(); |
|
386 | + } |
|
387 | + } else { |
|
388 | + return ''; |
|
389 | + } |
|
390 | + } |
|
391 | 391 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | } |
52 | 52 | if (count($result) == 0) { |
53 | - $evals_filtered=$evals; |
|
53 | + $evals_filtered = $evals; |
|
54 | 54 | } else { |
55 | - $evals_filtered=$evals_filtered_copy; |
|
55 | + $evals_filtered = $evals_filtered_copy; |
|
56 | 56 | } |
57 | 57 | $this->items = array_merge($evals_filtered, $links); |
58 | 58 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | // do some checks on count, redefine if invalid value |
87 | 87 | if (!isset($count)) { |
88 | - $count = count ($this->items) - $start; |
|
88 | + $count = count($this->items) - $start; |
|
89 | 89 | } |
90 | 90 | if ($count < 0) { |
91 | 91 | $count = 0; |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
105 | 105 | // if user sorts on average scores, first calculate them and cache them |
106 | 106 | foreach ($allitems as $item) { |
107 | - $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
107 | + $this->avgcache[$item->get_item_type().$item->get_id()] = $item->calc_score(); |
|
108 | 108 | } |
109 | 109 | usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
110 | 110 | } elseif ($sorting & self :: UDG_SORT_SCORE) { |
111 | 111 | // if user sorts on student's scores, first calculate them and cache them |
112 | 112 | foreach ($allitems as $item) { |
113 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
113 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
114 | 114 | = $item->calc_score($this->userid); |
115 | 115 | } |
116 | 116 | usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
117 | 117 | } elseif ($sorting & self :: UDG_SORT_MASK) { |
118 | 118 | // if user sorts on student's masks, first calculate scores and cache them |
119 | 119 | foreach ($allitems as $item) { |
120 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
120 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
121 | 121 | = $item->calc_score($this->userid); |
122 | 122 | } |
123 | 123 | usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | // fill score cache if not done yet |
133 | 133 | if (!isset ($this->scorecache)) { |
134 | 134 | foreach ($visibleitems as $item) { |
135 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
135 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
136 | 136 | = $item->calc_score($this->userid); |
137 | 137 | } |
138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $scoredisplay = ScoreDisplay :: instance(); |
142 | 142 | $data = array(); |
143 | 143 | foreach ($visibleitems as $item) { |
144 | - $row = array (); |
|
144 | + $row = array(); |
|
145 | 145 | $row[] = $item; |
146 | 146 | $row[] = $item->get_name(); |
147 | 147 | $row[] = $this->build_course_name($item); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | function sort_by_type($item1, $item2) |
164 | 164 | { |
165 | 165 | if ($item1->get_item_type() == $item2->get_item_type()) { |
166 | - return $this->sort_by_name($item1,$item2); |
|
166 | + return $this->sort_by_name($item1, $item2); |
|
167 | 167 | } else { |
168 | 168 | return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
169 | 169 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | function sort_by_name($item1, $item2) |
205 | 205 | { |
206 | - return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
206 | + return api_strnatcmp($item1->get_name(), $item2->get_name()); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | */ |
214 | 214 | function sort_by_average($item1, $item2) |
215 | 215 | { |
216 | - $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
217 | - $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
216 | + $score1 = $this->avgcache[$item1->get_item_type().$item1->get_id()]; |
|
217 | + $score2 = $this->avgcache[$item2->get_item_type().$item2->get_id()]; |
|
218 | 218 | |
219 | 219 | return $this->compare_scores($score1, $score2); |
220 | 220 | } |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function sort_by_score($item1, $item2) |
228 | 228 | { |
229 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
230 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
229 | + $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()]; |
|
230 | + $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()]; |
|
231 | 231 | |
232 | 232 | return $this->compare_scores($score1, $score2); |
233 | 233 | } |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | */ |
240 | 240 | function sort_by_mask($item1, $item2) |
241 | 241 | { |
242 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
243 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
242 | + $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()]; |
|
243 | + $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()]; |
|
244 | 244 | |
245 | 245 | return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
246 | 246 | } |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | return (isset($score2) ? 1 : 0); |
257 | 257 | } elseif (!isset($score2)) { |
258 | 258 | return -1; |
259 | - } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
259 | + } elseif (($score1[0] / $score1[1]) == ($score2[0] / $score2[1])) { |
|
260 | 260 | return 0; |
261 | 261 | } else { |
262 | - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
262 | + return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | private function build_average_column($item, $ignore_score_color) |
292 | 292 | { |
293 | 293 | if (isset($this->avgcache)) { |
294 | - $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
294 | + $avgscore = $this->avgcache[$item->get_item_type().$item->get_id()]; |
|
295 | 295 | } else { |
296 | 296 | $avgscore = $item->calc_score(); |
297 | 297 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | private function build_result_column($item, $ignore_score_color) |
313 | 313 | { |
314 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
314 | + $studscore = $this->scorecache[$item->get_item_type().$item->get_id()]; |
|
315 | 315 | $scoredisplay = ScoreDisplay :: instance(); |
316 | 316 | $displaytype = SCORE_DIV_PERCENT; |
317 | 317 | if ($ignore_score_color) { |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | private function build_mask_column($item, $ignore_score_color) |
330 | 330 | { |
331 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
331 | + $studscore = $this->scorecache[$item->get_item_type().$item->get_id()]; |
|
332 | 332 | $scoredisplay = ScoreDisplay :: instance(); |
333 | 333 | $displaytype = SCORE_DIV_PERCENT; |
334 | 334 | if ($ignore_score_color) { |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | if (isset ($this->categorycache) |
363 | 363 | && isset ($this->categorycache[$category_id])) { |
364 | 364 | return $this->categorycache[$category_id]; |
365 | - }else { |
|
365 | + } else { |
|
366 | 366 | $cat = Category::load($category_id); |
367 | - if (isset($cat)){ |
|
367 | + if (isset($cat)) { |
|
368 | 368 | $this->categorycache[$category_id] = $cat[0]; |
369 | 369 | return $cat[0]; |
370 | - }else |
|
370 | + } else |
|
371 | 371 | return null; |
372 | 372 | } |
373 | 373 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | private function get_category_name_to_display($cat) |
380 | 380 | { |
381 | 381 | if (isset($cat)) { |
382 | - if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
382 | + if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null) { |
|
383 | 383 | return ''; |
384 | 384 | } else { |
385 | 385 | return $cat->get_name(); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // sort users array |
96 | 96 | if ($sorting & self :: UDG_SORT_TYPE) { |
97 | 97 | usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
98 | - }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
98 | + } elseif ($sorting & self :: UDG_SORT_NAME) { |
|
99 | 99 | usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
100 | 100 | } elseif ($sorting & self :: UDG_SORT_COURSE) { |
101 | 101 | usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
@@ -148,8 +148,9 @@ discard block |
||
148 | 148 | $row[] = $this->build_category_name($item); |
149 | 149 | $row[] = $this->build_average_column($item, $ignore_score_color); |
150 | 150 | $row[] = $this->build_result_column($item, $ignore_score_color); |
151 | - if ($scoredisplay->is_custom()) |
|
152 | - $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
151 | + if ($scoredisplay->is_custom()) { |
|
152 | + $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
153 | + } |
|
153 | 154 | $data[] = $row; |
154 | 155 | } |
155 | 156 | return $data; |
@@ -362,13 +363,14 @@ discard block |
||
362 | 363 | if (isset ($this->categorycache) |
363 | 364 | && isset ($this->categorycache[$category_id])) { |
364 | 365 | return $this->categorycache[$category_id]; |
365 | - }else { |
|
366 | + } else { |
|
366 | 367 | $cat = Category::load($category_id); |
367 | 368 | if (isset($cat)){ |
368 | 369 | $this->categorycache[$category_id] = $cat[0]; |
369 | 370 | return $cat[0]; |
370 | - }else |
|
371 | - return null; |
|
371 | + } else { |
|
372 | + return null; |
|
373 | + } |
|
372 | 374 | } |
373 | 375 | } |
374 | 376 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | - * @return array |
|
21 | + * @return string[] |
|
22 | 22 | */ |
23 | 23 | public static function get_tags() |
24 | 24 | { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param string $course_code |
41 | 41 | * @param int $session_id |
42 | 42 | * |
43 | - * @return mixed |
|
43 | + * @return string |
|
44 | 44 | */ |
45 | 45 | public static function parse_content($userId, $content, $course_code, $session_id = 0) |
46 | 46 | { |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * @param array uploaded file $_FILES |
350 | 350 | * @param string Comment describing the attachment |
351 | 351 | * @param bool $sendToUsersInSession |
352 | - * @return int false on failure, ID of the announcement on success |
|
352 | + * @return false|string false on failure, ID of the announcement on success |
|
353 | 353 | */ |
354 | 354 | public static function add_announcement( |
355 | 355 | $emailTitle, |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param $to_users |
461 | 461 | * @param array $file |
462 | 462 | * @param string $file_comment |
463 | - * @return bool|int |
|
463 | + * @return false|string |
|
464 | 464 | */ |
465 | 465 | public static function add_group_announcement( |
466 | 466 | $emailTitle, |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | /** |
701 | 701 | * @param int $insert_id |
702 | - * @return bool |
|
702 | + * @return false|null |
|
703 | 703 | */ |
704 | 704 | public static function update_mail_sent($insert_id) |
705 | 705 | { |
@@ -719,6 +719,7 @@ discard block |
||
719 | 719 | * Gets all announcements from a user by course |
720 | 720 | * @param string course db |
721 | 721 | * @param int user id |
722 | + * @param integer $user_id |
|
722 | 723 | * @return array html with the content and count of announcements or false otherwise |
723 | 724 | */ |
724 | 725 | public static function get_all_annoucement_by_user_course($course_code, $user_id) |
@@ -1184,6 +1185,7 @@ discard block |
||
1184 | 1185 | * has been sent to |
1185 | 1186 | * @param string The tool (announcement, agenda, ...) |
1186 | 1187 | * @param int ID of the element of the corresponding type |
1188 | + * @param string $tool |
|
1187 | 1189 | * @return array Array of users and groups to whom the element has been sent |
1188 | 1190 | */ |
1189 | 1191 | public static function sent_to($tool, $id) |
@@ -1308,6 +1310,8 @@ discard block |
||
1308 | 1310 | * @param int attach id |
1309 | 1311 | * @param array uploaded file $_FILES |
1310 | 1312 | * @param string file comment |
1313 | + * @param integer $id_attach |
|
1314 | + * @param string $file_comment |
|
1311 | 1315 | * @return int |
1312 | 1316 | */ |
1313 | 1317 | public static function edit_announcement_attachment_file($id_attach, $file, $file_comment) |
@@ -1510,7 +1510,7 @@ |
||
1510 | 1510 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) |
1511 | 1511 | ) "; |
1512 | 1512 | } else { |
1513 | - $cond_user_id = " AND ( |
|
1513 | + $cond_user_id = " AND ( |
|
1514 | 1514 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".api_get_group_id().")) |
1515 | 1515 | )"; |
1516 | 1516 | } |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | announcement.id = '$announcement_id' AND |
217 | 217 | toolitemproperties.tool='announcement' AND |
218 | 218 | ( |
219 | - toolitemproperties.to_user_id='" . api_get_user_id() . "' OR |
|
220 | - toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list) . "') OR |
|
219 | + toolitemproperties.to_user_id='".api_get_user_id()."' OR |
|
220 | + toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list)."') OR |
|
221 | 221 | toolitemproperties.to_group_id IS NULL |
222 | 222 | ) AND |
223 | 223 | toolitemproperties.visibility='1' AND |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | $title = $result['title']; |
247 | 247 | $content = $result['content']; |
248 | 248 | $html .= "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" class=\"data_table\">"; |
249 | - $html .= "<tr><td><h2>" . $title . "</h2></td></tr>"; |
|
249 | + $html .= "<tr><td><h2>".$title."</h2></td></tr>"; |
|
250 | 250 | |
251 | 251 | if (api_is_allowed_to_edit(false, true) || |
252 | 252 | (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
253 | 253 | ) { |
254 | - $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $announcement_id . "\">" . |
|
255 | - Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>"; |
|
254 | + $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$announcement_id."\">". |
|
255 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
256 | 256 | if ($result['visibility'] == 1) { |
257 | 257 | $image_visibility = "visible"; |
258 | 258 | $alt_visibility = get_lang('Hide'); |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | } |
263 | 263 | global $stok; |
264 | 264 | |
265 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . (!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '') . "&action=showhide&id=" . $announcement_id . "&sec_token=" . $stok . "\">" . |
|
266 | - Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>"; |
|
265 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '')."&action=showhide&id=".$announcement_id."&sec_token=".$stok."\">". |
|
266 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
267 | 267 | |
268 | 268 | if (api_is_allowed_to_edit(false, true)) { |
269 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=delete&id=" . $announcement_id . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" . |
|
270 | - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . |
|
269 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$announcement_id."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."')) return false;\">". |
|
270 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
271 | 271 | "</a>"; |
272 | 272 | } |
273 | 273 | $html .= "<tr><th style='text-align:right'>$modify_icons</th></tr>"; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $content = self::parse_content($result['to_user_id'], $content, api_get_course_id(), api_get_session_id()); |
277 | 277 | |
278 | 278 | $html .= "<tr><td>$content</td></tr>"; |
279 | - $html .= "<tr><td class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " . api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG) . "</td></tr>"; |
|
279 | + $html .= "<tr><td class=\"announcements_datum\">".get_lang('LastUpdateDate')." : ".api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG)."</td></tr>"; |
|
280 | 280 | |
281 | 281 | // User or group icon |
282 | 282 | $sent_to_icon = ''; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $sent_to_form = self::sent_to_form($sent_to); |
289 | 289 | $html .= Display::tag( |
290 | 290 | 'td', |
291 | - get_lang('SentTo') . ' : ' . $sent_to_form, |
|
291 | + get_lang('SentTo').' : '.$sent_to_form, |
|
292 | 292 | array('class' => 'announcements_datum') |
293 | 293 | ); |
294 | 294 | } |
@@ -298,15 +298,15 @@ discard block |
||
298 | 298 | $html .= "<tr><td>"; |
299 | 299 | $realname = $attachment_list['path']; |
300 | 300 | $user_filename = $attachment_list['filename']; |
301 | - $full_file_name = 'download.php?'.api_get_cidreq().'&file=' . $realname; |
|
301 | + $full_file_name = 'download.php?'.api_get_cidreq().'&file='.$realname; |
|
302 | 302 | $html .= '<br/>'; |
303 | 303 | $html .= Display::return_icon('attachment.gif', get_lang('Attachment')); |
304 | - $html .= '<a href="' . $full_file_name . ' "> ' . $user_filename . ' </a>'; |
|
305 | - $html .= ' - <span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>'; |
|
304 | + $html .= '<a href="'.$full_file_name.' "> '.$user_filename.' </a>'; |
|
305 | + $html .= ' - <span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
|
306 | 306 | if (api_is_allowed_to_edit(false, true)) { |
307 | 307 | $html .= Display::url( |
308 | 308 | Display::return_icon('delete.png', get_lang('Delete'), '', 16), |
309 | - api_get_self() . "?" . api_get_cidreq() . "&action=delete_attachment&id_attach=" . $attachment_list['id'] . "&sec_token=" . $stok |
|
309 | + api_get_self()."?".api_get_cidreq()."&action=delete_attachment&id_attach=".$attachment_list['id']."&sec_token=".$stok |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | $html .= '</td></tr>'; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $order = 0; |
335 | 335 | if (Database::num_rows($res_max)) { |
336 | 336 | $row_max = Database::fetch_array($res_max); |
337 | - $order = intval($row_max[0])+1; |
|
337 | + $order = intval($row_max[0]) + 1; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $order; |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | $result = array(); |
755 | 755 | if ($num_rows > 0) { |
756 | 756 | while ($myrow = Database::fetch_array($rs)) { |
757 | - $content.= '<strong>' . $myrow['title'] . '</strong><br /><br />'; |
|
758 | - $content.= $myrow['content']; |
|
757 | + $content .= '<strong>'.$myrow['title'].'</strong><br /><br />'; |
|
758 | + $content .= $myrow['content']; |
|
759 | 759 | $i++; |
760 | 760 | } |
761 | 761 | $result['content'] = $content; |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | echo "<table id=\"recipient_list\" >"; |
787 | 787 | echo '<tr>'; |
788 | 788 | echo '<td>'; |
789 | - echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers') . "</label>"; |
|
789 | + echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers')."</label>"; |
|
790 | 790 | echo "</td>"; |
791 | 791 | echo '</tr>'; |
792 | 792 | echo '<tr>'; |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | |
795 | 795 | // the form containing all the groups and all the users of the course |
796 | 796 | echo '<td>'; |
797 | - echo "<strong>" . get_lang('Users') . "</strong><br />"; |
|
797 | + echo "<strong>".get_lang('Users')."</strong><br />"; |
|
798 | 798 | |
799 | 799 | self::construct_not_selected_select_form($groupList, $userList, $to_already_selected); |
800 | 800 | echo "</td>"; |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | echo "<td>"; |
810 | 810 | |
811 | 811 | // the form containing the selected groups and users |
812 | - echo "<strong>" . get_lang('DestinationUsers') . "</strong><br />"; |
|
812 | + echo "<strong>".get_lang('DestinationUsers')."</strong><br />"; |
|
813 | 813 | self::construct_selected_select_form($groupList, $userList, $to_already_selected); |
814 | 814 | echo "</td>"; |
815 | 815 | echo "</tr>"; |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | echo "<select id=\"not_selected_form\" name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>"; |
828 | 828 | $group_users = GroupManager::getStudentsAndTutors($group_id); |
829 | 829 | foreach ($group_users as $user) { |
830 | - echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' . |
|
831 | - api_get_person_name($user['firstname'], $user['lastname']) . |
|
830 | + echo '<option value="'.$user['user_id'].'" title="'.sprintf(get_lang('LoginX'), $user['username']).'" >'. |
|
831 | + api_get_person_name($user['firstname'], $user['lastname']). |
|
832 | 832 | '</option>'; |
833 | 833 | } |
834 | 834 | echo '</select>'; |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | if (!empty($groupList)) { |
867 | 867 | foreach ($groupList as $this_group) { |
868 | 868 | if (is_array($to_already_selected)) { |
869 | - if (!in_array("GROUP:" . $this_group['id'], $to_already_selected)) { |
|
869 | + if (!in_array("GROUP:".$this_group['id'], $to_already_selected)) { |
|
870 | 870 | // $to_already_selected is the array containing the groups (and users) that are already selected |
871 | - $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser') ; |
|
872 | - $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled" ; |
|
873 | - echo "<option $user_disabled value=\"GROUP:" . $this_group['id'] . "\">", |
|
874 | - "G: ", $this_group['name'], " - " . $this_group['userNb'] . " " . $user_label . |
|
871 | + $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser'); |
|
872 | + $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled"; |
|
873 | + echo "<option $user_disabled value=\"GROUP:".$this_group['id']."\">", |
|
874 | + "G: ", $this_group['name'], " - ".$this_group['userNb']." ".$user_label. |
|
875 | 875 | "</option>"; |
876 | 876 | } |
877 | 877 | } |
@@ -885,15 +885,15 @@ discard block |
||
885 | 885 | if (!empty($userList)) { |
886 | 886 | foreach ($userList as $user) { |
887 | 887 | if (is_array($to_already_selected)) { |
888 | - if (!in_array("USER:" . $user['user_id'], $to_already_selected)) { |
|
888 | + if (!in_array("USER:".$user['user_id'], $to_already_selected)) { |
|
889 | 889 | // $to_already_selected is the array containing the users (and groups) that are already selected |
890 | - echo "<option value=\"USER:" . $user['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $user['username']) . "'>", |
|
890 | + echo "<option value=\"USER:".$user['user_id']."\" title='".sprintf(get_lang('LoginX'), $user['username'])."'>", |
|
891 | 891 | "", api_get_person_name($user['firstname'], $user['lastname']), |
892 | 892 | "</option>"; |
893 | 893 | |
894 | 894 | if (isset($user['drh_list']) && !empty($user['drh_list'])) { |
895 | 895 | foreach ($user['drh_list'] as $drh) { |
896 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
896 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
897 | 897 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
898 | 898 | "</option>"; |
899 | 899 | } |
@@ -925,16 +925,16 @@ discard block |
||
925 | 925 | foreach ($to_already_selected as $groupuser) { |
926 | 926 | list($type, $id) = explode(":", $groupuser); |
927 | 927 | if ($type == "GROUP") { |
928 | - echo "<option value=\"" . $groupuser . "\">G: " . $ref_array_groups[$id]['name'] . "</option>"; |
|
928 | + echo "<option value=\"".$groupuser."\">G: ".$ref_array_groups[$id]['name']."</option>"; |
|
929 | 929 | } else { |
930 | 930 | foreach ($ref_array_users as $key => $value) { |
931 | 931 | if ($value['user_id'] == $id) { |
932 | - echo "<option value=\"" . $groupuser . "\" title='" . sprintf(get_lang('LoginX'), $value['username']) . "'>" . |
|
933 | - api_get_person_name($value['firstname'], $value['lastname']) . "</option>"; |
|
932 | + echo "<option value=\"".$groupuser."\" title='".sprintf(get_lang('LoginX'), $value['username'])."'>". |
|
933 | + api_get_person_name($value['firstname'], $value['lastname'])."</option>"; |
|
934 | 934 | |
935 | 935 | if (isset($value['drh_list']) && !empty($value['drh_list'])) { |
936 | 936 | foreach ($value['drh_list'] as $drh) { |
937 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
937 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
938 | 938 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
939 | 939 | "</option>"; |
940 | 940 | } |
@@ -950,17 +950,17 @@ discard block |
||
950 | 950 | if (is_array($ref_array_groups)) { |
951 | 951 | foreach ($ref_array_groups as $this_group) { |
952 | 952 | //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]); |
953 | - if (!is_array($to_already_selected) || !in_array("GROUP:" . $this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
954 | - echo "<option value=\"GROUP:" . $this_group['id'] . "\">", |
|
955 | - "G: ", $this_group['name'], " – " . $this_group['userNb'] . " " . get_lang('Users') . |
|
953 | + if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
954 | + echo "<option value=\"GROUP:".$this_group['id']."\">", |
|
955 | + "G: ", $this_group['name'], " – ".$this_group['userNb']." ".get_lang('Users'). |
|
956 | 956 | "</option>"; |
957 | 957 | } |
958 | 958 | } |
959 | 959 | } |
960 | 960 | // adding the individual users to the select form |
961 | 961 | foreach ($ref_array_users as $this_user) { |
962 | - if (!is_array($to_already_selected) || !in_array("USER:" . $this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
963 | - echo "<option value=\"USER:", $this_user['user_id'], "\" title='" . sprintf(get_lang('LoginX'), $this_user['username']) . "'>", |
|
962 | + if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
963 | + echo "<option value=\"USER:", $this_user['user_id'], "\" title='".sprintf(get_lang('LoginX'), $this_user['username'])."'>", |
|
964 | 964 | "", api_get_person_name($this_user['firstname'], $this_user['lastname']), |
965 | 965 | "</option>"; |
966 | 966 | } |
@@ -1073,14 +1073,14 @@ discard block |
||
1073 | 1073 | switch ($to_group) { |
1074 | 1074 | // it was send to one specific user |
1075 | 1075 | case null: |
1076 | - $to[] = "USER:" . $row['to_user_id']; |
|
1076 | + $to[] = "USER:".$row['to_user_id']; |
|
1077 | 1077 | break; |
1078 | 1078 | // it was sent to everyone |
1079 | 1079 | case 0: |
1080 | 1080 | return "everyone"; |
1081 | 1081 | break; |
1082 | 1082 | default: |
1083 | - $to[] = "GROUP:" . $row['to_group_id']; |
|
1083 | + $to[] = "GROUP:".$row['to_group_id']; |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | return $to; |
@@ -1161,10 +1161,10 @@ discard block |
||
1161 | 1161 | $sent_to_array['groups'][0] !== 0 |
1162 | 1162 | ) { |
1163 | 1163 | $group_id = $sent_to_array['groups'][0]; |
1164 | - $output[] = " " . $group_names[$group_id]['name']; |
|
1164 | + $output[] = " ".$group_names[$group_id]['name']; |
|
1165 | 1165 | } |
1166 | 1166 | if (empty($sent_to_array['groups']) and empty($sent_to_array['users'])) { |
1167 | - $output[] = " " . get_lang('Everybody'); |
|
1167 | + $output[] = " ".get_lang('Everybody'); |
|
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | |
1200 | 1200 | $sql = "SELECT to_group_id, to_user_id |
1201 | 1201 | FROM $tbl_item_property |
1202 | - WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id; |
|
1202 | + WHERE c_id = $course_id AND tool = '$tool' AND ref=".$id; |
|
1203 | 1203 | $result = Database::query($sql); |
1204 | 1204 | |
1205 | 1205 | while ($row = Database::fetch_array($result)) { |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | $announcement_id = intval($announcement_id); |
1239 | 1239 | $course_id = api_get_course_int_id(); |
1240 | 1240 | $row = array(); |
1241 | - $sql = 'SELECT id, path, filename, comment FROM ' . $tbl_announcement_attachment . ' |
|
1242 | - WHERE c_id = ' . $course_id . ' AND announcement_id = ' . $announcement_id . ''; |
|
1241 | + $sql = 'SELECT id, path, filename, comment FROM '.$tbl_announcement_attachment.' |
|
1242 | + WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcement_id.''; |
|
1243 | 1243 | $result = Database::query($sql); |
1244 | 1244 | if (Database::num_rows($result) != 0) { |
1245 | 1245 | $row = Database::fetch_array($result, 'ASSOC'); |
@@ -1264,9 +1264,9 @@ discard block |
||
1264 | 1264 | |
1265 | 1265 | if (is_array($file) && $file['error'] == 0) { |
1266 | 1266 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
1267 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
1267 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
1268 | 1268 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
1269 | - $updir = $sys_course_path . $courseDir; |
|
1269 | + $updir = $sys_course_path.$courseDir; |
|
1270 | 1270 | |
1271 | 1271 | // Try to add an extension to the file if it hasn't one |
1272 | 1272 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
1279 | 1279 | } else { |
1280 | 1280 | $new_file_name = uniqid(''); |
1281 | - $new_path = $updir . '/' . $new_file_name; |
|
1281 | + $new_path = $updir.'/'.$new_file_name; |
|
1282 | 1282 | move_uploaded_file($file['tmp_name'], $new_path); |
1283 | 1283 | |
1284 | 1284 | $params = [ |
@@ -1319,9 +1319,9 @@ discard block |
||
1319 | 1319 | |
1320 | 1320 | if (is_array($file) && $file['error'] == 0) { |
1321 | 1321 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
1322 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
1322 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
1323 | 1323 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
1324 | - $updir = $sys_course_path . $courseDir; |
|
1324 | + $updir = $sys_course_path.$courseDir; |
|
1325 | 1325 | |
1326 | 1326 | // Try to add an extension to the file if it hasn't one |
1327 | 1327 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1333,13 +1333,13 @@ discard block |
||
1333 | 1333 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
1334 | 1334 | } else { |
1335 | 1335 | $new_file_name = uniqid(''); |
1336 | - $new_path = $updir . '/' . $new_file_name; |
|
1336 | + $new_path = $updir.'/'.$new_file_name; |
|
1337 | 1337 | @move_uploaded_file($file['tmp_name'], $new_path); |
1338 | 1338 | $safe_file_comment = Database::escape_string($file_comment); |
1339 | 1339 | $safe_file_name = Database::escape_string($file_name); |
1340 | 1340 | $safe_new_file_name = Database::escape_string($new_file_name); |
1341 | 1341 | $id_attach = intval($id_attach); |
1342 | - $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='" . intval($file['size']) . "' |
|
1342 | + $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='".intval($file['size'])."' |
|
1343 | 1343 | WHERE c_id = $course_id AND id = '$id_attach'"; |
1344 | 1344 | $result = Database::query($sql); |
1345 | 1345 | if ($result === false) { |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | |
1442 | 1442 | //if (!empty($user_id)) { |
1443 | 1443 | if (0) { |
1444 | - if (is_array($group_memberships) && count($group_memberships) > 0 ) { |
|
1444 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1445 | 1445 | $sql = "SELECT $select |
1446 | 1446 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1447 | 1447 | WHERE |
@@ -1652,8 +1652,8 @@ discard block |
||
1652 | 1652 | $attachment_list = AnnouncementManager::get_attachment($myrow['id']); |
1653 | 1653 | |
1654 | 1654 | $attachment_icon = ''; |
1655 | - if (count($attachment_list)>0) { |
|
1656 | - $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1655 | + if (count($attachment_list) > 0) { |
|
1656 | + $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
1657 | 1657 | } |
1658 | 1658 | |
1659 | 1659 | /* TITLE */ |
@@ -1672,16 +1672,16 @@ discard block |
||
1672 | 1672 | || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
1673 | 1673 | ) { |
1674 | 1674 | $modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$myrow['id']."\">". |
1675 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>"; |
|
1676 | - if ($myrow['visibility']==1) { |
|
1677 | - $image_visibility="visible"; |
|
1678 | - $alt_visibility=get_lang('Hide'); |
|
1675 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
1676 | + if ($myrow['visibility'] == 1) { |
|
1677 | + $image_visibility = "visible"; |
|
1678 | + $alt_visibility = get_lang('Hide'); |
|
1679 | 1679 | } else { |
1680 | - $image_visibility="invisible"; |
|
1681 | - $alt_visibility=get_lang('Visible'); |
|
1680 | + $image_visibility = "invisible"; |
|
1681 | + $alt_visibility = get_lang('Visible'); |
|
1682 | 1682 | } |
1683 | - $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
1684 | - Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>"; |
|
1683 | + $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
1684 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
1685 | 1685 | |
1686 | 1686 | // DISPLAY MOVE UP COMMAND only if it is not the top announcement |
1687 | 1687 | if ($iterator != 1) { |
@@ -1696,12 +1696,12 @@ discard block |
||
1696 | 1696 | } else { |
1697 | 1697 | $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); |
1698 | 1698 | } |
1699 | - if (api_is_allowed_to_edit(false,true)) { |
|
1700 | - $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding()))."')) return false;\">". |
|
1701 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). |
|
1699 | + if (api_is_allowed_to_edit(false, true)) { |
|
1700 | + $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">". |
|
1701 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
1702 | 1702 | "</a>"; |
1703 | 1703 | } |
1704 | - $iterator ++; |
|
1704 | + $iterator++; |
|
1705 | 1705 | } else { |
1706 | 1706 | $modify_icons = Display::url( |
1707 | 1707 | Display::return_icon('default.png'), |
@@ -1731,7 +1731,7 @@ discard block |
||
1731 | 1731 | public static function getNumberAnnouncements() |
1732 | 1732 | { |
1733 | 1733 | // Maximum title messages to display |
1734 | - $maximum = '12'; |
|
1734 | + $maximum = '12'; |
|
1735 | 1735 | // Database Table Definitions |
1736 | 1736 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
1737 | 1737 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | $userId = api_get_user_id(); |
1743 | 1743 | $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id'); |
1744 | 1744 | |
1745 | - if (api_is_allowed_to_edit(false,true)) { |
|
1745 | + if (api_is_allowed_to_edit(false, true)) { |
|
1746 | 1746 | // check teacher status |
1747 | 1747 | if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { |
1748 | 1748 | |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | } |
1806 | 1806 | |
1807 | 1807 | // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements |
1808 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
1808 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1809 | 1809 | $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
1810 | 1810 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1811 | 1811 | WHERE |
@@ -1855,7 +1855,7 @@ discard block |
||
1855 | 1855 | } |
1856 | 1856 | |
1857 | 1857 | // the user is not identiefied => show only the general announcements |
1858 | - $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
1858 | + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
1859 | 1859 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1860 | 1860 | WHERE |
1861 | 1861 | announcement.c_id = $course_id AND |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * Displays the tools of a certain category. |
215 | 215 | * |
216 | - * @return void |
|
216 | + * @return string |
|
217 | 217 | * @param string $course_tool_category contains the category of tools to display: |
218 | 218 | * "Public", "PublicButHide", "courseAdmin", "claroAdmin" |
219 | 219 | */ |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | * @param array $all_tools_list List of tools as returned by get_tools_category() |
651 | 651 | * @param bool $rows |
652 | 652 | * |
653 | - * @return void |
|
653 | + * @return string |
|
654 | 654 | */ |
655 | 655 | public static function show_tools_category($all_tools_list, $rows = false) |
656 | 656 | { |
@@ -1194,6 +1194,7 @@ discard block |
||
1194 | 1194 | |
1195 | 1195 | /** |
1196 | 1196 | * Show a toolbar with shortcuts to the course tool |
1197 | + * @param integer $orientation |
|
1197 | 1198 | */ |
1198 | 1199 | public static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) |
1199 | 1200 | { |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | array(), |
352 | 352 | null, |
353 | 353 | ICON_SIZE_MEDIUM |
354 | - ) . ' ' . $tool_name . '</a>'; |
|
354 | + ).' '.$tool_name.'</a>'; |
|
355 | 355 | |
356 | 356 | // This part displays the links to hide or remove a tool. |
357 | 357 | // These links are only visible by the course manager. |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | $session_id = api_get_session_id(); |
679 | 679 | $is_platform_admin = api_is_platform_admin(); |
680 | 680 | |
681 | - if ($session_id == 0 ) { |
|
681 | + if ($session_id == 0) { |
|
682 | 682 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin(); |
683 | 683 | } else { |
684 | 684 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach(); |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | return array(); |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - $table = Database::get_course_table(TABLE_TOOL_LIST); |
|
1258 | + $table = Database::get_course_table(TABLE_TOOL_LIST); |
|
1259 | 1259 | $sql = "SELECT * FROM $table |
1260 | 1260 | WHERE category in ('authoring','interaction') |
1261 | 1261 | AND c_id = $courseId |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | $temp = new Image($path); |
1362 | 1362 | $r = $temp->convert2bw(); |
1363 | 1363 | $ext = pathinfo($path, PATHINFO_EXTENSION); |
1364 | - $bwPath = substr($path,0,-(strlen($ext)+1)) . '_na.' . $ext; |
|
1364 | + $bwPath = substr($path, 0, -(strlen($ext) + 1)).'_na.'.$ext; |
|
1365 | 1365 | |
1366 | 1366 | if ($r === false) { |
1367 | 1367 | error_log('Conversion to B&W of '.$path.' failed in '.__FILE__.' at line '.__LINE__); |
@@ -1200,9 +1200,9 @@ |
||
1200 | 1200 | $navigation_items = self::get_navigation_items(false); |
1201 | 1201 | $html = ''; |
1202 | 1202 | if (!empty($navigation_items)) { |
1203 | - if ($orientation == SHORTCUTS_HORIZONTAL) |
|
1204 | - $style_id = "toolshortcuts_horizontal"; |
|
1205 | - else { |
|
1203 | + if ($orientation == SHORTCUTS_HORIZONTAL) { |
|
1204 | + $style_id = "toolshortcuts_horizontal"; |
|
1205 | + } else { |
|
1206 | 1206 | $style_id = "toolshortcuts_vertical"; |
1207 | 1207 | } |
1208 | 1208 | $html .= '<div id="'.$style_id.'">'; |
@@ -351,6 +351,12 @@ |
||
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Additional functions needed for fast integration |
354 | + * @param integer $status |
|
355 | + * @param string $section |
|
356 | + * @param string $title |
|
357 | + * @param string $url |
|
358 | + * @param string|null $formatter |
|
359 | + * @param string $comment |
|
354 | 360 | */ |
355 | 361 | public function build_setting($status, $section, $title, $url, $current_value, $expected_value, $formatter, $comment, $img_path = null) { |
356 | 362 | switch ($status) { |
@@ -401,19 +401,19 @@ |
||
401 | 401 | |
402 | 402 | public function format_yes_no_optional($value) |
403 | 403 | { |
404 | - $return = ''; |
|
405 | - switch($value) { |
|
406 | - case 0: |
|
407 | - $return = get_lang('No'); |
|
408 | - break; |
|
409 | - case 1: |
|
410 | - $return = get_lang('Yes'); |
|
411 | - break; |
|
412 | - case 2: |
|
413 | - $return = get_lang('Optional'); |
|
414 | - break; |
|
415 | - } |
|
416 | - return $return; |
|
404 | + $return = ''; |
|
405 | + switch($value) { |
|
406 | + case 0: |
|
407 | + $return = get_lang('No'); |
|
408 | + break; |
|
409 | + case 1: |
|
410 | + $return = get_lang('Yes'); |
|
411 | + break; |
|
412 | + case 2: |
|
413 | + $return = get_lang('Optional'); |
|
414 | + break; |
|
415 | + } |
|
416 | + return $return; |
|
417 | 417 | |
418 | 418 | } |
419 | 419 |
@@ -158,8 +158,9 @@ discard block |
||
158 | 158 | $array[] = $this->build_setting($status, '[INI]', 'display_errors', 'http://www.php.net/manual/en/ini.core.php#ini.display_errors', $setting, $req_setting, 'on_off', get_lang('DisplayErrorsInfo')); |
159 | 159 | |
160 | 160 | $setting = ini_get('default_charset'); |
161 | - if ($setting == '') |
|
162 | - $setting = null; |
|
161 | + if ($setting == '') { |
|
162 | + $setting = null; |
|
163 | + } |
|
163 | 164 | $req_setting = null; |
164 | 165 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_ERROR; |
165 | 166 | $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo')); |
@@ -177,22 +178,25 @@ discard block |
||
177 | 178 | $setting = ini_get('memory_limit'); |
178 | 179 | $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M'; |
179 | 180 | $status = self :: STATUS_ERROR; |
180 | - if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
181 | - $status = self :: STATUS_OK; |
|
181 | + if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) { |
|
182 | + $status = self :: STATUS_OK; |
|
183 | + } |
|
182 | 184 | $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo')); |
183 | 185 | |
184 | 186 | $setting = ini_get('post_max_size'); |
185 | 187 | $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M'; |
186 | 188 | $status = self :: STATUS_ERROR; |
187 | - if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
188 | - $status = self :: STATUS_OK; |
|
189 | + if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) { |
|
190 | + $status = self :: STATUS_OK; |
|
191 | + } |
|
189 | 192 | $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo')); |
190 | 193 | |
191 | 194 | $setting = ini_get('upload_max_filesize'); |
192 | 195 | $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M'; |
193 | 196 | $status = self :: STATUS_ERROR; |
194 | - if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
195 | - $status = self :: STATUS_OK; |
|
197 | + if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) { |
|
198 | + $status = self :: STATUS_OK; |
|
199 | + } |
|
196 | 200 | $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo')); |
197 | 201 | |
198 | 202 | $setting = ini_get('variables_order'); |
@@ -205,7 +209,7 @@ discard block |
||
205 | 209 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
206 | 210 | $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo')); |
207 | 211 | |
208 | - if (api_check_browscap()){$setting = true;}else{$setting=false;} |
|
212 | + if (api_check_browscap()){$setting = true;} else{$setting=false;} |
|
209 | 213 | $req_setting = true; |
210 | 214 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
211 | 215 | $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo')); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | const STATUS_OK = 1; |
17 | 17 | const STATUS_WARNING = 2; |
18 | - const STATUS_ERROR = 3; |
|
18 | + const STATUS_ERROR = 3; |
|
19 | 19 | const STATUS_INFORMATION = 4; |
20 | 20 | |
21 | 21 | /** |
@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | $html .= '<li>'; |
45 | 45 | } |
46 | 46 | $params['section'] = $section; |
47 | - $html .='<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
47 | + $html .= '<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $html .= '</ul><div class="tab-pane">'; |
51 | 51 | |
52 | - $data = call_user_func(array($this, 'get_' . $current_section . '_data')); |
|
52 | + $data = call_user_func(array($this, 'get_'.$current_section.'_data')); |
|
53 | 53 | echo $html; |
54 | 54 | $table = new SortableTableFromArray($data, 1, 100); |
55 | 55 | |
56 | - $table->set_header(0,'', false); |
|
57 | - $table->set_header(1,get_lang('Section'), false); |
|
58 | - $table->set_header(2,get_lang('Setting'), false); |
|
59 | - $table->set_header(3,get_lang('Current'), false); |
|
60 | - $table->set_header(4,get_lang('Expected'), false); |
|
61 | - $table->set_header(5,get_lang('Comment'), false); |
|
56 | + $table->set_header(0, '', false); |
|
57 | + $table->set_header(1, get_lang('Section'), false); |
|
58 | + $table->set_header(2, get_lang('Setting'), false); |
|
59 | + $table->set_header(3, get_lang('Current'), false); |
|
60 | + $table->set_header(4, get_lang('Expected'), false); |
|
61 | + $table->set_header(5, get_lang('Comment'), false); |
|
62 | 62 | |
63 | 63 | $table->display(); |
64 | 64 | echo '</div></div>'; |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | { |
73 | 73 | $array = array(); |
74 | 74 | $writable_folders = array( |
75 | - api_get_path(SYS_APP_PATH) .'cache', |
|
75 | + api_get_path(SYS_APP_PATH).'cache', |
|
76 | 76 | api_get_path(SYS_COURSE_PATH), |
77 | - api_get_path(SYS_APP_PATH) .'home', |
|
78 | - api_get_path(SYS_APP_PATH) .'upload/users/', |
|
79 | - api_get_path(SYS_PATH) .'main/default_course_document/images/', |
|
77 | + api_get_path(SYS_APP_PATH).'home', |
|
78 | + api_get_path(SYS_APP_PATH).'upload/users/', |
|
79 | + api_get_path(SYS_PATH).'main/default_course_document/images/', |
|
80 | 80 | ); |
81 | 81 | |
82 | 82 | foreach ($writable_folders as $index => $folder) { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $array[] = $this->build_setting( |
100 | 100 | $status, |
101 | 101 | '[FILES]', |
102 | - get_lang('DirectoryExists') . ': /install', |
|
102 | + get_lang('DirectoryExists').': /install', |
|
103 | 103 | 'http://be2.php.net/file_exists', |
104 | 104 | $exists, |
105 | 105 | 0, |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $message2 .= get_lang('SpaceUsedOnSystemCannotBeMeasuredOnWindows'); |
130 | 130 | } else { |
131 | 131 | $dir = api_get_path(SYS_PATH); |
132 | - $du = exec('du -sh ' . $dir, $err); |
|
132 | + $du = exec('du -sh '.$dir, $err); |
|
133 | 133 | list($size, $none) = explode("\t", $du); |
134 | 134 | $limit = $_configuration[$access_url_id]['hosting_limit_disk_space']; |
135 | 135 | $message2 .= sprintf(get_lang('TotalSpaceUsedByPortalXLimitIsYMB'), $size, $limit); |
@@ -216,33 +216,33 @@ discard block |
||
216 | 216 | $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo')); |
217 | 217 | |
218 | 218 | $setting = ini_get('max_execution_time'); |
219 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
219 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
220 | 220 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
221 | 221 | $array[] = $this->build_setting($status, '[INI]', 'max_execution_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-execution-time', $setting, $req_setting, null, get_lang('MaxExecutionTimeInfo')); |
222 | 222 | |
223 | 223 | $setting = ini_get('max_input_time'); |
224 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
224 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
225 | 225 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
226 | 226 | $array[] = $this->build_setting($status, '[INI]', 'max_input_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-input-time', $setting, $req_setting, null, get_lang('MaxInputTimeInfo')); |
227 | 227 | |
228 | 228 | $setting = ini_get('memory_limit'); |
229 | 229 | $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M'; |
230 | 230 | $status = self :: STATUS_ERROR; |
231 | - if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
231 | + if ((float) $setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
232 | 232 | $status = self :: STATUS_OK; |
233 | 233 | $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo')); |
234 | 234 | |
235 | 235 | $setting = ini_get('post_max_size'); |
236 | 236 | $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M'; |
237 | 237 | $status = self :: STATUS_ERROR; |
238 | - if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
238 | + if ((float) $setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
239 | 239 | $status = self :: STATUS_OK; |
240 | 240 | $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo')); |
241 | 241 | |
242 | 242 | $setting = ini_get('upload_max_filesize'); |
243 | 243 | $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M'; |
244 | 244 | $status = self :: STATUS_ERROR; |
245 | - if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
245 | + if ((float) $setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
246 | 246 | $status = self :: STATUS_OK; |
247 | 247 | $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo')); |
248 | 248 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
257 | 257 | $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo')); |
258 | 258 | |
259 | - if (api_check_browscap()){$setting = true;}else{$setting=false;} |
|
259 | + if (api_check_browscap()) {$setting = true; } else {$setting = false; } |
|
260 | 260 | $req_setting = true; |
261 | 261 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
262 | 262 | $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo')); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | $loaded = extension_loaded($extension); |
314 | 314 | $status = $loaded ? self :: STATUS_OK : self :: STATUS_ERROR; |
315 | - $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension') . ': ' . $extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
315 | + $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension').': '.$extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | return $array; |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | $formatted_expected_value = $expected_value; |
436 | 436 | |
437 | 437 | if ($formatter) { |
438 | - if (method_exists($this, 'format_' . $formatter)) { |
|
439 | - $formatted_current_value = call_user_func(array($this, 'format_' . $formatter), $current_value); |
|
440 | - $formatted_expected_value = call_user_func(array($this, 'format_' . $formatter), $expected_value); |
|
438 | + if (method_exists($this, 'format_'.$formatter)) { |
|
439 | + $formatted_current_value = call_user_func(array($this, 'format_'.$formatter), $current_value); |
|
440 | + $formatted_expected_value = call_user_func(array($this, 'format_'.$formatter), $expected_value); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function get_link($title, $url) |
454 | 454 | { |
455 | - return '<a href="' . $url . '" target="about:bank">' . $title . '</a>'; |
|
455 | + return '<a href="'.$url.'" target="about:bank">'.$title.'</a>'; |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | public function format_yes_no_optional($value) |
459 | 459 | { |
460 | 460 | $return = ''; |
461 | - switch($value) { |
|
461 | + switch ($value) { |
|
462 | 462 | case 0: |
463 | 463 | $return = get_lang('No'); |
464 | 464 | break; |