@@ -327,6 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Serialize the course with the best serializer available |
330 | + * @return string |
|
330 | 331 | */ |
331 | 332 | public static function serialize($course) |
332 | 333 | { |
@@ -339,6 +340,7 @@ discard block |
||
339 | 340 | |
340 | 341 | /** |
341 | 342 | * Unserialize the course with the best serializer available |
343 | + * @param string $course |
|
342 | 344 | */ |
343 | 345 | public static function unserialize($course) |
344 | 346 | { |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
329 | - * Serialize the course with the best serializer available |
|
330 | - */ |
|
329 | + * Serialize the course with the best serializer available |
|
330 | + */ |
|
331 | 331 | public static function serialize($course) |
332 | 332 | { |
333 | 333 | if (extension_loaded('igbinary')) { |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
341 | - * Unserialize the course with the best serializer available |
|
342 | - */ |
|
341 | + * Unserialize the course with the best serializer available |
|
342 | + */ |
|
343 | 343 | public static function unserialize($course) |
344 | 344 | { |
345 | 345 | if (extension_loaded('igbinary')) { |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | if (is_array($resources)) { |
41 | 41 | foreach ($resources as $resource) { |
42 | 42 | Coursecopy\Resource::setClassType($resource); |
43 | - if ($resource->links_to($resource_to_check) ) { |
|
43 | + if ($resource->links_to($resource_to_check)) { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | - if ($type == RESOURCE_LEARNPATH && get_class($resource)=='CourseCopyLearnpath') { |
|
46 | + if ($type == RESOURCE_LEARNPATH && get_class($resource) == 'CourseCopyLearnpath') { |
|
47 | 47 | if ($resource->has_item($resource_to_check)) { |
48 | 48 | return true; |
49 | 49 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function has_resources($resource_type = null) |
72 | 72 | { |
73 | - if( $resource_type != null) { |
|
73 | + if ($resource_type != null) { |
|
74 | 74 | return isset($this->resources[$resource_type]) && is_array($this->resources[$resource_type]) && (count( |
75 | 75 | $this->resources[$resource_type] |
76 | 76 | ) > 0); |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | $description = $resource->content; |
178 | 178 | break; |
179 | 179 | case RESOURCE_THEMATIC: |
180 | - $title = $resource->title; |
|
181 | - $description = $resource->content; |
|
180 | + $title = $resource->title; |
|
181 | + $description = $resource->content; |
|
182 | 182 | break; |
183 | 183 | case RESOURCE_ATTENDANCE: |
184 | - $title = $resource->params['name']; |
|
185 | - $description = $resource->params['description']; |
|
184 | + $title = $resource->params['name']; |
|
185 | + $description = $resource->params['description']; |
|
186 | 186 | break; |
187 | 187 | case RESOURCE_WORK: |
188 | 188 | $title = $resource->title; |
@@ -173,7 +173,7 @@ |
||
173 | 173 | |
174 | 174 | /** |
175 | 175 | * @param array $file |
176 | - * @return bool|string |
|
176 | + * @return string|false |
|
177 | 177 | */ |
178 | 178 | public static function import_uploaded_file($file) |
179 | 179 | { |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | while (($file = readdir($handle)) !== false) { |
24 | 24 | if ($file != "." && $file != ".." && |
25 | 25 | strpos($file, 'CourseArchiver_') === 0 && |
26 | - is_dir($dir . '/' . $file) |
|
26 | + is_dir($dir.'/'.$file) |
|
27 | 27 | ) { |
28 | - rmdirr($dir . '/' . $file); |
|
28 | + rmdirr($dir.'/'.$file); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | closedir($handle); |
@@ -43,48 +43,48 @@ discard block |
||
43 | 43 | CourseArchiver::clean_backup_dir(); |
44 | 44 | |
45 | 45 | // Create a temp directory |
46 | - $tmp_dir_name = 'CourseArchiver_' . api_get_unique_id(); |
|
47 | - $backup_dir = api_get_path(SYS_ARCHIVE_PATH) . $tmp_dir_name . '/'; |
|
46 | + $tmp_dir_name = 'CourseArchiver_'.api_get_unique_id(); |
|
47 | + $backup_dir = api_get_path(SYS_ARCHIVE_PATH).$tmp_dir_name.'/'; |
|
48 | 48 | |
49 | 49 | // All course-information will be stored in course_info.dat |
50 | - $course_info_file = $backup_dir . 'course_info.dat'; |
|
50 | + $course_info_file = $backup_dir.'course_info.dat'; |
|
51 | 51 | $zip_dir = api_get_path(SYS_ARCHIVE_PATH); |
52 | 52 | $user = api_get_user_info(); |
53 | 53 | $date = new DateTime(api_get_local_time()); |
54 | - $zip_file = $user['user_id'] . '_' . $course->code . '_' . $date->format('Ymd-His') . '.zip'; |
|
54 | + $zip_file = $user['user_id'].'_'.$course->code.'_'.$date->format('Ymd-His').'.zip'; |
|
55 | 55 | $php_errormsg = ''; |
56 | 56 | $res = @mkdir($backup_dir, $perm_dirs); |
57 | 57 | if ($res === false) { |
58 | 58 | //TODO set and handle an error message telling the user to review the permissions on the archive directory |
59 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini') . ' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0); |
|
59 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0); |
|
60 | 60 | } |
61 | 61 | // Write the course-object to the file |
62 | 62 | $fp = @fopen($course_info_file, 'w'); |
63 | 63 | if ($fp === false) { |
64 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
64 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $res = @fwrite($fp, base64_encode(serialize($course))); |
68 | 68 | if ($res === false) { |
69 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
69 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $res = @fclose($fp); |
73 | 73 | if ($res === false) { |
74 | - error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
74 | + error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Copy all documents to the temp-dir |
78 | 78 | if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) { |
79 | 79 | foreach ($course->resources[RESOURCE_DOCUMENT] as $document) { |
80 | 80 | if ($document->file_type == DOCUMENT) { |
81 | - $doc_dir = $backup_dir . $document->path; |
|
81 | + $doc_dir = $backup_dir.$document->path; |
|
82 | 82 | @mkdir(dirname($doc_dir), $perm_dirs, true); |
83 | - if (file_exists($course->path . $document->path)) { |
|
84 | - copy($course->path . $document->path, $doc_dir); |
|
83 | + if (file_exists($course->path.$document->path)) { |
|
84 | + copy($course->path.$document->path, $doc_dir); |
|
85 | 85 | } |
86 | 86 | } else { |
87 | - @mkdir($backup_dir . $document->path, $perm_dirs, true); |
|
87 | + @mkdir($backup_dir.$document->path, $perm_dirs, true); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
@@ -92,49 +92,49 @@ discard block |
||
92 | 92 | // Copy all scorm documents to the temp-dir |
93 | 93 | if (isset($course->resources[RESOURCE_SCORM]) && is_array($course->resources[RESOURCE_SCORM])) { |
94 | 94 | foreach ($course->resources[RESOURCE_SCORM] as $document) { |
95 | - $doc_dir = dirname($backup_dir . $document->path); |
|
95 | + $doc_dir = dirname($backup_dir.$document->path); |
|
96 | 96 | @mkdir($doc_dir, $perm_dirs, true); |
97 | - copyDirTo($course->path . $document->path, $doc_dir, false); |
|
97 | + copyDirTo($course->path.$document->path, $doc_dir, false); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | // Copy calendar attachments. |
102 | 102 | |
103 | 103 | if (isset($course->resources[RESOURCE_EVENT]) && is_array($course->resources[RESOURCE_EVENT])) { |
104 | - $doc_dir = dirname($backup_dir . '/upload/calendar/'); |
|
104 | + $doc_dir = dirname($backup_dir.'/upload/calendar/'); |
|
105 | 105 | @mkdir($doc_dir, $perm_dirs, true); |
106 | - copyDirTo($course->path . 'upload/calendar/', $doc_dir, false); |
|
106 | + copyDirTo($course->path.'upload/calendar/', $doc_dir, false); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Copy Learning path author image. |
110 | 110 | if (isset($course->resources[RESOURCE_LEARNPATH]) && is_array($course->resources[RESOURCE_LEARNPATH])) { |
111 | - $doc_dir = dirname($backup_dir . '/upload/learning_path/'); |
|
111 | + $doc_dir = dirname($backup_dir.'/upload/learning_path/'); |
|
112 | 112 | @mkdir($doc_dir, $perm_dirs, true); |
113 | - copyDirTo($course->path . 'upload/learning_path/', $doc_dir, false); |
|
113 | + copyDirTo($course->path.'upload/learning_path/', $doc_dir, false); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // Copy announcements attachments. |
117 | 117 | if (isset($course->resources[RESOURCE_ANNOUNCEMENT]) && is_array($course->resources[RESOURCE_ANNOUNCEMENT])) { |
118 | - $doc_dir = dirname($backup_dir . '/upload/announcements/'); |
|
118 | + $doc_dir = dirname($backup_dir.'/upload/announcements/'); |
|
119 | 119 | @mkdir($doc_dir, $perm_dirs, true); |
120 | - copyDirTo($course->path . 'upload/announcements/', $doc_dir, false); |
|
120 | + copyDirTo($course->path.'upload/announcements/', $doc_dir, false); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Copy work folders (only folders) |
124 | 124 | if (isset($course->resources[RESOURCE_WORK]) && is_array($course->resources[RESOURCE_WORK])) { |
125 | - $doc_dir = dirname($backup_dir . '/upload/work/'); |
|
125 | + $doc_dir = dirname($backup_dir.'/upload/work/'); |
|
126 | 126 | @mkdir($doc_dir, $perm_dirs, true); |
127 | 127 | // @todo: adjust to only create subdirs, but not copy files |
128 | - copyDirTo($course->path . 'upload/work/', $doc_dir, false); |
|
128 | + copyDirTo($course->path.'upload/work/', $doc_dir, false); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Zip the course-contents |
132 | - $zip = new PclZip($zip_dir . $zip_file); |
|
133 | - $zip->create($zip_dir . $tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir . $tmp_dir_name . '/'); |
|
132 | + $zip = new PclZip($zip_dir.$zip_file); |
|
133 | + $zip->create($zip_dir.$tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir.$tmp_dir_name.'/'); |
|
134 | 134 | //$zip->deleteByIndex(0); |
135 | 135 | // Remove the temp-dir. |
136 | 136 | rmdirr($backup_dir); |
137 | - return '' . $zip_file; |
|
137 | + return ''.$zip_file; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | global $dateTimeFormatLong; |
147 | 147 | $backup_files = array(); |
148 | - $dirname = api_get_path(SYS_ARCHIVE_PATH) . ''; |
|
148 | + $dirname = api_get_path(SYS_ARCHIVE_PATH).''; |
|
149 | 149 | if ($dir = opendir($dirname)) { |
150 | 150 | while (($file = readdir($dir)) !== false) { |
151 | 151 | $file_parts = explode('_', $file); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $date = $file_parts[0]; |
157 | 157 | $ext = isset($file_parts[1]) ? $file_parts[1] : null; |
158 | 158 | if ($ext == 'zip' && ($user_id != null && $owner_id == $user_id || $user_id == null)) { |
159 | - $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 9, 2) . ':' . substr($date, 11, 2) . ':' . substr($date, 13, 2); |
|
159 | + $date = substr($date, 0, 4).'-'.substr($date, 4, 2).'-'.substr($date, 6, 2).' '.substr($date, 9, 2).':'.substr($date, 11, 2).':'.substr($date, 13, 2); |
|
160 | 160 | $backup_files[] = array( |
161 | 161 | 'file' => $file, |
162 | 162 | 'date' => $date, |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public static function import_uploaded_file($file) |
179 | 179 | { |
180 | - $new_filename = uniqid('') . '.zip'; |
|
180 | + $new_filename = uniqid('').'.zip'; |
|
181 | 181 | $new_dir = api_get_path(SYS_ARCHIVE_PATH); |
182 | 182 | if (is_dir($new_dir) && is_writable($new_dir)) { |
183 | 183 | move_uploaded_file($file, api_get_path(SYS_ARCHIVE_PATH).$new_filename); |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | { |
201 | 201 | CourseArchiver::clean_backup_dir(); |
202 | 202 | // Create a temp directory |
203 | - $tmp_dir_name = 'CourseArchiver_' . uniqid(''); |
|
204 | - $unzip_dir = api_get_path(SYS_ARCHIVE_PATH) . '' . $tmp_dir_name; |
|
203 | + $tmp_dir_name = 'CourseArchiver_'.uniqid(''); |
|
204 | + $unzip_dir = api_get_path(SYS_ARCHIVE_PATH).''.$tmp_dir_name; |
|
205 | 205 | @mkdir($unzip_dir, api_get_permissions_for_new_directories(), true); |
206 | - @copy(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename, $unzip_dir . '/backup.zip'); |
|
206 | + @copy(api_get_path(SYS_ARCHIVE_PATH).''.$filename, $unzip_dir.'/backup.zip'); |
|
207 | 207 | // unzip the archive |
208 | - $zip = new PclZip($unzip_dir . '/backup.zip'); |
|
208 | + $zip = new PclZip($unzip_dir.'/backup.zip'); |
|
209 | 209 | @chdir($unzip_dir); |
210 | 210 | $zip->extract(PCLZIP_OPT_TEMP_FILE_ON); |
211 | 211 | // remove the archive-file |
212 | 212 | if ($delete) { |
213 | - @unlink(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename); |
|
213 | + @unlink(api_get_path(SYS_ARCHIVE_PATH).''.$filename); |
|
214 | 214 | } |
215 | 215 | // read the course |
216 | 216 | if (!is_file('course_info.dat')) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * @param array $array |
|
94 | + * @param string[] $array |
|
95 | 95 | */ |
96 | 96 | public function set_tools_to_build($array) |
97 | 97 | { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string $courseCode |
124 | 124 | * @param bool true if you want to get the elements that exists in the course and |
125 | 125 | * in the session, (session_id = 0 or session_id = X) |
126 | - * @return object The course object structure |
|
126 | + * @return Course The course object structure |
|
127 | 127 | */ |
128 | 128 | public function build( |
129 | 129 | $session_id = 0, |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | $table_doc = Database:: get_course_table(TABLE_DOCUMENT); |
596 | 596 | |
597 | 597 | if (!empty($courseId) && !empty($session_id)) { |
598 | - $session_id = intval($session_id); |
|
598 | + $session_id = intval($session_id); |
|
599 | 599 | if ($with_base_content) { |
600 | 600 | $session_condition = api_get_session_condition( |
601 | 601 | $session_id, |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | 'title' => get_lang('OrphanQuestions', ''), |
805 | 805 | 'type' => 2 |
806 | 806 | ); |
807 | - $newQuiz = new Quiz((object)$obj); |
|
807 | + $newQuiz = new Quiz((object) $obj); |
|
808 | 808 | if (!empty($orphanQuestionIds)) { |
809 | 809 | foreach ($orphanQuestionIds as $index => $orphanId) { |
810 | 810 | $order = $index + 1; |
@@ -84,6 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Create a new CourseRestorer |
87 | + * @param Course $course |
|
87 | 88 | */ |
88 | 89 | public function __construct($course) |
89 | 90 | { |
@@ -132,7 +133,7 @@ discard block |
||
132 | 133 | * @param int $session_id |
133 | 134 | * @param bool $update_course_settings Course settings are going to be restore? |
134 | 135 | * @param bool $respect_base_content |
135 | - * @return bool |
|
136 | + * @return false|null |
|
136 | 137 | */ |
137 | 138 | public function restore( |
138 | 139 | $destination_course_code = '', |
@@ -1084,6 +1085,7 @@ discard block |
||
1084 | 1085 | |
1085 | 1086 | /** |
1086 | 1087 | * Restore a forum-topic |
1088 | + * @param false|string $forum_id |
|
1087 | 1089 | */ |
1088 | 1090 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
1089 | 1091 | { |
@@ -1140,6 +1142,7 @@ discard block |
||
1140 | 1142 | /** |
1141 | 1143 | * Restore a forum-post |
1142 | 1144 | * @TODO Restore tree-structure of posts. For example: attachments to posts. |
1145 | + * @param false|string $topic_id |
|
1143 | 1146 | */ |
1144 | 1147 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1145 | 1148 | { |
@@ -2231,6 +2234,7 @@ discard block |
||
2231 | 2234 | |
2232 | 2235 | /** |
2233 | 2236 | * Check availability of a survey code |
2237 | + * @param string $survey_code |
|
2234 | 2238 | */ |
2235 | 2239 | public function is_survey_code_available($survey_code) |
2236 | 2240 | { |
@@ -2245,6 +2249,7 @@ discard block |
||
2245 | 2249 | |
2246 | 2250 | /** |
2247 | 2251 | * Restore survey-questions |
2252 | + * @param string $survey_id |
|
2248 | 2253 | */ |
2249 | 2254 | public function restore_survey_question($id, $survey_id) |
2250 | 2255 | { |
@@ -2701,6 +2706,8 @@ discard block |
||
2701 | 2706 | * @param string The path origin |
2702 | 2707 | * @param string The path destination |
2703 | 2708 | * @param boolean Option Overwrite |
2709 | + * @param string $source |
|
2710 | + * @param string $dest |
|
2704 | 2711 | * @return void() |
2705 | 2712 | * @deprecated |
2706 | 2713 | */ |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | $this->course->backup_path, |
521 | 521 | $this->course->info['path'] |
522 | 522 | ); |
523 | - file_put_contents($path.$document->path,$content); |
|
523 | + file_put_contents($path.$document->path, $content); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | $params = [ |
@@ -564,14 +564,14 @@ discard block |
||
564 | 564 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
565 | 565 | $file_exists = file_exists($path.$new_file_name); |
566 | 566 | while ($file_exists) { |
567 | - $i ++; |
|
567 | + $i++; |
|
568 | 568 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
569 | 569 | $file_exists = file_exists($path.$new_file_name); |
570 | 570 | } |
571 | 571 | |
572 | 572 | if (!empty($session_id)) { |
573 | 573 | |
574 | - $document_path = explode('/',$document->path,3); |
|
574 | + $document_path = explode('/', $document->path, 3); |
|
575 | 575 | $course_path = $path; |
576 | 576 | $orig_base_folder = $document_path[1]; |
577 | 577 | $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | |
590 | 590 | $folder_exists = file_exists($new_base_path); |
591 | 591 | if ($folder_exists) { |
592 | - $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
592 | + $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
593 | 593 | $x = ''; |
594 | 594 | while ($folder_exists) { |
595 | 595 | $x = $x + 1; |
@@ -609,9 +609,9 @@ discard block |
||
609 | 609 | $new_base_path = $_SESSION['new_base_path']; |
610 | 610 | } |
611 | 611 | |
612 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
613 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
614 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
612 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
613 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
614 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
615 | 615 | |
616 | 616 | $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
617 | 617 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | //Replace old course code with the new destination code see BT#1985 |
632 | 632 | if (file_exists($dest_document_path)) { |
633 | 633 | $file_info = pathinfo($dest_document_path); |
634 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
634 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
635 | 635 | $content = file_get_contents($dest_document_path); |
636 | 636 | if (UTF8_CONVERT) { |
637 | 637 | $content = utf8_encode($content); |
@@ -687,8 +687,8 @@ discard block |
||
687 | 687 | //Replace old course code with the new destination code see BT#1985 |
688 | 688 | if (file_exists($path.$new_file_name)) { |
689 | 689 | $file_info = pathinfo($path.$new_file_name); |
690 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
691 | - $content = file_get_contents($path.$new_file_name); |
|
690 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
691 | + $content = file_get_contents($path.$new_file_name); |
|
692 | 692 | if (UTF8_CONVERT) { |
693 | 693 | $content = utf8_encode($content); |
694 | 694 | } |
@@ -741,8 +741,8 @@ discard block |
||
741 | 741 | //Replace old course code with the new destination code see BT#1985 |
742 | 742 | if (file_exists($path.$new_file_name)) { |
743 | 743 | $file_info = pathinfo($path.$new_file_name); |
744 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
745 | - $content = file_get_contents($path.$new_file_name); |
|
744 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
745 | + $content = file_get_contents($path.$new_file_name); |
|
746 | 746 | if (UTF8_CONVERT) { |
747 | 747 | $content = utf8_encode($content); |
748 | 748 | } |
@@ -805,8 +805,8 @@ discard block |
||
805 | 805 | //Replace old course code with the new destination code see BT#1985 |
806 | 806 | if (file_exists($path.$document->path)) { |
807 | 807 | $file_info = pathinfo($path.$document->path); |
808 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
809 | - $content = file_get_contents($path.$document->path); |
|
808 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
809 | + $content = file_get_contents($path.$document->path); |
|
810 | 810 | if (UTF8_CONVERT) { |
811 | 811 | $content = utf8_encode($content); |
812 | 812 | } |
@@ -896,8 +896,8 @@ discard block |
||
896 | 896 | case FILE_OVERWRITE: |
897 | 897 | rmdirr($path.$document->path); |
898 | 898 | copyDirTo( |
899 | - $this->course->backup_path . '/' . $document->path, |
|
900 | - $path . dirname($document->path), |
|
899 | + $this->course->backup_path.'/'.$document->path, |
|
900 | + $path.dirname($document->path), |
|
901 | 901 | false |
902 | 902 | ); |
903 | 903 | break; |
@@ -919,23 +919,23 @@ discard block |
||
919 | 919 | $file_exists = file_exists($path.$new_file_name); |
920 | 920 | |
921 | 921 | while ($file_exists) { |
922 | - $i ++; |
|
922 | + $i++; |
|
923 | 923 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
924 | 924 | $file_exists = file_exists($path.$new_file_name); |
925 | 925 | } |
926 | 926 | |
927 | 927 | rename( |
928 | - $this->course->backup_path . '/' . $document->path, |
|
929 | - $this->course->backup_path . '/' . $new_file_name |
|
928 | + $this->course->backup_path.'/'.$document->path, |
|
929 | + $this->course->backup_path.'/'.$new_file_name |
|
930 | 930 | ); |
931 | 931 | copyDirTo( |
932 | - $this->course->backup_path . '/' . $new_file_name, |
|
933 | - $path . dirname($new_file_name), |
|
932 | + $this->course->backup_path.'/'.$new_file_name, |
|
933 | + $path.dirname($new_file_name), |
|
934 | 934 | false |
935 | 935 | ); |
936 | 936 | rename( |
937 | - $this->course->backup_path . '/' . $new_file_name, |
|
938 | - $this->course->backup_path . '/' . $document->path |
|
937 | + $this->course->backup_path.'/'.$new_file_name, |
|
938 | + $this->course->backup_path.'/'.$document->path |
|
939 | 939 | ); |
940 | 940 | |
941 | 941 | break; |
@@ -943,8 +943,8 @@ discard block |
||
943 | 943 | } else { |
944 | 944 | // end if file exists |
945 | 945 | copyDirTo( |
946 | - $this->course->backup_path . '/' . $document->path, |
|
947 | - $path . dirname($document->path), |
|
946 | + $this->course->backup_path.'/'.$document->path, |
|
947 | + $path.dirname($document->path), |
|
948 | 948 | false |
949 | 949 | ); |
950 | 950 | } |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | $table_forum = Database::get_course_table(TABLE_FORUM); |
963 | 963 | $resources = $this->course->resources; |
964 | 964 | foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
965 | - $params = (array)$forum->obj; |
|
965 | + $params = (array) $forum->obj; |
|
966 | 966 | $cat_id = ''; |
967 | 967 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
968 | 968 | isset($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']])) { |
@@ -1014,13 +1014,13 @@ discard block |
||
1014 | 1014 | foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
1015 | 1015 | if ($topic->obj->forum_id == $id) { |
1016 | 1016 | $this->restore_topic($topic_id, $new_id, $sessionId); |
1017 | - $forum_topics ++; |
|
1017 | + $forum_topics++; |
|
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | } |
1021 | 1021 | if ($forum_topics > 0) { |
1022 | 1022 | $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
1023 | - WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
|
1023 | + WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int) $new_id; |
|
1024 | 1024 | Database::query($sql); |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1090,13 +1090,13 @@ discard block |
||
1090 | 1090 | $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
1091 | 1091 | $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
1092 | 1092 | |
1093 | - $params = (array)$topic->obj; |
|
1093 | + $params = (array) $topic->obj; |
|
1094 | 1094 | $params = self::DBUTF8_array($params); |
1095 | 1095 | $params['c_id'] = $this->destination_course_id; |
1096 | 1096 | $params['forum_id'] = $forum_id; |
1097 | 1097 | $params['thread_poster_id'] = $this->first_teacher_id; |
1098 | 1098 | $params['thread_date'] = api_get_utc_datetime(); |
1099 | - $params['thread_close_date'] = '0000-00-00 00:00:00'; |
|
1099 | + $params['thread_close_date'] = '0000-00-00 00:00:00'; |
|
1100 | 1100 | $params['thread_last_post'] = 0; |
1101 | 1101 | $params['thread_replies'] = 0; |
1102 | 1102 | $params['thread_views'] = 0; |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | FROM $link_table |
1203 | 1203 | WHERE |
1204 | 1204 | c_id = ".$this->destination_course_id." AND |
1205 | - category_id='" . intval($cat_id). "'"; |
|
1205 | + category_id='" . intval($cat_id)."'"; |
|
1206 | 1206 | $result = Database::query($sql); |
1207 | 1207 | list($max_order) = Database::fetch_array($result); |
1208 | 1208 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | $params['description'] = self::DBUTF8($link->description); |
1218 | 1218 | $params['category_id'] = $cat_id; |
1219 | 1219 | $params['on_homepage'] = $link->on_homepage; |
1220 | - $params['display_order'] = $max_order+1; |
|
1220 | + $params['display_order'] = $max_order + 1; |
|
1221 | 1221 | |
1222 | 1222 | $id = Database::insert($link_table, $params); |
1223 | 1223 | |
@@ -1261,9 +1261,9 @@ discard block |
||
1261 | 1261 | if (is_object($link_cat) && !$link_cat->is_restored()) { |
1262 | 1262 | $sql = "SELECT MAX(display_order) FROM $link_cat_table |
1263 | 1263 | WHERE c_id = ".$this->destination_course_id." "; |
1264 | - $result=Database::query($sql); |
|
1265 | - list($orderMax)=Database::fetch_array($result,'NUM'); |
|
1266 | - $display_order=$orderMax+1; |
|
1264 | + $result = Database::query($sql); |
|
1265 | + list($orderMax) = Database::fetch_array($result, 'NUM'); |
|
1266 | + $display_order = $orderMax + 1; |
|
1267 | 1267 | |
1268 | 1268 | $params['c_id'] = $this->destination_course_id; |
1269 | 1269 | $params['category_title'] = self::DBUTF8($link_cat->title); |
@@ -1639,9 +1639,9 @@ discard block |
||
1639 | 1639 | if (!empty($quiz->sound)) { |
1640 | 1640 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
1641 | 1641 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
1642 | - $sql = "SELECT path FROM " . $table_doc . " |
|
1642 | + $sql = "SELECT path FROM ".$table_doc." |
|
1643 | 1643 | WHERE |
1644 | - c_id = " . $this->destination_course_id . " AND |
|
1644 | + c_id = " . $this->destination_course_id." AND |
|
1645 | 1645 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
1646 | 1646 | $doc = Database::query($sql); |
1647 | 1647 | $doc = Database::fetch_object($doc); |
@@ -1675,19 +1675,19 @@ discard block |
||
1675 | 1675 | 'random' => $quiz->random, |
1676 | 1676 | 'active' => $quiz->active, |
1677 | 1677 | 'sound' => self::DBUTF8($doc), |
1678 | - 'max_attempt' => (int)$quiz->max_attempt, |
|
1679 | - 'results_disabled' => (int)$quiz->results_disabled, |
|
1678 | + 'max_attempt' => (int) $quiz->max_attempt, |
|
1679 | + 'results_disabled' => (int) $quiz->results_disabled, |
|
1680 | 1680 | 'access_condition' => $quiz->access_condition, |
1681 | 1681 | 'start_time' => $quiz->start_time, |
1682 | 1682 | 'pass_percentage' => $quiz->pass_percentage, |
1683 | 1683 | 'end_time' => $quiz->end_time, |
1684 | - 'feedback_type' => (int)$quiz->feedback_type, |
|
1685 | - 'random_answers' => (int)$quiz->random_answers, |
|
1684 | + 'feedback_type' => (int) $quiz->feedback_type, |
|
1685 | + 'random_answers' => (int) $quiz->random_answers, |
|
1686 | 1686 | 'random_by_category' => $quiz->random_by_category, |
1687 | 1687 | 'review_answers' => $quiz->review_answers, |
1688 | 1688 | 'propagate_neg' => $quiz->propagate_neg, |
1689 | 1689 | 'text_when_finished' => $quiz->text_when_finished, |
1690 | - 'expired_time' => (int)$quiz->expired_time, |
|
1690 | + 'expired_time' => (int) $quiz->expired_time, |
|
1691 | 1691 | ); |
1692 | 1692 | |
1693 | 1693 | if ($respect_base_content) { |
@@ -1723,9 +1723,9 @@ discard block |
||
1723 | 1723 | $qid = $this->restore_quiz_question($question_id); |
1724 | 1724 | $question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : ++$order; |
1725 | 1725 | $sql = "INSERT IGNORE INTO $table_rel SET |
1726 | - c_id = " . $this->destination_course_id . ", |
|
1727 | - question_id = " . $qid . ", |
|
1728 | - exercice_id = " . $new_id . ", |
|
1726 | + c_id = ".$this->destination_course_id.", |
|
1727 | + question_id = " . $qid.", |
|
1728 | + exercice_id = " . $new_id.", |
|
1729 | 1729 | question_order = " . $question_order; |
1730 | 1730 | Database::query($sql); |
1731 | 1731 | } |
@@ -1800,7 +1800,7 @@ discard block |
||
1800 | 1800 | $sql = "UPDATE $table_que SET |
1801 | 1801 | picture = '$picture_name' |
1802 | 1802 | WHERE |
1803 | - c_id = " . $this->destination_course_id . " AND |
|
1803 | + c_id = ".$this->destination_course_id." AND |
|
1804 | 1804 | id = $new_id "; |
1805 | 1805 | Database::query($sql); |
1806 | 1806 | } |
@@ -1955,7 +1955,7 @@ discard block |
||
1955 | 1955 | } |
1956 | 1956 | } |
1957 | 1957 | |
1958 | - foreach($correct_answers as $answer_id => $correct_answer) { |
|
1958 | + foreach ($correct_answers as $answer_id => $correct_answer) { |
|
1959 | 1959 | $params = array(); |
1960 | 1960 | $params['correct'] = $new_options[$correct_answer]; |
1961 | 1961 | Database::update( |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table |
1990 | 1990 | if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) { |
1991 | 1991 | $resources = $this->course->resources; |
1992 | - foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory ) { |
|
1992 | + foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory) { |
|
1993 | 1993 | $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id; |
1994 | 1994 | // check if this test_category already exist in the destination BDD |
1995 | 1995 | // do not Database::escape_string $title and $description, it will be done later |
@@ -2135,7 +2135,7 @@ discard block |
||
2135 | 2135 | break; |
2136 | 2136 | case FILE_RENAME: |
2137 | 2137 | $survey_code = $survey->code.'_'; |
2138 | - $i=1; |
|
2138 | + $i = 1; |
|
2139 | 2139 | $temp_survey_code = $survey_code.$i; |
2140 | 2140 | while (!$this->is_survey_code_available($temp_survey_code)) { |
2141 | 2141 | $temp_survey_code = $survey_code.++$i; |
@@ -2167,15 +2167,15 @@ discard block |
||
2167 | 2167 | $sql = "SELECT * FROM $table_sur |
2168 | 2168 | WHERE |
2169 | 2169 | c_id = ".$this->destination_course_id." AND |
2170 | - survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
|
2170 | + survey_id='".self::DBUTF8escapestring(Database::result($result_check, 0, 0))."'"; |
|
2171 | 2171 | $result = Database::query($sql); |
2172 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2172 | + $survey_data = Database::fetch_array($result, 'ASSOC'); |
|
2173 | 2173 | |
2174 | 2174 | // if the survey is shared => also delete the shared content |
2175 | 2175 | if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
2176 | - SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
|
2176 | + SurveyManager::delete_survey($survey_data['survey_share'], true, $this->destination_course_id); |
|
2177 | 2177 | } |
2178 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2178 | + SurveyManager :: delete_survey($survey_data['survey_id'], false, $this->destination_course_id); |
|
2179 | 2179 | |
2180 | 2180 | // Insert the new source survey |
2181 | 2181 | $new_id = Database::insert($table_sur, $params); |
@@ -2251,7 +2251,7 @@ discard block |
||
2251 | 2251 | $resources = $this->course->resources; |
2252 | 2252 | $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
2253 | 2253 | |
2254 | - $new_id=0; |
|
2254 | + $new_id = 0; |
|
2255 | 2255 | |
2256 | 2256 | if (is_object($question)) { |
2257 | 2257 | if ($question->is_restored()) { |
@@ -2356,14 +2356,14 @@ discard block |
||
2356 | 2356 | |
2357 | 2357 | // Adding the author's image |
2358 | 2358 | if (!empty($lp->preview_image)) { |
2359 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2359 | + $new_filename = uniqid('').substr($lp->preview_image, strlen($lp->preview_image) - 7, strlen($lp->preview_image)); |
|
2360 | 2360 | if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
2361 | 2361 | $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
2362 | 2362 | //$copy_result = true; |
2363 | 2363 | if ($copy_result) { |
2364 | 2364 | $lp->preview_image = $new_filename; |
2365 | 2365 | } else { |
2366 | - $lp->preview_image =''; |
|
2366 | + $lp->preview_image = ''; |
|
2367 | 2367 | } |
2368 | 2368 | } |
2369 | 2369 | } |
@@ -2524,20 +2524,20 @@ discard block |
||
2524 | 2524 | $next_item_ids[$new_item_id] = $item['next_item_id']; |
2525 | 2525 | |
2526 | 2526 | if (!empty($item['prerequisite'])) { |
2527 | - if ($lp->lp_type =='2') { |
|
2527 | + if ($lp->lp_type == '2') { |
|
2528 | 2528 | // if is an sco |
2529 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2529 | + $old_prerequisite[$new_item_id] = $item['prerequisite']; |
|
2530 | 2530 | } else { |
2531 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2531 | + $old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']]; |
|
2532 | 2532 | } |
2533 | 2533 | } |
2534 | 2534 | |
2535 | 2535 | if (!empty($ref)) { |
2536 | - if ($lp->lp_type =='2') { |
|
2536 | + if ($lp->lp_type == '2') { |
|
2537 | 2537 | // if is an sco |
2538 | - $old_refs[$new_item_id]= $ref; |
|
2538 | + $old_refs[$new_item_id] = $ref; |
|
2539 | 2539 | } else { |
2540 | - $old_refs[$new_item_id]= $new_item_ids[$ref]; |
|
2540 | + $old_refs[$new_item_id] = $new_item_ids[$ref]; |
|
2541 | 2541 | } |
2542 | 2542 | } |
2543 | 2543 | |
@@ -2546,7 +2546,7 @@ discard block |
||
2546 | 2546 | |
2547 | 2547 | // Updating prerequisites |
2548 | 2548 | foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
2549 | - if($my_old_prerequisite != ''){ |
|
2549 | + if ($my_old_prerequisite != '') { |
|
2550 | 2550 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
2551 | 2551 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2552 | 2552 | Database::query($sql); |
@@ -2564,7 +2564,7 @@ discard block |
||
2564 | 2564 | |
2565 | 2565 | foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
2566 | 2566 | $parent_new_id = 0; |
2567 | - if($parent_item_old_id != 0){ |
|
2567 | + if ($parent_item_old_id != 0) { |
|
2568 | 2568 | $parent_new_id = $new_item_ids[$parent_item_old_id]; |
2569 | 2569 | } |
2570 | 2570 | $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
@@ -2573,7 +2573,7 @@ discard block |
||
2573 | 2573 | } |
2574 | 2574 | foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
2575 | 2575 | $previous_new_id = 0; |
2576 | - if($previous_item_old_id != 0){ |
|
2576 | + if ($previous_item_old_id != 0) { |
|
2577 | 2577 | $previous_new_id = $new_item_ids[$previous_item_old_id]; |
2578 | 2578 | } |
2579 | 2579 | $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
@@ -2583,7 +2583,7 @@ discard block |
||
2583 | 2583 | |
2584 | 2584 | foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
2585 | 2585 | $next_new_id = 0; |
2586 | - if($next_item_old_id != 0){ |
|
2586 | + if ($next_item_old_id != 0) { |
|
2587 | 2587 | $next_new_id = $new_item_ids[$next_item_old_id]; |
2588 | 2588 | } |
2589 | 2589 | $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
@@ -2593,7 +2593,7 @@ discard block |
||
2593 | 2593 | |
2594 | 2594 | foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
2595 | 2595 | $prerequisite_new_id = 0; |
2596 | - if($prerequisite_old_id != 0){ |
|
2596 | + if ($prerequisite_old_id != 0) { |
|
2597 | 2597 | $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
2598 | 2598 | } |
2599 | 2599 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
@@ -2613,9 +2613,9 @@ discard block |
||
2613 | 2613 | public function restore_student_publication($sessionId = 0) |
2614 | 2614 | { |
2615 | 2615 | $sessionId = intval($sessionId); |
2616 | - $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
2616 | + $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
2617 | 2617 | $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
2618 | - $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
2618 | + $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
2619 | 2619 | |
2620 | 2620 | // Query in student publication |
2621 | 2621 | $sql = 'SELECT * FROM '.$work_table.' |
@@ -2693,7 +2693,7 @@ discard block |
||
2693 | 2693 | |
2694 | 2694 | $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
2695 | 2695 | $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
2696 | - self::allow_create_all_directory($origin,$destination,false); |
|
2696 | + self::allow_create_all_directory($origin, $destination, false); |
|
2697 | 2697 | } |
2698 | 2698 | |
2699 | 2699 | /** |
@@ -2712,16 +2712,16 @@ discard block |
||
2712 | 2712 | if ($handle = opendir($source)) { // if the folder exploration is sucsessful, continue |
2713 | 2713 | while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue |
2714 | 2714 | if ($file != '.' && $file != '..') { |
2715 | - $path = $source . '/' . $file; |
|
2715 | + $path = $source.'/'.$file; |
|
2716 | 2716 | if (is_file($path)) { |
2717 | 2717 | /* if (!is_file($dest . '/' . $file) || $overwrite) |
2718 | 2718 | if (!@copy($path, $dest . '/' . $file)) { |
2719 | 2719 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2720 | 2720 | }*/ |
2721 | - } elseif(is_dir($path)) { |
|
2722 | - if (!is_dir($dest . '/' . $file)) |
|
2723 | - mkdir($dest . '/' . $file); |
|
2724 | - self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
2721 | + } elseif (is_dir($path)) { |
|
2722 | + if (!is_dir($dest.'/'.$file)) |
|
2723 | + mkdir($dest.'/'.$file); |
|
2724 | + self:: allow_create_all_directory($path, $dest.'/'.$file, $overwrite); |
|
2725 | 2725 | } |
2726 | 2726 | } |
2727 | 2727 | } |
@@ -2908,7 +2908,7 @@ discard block |
||
2908 | 2908 | $this->course->backup_path, |
2909 | 2909 | $this->course->info['path'] |
2910 | 2910 | ); |
2911 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
2911 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
2912 | 2912 | unset($thematic->params['id']); |
2913 | 2913 | unset($thematic->params['iid']); |
2914 | 2914 | |
@@ -2932,7 +2932,7 @@ discard block |
||
2932 | 2932 | unset($thematic_advance['iid']); |
2933 | 2933 | $thematic_advance['attendance_id'] = 0; |
2934 | 2934 | $thematic_advance['thematic_id'] = $last_id; |
2935 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
2935 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
2936 | 2936 | $my_id = Database::insert( |
2937 | 2937 | $table_thematic_advance, |
2938 | 2938 | $thematic_advance, |
@@ -2954,7 +2954,7 @@ discard block |
||
2954 | 2954 | } |
2955 | 2955 | } |
2956 | 2956 | |
2957 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
2957 | + foreach ($thematic->thematic_plan_list as $thematic_plan) { |
|
2958 | 2958 | unset($thematic_plan['id']); |
2959 | 2959 | unset($thematic_plan['iid']); |
2960 | 2960 | $thematic_plan['thematic_id'] = $last_id; |
@@ -3070,7 +3070,7 @@ discard block |
||
3070 | 3070 | // re-create dir |
3071 | 3071 | // @todo check security against injection of dir in crafted course backup here! |
3072 | 3072 | $path = $obj->params['url']; |
3073 | - $path = '/'.str_replace('/','',substr($path,1)); |
|
3073 | + $path = '/'.str_replace('/', '', substr($path, 1)); |
|
3074 | 3074 | |
3075 | 3075 | $workData = array(); |
3076 | 3076 | switch ($this->file_option) { |
@@ -3092,9 +3092,9 @@ discard block |
||
3092 | 3092 | $obj->params['new_dir'] = $obj->params['title']; |
3093 | 3093 | |
3094 | 3094 | if (!empty($this->course_origin_id)) { |
3095 | - $sql = 'SELECT * FROM ' . $table_work_assignment . ' |
|
3095 | + $sql = 'SELECT * FROM '.$table_work_assignment.' |
|
3096 | 3096 | WHERE |
3097 | - c_id = ' . $this->course_origin_id . ' AND |
|
3097 | + c_id = ' . $this->course_origin_id.' AND |
|
3098 | 3098 | publication_id = ' . $id_work; |
3099 | 3099 | |
3100 | 3100 | $result = Database::query($sql); |
@@ -3206,7 +3206,7 @@ discard block |
||
3206 | 3206 | public function DBUTF8_array($array) |
3207 | 3207 | { |
3208 | 3208 | if (UTF8_CONVERT) { |
3209 | - foreach ($array as &$item) { |
|
3209 | + foreach ($array as &$item) { |
|
3210 | 3210 | $item = utf8_encode($item); |
3211 | 3211 | } |
3212 | 3212 | return $array; |
@@ -512,7 +512,9 @@ discard block |
||
512 | 512 | |
513 | 513 | if (in_array($file_info['extension'], array('html', 'htm'))) { |
514 | 514 | $content = file_get_contents($path.$document->path); |
515 | - if (UTF8_CONVERT) $content = utf8_encode($content); |
|
515 | + if (UTF8_CONVERT) { |
|
516 | + $content = utf8_encode($content); |
|
517 | + } |
|
516 | 518 | $content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
517 | 519 | $content, |
518 | 520 | $this->course->code, |
@@ -2240,7 +2242,11 @@ discard block |
||
2240 | 2242 | c_id = ".$this->destination_course_id." AND |
2241 | 2243 | code='".self::DBUTF8escapestring($survey_code)."'"; |
2242 | 2244 | $result = Database::query($sql); |
2243 | - if (Database::num_rows($result) > 0) return false; else return true; |
|
2245 | + if (Database::num_rows($result) > 0) { |
|
2246 | + return false; |
|
2247 | + } else { |
|
2248 | + return true; |
|
2249 | + } |
|
2244 | 2250 | } |
2245 | 2251 | |
2246 | 2252 | /** |
@@ -2719,8 +2725,9 @@ discard block |
||
2719 | 2725 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2720 | 2726 | }*/ |
2721 | 2727 | } elseif(is_dir($path)) { |
2722 | - if (!is_dir($dest . '/' . $file)) |
|
2723 | - mkdir($dest . '/' . $file); |
|
2728 | + if (!is_dir($dest . '/' . $file)) { |
|
2729 | + mkdir($dest . '/' . $file); |
|
2730 | + } |
|
2724 | 2731 | self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
2725 | 2732 | } |
2726 | 2733 | } |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class CourseRestorer |
38 | 38 | { |
39 | - /** |
|
40 | - * The course-object |
|
41 | - */ |
|
39 | + /** |
|
40 | + * The course-object |
|
41 | + */ |
|
42 | 42 | public $course; |
43 | 43 | public $destination_course_info; |
44 | 44 | |
45 | - /** |
|
46 | - * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
47 | - * FILE_OVERWRITE) |
|
48 | - */ |
|
45 | + /** |
|
46 | + * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
47 | + * FILE_OVERWRITE) |
|
48 | + */ |
|
49 | 49 | public $file_option; |
50 | 50 | public $set_tools_invisible_by_default; |
51 | 51 | public $skip_content; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'events', |
58 | 58 | 'forum_category', |
59 | 59 | 'forums', |
60 | - // 'forum_topics', |
|
60 | + // 'forum_topics', |
|
61 | 61 | 'glossary', |
62 | 62 | 'quizzes', |
63 | 63 | 'test_category', |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | public $add_text_in_items = false; |
83 | 83 | public $destination_course_id; |
84 | 84 | |
85 | - /** |
|
86 | - * Create a new CourseRestorer |
|
87 | - */ |
|
85 | + /** |
|
86 | + * Create a new CourseRestorer |
|
87 | + */ |
|
88 | 88 | public function __construct($course) |
89 | 89 | { |
90 | 90 | $this->course = $course; |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | $this->file_option = FILE_RENAME; |
98 | 98 | $this->set_tools_invisible_by_default = false; |
99 | 99 | $this->skip_content = array(); |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Set the file-option |
|
104 | - * @param int $option (optional) What to do with files with same name |
|
102 | + /** |
|
103 | + * Set the file-option |
|
104 | + * @param int $option (optional) What to do with files with same name |
|
105 | 105 | * FILE_SKIP, FILE_RENAME or FILE_OVERWRITE |
106 | - */ |
|
106 | + */ |
|
107 | 107 | public function set_file_option($option = FILE_OVERWRITE) |
108 | 108 | { |
109 | - $this->file_option = $option; |
|
110 | - } |
|
109 | + $this->file_option = $option; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * @param string $status |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | $this->tool_copy_settings = $array; |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Restore a course. |
|
128 | + /** |
|
129 | + * Restore a course. |
|
130 | 130 | * |
131 | - * @param string $destination_course_code code of the Chamilo-course in |
|
132 | - * @param int $session_id |
|
133 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
131 | + * @param string $destination_course_code code of the Chamilo-course in |
|
132 | + * @param int $session_id |
|
133 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
134 | 134 | * @param bool $respect_base_content |
135 | 135 | * @return bool |
136 | - */ |
|
136 | + */ |
|
137 | 137 | public function restore( |
138 | 138 | $destination_course_code = '', |
139 | 139 | $session_id = 0, |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - /** |
|
275 | - * Restore only harmless course settings: |
|
274 | + /** |
|
275 | + * Restore only harmless course settings: |
|
276 | 276 | * course_language, visibility, department_name,department_url, |
277 | 277 | * subscribe, unsubscribe ,category_code |
278 | - * |
|
279 | - * @param string $destination_course_code |
|
280 | - */ |
|
278 | + * |
|
279 | + * @param string $destination_course_code |
|
280 | + */ |
|
281 | 281 | public function restore_course_settings($destination_course_code) |
282 | 282 | { |
283 | - $origin_course_info = api_get_course_info($destination_course_code); |
|
284 | - $course_info = $this->course->info; |
|
283 | + $origin_course_info = api_get_course_info($destination_course_code); |
|
284 | + $course_info = $this->course->info; |
|
285 | 285 | $params['course_language'] = $course_info['language']; |
286 | 286 | $params['visibility'] = $course_info['visibility']; |
287 | 287 | $params['department_name'] = $course_info['department_name']; |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | $params['category_code'] = $course_info['categoryCode']; |
291 | 291 | $params['subscribe'] = $course_info['subscribe_allowed']; |
292 | 292 | $params['unsubscribe'] = $course_info['unsubscribe']; |
293 | - CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
294 | - } |
|
293 | + CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
294 | + } |
|
295 | 295 | |
296 | 296 | /** |
297 | 297 | * Restore documents |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | $course_info = api_get_course_info($destination_course_code); |
306 | 306 | |
307 | 307 | if ($this->course->has_resources(RESOURCE_DOCUMENT)) { |
308 | - $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
309 | - $resources = $this->course->resources; |
|
308 | + $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
309 | + $resources = $this->course->resources; |
|
310 | 310 | $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
311 | 311 | |
312 | - foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
312 | + foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
313 | 313 | |
314 | 314 | if (empty($document->item_properties[0]['id_session'])) { |
315 | 315 | $my_session_id = 0; |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | $my_session_id = $session_id; |
318 | 318 | } |
319 | 319 | |
320 | - if ($document->file_type == FOLDER) { |
|
321 | - $visibility = $document->item_properties[0]['visibility']; |
|
322 | - $new = substr($document->path, 8); |
|
320 | + if ($document->file_type == FOLDER) { |
|
321 | + $visibility = $document->item_properties[0]['visibility']; |
|
322 | + $new = substr($document->path, 8); |
|
323 | 323 | |
324 | 324 | $folderList = explode('/', $new); |
325 | 325 | $tempFolder = ''; |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | } |
382 | - } elseif ($document->file_type == DOCUMENT) { |
|
382 | + } elseif ($document->file_type == DOCUMENT) { |
|
383 | 383 | //Checking if folder exists in the database otherwise we created it |
384 | 384 | $dir_to_create = dirname($document->path); |
385 | 385 | |
@@ -427,19 +427,19 @@ discard block |
||
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | - if (file_exists($path.$document->path)) { |
|
431 | - switch ($this->file_option) { |
|
432 | - case FILE_OVERWRITE: |
|
430 | + if (file_exists($path.$document->path)) { |
|
431 | + switch ($this->file_option) { |
|
432 | + case FILE_OVERWRITE: |
|
433 | 433 | $origin_path = $this->course->backup_path.'/'.$document->path; |
434 | 434 | |
435 | - if (file_exists($origin_path)) { |
|
436 | - copy($origin_path, $path.$document->path); |
|
435 | + if (file_exists($origin_path)) { |
|
436 | + copy($origin_path, $path.$document->path); |
|
437 | 437 | $sql = "SELECT id FROM $table |
438 | 438 | WHERE |
439 | 439 | c_id = ".$this->destination_course_id." AND |
440 | 440 | path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
441 | 441 | |
442 | - $res = Database::query($sql); |
|
442 | + $res = Database::query($sql); |
|
443 | 443 | $count = Database::num_rows($res); |
444 | 444 | |
445 | 445 | if ($count == 0) { |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | 'session_id' => $my_session_id, |
454 | 454 | ]; |
455 | 455 | |
456 | - $document_id = Database::insert($table, $params); |
|
456 | + $document_id = Database::insert($table, $params); |
|
457 | 457 | |
458 | 458 | if ($document_id) { |
459 | 459 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -544,84 +544,84 @@ discard block |
||
544 | 544 | ], |
545 | 545 | ] |
546 | 546 | ); |
547 | - } |
|
547 | + } |
|
548 | 548 | |
549 | - break; |
|
550 | - case FILE_SKIP : |
|
551 | - $sql = "SELECT id FROM $table |
|
549 | + break; |
|
550 | + case FILE_SKIP : |
|
551 | + $sql = "SELECT id FROM $table |
|
552 | 552 | WHERE |
553 | 553 | c_id = ".$this->destination_course_id." AND |
554 | 554 | path='/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
555 | - $res = Database::query($sql); |
|
556 | - $obj = Database::fetch_object($res); |
|
557 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
558 | - break; |
|
559 | - case FILE_RENAME : |
|
560 | - $i = 1; |
|
561 | - $ext = explode('.', basename($document->path)); |
|
562 | - if (count($ext) > 1) { |
|
563 | - $ext = array_pop($ext); |
|
564 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
565 | - $ext = '.'.$ext; |
|
566 | - } else { |
|
567 | - $ext = ''; |
|
568 | - $file_name_no_ext = $document->path; |
|
569 | - } |
|
570 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
571 | - $file_exists = file_exists($path.$new_file_name); |
|
572 | - while ($file_exists) { |
|
573 | - $i ++; |
|
574 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
575 | - $file_exists = file_exists($path.$new_file_name); |
|
576 | - } |
|
577 | - |
|
578 | - if (!empty($session_id)) { |
|
579 | - |
|
580 | - $document_path = explode('/',$document->path,3); |
|
581 | - $course_path = $path; |
|
582 | - $orig_base_folder = $document_path[1]; |
|
583 | - $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
584 | - |
|
585 | - if (is_dir($orig_base_path)) { |
|
586 | - |
|
587 | - $new_base_foldername = $orig_base_folder; |
|
588 | - $new_base_path = $orig_base_path; |
|
589 | - |
|
590 | - if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
591 | - unset($_SESSION['new_base_foldername']); |
|
592 | - unset($_SESSION['orig_base_foldername']); |
|
593 | - unset($_SESSION['new_base_path']); |
|
594 | - } |
|
595 | - |
|
596 | - $folder_exists = file_exists($new_base_path); |
|
597 | - if ($folder_exists) { |
|
598 | - $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
599 | - $x = ''; |
|
600 | - while ($folder_exists) { |
|
601 | - $x = $x + 1; |
|
602 | - $new_base_foldername = $document_path[1].'_'.$x; |
|
603 | - $new_base_path = $orig_base_path.'_'.$x; |
|
555 | + $res = Database::query($sql); |
|
556 | + $obj = Database::fetch_object($res); |
|
557 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
558 | + break; |
|
559 | + case FILE_RENAME : |
|
560 | + $i = 1; |
|
561 | + $ext = explode('.', basename($document->path)); |
|
562 | + if (count($ext) > 1) { |
|
563 | + $ext = array_pop($ext); |
|
564 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
565 | + $ext = '.'.$ext; |
|
566 | + } else { |
|
567 | + $ext = ''; |
|
568 | + $file_name_no_ext = $document->path; |
|
569 | + } |
|
570 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
571 | + $file_exists = file_exists($path.$new_file_name); |
|
572 | + while ($file_exists) { |
|
573 | + $i ++; |
|
574 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
575 | + $file_exists = file_exists($path.$new_file_name); |
|
576 | + } |
|
577 | + |
|
578 | + if (!empty($session_id)) { |
|
579 | + |
|
580 | + $document_path = explode('/',$document->path,3); |
|
581 | + $course_path = $path; |
|
582 | + $orig_base_folder = $document_path[1]; |
|
583 | + $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
584 | + |
|
585 | + if (is_dir($orig_base_path)) { |
|
586 | + |
|
587 | + $new_base_foldername = $orig_base_folder; |
|
588 | + $new_base_path = $orig_base_path; |
|
589 | + |
|
590 | + if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
591 | + unset($_SESSION['new_base_foldername']); |
|
592 | + unset($_SESSION['orig_base_foldername']); |
|
593 | + unset($_SESSION['new_base_path']); |
|
594 | + } |
|
595 | + |
|
596 | + $folder_exists = file_exists($new_base_path); |
|
597 | + if ($folder_exists) { |
|
598 | + $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
599 | + $x = ''; |
|
600 | + while ($folder_exists) { |
|
601 | + $x = $x + 1; |
|
602 | + $new_base_foldername = $document_path[1].'_'.$x; |
|
603 | + $new_base_path = $orig_base_path.'_'.$x; |
|
604 | 604 | if ($_SESSION['new_base_foldername'] == $new_base_foldername) { |
605 | 605 | break; |
606 | 606 | } |
607 | - $folder_exists = file_exists($new_base_path); |
|
608 | - } |
|
609 | - $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
610 | - $_SESSION['new_base_path'] = $new_base_path; |
|
611 | - } |
|
607 | + $folder_exists = file_exists($new_base_path); |
|
608 | + } |
|
609 | + $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
610 | + $_SESSION['new_base_path'] = $new_base_path; |
|
611 | + } |
|
612 | 612 | |
613 | - if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
614 | - $new_base_foldername = $_SESSION['new_base_foldername']; |
|
615 | - $new_base_path = $_SESSION['new_base_path']; |
|
616 | - } |
|
613 | + if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
614 | + $new_base_foldername = $_SESSION['new_base_foldername']; |
|
615 | + $new_base_path = $_SESSION['new_base_path']; |
|
616 | + } |
|
617 | 617 | |
618 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
619 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
620 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
618 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
619 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
620 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
621 | 621 | |
622 | - $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
622 | + $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
623 | 623 | |
624 | - copy_folder_course_session( |
|
624 | + copy_folder_course_session( |
|
625 | 625 | $basedir_dest_path, |
626 | 626 | $base_path_document, |
627 | 627 | $session_id, |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | 'session_id' => $my_session_id, |
664 | 664 | ]; |
665 | 665 | |
666 | - $document_id = Database::insert($table, $params); |
|
666 | + $document_id = Database::insert($table, $params); |
|
667 | 667 | |
668 | 668 | if ($document_id) { |
669 | 669 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | $my_session_id |
685 | 685 | ); |
686 | 686 | |
687 | - } else { |
|
687 | + } else { |
|
688 | 688 | |
689 | - if (file_exists($path.$document->path)) { |
|
689 | + if (file_exists($path.$document->path)) { |
|
690 | 690 | copy($path.$document->path, $path.$new_file_name); |
691 | - } |
|
691 | + } |
|
692 | 692 | |
693 | 693 | //Replace old course code with the new destination code see BT#1985 |
694 | 694 | if (file_exists($path.$new_file_name)) { |
@@ -739,10 +739,10 @@ discard block |
||
739 | 739 | $my_session_id |
740 | 740 | ); |
741 | 741 | } |
742 | - } |
|
743 | - } else { |
|
742 | + } |
|
743 | + } else { |
|
744 | 744 | |
745 | - copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
745 | + copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
746 | 746 | |
747 | 747 | //Replace old course code with the new destination code see BT#1985 |
748 | 748 | if (file_exists($path.$new_file_name)) { |
@@ -793,20 +793,20 @@ discard block |
||
793 | 793 | null, |
794 | 794 | $my_session_id |
795 | 795 | ); |
796 | - } |
|
797 | - break; |
|
798 | - |
|
799 | - } // end switch |
|
800 | - } else { |
|
801 | - // end if file exists |
|
802 | - //make sure the source file actually exists |
|
803 | - if (is_file($this->course->backup_path.'/'.$document->path) && |
|
796 | + } |
|
797 | + break; |
|
798 | + |
|
799 | + } // end switch |
|
800 | + } else { |
|
801 | + // end if file exists |
|
802 | + //make sure the source file actually exists |
|
803 | + if (is_file($this->course->backup_path.'/'.$document->path) && |
|
804 | 804 | is_readable($this->course->backup_path.'/'.$document->path) && |
805 | 805 | is_dir(dirname($path.$document->path)) && |
806 | 806 | is_writeable(dirname($path.$document->path)) |
807 | 807 | ) { |
808 | - //echo 'Copying'; |
|
809 | - copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
808 | + //echo 'Copying'; |
|
809 | + copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
810 | 810 | |
811 | 811 | //Replace old course code with the new destination code see BT#1985 |
812 | 812 | if (file_exists($path.$document->path)) { |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | Database::query($sql); |
845 | 845 | } |
846 | 846 | |
847 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
847 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
848 | 848 | api_item_property_update( |
849 | 849 | $course_info, |
850 | 850 | TOOL_DOCUMENT, |
@@ -857,78 +857,78 @@ discard block |
||
857 | 857 | null, |
858 | 858 | $my_session_id |
859 | 859 | ); |
860 | - } else { |
|
861 | - //echo 'not Copying'; |
|
862 | - if (is_file($this->course->backup_path.'/'.$document->path) && is_readable($this->course->backup_path.'/'.$document->path)) { |
|
863 | - error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
864 | - } |
|
865 | - if (!is_dir(dirname($path.$document->path))) { |
|
866 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
867 | - } |
|
868 | - if (!is_writeable(dirname($path.$document->path))) { |
|
869 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
870 | - } |
|
871 | - } |
|
872 | - } // end file doesn't exist |
|
873 | - } |
|
874 | - } // end for each |
|
875 | - |
|
876 | - // Delete sessions for the copy the new folder in session |
|
877 | - unset($_SESSION['new_base_foldername']); |
|
878 | - unset($_SESSION['orig_base_foldername']); |
|
879 | - unset($_SESSION['new_base_path']); |
|
880 | - } |
|
881 | - } |
|
882 | - |
|
883 | - /** |
|
884 | - * Restore scorm documents |
|
885 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
860 | + } else { |
|
861 | + //echo 'not Copying'; |
|
862 | + if (is_file($this->course->backup_path.'/'.$document->path) && is_readable($this->course->backup_path.'/'.$document->path)) { |
|
863 | + error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
864 | + } |
|
865 | + if (!is_dir(dirname($path.$document->path))) { |
|
866 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
867 | + } |
|
868 | + if (!is_writeable(dirname($path.$document->path))) { |
|
869 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
870 | + } |
|
871 | + } |
|
872 | + } // end file doesn't exist |
|
873 | + } |
|
874 | + } // end for each |
|
875 | + |
|
876 | + // Delete sessions for the copy the new folder in session |
|
877 | + unset($_SESSION['new_base_foldername']); |
|
878 | + unset($_SESSION['orig_base_foldername']); |
|
879 | + unset($_SESSION['new_base_path']); |
|
880 | + } |
|
881 | + } |
|
882 | + |
|
883 | + /** |
|
884 | + * Restore scorm documents |
|
885 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
886 | 886 | * see #7029 |
887 | - */ |
|
888 | - public function restore_scorm_documents() |
|
887 | + */ |
|
888 | + public function restore_scorm_documents() |
|
889 | 889 | { |
890 | - $perm = api_get_permissions_for_new_directories(); |
|
890 | + $perm = api_get_permissions_for_new_directories(); |
|
891 | 891 | |
892 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
893 | - $resources = $this->course->resources; |
|
892 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
893 | + $resources = $this->course->resources; |
|
894 | 894 | |
895 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
896 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
895 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
896 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
897 | 897 | |
898 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
898 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
899 | 899 | |
900 | - if (file_exists($path.$document->path)) { |
|
901 | - switch ($this->file_option) { |
|
902 | - case FILE_OVERWRITE: |
|
903 | - rmdirr($path.$document->path); |
|
900 | + if (file_exists($path.$document->path)) { |
|
901 | + switch ($this->file_option) { |
|
902 | + case FILE_OVERWRITE: |
|
903 | + rmdirr($path.$document->path); |
|
904 | 904 | copyDirTo( |
905 | 905 | $this->course->backup_path . '/' . $document->path, |
906 | 906 | $path . dirname($document->path), |
907 | 907 | false |
908 | 908 | ); |
909 | - break; |
|
910 | - case FILE_SKIP: |
|
911 | - break; |
|
909 | + break; |
|
910 | + case FILE_SKIP: |
|
911 | + break; |
|
912 | 912 | case FILE_RENAME: |
913 | - $i = 1; |
|
914 | - $ext = explode('.', basename($document->path)); |
|
915 | - if (count($ext) > 1) { |
|
916 | - $ext = array_pop($ext); |
|
917 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
918 | - $ext = '.'.$ext; |
|
919 | - } else { |
|
920 | - $ext = ''; |
|
921 | - $file_name_no_ext = $document->path; |
|
922 | - } |
|
923 | - |
|
924 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
925 | - $file_exists = file_exists($path.$new_file_name); |
|
926 | - |
|
927 | - while ($file_exists) { |
|
928 | - $i ++; |
|
929 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
930 | - $file_exists = file_exists($path.$new_file_name); |
|
931 | - } |
|
913 | + $i = 1; |
|
914 | + $ext = explode('.', basename($document->path)); |
|
915 | + if (count($ext) > 1) { |
|
916 | + $ext = array_pop($ext); |
|
917 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
918 | + $ext = '.'.$ext; |
|
919 | + } else { |
|
920 | + $ext = ''; |
|
921 | + $file_name_no_ext = $document->path; |
|
922 | + } |
|
923 | + |
|
924 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
925 | + $file_exists = file_exists($path.$new_file_name); |
|
926 | + |
|
927 | + while ($file_exists) { |
|
928 | + $i ++; |
|
929 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
930 | + $file_exists = file_exists($path.$new_file_name); |
|
931 | + } |
|
932 | 932 | |
933 | 933 | rename( |
934 | 934 | $this->course->backup_path . '/' . $document->path, |
@@ -944,30 +944,30 @@ discard block |
||
944 | 944 | $this->course->backup_path . '/' . $document->path |
945 | 945 | ); |
946 | 946 | |
947 | - break; |
|
948 | - } // end switch |
|
949 | - } else { |
|
947 | + break; |
|
948 | + } // end switch |
|
949 | + } else { |
|
950 | 950 | // end if file exists |
951 | 951 | copyDirTo( |
952 | 952 | $this->course->backup_path . '/' . $document->path, |
953 | 953 | $path . dirname($document->path), |
954 | 954 | false |
955 | 955 | ); |
956 | - } |
|
957 | - } // end for each |
|
958 | - } |
|
959 | - } |
|
960 | - |
|
961 | - /** |
|
962 | - * Restore forums |
|
963 | - */ |
|
964 | - public function restore_forums($sessionId = 0) |
|
956 | + } |
|
957 | + } // end for each |
|
958 | + } |
|
959 | + } |
|
960 | + |
|
961 | + /** |
|
962 | + * Restore forums |
|
963 | + */ |
|
964 | + public function restore_forums($sessionId = 0) |
|
965 | 965 | { |
966 | - if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
966 | + if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
967 | 967 | $sessionId = intval($sessionId); |
968 | - $table_forum = Database::get_course_table(TABLE_FORUM); |
|
969 | - $resources = $this->course->resources; |
|
970 | - foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
968 | + $table_forum = Database::get_course_table(TABLE_FORUM); |
|
969 | + $resources = $this->course->resources; |
|
970 | + foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
971 | 971 | $params = (array)$forum->obj; |
972 | 972 | $cat_id = ''; |
973 | 973 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
@@ -1013,33 +1013,33 @@ discard block |
||
1013 | 1013 | Database::query($sql); |
1014 | 1014 | } |
1015 | 1015 | |
1016 | - $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1017 | - |
|
1018 | - $forum_topics = 0; |
|
1019 | - if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1020 | - foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1021 | - if ($topic->obj->forum_id == $id) { |
|
1022 | - $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1023 | - $forum_topics ++; |
|
1024 | - } |
|
1025 | - } |
|
1026 | - } |
|
1027 | - if ($forum_topics > 0) { |
|
1028 | - $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1016 | + $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1017 | + |
|
1018 | + $forum_topics = 0; |
|
1019 | + if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1020 | + foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1021 | + if ($topic->obj->forum_id == $id) { |
|
1022 | + $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1023 | + $forum_topics ++; |
|
1024 | + } |
|
1025 | + } |
|
1026 | + } |
|
1027 | + if ($forum_topics > 0) { |
|
1028 | + $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1029 | 1029 | WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
1030 | - Database::query($sql); |
|
1031 | - } |
|
1032 | - } |
|
1033 | - } |
|
1034 | - } |
|
1035 | - |
|
1036 | - /** |
|
1037 | - * Restore forum-categories |
|
1038 | - */ |
|
1030 | + Database::query($sql); |
|
1031 | + } |
|
1032 | + } |
|
1033 | + } |
|
1034 | + } |
|
1035 | + |
|
1036 | + /** |
|
1037 | + * Restore forum-categories |
|
1038 | + */ |
|
1039 | 1039 | public function restore_forum_category($my_id = null, $sessionId = 0) |
1040 | 1040 | { |
1041 | - $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1042 | - $resources = $this->course->resources; |
|
1041 | + $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1042 | + $resources = $this->course->resources; |
|
1043 | 1043 | if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
1044 | 1044 | foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
1045 | 1045 | if (!empty($my_id)) { |
@@ -1086,15 +1086,15 @@ discard block |
||
1086 | 1086 | } |
1087 | 1087 | } |
1088 | 1088 | } |
1089 | - } |
|
1089 | + } |
|
1090 | 1090 | |
1091 | - /** |
|
1092 | - * Restore a forum-topic |
|
1093 | - */ |
|
1091 | + /** |
|
1092 | + * Restore a forum-topic |
|
1093 | + */ |
|
1094 | 1094 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
1095 | 1095 | { |
1096 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1097 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1096 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1097 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1098 | 1098 | |
1099 | 1099 | $params = (array)$topic->obj; |
1100 | 1100 | $params = self::DBUTF8_array($params); |
@@ -1130,27 +1130,27 @@ discard block |
||
1130 | 1130 | $sessionId |
1131 | 1131 | ); |
1132 | 1132 | |
1133 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1133 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1134 | 1134 | |
1135 | - $topic_replies = -1; |
|
1135 | + $topic_replies = -1; |
|
1136 | 1136 | |
1137 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1138 | - if ($post->obj->thread_id == $thread_id) { |
|
1139 | - $topic_replies++; |
|
1140 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1141 | - } |
|
1142 | - } |
|
1143 | - return $new_id; |
|
1144 | - } |
|
1137 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1138 | + if ($post->obj->thread_id == $thread_id) { |
|
1139 | + $topic_replies++; |
|
1140 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1141 | + } |
|
1142 | + } |
|
1143 | + return $new_id; |
|
1144 | + } |
|
1145 | 1145 | |
1146 | - /** |
|
1147 | - * Restore a forum-post |
|
1148 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1149 | - */ |
|
1146 | + /** |
|
1147 | + * Restore a forum-post |
|
1148 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1149 | + */ |
|
1150 | 1150 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1151 | 1151 | { |
1152 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1153 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1152 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1153 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1154 | 1154 | $params = (array) $post->obj; |
1155 | 1155 | $params['c_id'] = $this->destination_course_id; |
1156 | 1156 | $params['forum_id'] = $forum_id; |
@@ -1185,37 +1185,37 @@ discard block |
||
1185 | 1185 | null, |
1186 | 1186 | $sessionId |
1187 | 1187 | ); |
1188 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1188 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1189 | 1189 | |
1190 | - return $new_id; |
|
1191 | - } |
|
1190 | + return $new_id; |
|
1191 | + } |
|
1192 | 1192 | |
1193 | - /** |
|
1194 | - * Restore links |
|
1195 | - */ |
|
1193 | + /** |
|
1194 | + * Restore links |
|
1195 | + */ |
|
1196 | 1196 | public function restore_links($session_id = 0) |
1197 | 1197 | { |
1198 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1199 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
1200 | - $resources = $this->course->resources; |
|
1198 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1199 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
1200 | + $resources = $this->course->resources; |
|
1201 | 1201 | |
1202 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1202 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1203 | 1203 | $cat_id = $this->restore_link_category( |
1204 | 1204 | $link->category_id, |
1205 | 1205 | $session_id |
1206 | 1206 | ); |
1207 | - $sql = "SELECT MAX(display_order) |
|
1207 | + $sql = "SELECT MAX(display_order) |
|
1208 | 1208 | FROM $link_table |
1209 | 1209 | WHERE |
1210 | 1210 | c_id = ".$this->destination_course_id." AND |
1211 | 1211 | category_id='" . intval($cat_id). "'"; |
1212 | - $result = Database::query($sql); |
|
1213 | - list($max_order) = Database::fetch_array($result); |
|
1212 | + $result = Database::query($sql); |
|
1213 | + list($max_order) = Database::fetch_array($result); |
|
1214 | 1214 | |
1215 | 1215 | $params = []; |
1216 | - if (!empty($session_id)) { |
|
1216 | + if (!empty($session_id)) { |
|
1217 | 1217 | $params['session_id'] = $session_id; |
1218 | - } |
|
1218 | + } |
|
1219 | 1219 | |
1220 | 1220 | $params['c_id'] = $this->destination_course_id; |
1221 | 1221 | $params['url'] = self::DBUTF8($link->url); |
@@ -1244,9 +1244,9 @@ discard block |
||
1244 | 1244 | } |
1245 | 1245 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
1246 | 1246 | } |
1247 | - } |
|
1248 | - } |
|
1249 | - } |
|
1247 | + } |
|
1248 | + } |
|
1249 | + } |
|
1250 | 1250 | |
1251 | 1251 | /** |
1252 | 1252 | * Restore a link-category |
@@ -1290,21 +1290,21 @@ discard block |
||
1290 | 1290 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - /** |
|
1294 | - * Restore tool intro |
|
1295 | - */ |
|
1293 | + /** |
|
1294 | + * Restore tool intro |
|
1295 | + */ |
|
1296 | 1296 | public function restore_tool_intro($sessionId = 0) |
1297 | 1297 | { |
1298 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1298 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1299 | 1299 | $sessionId = intval($sessionId); |
1300 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1301 | - $resources = $this->course->resources; |
|
1302 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1303 | - $sql = "DELETE FROM ".$tool_intro_table." |
|
1300 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1301 | + $resources = $this->course->resources; |
|
1302 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1303 | + $sql = "DELETE FROM ".$tool_intro_table." |
|
1304 | 1304 | WHERE |
1305 | 1305 | c_id = ".$this->destination_course_id." AND |
1306 | 1306 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
1307 | - Database::query($sql); |
|
1307 | + Database::query($sql); |
|
1308 | 1308 | |
1309 | 1309 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1310 | 1310 | $tool_intro->intro_text, |
@@ -1332,21 +1332,21 @@ discard block |
||
1332 | 1332 | |
1333 | 1333 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
1334 | 1334 | } |
1335 | - } |
|
1336 | - } |
|
1337 | - } |
|
1335 | + } |
|
1336 | + } |
|
1337 | + } |
|
1338 | 1338 | |
1339 | - /** |
|
1340 | - * Restore events |
|
1341 | - */ |
|
1339 | + /** |
|
1340 | + * Restore events |
|
1341 | + */ |
|
1342 | 1342 | public function restore_events($sessionId = 0) |
1343 | 1343 | { |
1344 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1344 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1345 | 1345 | $sessionId = intval($sessionId); |
1346 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
1347 | - $resources = $this->course->resources; |
|
1348 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1349 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1346 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
1347 | + $resources = $this->course->resources; |
|
1348 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1349 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1350 | 1350 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1351 | 1351 | $event->content, |
1352 | 1352 | $this->course->code, |
@@ -1364,7 +1364,7 @@ discard block |
||
1364 | 1364 | 'end_date' => $event->end_date, |
1365 | 1365 | 'session_id' => $sessionId, |
1366 | 1366 | ]; |
1367 | - $new_event_id = Database::insert($table, $params); |
|
1367 | + $new_event_id = Database::insert($table, $params); |
|
1368 | 1368 | |
1369 | 1369 | if ($new_event_id) { |
1370 | 1370 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1377,30 +1377,30 @@ discard block |
||
1377 | 1377 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
1378 | 1378 | } |
1379 | 1379 | |
1380 | - // Copy event attachment |
|
1380 | + // Copy event attachment |
|
1381 | 1381 | |
1382 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1383 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1382 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1383 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1384 | 1384 | |
1385 | - if (!empty($this->course->orig)) { |
|
1385 | + if (!empty($this->course->orig)) { |
|
1386 | 1386 | |
1387 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1388 | - $sql = 'SELECT path, comment, size, filename |
|
1387 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1388 | + $sql = 'SELECT path, comment, size, filename |
|
1389 | 1389 | FROM '.$table_attachment.' |
1390 | 1390 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
1391 | - $attachment_event = Database::query($sql); |
|
1392 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1391 | + $attachment_event = Database::query($sql); |
|
1392 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1393 | 1393 | |
1394 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1394 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1395 | 1395 | !is_dir($origin_path.$attachment_event->path) |
1396 | 1396 | ) { |
1397 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1398 | - $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1399 | - //$copy_result = true; |
|
1400 | - if ($copy_result) { |
|
1401 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1397 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1398 | + $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1399 | + //$copy_result = true; |
|
1400 | + if ($copy_result) { |
|
1401 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1402 | 1402 | |
1403 | - $params = [ |
|
1403 | + $params = [ |
|
1404 | 1404 | 'c_id' => $this->destination_course_id, |
1405 | 1405 | 'path' => self::DBUTF8($new_filename), |
1406 | 1406 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1414,17 +1414,17 @@ discard block |
||
1414 | 1414 | Database::query($sql); |
1415 | 1415 | } |
1416 | 1416 | } |
1417 | - } |
|
1418 | - } else { |
|
1419 | - // get the info of the file |
|
1420 | - if (!empty($event->attachment_path) && |
|
1417 | + } |
|
1418 | + } else { |
|
1419 | + // get the info of the file |
|
1420 | + if (!empty($event->attachment_path) && |
|
1421 | 1421 | is_file($origin_path.$event->attachment_path) && |
1422 | 1422 | is_readable($origin_path.$event->attachment_path) |
1423 | 1423 | ) { |
1424 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1425 | - $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1426 | - if ($copy_result) { |
|
1427 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1424 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1425 | + $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1426 | + if ($copy_result) { |
|
1427 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1428 | 1428 | |
1429 | 1429 | $params = [ |
1430 | 1430 | 'c_id' => $this->destination_course_id, |
@@ -1440,23 +1440,23 @@ discard block |
||
1440 | 1440 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
1441 | 1441 | Database::query($sql); |
1442 | 1442 | } |
1443 | - } |
|
1444 | - } |
|
1445 | - } |
|
1446 | - } |
|
1447 | - } |
|
1448 | - } |
|
1449 | - |
|
1450 | - /** |
|
1451 | - * Restore course-description |
|
1452 | - */ |
|
1443 | + } |
|
1444 | + } |
|
1445 | + } |
|
1446 | + } |
|
1447 | + } |
|
1448 | + } |
|
1449 | + |
|
1450 | + /** |
|
1451 | + * Restore course-description |
|
1452 | + */ |
|
1453 | 1453 | public function restore_course_descriptions($session_id = 0) |
1454 | 1454 | { |
1455 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1456 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1457 | - $resources = $this->course->resources; |
|
1458 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1459 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1455 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1456 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1457 | + $resources = $this->course->resources; |
|
1458 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1459 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1460 | 1460 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1461 | 1461 | $cd->content, |
1462 | 1462 | $this->course->code, |
@@ -1466,10 +1466,10 @@ discard block |
||
1466 | 1466 | ); |
1467 | 1467 | |
1468 | 1468 | $params = []; |
1469 | - if (!empty($session_id)) { |
|
1470 | - $session_id = intval($session_id); |
|
1469 | + if (!empty($session_id)) { |
|
1470 | + $session_id = intval($session_id); |
|
1471 | 1471 | $params['session_id'] = $session_id; |
1472 | - } |
|
1472 | + } |
|
1473 | 1473 | $params['c_id'] = $this->destination_course_id; |
1474 | 1474 | $params['description_type'] = self::DBUTF8($cd->description_type); |
1475 | 1475 | $params['title'] = self::DBUTF8($cd->title); |
@@ -1485,22 +1485,22 @@ discard block |
||
1485 | 1485 | } |
1486 | 1486 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
1487 | 1487 | } |
1488 | - } |
|
1489 | - } |
|
1490 | - } |
|
1488 | + } |
|
1489 | + } |
|
1490 | + } |
|
1491 | 1491 | |
1492 | - /** |
|
1493 | - * Restore announcements |
|
1494 | - */ |
|
1492 | + /** |
|
1493 | + * Restore announcements |
|
1494 | + */ |
|
1495 | 1495 | public function restore_announcements($sessionId = 0) |
1496 | 1496 | { |
1497 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1497 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1498 | 1498 | $sessionId = intval($sessionId); |
1499 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1500 | - $resources = $this->course->resources; |
|
1501 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1499 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1500 | + $resources = $this->course->resources; |
|
1501 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1502 | 1502 | |
1503 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1503 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1504 | 1504 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1505 | 1505 | $announcement->content, |
1506 | 1506 | $this->course->code, |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | 'session_id' => $sessionId, |
1520 | 1520 | ]; |
1521 | 1521 | |
1522 | - $new_announcement_id = Database::insert($table, $params); |
|
1522 | + $new_announcement_id = Database::insert($table, $params); |
|
1523 | 1523 | |
1524 | 1524 | if ($new_announcement_id) { |
1525 | 1525 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1531,32 +1531,32 @@ discard block |
||
1531 | 1531 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
1532 | 1532 | } |
1533 | 1533 | |
1534 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1535 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1534 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1535 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1536 | 1536 | |
1537 | - // Copy announcement attachment file |
|
1538 | - if (!empty($this->course->orig)) { |
|
1537 | + // Copy announcement attachment file |
|
1538 | + if (!empty($this->course->orig)) { |
|
1539 | 1539 | |
1540 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1541 | - $sql = 'SELECT path, comment, size, filename |
|
1540 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1541 | + $sql = 'SELECT path, comment, size, filename |
|
1542 | 1542 | FROM '.$table_attachment.' |
1543 | 1543 | WHERE |
1544 | 1544 | c_id = '.$this->destination_course_id.' AND |
1545 | 1545 | announcement_id = '.$id; |
1546 | - $attachment_event = Database::query($sql); |
|
1547 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1546 | + $attachment_event = Database::query($sql); |
|
1547 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1548 | 1548 | |
1549 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1549 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1550 | 1550 | !is_dir($origin_path.$attachment_event->path) |
1551 | 1551 | ) { |
1552 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1552 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1553 | 1553 | $copy_result = copy( |
1554 | 1554 | $origin_path.$attachment_event->path, |
1555 | 1555 | $destination_path.$new_filename |
1556 | 1556 | ); |
1557 | 1557 | |
1558 | - if ($copy_result) { |
|
1559 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1558 | + if ($copy_result) { |
|
1559 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1560 | 1560 | |
1561 | 1561 | $params = [ |
1562 | 1562 | 'c_id' => $this->destination_course_id, |
@@ -1573,20 +1573,20 @@ discard block |
||
1573 | 1573 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1574 | 1574 | Database::query($sql); |
1575 | 1575 | } |
1576 | - } |
|
1577 | - } |
|
1578 | - } else { |
|
1579 | - // get the info of the file |
|
1580 | - if (!empty($announcement->attachment_path) && |
|
1576 | + } |
|
1577 | + } |
|
1578 | + } else { |
|
1579 | + // get the info of the file |
|
1580 | + if (!empty($announcement->attachment_path) && |
|
1581 | 1581 | is_file($origin_path.$announcement->attachment_path) && |
1582 | 1582 | is_readable($origin_path.$announcement->attachment_path) |
1583 | 1583 | ) { |
1584 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1585 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1584 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1585 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1586 | 1586 | |
1587 | - if ($copy_result) { |
|
1588 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1589 | - /*$sql = "INSERT INTO ".$table_attachment." SET |
|
1587 | + if ($copy_result) { |
|
1588 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1589 | + /*$sql = "INSERT INTO ".$table_attachment." SET |
|
1590 | 1590 | c_id = ".$this->destination_course_id." , |
1591 | 1591 | path = '".self::DBUTF8escapestring($new_filename)."', |
1592 | 1592 | comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."', |
@@ -1609,12 +1609,12 @@ discard block |
||
1609 | 1609 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1610 | 1610 | Database::query($sql); |
1611 | 1611 | } |
1612 | - } |
|
1613 | - } |
|
1614 | - } |
|
1615 | - } |
|
1616 | - } |
|
1617 | - } |
|
1612 | + } |
|
1613 | + } |
|
1614 | + } |
|
1615 | + } |
|
1616 | + } |
|
1617 | + } |
|
1618 | 1618 | |
1619 | 1619 | /** |
1620 | 1620 | * Restore Quiz |
@@ -1625,13 +1625,13 @@ discard block |
||
1625 | 1625 | $session_id = 0, |
1626 | 1626 | $respect_base_content = false |
1627 | 1627 | ) { |
1628 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1629 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1630 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1631 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1632 | - $resources = $this->course->resources; |
|
1628 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1629 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1630 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1631 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1632 | + $resources = $this->course->resources; |
|
1633 | 1633 | |
1634 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1634 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1635 | 1635 | |
1636 | 1636 | if (isset($quiz->obj)) { |
1637 | 1637 | //For new imports |
@@ -1641,7 +1641,7 @@ discard block |
||
1641 | 1641 | $quiz->obj = $quiz; |
1642 | 1642 | } |
1643 | 1643 | |
1644 | - $doc = ''; |
|
1644 | + $doc = ''; |
|
1645 | 1645 | if (!empty($quiz->sound)) { |
1646 | 1646 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
1647 | 1647 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
@@ -1649,14 +1649,14 @@ discard block |
||
1649 | 1649 | WHERE |
1650 | 1650 | c_id = " . $this->destination_course_id . " AND |
1651 | 1651 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
1652 | - $doc = Database::query($sql); |
|
1653 | - $doc = Database::fetch_object($doc); |
|
1654 | - $doc = str_replace('/audio/', '', $doc->path); |
|
1655 | - } |
|
1656 | - } |
|
1657 | - |
|
1658 | - if ($id != -1) { |
|
1659 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1652 | + $doc = Database::query($sql); |
|
1653 | + $doc = Database::fetch_object($doc); |
|
1654 | + $doc = str_replace('/audio/', '', $doc->path); |
|
1655 | + } |
|
1656 | + } |
|
1657 | + |
|
1658 | + if ($id != -1) { |
|
1659 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1660 | 1660 | $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1661 | 1661 | $quiz->description, |
1662 | 1662 | $this->course->code, |
@@ -1665,13 +1665,13 @@ discard block |
||
1665 | 1665 | $this->course->info['path'] |
1666 | 1666 | ); |
1667 | 1667 | |
1668 | - global $_custom; |
|
1669 | - if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1668 | + global $_custom; |
|
1669 | + if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1670 | 1670 | $_custom['exercises_clean_dates_when_restoring'] |
1671 | 1671 | ) { |
1672 | - $quiz->start_time = null; |
|
1673 | - $quiz->end_time = null; |
|
1674 | - } |
|
1672 | + $quiz->start_time = null; |
|
1673 | + $quiz->end_time = null; |
|
1674 | + } |
|
1675 | 1675 | |
1676 | 1676 | $params = array( |
1677 | 1677 | 'c_id' => $this->destination_course_id, |
@@ -1703,10 +1703,10 @@ discard block |
||
1703 | 1703 | } |
1704 | 1704 | $params['session_id'] = $my_session_id; |
1705 | 1705 | } else { |
1706 | - if (!empty($session_id)) { |
|
1707 | - $session_id = intval($session_id); |
|
1706 | + if (!empty($session_id)) { |
|
1707 | + $session_id = intval($session_id); |
|
1708 | 1708 | $params['session_id'] = $session_id; |
1709 | - } |
|
1709 | + } |
|
1710 | 1710 | } |
1711 | 1711 | $new_id = Database::insert($table_qui, $params); |
1712 | 1712 | |
@@ -1715,15 +1715,15 @@ discard block |
||
1715 | 1715 | Database::query($sql); |
1716 | 1716 | } |
1717 | 1717 | |
1718 | - } else { |
|
1719 | - // $id = -1 identifies the fictionary test for collecting |
|
1720 | - // orphan questions. We do not store it in the database. |
|
1721 | - $new_id = -1; |
|
1722 | - } |
|
1718 | + } else { |
|
1719 | + // $id = -1 identifies the fictionary test for collecting |
|
1720 | + // orphan questions. We do not store it in the database. |
|
1721 | + $new_id = -1; |
|
1722 | + } |
|
1723 | 1723 | |
1724 | - $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1724 | + $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1725 | 1725 | |
1726 | - $order = 0; |
|
1726 | + $order = 0; |
|
1727 | 1727 | if (!empty($quiz->question_ids)) { |
1728 | 1728 | foreach ($quiz->question_ids as $index => $question_id) { |
1729 | 1729 | $qid = $this->restore_quiz_question($question_id); |
@@ -1736,30 +1736,30 @@ discard block |
||
1736 | 1736 | Database::query($sql); |
1737 | 1737 | } |
1738 | 1738 | } |
1739 | - } |
|
1740 | - } |
|
1741 | - } |
|
1739 | + } |
|
1740 | + } |
|
1741 | + } |
|
1742 | 1742 | |
1743 | - /** |
|
1744 | - * Restore quiz-questions |
|
1743 | + /** |
|
1744 | + * Restore quiz-questions |
|
1745 | 1745 | * @params int question id |
1746 | - */ |
|
1746 | + */ |
|
1747 | 1747 | public function restore_quiz_question($id) |
1748 | 1748 | { |
1749 | - $resources = $this->course->resources; |
|
1749 | + $resources = $this->course->resources; |
|
1750 | 1750 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
1751 | 1751 | |
1752 | - $new_id = 0; |
|
1752 | + $new_id = 0; |
|
1753 | 1753 | |
1754 | - if (is_object($question)) { |
|
1755 | - if ($question->is_restored()) { |
|
1756 | - return $question->destination_id; |
|
1757 | - } |
|
1758 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1759 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1754 | + if (is_object($question)) { |
|
1755 | + if ($question->is_restored()) { |
|
1756 | + return $question->destination_id; |
|
1757 | + } |
|
1758 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1759 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1760 | 1760 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
1761 | 1761 | |
1762 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1762 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1763 | 1763 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1764 | 1764 | $question->description, |
1765 | 1765 | $this->course->code, |
@@ -1780,7 +1780,7 @@ discard block |
||
1780 | 1780 | 'extra' => self::DBUTF8($question->extra), |
1781 | 1781 | ]; |
1782 | 1782 | |
1783 | - $new_id = Database::insert($table_que, $params); |
|
1783 | + $new_id = Database::insert($table_que, $params); |
|
1784 | 1784 | |
1785 | 1785 | if ($new_id) { |
1786 | 1786 | |
@@ -1821,7 +1821,7 @@ discard block |
||
1821 | 1821 | |
1822 | 1822 | foreach ($temp as $index => $answer) { |
1823 | 1823 | //id = '".$index."', |
1824 | - $params = [ |
|
1824 | + $params = [ |
|
1825 | 1825 | 'c_id' => $this->destination_course_id, |
1826 | 1826 | 'question_id' => $new_id, |
1827 | 1827 | 'answer' => self::DBUTF8($answer['answer']), |
@@ -1838,12 +1838,12 @@ discard block |
||
1838 | 1838 | $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId"; |
1839 | 1839 | Database::query($sql); |
1840 | 1840 | } |
1841 | - } |
|
1842 | - } else { |
|
1841 | + } |
|
1842 | + } else { |
|
1843 | 1843 | $correct_answers = array(); |
1844 | - foreach ($question->answers as $index => $answer) { |
|
1844 | + foreach ($question->answers as $index => $answer) { |
|
1845 | 1845 | |
1846 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1846 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1847 | 1847 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1848 | 1848 | $answer['answer'], |
1849 | 1849 | $this->course->code, |
@@ -1882,8 +1882,8 @@ discard block |
||
1882 | 1882 | } |
1883 | 1883 | |
1884 | 1884 | $correct_answers[$answerId] = $answer['correct']; |
1885 | - } |
|
1886 | - } |
|
1885 | + } |
|
1886 | + } |
|
1887 | 1887 | |
1888 | 1888 | //Current course id |
1889 | 1889 | $course_id = api_get_course_int_id(); |
@@ -1980,12 +1980,12 @@ discard block |
||
1980 | 1980 | } |
1981 | 1981 | } |
1982 | 1982 | } |
1983 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
1984 | - } |
|
1985 | - return $new_id; |
|
1986 | - } |
|
1983 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
1984 | + } |
|
1985 | + return $new_id; |
|
1986 | + } |
|
1987 | 1987 | |
1988 | - /** |
|
1988 | + /** |
|
1989 | 1989 | * @todo : add session id when used for session |
1990 | 1990 | */ |
1991 | 1991 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2065,21 +2065,21 @@ discard block |
||
2065 | 2065 | $sessionId = intval($sessionId); |
2066 | 2066 | |
2067 | 2067 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
2068 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2069 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2070 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2071 | - $resources = $this->course->resources; |
|
2072 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2068 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2069 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2070 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2071 | + $resources = $this->course->resources; |
|
2072 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2073 | 2073 | |
2074 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2074 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2075 | 2075 | WHERE |
2076 | 2076 | c_id = '.$this->destination_course_id.' AND |
2077 | 2077 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
2078 | 2078 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
2079 | 2079 | |
2080 | - $result_check = Database::query($sql); |
|
2080 | + $result_check = Database::query($sql); |
|
2081 | 2081 | |
2082 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2082 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2083 | 2083 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2084 | 2084 | $survey->title, |
2085 | 2085 | $this->course->code, |
@@ -2133,20 +2133,20 @@ discard block |
||
2133 | 2133 | 'session_id' => $sessionId, |
2134 | 2134 | ]; |
2135 | 2135 | |
2136 | - //An existing survey exists with the same code and the same language |
|
2137 | - if (Database::num_rows($result_check) == 1) { |
|
2138 | - switch ($this->file_option) { |
|
2139 | - case FILE_SKIP: |
|
2140 | - //Do nothing |
|
2141 | - break; |
|
2142 | - case FILE_RENAME: |
|
2143 | - $survey_code = $survey->code.'_'; |
|
2144 | - $i=1; |
|
2145 | - $temp_survey_code = $survey_code.$i; |
|
2146 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2147 | - $temp_survey_code = $survey_code.++$i; |
|
2148 | - } |
|
2149 | - $survey_code = $temp_survey_code; |
|
2136 | + //An existing survey exists with the same code and the same language |
|
2137 | + if (Database::num_rows($result_check) == 1) { |
|
2138 | + switch ($this->file_option) { |
|
2139 | + case FILE_SKIP: |
|
2140 | + //Do nothing |
|
2141 | + break; |
|
2142 | + case FILE_RENAME: |
|
2143 | + $survey_code = $survey->code.'_'; |
|
2144 | + $i=1; |
|
2145 | + $temp_survey_code = $survey_code.$i; |
|
2146 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2147 | + $temp_survey_code = $survey_code.++$i; |
|
2148 | + } |
|
2149 | + $survey_code = $temp_survey_code; |
|
2150 | 2150 | |
2151 | 2151 | $params['code'] = $survey_code; |
2152 | 2152 | $new_id = Database::insert($table_sur, $params); |
@@ -2165,25 +2165,25 @@ discard block |
||
2165 | 2165 | Database::query($sql); |
2166 | 2166 | } |
2167 | 2167 | } |
2168 | - break; |
|
2169 | - case FILE_OVERWRITE: |
|
2170 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
2171 | - // getting the information of the survey (used for when the survey is shared) |
|
2168 | + break; |
|
2169 | + case FILE_OVERWRITE: |
|
2170 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
2171 | + // getting the information of the survey (used for when the survey is shared) |
|
2172 | 2172 | |
2173 | - $sql = "SELECT * FROM $table_sur |
|
2173 | + $sql = "SELECT * FROM $table_sur |
|
2174 | 2174 | WHERE |
2175 | 2175 | c_id = ".$this->destination_course_id." AND |
2176 | 2176 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
2177 | - $result = Database::query($sql); |
|
2178 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2177 | + $result = Database::query($sql); |
|
2178 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2179 | 2179 | |
2180 | - // if the survey is shared => also delete the shared content |
|
2181 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2180 | + // if the survey is shared => also delete the shared content |
|
2181 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2182 | 2182 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
2183 | - } |
|
2184 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2183 | + } |
|
2184 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2185 | 2185 | |
2186 | - // Insert the new source survey |
|
2186 | + // Insert the new source survey |
|
2187 | 2187 | $new_id = Database::insert($table_sur, $params); |
2188 | 2188 | |
2189 | 2189 | if ($new_id) { |
@@ -2204,11 +2204,11 @@ discard block |
||
2204 | 2204 | Database::query($sql); |
2205 | 2205 | } |
2206 | 2206 | } |
2207 | - break; |
|
2208 | - default: |
|
2209 | - break; |
|
2210 | - } |
|
2211 | - } else { |
|
2207 | + break; |
|
2208 | + default: |
|
2209 | + break; |
|
2210 | + } |
|
2211 | + } else { |
|
2212 | 2212 | // No existing survey with the same language and the same code, we just copy the survey |
2213 | 2213 | $new_id = Database::insert($table_sur, $params); |
2214 | 2214 | |
@@ -2230,43 +2230,43 @@ discard block |
||
2230 | 2230 | Database::query($sql); |
2231 | 2231 | } |
2232 | 2232 | } |
2233 | - } |
|
2234 | - } |
|
2235 | - } |
|
2236 | - } |
|
2237 | - |
|
2238 | - /** |
|
2239 | - * Check availability of a survey code |
|
2240 | - */ |
|
2233 | + } |
|
2234 | + } |
|
2235 | + } |
|
2236 | + } |
|
2237 | + |
|
2238 | + /** |
|
2239 | + * Check availability of a survey code |
|
2240 | + */ |
|
2241 | 2241 | public function is_survey_code_available($survey_code) |
2242 | 2242 | { |
2243 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2244 | - $sql = "SELECT * FROM $table_sur |
|
2243 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2244 | + $sql = "SELECT * FROM $table_sur |
|
2245 | 2245 | WHERE |
2246 | 2246 | c_id = ".$this->destination_course_id." AND |
2247 | 2247 | code='".self::DBUTF8escapestring($survey_code)."'"; |
2248 | - $result = Database::query($sql); |
|
2249 | - if (Database::num_rows($result) > 0) return false; else return true; |
|
2250 | - } |
|
2248 | + $result = Database::query($sql); |
|
2249 | + if (Database::num_rows($result) > 0) return false; else return true; |
|
2250 | + } |
|
2251 | 2251 | |
2252 | - /** |
|
2253 | - * Restore survey-questions |
|
2254 | - */ |
|
2252 | + /** |
|
2253 | + * Restore survey-questions |
|
2254 | + */ |
|
2255 | 2255 | public function restore_survey_question($id, $survey_id) |
2256 | 2256 | { |
2257 | - $resources = $this->course->resources; |
|
2258 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2257 | + $resources = $this->course->resources; |
|
2258 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2259 | 2259 | |
2260 | - $new_id=0; |
|
2260 | + $new_id=0; |
|
2261 | 2261 | |
2262 | - if (is_object($question)) { |
|
2263 | - if ($question->is_restored()) { |
|
2264 | - return $question->destination_id; |
|
2265 | - } |
|
2266 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2267 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2262 | + if (is_object($question)) { |
|
2263 | + if ($question->is_restored()) { |
|
2264 | + return $question->destination_id; |
|
2265 | + } |
|
2266 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2267 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2268 | 2268 | |
2269 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2269 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2270 | 2270 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2271 | 2271 | $question->survey_question, |
2272 | 2272 | $this->course->code, |
@@ -2320,10 +2320,10 @@ discard block |
||
2320 | 2320 | } |
2321 | 2321 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
2322 | 2322 | } |
2323 | - } |
|
2323 | + } |
|
2324 | 2324 | |
2325 | - return $new_id; |
|
2326 | - } |
|
2325 | + return $new_id; |
|
2326 | + } |
|
2327 | 2327 | |
2328 | 2328 | /** |
2329 | 2329 | * Restoring learning paths |
@@ -2334,20 +2334,20 @@ discard block |
||
2334 | 2334 | { |
2335 | 2335 | $session_id = intval($session_id); |
2336 | 2336 | |
2337 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2337 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2338 | 2338 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
2339 | 2339 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
2340 | 2340 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
2341 | 2341 | |
2342 | - $resources = $this->course->resources; |
|
2342 | + $resources = $this->course->resources; |
|
2343 | 2343 | |
2344 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2345 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2344 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2345 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2346 | 2346 | |
2347 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2347 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2348 | 2348 | |
2349 | - $condition_session = ""; |
|
2350 | - if (!empty($session_id)) { |
|
2349 | + $condition_session = ""; |
|
2350 | + if (!empty($session_id)) { |
|
2351 | 2351 | if ($respect_base_content) { |
2352 | 2352 | $my_session_id = $lp->session_id; |
2353 | 2353 | if (!empty($lp->session_id)) { |
@@ -2358,21 +2358,21 @@ discard block |
||
2358 | 2358 | $session_id = intval($session_id); |
2359 | 2359 | $condition_session = $session_id; |
2360 | 2360 | } |
2361 | - } |
|
2362 | - |
|
2363 | - // Adding the author's image |
|
2364 | - if (!empty($lp->preview_image)) { |
|
2365 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2366 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2367 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2368 | - //$copy_result = true; |
|
2369 | - if ($copy_result) { |
|
2370 | - $lp->preview_image = $new_filename; |
|
2371 | - } else { |
|
2372 | - $lp->preview_image =''; |
|
2373 | - } |
|
2374 | - } |
|
2375 | - } |
|
2361 | + } |
|
2362 | + |
|
2363 | + // Adding the author's image |
|
2364 | + if (!empty($lp->preview_image)) { |
|
2365 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2366 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2367 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2368 | + //$copy_result = true; |
|
2369 | + if ($copy_result) { |
|
2370 | + $lp->preview_image = $new_filename; |
|
2371 | + } else { |
|
2372 | + $lp->preview_image =''; |
|
2373 | + } |
|
2374 | + } |
|
2375 | + } |
|
2376 | 2376 | |
2377 | 2377 | if ($this->add_text_in_items) { |
2378 | 2378 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2419,7 +2419,7 @@ discard block |
||
2419 | 2419 | $params['session_id'] = $condition_session; |
2420 | 2420 | } |
2421 | 2421 | |
2422 | - $new_lp_id = Database::insert($table_main, $params); |
|
2422 | + $new_lp_id = Database::insert($table_main, $params); |
|
2423 | 2423 | |
2424 | 2424 | if ($new_lp_id) { |
2425 | 2425 | |
@@ -2480,13 +2480,13 @@ discard block |
||
2480 | 2480 | $old_refs = array(); |
2481 | 2481 | $prerequisite_ids = array(); |
2482 | 2482 | |
2483 | - foreach ($lp->get_items() as $index => $item) { |
|
2484 | - // we set the ref code here and then we update in a for loop |
|
2485 | - $ref = $item['ref']; |
|
2483 | + foreach ($lp->get_items() as $index => $item) { |
|
2484 | + // we set the ref code here and then we update in a for loop |
|
2485 | + $ref = $item['ref']; |
|
2486 | 2486 | |
2487 | - // Dealing with path the same way as ref as some data has |
|
2487 | + // Dealing with path the same way as ref as some data has |
|
2488 | 2488 | // been put into path when it's a local resource |
2489 | - // Only fix the path for no scos |
|
2489 | + // Only fix the path for no scos |
|
2490 | 2490 | if ($item['item_type'] == 'sco') { |
2491 | 2491 | $path = $item['path']; |
2492 | 2492 | } else { |
@@ -2515,128 +2515,128 @@ discard block |
||
2515 | 2515 | 'launch_data' => self::DBUTF8($item['launch_data']), |
2516 | 2516 | ]; |
2517 | 2517 | |
2518 | - $new_item_id = Database::insert($table_item, $params); |
|
2518 | + $new_item_id = Database::insert($table_item, $params); |
|
2519 | 2519 | |
2520 | 2520 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
2521 | 2521 | Database::query($sql); |
2522 | 2522 | |
2523 | - //save a link between old and new item IDs |
|
2524 | - $new_item_ids[$item['id']] = $new_item_id; |
|
2525 | - //save a reference of items that need a parent_item_id refresh |
|
2526 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2527 | - //save a reference of items that need a previous_item_id refresh |
|
2528 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2529 | - //save a reference of items that need a next_item_id refresh |
|
2530 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2531 | - |
|
2532 | - if (!empty($item['prerequisite'])) { |
|
2533 | - if ($lp->lp_type =='2') { |
|
2534 | - // if is an sco |
|
2535 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2536 | - } else { |
|
2537 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2538 | - } |
|
2539 | - } |
|
2540 | - |
|
2541 | - if (!empty($ref)) { |
|
2542 | - if ($lp->lp_type =='2') { |
|
2543 | - // if is an sco |
|
2544 | - $old_refs[$new_item_id]= $ref; |
|
2545 | - } else { |
|
2523 | + //save a link between old and new item IDs |
|
2524 | + $new_item_ids[$item['id']] = $new_item_id; |
|
2525 | + //save a reference of items that need a parent_item_id refresh |
|
2526 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2527 | + //save a reference of items that need a previous_item_id refresh |
|
2528 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2529 | + //save a reference of items that need a next_item_id refresh |
|
2530 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2531 | + |
|
2532 | + if (!empty($item['prerequisite'])) { |
|
2533 | + if ($lp->lp_type =='2') { |
|
2534 | + // if is an sco |
|
2535 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2536 | + } else { |
|
2537 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2538 | + } |
|
2539 | + } |
|
2540 | + |
|
2541 | + if (!empty($ref)) { |
|
2542 | + if ($lp->lp_type =='2') { |
|
2543 | + // if is an sco |
|
2544 | + $old_refs[$new_item_id]= $ref; |
|
2545 | + } else { |
|
2546 | 2546 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
2547 | - } |
|
2548 | - } |
|
2547 | + } |
|
2548 | + } |
|
2549 | 2549 | |
2550 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2551 | - } |
|
2550 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2551 | + } |
|
2552 | 2552 | |
2553 | - // Updating prerequisites |
|
2554 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2555 | - if($my_old_prerequisite != ''){ |
|
2556 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2553 | + // Updating prerequisites |
|
2554 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2555 | + if($my_old_prerequisite != ''){ |
|
2556 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2557 | 2557 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2558 | - Database::query($sql); |
|
2559 | - } |
|
2560 | - } |
|
2561 | - |
|
2562 | - // Updating refs |
|
2563 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
2564 | - if ($my_old_ref != '') { |
|
2565 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2558 | + Database::query($sql); |
|
2559 | + } |
|
2560 | + } |
|
2561 | + |
|
2562 | + // Updating refs |
|
2563 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
2564 | + if ($my_old_ref != '') { |
|
2565 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2566 | 2566 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2567 | - Database::query($sql); |
|
2568 | - } |
|
2569 | - } |
|
2570 | - |
|
2571 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2572 | - $parent_new_id = 0; |
|
2573 | - if($parent_item_old_id != 0){ |
|
2574 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2575 | - } |
|
2576 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2567 | + Database::query($sql); |
|
2568 | + } |
|
2569 | + } |
|
2570 | + |
|
2571 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2572 | + $parent_new_id = 0; |
|
2573 | + if($parent_item_old_id != 0){ |
|
2574 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2575 | + } |
|
2576 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2577 | 2577 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2578 | - Database::query($sql); |
|
2579 | - } |
|
2580 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2581 | - $previous_new_id = 0; |
|
2582 | - if($previous_item_old_id != 0){ |
|
2583 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2584 | - } |
|
2585 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2578 | + Database::query($sql); |
|
2579 | + } |
|
2580 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2581 | + $previous_new_id = 0; |
|
2582 | + if($previous_item_old_id != 0){ |
|
2583 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2584 | + } |
|
2585 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2586 | 2586 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2587 | - Database::query($sql); |
|
2588 | - } |
|
2589 | - |
|
2590 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2591 | - $next_new_id = 0; |
|
2592 | - if($next_item_old_id != 0){ |
|
2593 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2594 | - } |
|
2595 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2587 | + Database::query($sql); |
|
2588 | + } |
|
2589 | + |
|
2590 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2591 | + $next_new_id = 0; |
|
2592 | + if($next_item_old_id != 0){ |
|
2593 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2594 | + } |
|
2595 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2596 | 2596 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2597 | - Database::query($sql); |
|
2598 | - } |
|
2599 | - |
|
2600 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2601 | - $prerequisite_new_id = 0; |
|
2602 | - if($prerequisite_old_id != 0){ |
|
2603 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2604 | - } |
|
2605 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2597 | + Database::query($sql); |
|
2598 | + } |
|
2599 | + |
|
2600 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2601 | + $prerequisite_new_id = 0; |
|
2602 | + if($prerequisite_old_id != 0){ |
|
2603 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2604 | + } |
|
2605 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2606 | 2606 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2607 | - Database::query($sql); |
|
2608 | - } |
|
2609 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2610 | - } |
|
2611 | - } |
|
2612 | - } |
|
2613 | - |
|
2614 | - /** |
|
2615 | - * Restore works |
|
2607 | + Database::query($sql); |
|
2608 | + } |
|
2609 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2610 | + } |
|
2611 | + } |
|
2612 | + } |
|
2613 | + |
|
2614 | + /** |
|
2615 | + * Restore works |
|
2616 | 2616 | * @deprecated use restore_works |
2617 | 2617 | * |
2618 | - */ |
|
2619 | - public function restore_student_publication($sessionId = 0) |
|
2618 | + */ |
|
2619 | + public function restore_student_publication($sessionId = 0) |
|
2620 | 2620 | { |
2621 | 2621 | $sessionId = intval($sessionId); |
2622 | - $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
2623 | - $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
2624 | - $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
2622 | + $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
2623 | + $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
2624 | + $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
2625 | 2625 | |
2626 | - // Query in student publication |
|
2627 | - $sql = 'SELECT * FROM '.$work_table.' |
|
2626 | + // Query in student publication |
|
2627 | + $sql = 'SELECT * FROM '.$work_table.' |
|
2628 | 2628 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
2629 | 2629 | |
2630 | - $result = Database::query($sql); |
|
2631 | - $folders = Database::store_result($result, 'ASSOC'); |
|
2630 | + $result = Database::query($sql); |
|
2631 | + $folders = Database::store_result($result, 'ASSOC'); |
|
2632 | 2632 | |
2633 | - foreach ($folders as $folder) { |
|
2634 | - $old_id = $folder['id']; |
|
2633 | + foreach ($folders as $folder) { |
|
2634 | + $old_id = $folder['id']; |
|
2635 | 2635 | unset($folder['id']); |
2636 | - $folder['c_id'] = $this->destination_course_id; |
|
2636 | + $folder['c_id'] = $this->destination_course_id; |
|
2637 | 2637 | $folder['parent_id'] = 0; |
2638 | 2638 | $folder['session_id'] = $sessionId; |
2639 | - $new_id = Database::insert($work_table, $folder); |
|
2639 | + $new_id = Database::insert($work_table, $folder); |
|
2640 | 2640 | |
2641 | 2641 | if ($new_id) { |
2642 | 2642 | //query in item property |
@@ -2695,21 +2695,21 @@ discard block |
||
2695 | 2695 | } |
2696 | 2696 | } |
2697 | 2697 | } |
2698 | - } |
|
2698 | + } |
|
2699 | 2699 | |
2700 | - $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
|
2701 | - $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
|
2702 | - self::allow_create_all_directory($origin,$destination,false); |
|
2703 | - } |
|
2700 | + $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
|
2701 | + $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
|
2702 | + self::allow_create_all_directory($origin,$destination,false); |
|
2703 | + } |
|
2704 | 2704 | |
2705 | 2705 | /** |
2706 | - * copy all directory and sub directory |
|
2707 | - * @param string The path origin |
|
2708 | - * @param string The path destination |
|
2709 | - * @param boolean Option Overwrite |
|
2710 | - * @return void() |
|
2711 | - * @deprecated |
|
2712 | - */ |
|
2706 | + * copy all directory and sub directory |
|
2707 | + * @param string The path origin |
|
2708 | + * @param string The path destination |
|
2709 | + * @param boolean Option Overwrite |
|
2710 | + * @return void() |
|
2711 | + * @deprecated |
|
2712 | + */ |
|
2713 | 2713 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
2714 | 2714 | { |
2715 | 2715 | if (!is_dir($dest)) { |
@@ -2720,14 +2720,14 @@ discard block |
||
2720 | 2720 | if ($file != '.' && $file != '..') { |
2721 | 2721 | $path = $source . '/' . $file; |
2722 | 2722 | if (is_file($path)) { |
2723 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2723 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2724 | 2724 | if (!@copy($path, $dest . '/' . $file)) { |
2725 | 2725 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2726 | 2726 | }*/ |
2727 | 2727 | } elseif(is_dir($path)) { |
2728 | 2728 | if (!is_dir($dest . '/' . $file)) |
2729 | 2729 | mkdir($dest . '/' . $file); |
2730 | - self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
2730 | + self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
2731 | 2731 | } |
2732 | 2732 | } |
2733 | 2733 | } |
@@ -2735,12 +2735,12 @@ discard block |
||
2735 | 2735 | } |
2736 | 2736 | } |
2737 | 2737 | |
2738 | - /** |
|
2739 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2740 | - * @param string Tool name |
|
2741 | - * @param integer Old ID |
|
2742 | - * @return integer New ID |
|
2743 | - */ |
|
2738 | + /** |
|
2739 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2740 | + * @param string Tool name |
|
2741 | + * @param integer Old ID |
|
2742 | + * @return integer New ID |
|
2743 | + */ |
|
2744 | 2744 | public function get_new_id($tool, $ref) |
2745 | 2745 | { |
2746 | 2746 | // Check if the value exist in the current array. |
@@ -2762,25 +2762,25 @@ discard block |
||
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | return ''; |
2765 | - } |
|
2765 | + } |
|
2766 | 2766 | |
2767 | - /** |
|
2768 | - * Restore glossary |
|
2769 | - */ |
|
2767 | + /** |
|
2768 | + * Restore glossary |
|
2769 | + */ |
|
2770 | 2770 | public function restore_glossary($session_id = 0) |
2771 | 2771 | { |
2772 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2773 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2774 | - $resources = $this->course->resources; |
|
2775 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2772 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2773 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2774 | + $resources = $this->course->resources; |
|
2775 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2776 | 2776 | |
2777 | 2777 | $params = []; |
2778 | - if (!empty($session_id)) { |
|
2779 | - $session_id = intval($session_id); |
|
2778 | + if (!empty($session_id)) { |
|
2779 | + $session_id = intval($session_id); |
|
2780 | 2780 | $params['session_id'] = $session_id; |
2781 | - } |
|
2781 | + } |
|
2782 | 2782 | |
2783 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2783 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2784 | 2784 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2785 | 2785 | $glossary->description, |
2786 | 2786 | $this->course->code, |
@@ -2814,27 +2814,27 @@ discard block |
||
2814 | 2814 | |
2815 | 2815 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
2816 | 2816 | } |
2817 | - } |
|
2818 | - } |
|
2819 | - } |
|
2817 | + } |
|
2818 | + } |
|
2819 | + } |
|
2820 | 2820 | |
2821 | 2821 | /** |
2822 | 2822 | * @param int $session_id |
2823 | 2823 | */ |
2824 | 2824 | public function restore_wiki($session_id = 0) |
2825 | 2825 | { |
2826 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2827 | - // wiki table of the target course |
|
2828 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2829 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2826 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2827 | + // wiki table of the target course |
|
2828 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2829 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2830 | 2830 | |
2831 | - // storing all the resources that have to be copied in an array |
|
2832 | - $resources = $this->course->resources; |
|
2831 | + // storing all the resources that have to be copied in an array |
|
2832 | + $resources = $this->course->resources; |
|
2833 | 2833 | |
2834 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2835 | - // the sql statement to insert the groups from the old course to the new course |
|
2834 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2835 | + // the sql statement to insert the groups from the old course to the new course |
|
2836 | 2836 | |
2837 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2837 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2838 | 2838 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2839 | 2839 | $wiki->content, |
2840 | 2840 | $this->course->code, |
@@ -2857,7 +2857,7 @@ discard block |
||
2857 | 2857 | 'session_id' => !empty($session_id) ? intval($session_id) : 0, |
2858 | 2858 | ]; |
2859 | 2859 | |
2860 | - $new_id = Database::insert($table_wiki, $params); |
|
2860 | + $new_id = Database::insert($table_wiki, $params); |
|
2861 | 2861 | |
2862 | 2862 | if ($new_id) { |
2863 | 2863 | |
@@ -2888,9 +2888,9 @@ discard block |
||
2888 | 2888 | |
2889 | 2889 | Database::insert($table_wiki_conf, $params); |
2890 | 2890 | } |
2891 | - } |
|
2892 | - } |
|
2893 | - } |
|
2891 | + } |
|
2892 | + } |
|
2893 | + } |
|
2894 | 2894 | |
2895 | 2895 | /** |
2896 | 2896 | * Restore Thematics |
@@ -2898,15 +2898,15 @@ discard block |
||
2898 | 2898 | */ |
2899 | 2899 | public function restore_thematic($session_id = 0) |
2900 | 2900 | { |
2901 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2901 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2902 | 2902 | $table_thematic = Database:: get_course_table(TABLE_THEMATIC); |
2903 | 2903 | $table_thematic_advance = Database:: get_course_table(TABLE_THEMATIC_ADVANCE); |
2904 | 2904 | $table_thematic_plan = Database:: get_course_table(TABLE_THEMATIC_PLAN); |
2905 | 2905 | |
2906 | - $resources = $this->course->resources; |
|
2907 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
2906 | + $resources = $this->course->resources; |
|
2907 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
2908 | 2908 | |
2909 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2909 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2910 | 2910 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2911 | 2911 | $thematic->params['content'], |
2912 | 2912 | $this->course->code, |
@@ -2914,13 +2914,13 @@ discard block |
||
2914 | 2914 | $this->course->backup_path, |
2915 | 2915 | $this->course->info['path'] |
2916 | 2916 | ); |
2917 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
2918 | - unset($thematic->params['id']); |
|
2917 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
2918 | + unset($thematic->params['id']); |
|
2919 | 2919 | unset($thematic->params['iid']); |
2920 | 2920 | |
2921 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
2921 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
2922 | 2922 | |
2923 | - if ($last_id) { |
|
2923 | + if ($last_id) { |
|
2924 | 2924 | |
2925 | 2925 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
2926 | 2926 | Database::query($sql); |
@@ -2933,19 +2933,19 @@ discard block |
||
2933 | 2933 | api_get_user_id() |
2934 | 2934 | ); |
2935 | 2935 | |
2936 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
2937 | - unset($thematic_advance['id']); |
|
2936 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
2937 | + unset($thematic_advance['id']); |
|
2938 | 2938 | unset($thematic_advance['iid']); |
2939 | - $thematic_advance['attendance_id'] = 0; |
|
2940 | - $thematic_advance['thematic_id'] = $last_id; |
|
2941 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
2939 | + $thematic_advance['attendance_id'] = 0; |
|
2940 | + $thematic_advance['thematic_id'] = $last_id; |
|
2941 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
2942 | 2942 | $my_id = Database::insert( |
2943 | 2943 | $table_thematic_advance, |
2944 | 2944 | $thematic_advance, |
2945 | 2945 | false |
2946 | 2946 | ); |
2947 | 2947 | |
2948 | - if ($my_id) { |
|
2948 | + if ($my_id) { |
|
2949 | 2949 | |
2950 | 2950 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
2951 | 2951 | Database::query($sql); |
@@ -2957,17 +2957,17 @@ discard block |
||
2957 | 2957 | "ThematicAdvanceAdded", |
2958 | 2958 | api_get_user_id() |
2959 | 2959 | ); |
2960 | - } |
|
2961 | - } |
|
2960 | + } |
|
2961 | + } |
|
2962 | 2962 | |
2963 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
2964 | - unset($thematic_plan['id']); |
|
2963 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
2964 | + unset($thematic_plan['id']); |
|
2965 | 2965 | unset($thematic_plan['iid']); |
2966 | - $thematic_plan['thematic_id'] = $last_id; |
|
2967 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
2968 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
2966 | + $thematic_plan['thematic_id'] = $last_id; |
|
2967 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
2968 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
2969 | 2969 | |
2970 | - if ($my_id) { |
|
2970 | + if ($my_id) { |
|
2971 | 2971 | |
2972 | 2972 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
2973 | 2973 | Database::query($sql); |
@@ -2979,12 +2979,12 @@ discard block |
||
2979 | 2979 | "ThematicPlanAdded", |
2980 | 2980 | api_get_user_id() |
2981 | 2981 | ); |
2982 | - } |
|
2983 | - } |
|
2984 | - } |
|
2985 | - } |
|
2986 | - } |
|
2987 | - } |
|
2982 | + } |
|
2983 | + } |
|
2984 | + } |
|
2985 | + } |
|
2986 | + } |
|
2987 | + } |
|
2988 | 2988 | |
2989 | 2989 | /** |
2990 | 2990 | * Restore Attendance |
@@ -2992,14 +2992,14 @@ discard block |
||
2992 | 2992 | */ |
2993 | 2993 | public function restore_attendance($session_id = 0) |
2994 | 2994 | { |
2995 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
2996 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
2997 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
2995 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
2996 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
2997 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
2998 | 2998 | |
2999 | - $resources = $this->course->resources; |
|
3000 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
2999 | + $resources = $this->course->resources; |
|
3000 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3001 | 3001 | |
3002 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3002 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3003 | 3003 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3004 | 3004 | $obj->params['description'], |
3005 | 3005 | $this->course->code, |
@@ -3011,11 +3011,11 @@ discard block |
||
3011 | 3011 | unset($obj->params['id']); |
3012 | 3012 | unset($obj->params['iid']); |
3013 | 3013 | |
3014 | - $obj->params['c_id'] = $this->destination_course_id; |
|
3014 | + $obj->params['c_id'] = $this->destination_course_id; |
|
3015 | 3015 | |
3016 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
3016 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
3017 | 3017 | |
3018 | - if (is_numeric($last_id)) { |
|
3018 | + if (is_numeric($last_id)) { |
|
3019 | 3019 | |
3020 | 3020 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
3021 | 3021 | Database::query($sql); |
@@ -3029,11 +3029,11 @@ discard block |
||
3029 | 3029 | ); |
3030 | 3030 | |
3031 | 3031 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
3032 | - unset($attendance_calendar['id']); |
|
3032 | + unset($attendance_calendar['id']); |
|
3033 | 3033 | unset($attendance_calendar['iid']); |
3034 | 3034 | |
3035 | - $attendance_calendar['attendance_id'] = $last_id; |
|
3036 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3035 | + $attendance_calendar['attendance_id'] = $last_id; |
|
3036 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3037 | 3037 | $attendanceCalendarId = Database::insert( |
3038 | 3038 | $table_attendance_calendar, |
3039 | 3039 | $attendance_calendar |
@@ -3041,11 +3041,11 @@ discard block |
||
3041 | 3041 | |
3042 | 3042 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
3043 | 3043 | Database::query($sql); |
3044 | - } |
|
3045 | - } |
|
3046 | - } |
|
3047 | - } |
|
3048 | - } |
|
3044 | + } |
|
3045 | + } |
|
3046 | + } |
|
3047 | + } |
|
3048 | + } |
|
3049 | 3049 | |
3050 | 3050 | /** |
3051 | 3051 | * Restore Works |
@@ -3187,11 +3187,11 @@ discard block |
||
3187 | 3187 | */ |
3188 | 3188 | public function DBUTF8($str) |
3189 | 3189 | { |
3190 | - if (UTF8_CONVERT) { |
|
3190 | + if (UTF8_CONVERT) { |
|
3191 | 3191 | $str = utf8_encode($str); |
3192 | 3192 | } |
3193 | - return $str; |
|
3194 | - } |
|
3193 | + return $str; |
|
3194 | + } |
|
3195 | 3195 | |
3196 | 3196 | /** |
3197 | 3197 | * @param string $str |
@@ -3202,8 +3202,8 @@ discard block |
||
3202 | 3202 | if (UTF8_CONVERT) { |
3203 | 3203 | $str = utf8_encode($str); |
3204 | 3204 | } |
3205 | - return Database::escape_string($str); |
|
3206 | - } |
|
3205 | + return Database::escape_string($str); |
|
3206 | + } |
|
3207 | 3207 | |
3208 | 3208 | /** |
3209 | 3209 | * @param array $array |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | /** |
15 | 15 | * Display the form |
16 | - * @param array $hidden_fiels Hidden fields to add to the form. |
|
16 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
17 | 17 | * @param boolean the document array will be serialize. This is used in the course_copy.php file |
18 | 18 | */ |
19 | 19 | static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | |
571 | 571 | /** |
572 | 572 | * Display the form session export |
573 | - * @param array $hidden_fiels Hidden fields to add to the form. |
|
573 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
574 | 574 | * @param boolean the document array will be serialize. This is used in the course_copy.php file |
575 | 575 | */ |
576 | 576 | public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class CourseSelectForm |
13 | 13 | { |
14 | - /** |
|
15 | - * Display the form |
|
16 | - * @param array $hidden_fiels Hidden fields to add to the form. |
|
17 | - * @param boolean the document array will be serialize. This is used in the course_copy.php file |
|
18 | - */ |
|
19 | - static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
|
14 | + /** |
|
15 | + * Display the form |
|
16 | + * @param array $hidden_fiels Hidden fields to add to the form. |
|
17 | + * @param boolean the document array will be serialize. This is used in the course_copy.php file |
|
18 | + */ |
|
19 | + static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
|
20 | 20 | { |
21 | 21 | global $charset; |
22 | 22 | $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook'); |
@@ -134,50 +134,50 @@ discard block |
||
134 | 134 | </script> |
135 | 135 | <?php |
136 | 136 | |
137 | - //get destination course title |
|
138 | - if (!empty($hidden_fields['destination_course'])) { |
|
137 | + //get destination course title |
|
138 | + if (!empty($hidden_fields['destination_course'])) { |
|
139 | 139 | $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name( |
140 | 140 | $hidden_fields['destination_session'] |
141 | 141 | ) . ')' : null; |
142 | 142 | |
143 | 143 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
144 | - echo '<h3>'; |
|
145 | - echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
146 | - echo '</h3>'; |
|
147 | - } |
|
144 | + echo '<h3>'; |
|
145 | + echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
146 | + echo '</h3>'; |
|
147 | + } |
|
148 | 148 | echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
149 | - echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
149 | + echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
150 | 150 | |
151 | - echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">'; |
|
152 | - echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
151 | + echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">'; |
|
152 | + echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
153 | 153 | |
154 | - if (!empty($hidden_fields['destination_course']) && |
|
154 | + if (!empty($hidden_fields['destination_course']) && |
|
155 | 155 | !empty($hidden_fields['origin_course']) && |
156 | 156 | !empty($hidden_fields['destination_session']) && |
157 | 157 | !empty($hidden_fields['origin_session']) |
158 | 158 | ) { |
159 | - echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>'; |
|
160 | - echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>'; |
|
161 | - echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>'; |
|
162 | - echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>'; |
|
163 | - } |
|
159 | + echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>'; |
|
160 | + echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>'; |
|
161 | + echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>'; |
|
162 | + echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>'; |
|
163 | + } |
|
164 | 164 | |
165 | - $element_count = 0; |
|
165 | + $element_count = 0; |
|
166 | 166 | $forum_categories = array(); |
167 | 167 | $forums = array(); |
168 | 168 | $forum_topics = array(); |
169 | 169 | |
170 | 170 | echo '<p>'; |
171 | - echo get_lang('SelectResources'); |
|
172 | - echo '</p>'; |
|
171 | + echo get_lang('SelectResources'); |
|
172 | + echo '</p>'; |
|
173 | 173 | |
174 | 174 | Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt')); |
175 | 175 | |
176 | 176 | foreach ($course->resources as $type => $resources) { |
177 | 177 | if (count($resources) > 0) { |
178 | - switch ($type) { |
|
179 | - //Resources to avoid |
|
180 | - case RESOURCE_FORUMCATEGORY: |
|
178 | + switch ($type) { |
|
179 | + //Resources to avoid |
|
180 | + case RESOURCE_FORUMCATEGORY: |
|
181 | 181 | foreach ($resources as $id => $resource) { |
182 | 182 | $forum_categories[$id] = $resource; |
183 | 183 | } |
@@ -196,49 +196,49 @@ discard block |
||
196 | 196 | $element_count++; |
197 | 197 | break; |
198 | 198 | case RESOURCE_LINKCATEGORY: |
199 | - case RESOURCE_FORUMPOST: |
|
200 | - case RESOURCE_QUIZQUESTION: |
|
201 | - case RESOURCE_SURVEYQUESTION: |
|
202 | - case RESOURCE_SURVEYINVITATION: |
|
203 | - case RESOURCE_SCORM: |
|
204 | - break; |
|
199 | + case RESOURCE_FORUMPOST: |
|
200 | + case RESOURCE_QUIZQUESTION: |
|
201 | + case RESOURCE_SURVEYQUESTION: |
|
202 | + case RESOURCE_SURVEYINVITATION: |
|
203 | + case RESOURCE_SCORM: |
|
204 | + break; |
|
205 | 205 | default : |
206 | - echo '<img id="img_'.$type.'" src="../img/1.gif" onclick="javascript:exp('."'$type'".');" /> '; |
|
207 | - echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />'; |
|
208 | - echo '<div id="div_'.$type.'">'; |
|
209 | - if ($type == RESOURCE_LEARNPATH) { |
|
210 | - Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz')); |
|
211 | - Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments')); |
|
212 | - } |
|
213 | - if ($type == RESOURCE_DOCUMENT) { |
|
206 | + echo '<img id="img_'.$type.'" src="../img/1.gif" onclick="javascript:exp('."'$type'".');" /> '; |
|
207 | + echo '<b onclick="javascript:exp('."'$type'".');" >'.$resource_titles[$type].'</b><br />'; |
|
208 | + echo '<div id="div_'.$type.'">'; |
|
209 | + if ($type == RESOURCE_LEARNPATH) { |
|
210 | + Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz')); |
|
211 | + Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments')); |
|
212 | + } |
|
213 | + if ($type == RESOURCE_DOCUMENT) { |
|
214 | 214 | if (api_get_setting('show_glossary_in_documents') != 'none') { |
215 | 215 | Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary')); |
216 | 216 | } |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - echo '<blockquote>'; |
|
219 | + echo '<blockquote>'; |
|
220 | 220 | echo '<div class="btn-group">'; |
221 | - echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>"; |
|
221 | + echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>"; |
|
222 | 222 | echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>"; |
223 | - echo '</div><br />'; |
|
223 | + echo '</div><br />'; |
|
224 | 224 | |
225 | - foreach ($resources as $id => $resource) { |
|
225 | + foreach ($resources as $id => $resource) { |
|
226 | 226 | if ($resource) { |
227 | - // Event obj in 1.9.x in 1.10.x the class is CalendarEvent |
|
227 | + // Event obj in 1.9.x in 1.10.x the class is CalendarEvent |
|
228 | 228 | Coursecopy\Resource::setClassType($resource); |
229 | 229 | echo '<label class="checkbox">'; |
230 | 230 | echo '<input type="checkbox" name="resource['.$type.']['.$id.']" id="resource['.$type.']['.$id.']" />'; |
231 | 231 | $resource->show(); |
232 | 232 | echo '</label>'; |
233 | 233 | } |
234 | - } |
|
235 | - echo '</blockquote>'; |
|
236 | - echo '</div>'; |
|
237 | - echo '<script language="javascript">exp('."'$type'".')</script>'; |
|
238 | - $element_count++; |
|
234 | + } |
|
235 | + echo '</blockquote>'; |
|
236 | + echo '</div>'; |
|
237 | + echo '<script language="javascript">exp('."'$type'".')</script>'; |
|
238 | + $element_count++; |
|
239 | 239 | } |
240 | - } |
|
241 | - } |
|
240 | + } |
|
241 | + } |
|
242 | 242 | |
243 | 243 | //Fixes forum order |
244 | 244 | if (!empty($forum_categories)) { |
@@ -294,65 +294,65 @@ discard block |
||
294 | 294 | echo '<script language="javascript">exp('."'$type'".')</script>'; |
295 | 295 | } |
296 | 296 | |
297 | - if ($avoid_serialize) { |
|
298 | - /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
|
297 | + if ($avoid_serialize) { |
|
298 | + /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
|
299 | 299 | (when there are directories with hundred/thousand of files) */ |
300 | - // this is a known issue of serialize |
|
301 | - $course->resources['document']= null; |
|
302 | - } |
|
300 | + // this is a known issue of serialize |
|
301 | + $course->resources['document']= null; |
|
302 | + } |
|
303 | 303 | |
304 | - echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
304 | + echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
305 | 305 | |
306 | - if (is_array($hidden_fields)) { |
|
307 | - foreach ($hidden_fields as $key => $value) { |
|
308 | - echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
309 | - } |
|
310 | - } |
|
306 | + if (is_array($hidden_fields)) { |
|
307 | + foreach ($hidden_fields as $key => $value) { |
|
308 | + echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
309 | + } |
|
310 | + } |
|
311 | 311 | |
312 | 312 | $recycleOption = isset($_POST['recycle_option']) ? true : false; |
313 | 313 | |
314 | - if (empty($element_count)) { |
|
315 | - Display::display_warning_message(get_lang('NoDataAvailable')); |
|
316 | - } else { |
|
317 | - if (!empty($hidden_fields['destination_session'])) { |
|
318 | - echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
314 | + if (empty($element_count)) { |
|
315 | + Display::display_warning_message(get_lang('NoDataAvailable')); |
|
316 | + } else { |
|
317 | + if (!empty($hidden_fields['destination_session'])) { |
|
318 | + echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
319 | 319 | get_lang('Ok').'</button>'; |
320 | - } else { |
|
320 | + } else { |
|
321 | 321 | if ($recycleOption) { |
322 | 322 | echo '<br /><button class="save" type="submit">'. |
323 | 323 | get_lang('Ok').'</button>'; |
324 | 324 | } else { |
325 | - echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'. |
|
325 | + echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'. |
|
326 | 326 | get_lang('Ok').'</button>'; |
327 | 327 | } |
328 | - } |
|
329 | - } |
|
328 | + } |
|
329 | + } |
|
330 | 330 | |
331 | - CourseSelectForm :: display_hidden_quiz_questions($course); |
|
332 | - CourseSelectForm :: display_hidden_scorm_directories($course); |
|
333 | - echo '</form>'; |
|
334 | - echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
335 | - } |
|
331 | + CourseSelectForm :: display_hidden_quiz_questions($course); |
|
332 | + CourseSelectForm :: display_hidden_scorm_directories($course); |
|
333 | + echo '</form>'; |
|
334 | + echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
335 | + } |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * @param $course |
339 | 339 | */ |
340 | 340 | static function display_hidden_quiz_questions($course) |
341 | 341 | { |
342 | - if(is_array($course->resources)){ |
|
343 | - foreach ($course->resources as $type => $resources) { |
|
344 | - if (count($resources) > 0) { |
|
345 | - switch ($type) { |
|
346 | - case RESOURCE_QUIZQUESTION: |
|
347 | - foreach ($resources as $id => $resource) { |
|
348 | - echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />'; |
|
349 | - } |
|
350 | - break; |
|
351 | - } |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - } |
|
342 | + if(is_array($course->resources)){ |
|
343 | + foreach ($course->resources as $type => $resources) { |
|
344 | + if (count($resources) > 0) { |
|
345 | + switch ($type) { |
|
346 | + case RESOURCE_QUIZQUESTION: |
|
347 | + foreach ($resources as $id => $resource) { |
|
348 | + echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />'; |
|
349 | + } |
|
350 | + break; |
|
351 | + } |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + } |
|
356 | 356 | |
357 | 357 | /** |
358 | 358 | * @param $course |
@@ -360,30 +360,30 @@ discard block |
||
360 | 360 | static function display_hidden_scorm_directories($course) |
361 | 361 | { |
362 | 362 | if (is_array($course->resources)){ |
363 | - foreach ($course->resources as $type => $resources) { |
|
364 | - if (count($resources) > 0) { |
|
365 | - switch($type) { |
|
366 | - case RESOURCE_SCORM: |
|
367 | - foreach ($resources as $id => $resource) { |
|
368 | - echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
|
369 | - } |
|
370 | - break; |
|
371 | - } |
|
372 | - } |
|
373 | - } |
|
374 | - } |
|
375 | - } |
|
363 | + foreach ($course->resources as $type => $resources) { |
|
364 | + if (count($resources) > 0) { |
|
365 | + switch($type) { |
|
366 | + case RESOURCE_SCORM: |
|
367 | + foreach ($resources as $id => $resource) { |
|
368 | + echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
|
369 | + } |
|
370 | + break; |
|
371 | + } |
|
372 | + } |
|
373 | + } |
|
374 | + } |
|
375 | + } |
|
376 | 376 | |
377 | - /** |
|
378 | - * Get the posted course |
|
379 | - * @param string $from who calls the function? |
|
377 | + /** |
|
378 | + * Get the posted course |
|
379 | + * @param string $from who calls the function? |
|
380 | 380 | * It can be copy_course, create_backup, import_backup or recycle_course |
381 | 381 | * @param int $session_id |
382 | 382 | * @param string $course_code |
383 | - * @return course The course-object with all resources selected by the user |
|
384 | - * in the form given by display_form(...) |
|
385 | - */ |
|
386 | - public static function get_posted_course($from = '', $session_id = 0, $course_code = '') |
|
383 | + * @return course The course-object with all resources selected by the user |
|
384 | + * in the form given by display_form(...) |
|
385 | + */ |
|
386 | + public static function get_posted_course($from = '', $session_id = 0, $course_code = '') |
|
387 | 387 | { |
388 | 388 | $course = null; |
389 | 389 | |
@@ -393,30 +393,30 @@ discard block |
||
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | |
396 | - // Create the resource DOCUMENT objects |
|
397 | - // Loading the results from the checkboxes of ethe javascript |
|
398 | - $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
396 | + // Create the resource DOCUMENT objects |
|
397 | + // Loading the results from the checkboxes of ethe javascript |
|
398 | + $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
399 | 399 | |
400 | - $course_info = api_get_course_info($course_code); |
|
401 | - $table_doc = Database::get_course_table(TABLE_DOCUMENT); |
|
402 | - $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
403 | - $course_id = $course_info['real_id']; |
|
400 | + $course_info = api_get_course_info($course_code); |
|
401 | + $table_doc = Database::get_course_table(TABLE_DOCUMENT); |
|
402 | + $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
403 | + $course_id = $course_info['real_id']; |
|
404 | 404 | |
405 | - /* Searching the documents resource that have been set to null because |
|
405 | + /* Searching the documents resource that have been set to null because |
|
406 | 406 | $avoid_serialize is true in the display_form() function*/ |
407 | - if ($from == 'copy_course') { |
|
408 | - if (is_array($resource)) { |
|
409 | - $resource = array_keys($resource); |
|
407 | + if ($from == 'copy_course') { |
|
408 | + if (is_array($resource)) { |
|
409 | + $resource = array_keys($resource); |
|
410 | 410 | |
411 | - foreach ($resource as $resource_item) { |
|
411 | + foreach ($resource as $resource_item) { |
|
412 | 412 | |
413 | - $condition_session = ''; |
|
414 | - if (!empty($session_id)) { |
|
415 | - $session_id = intval($session_id); |
|
416 | - $condition_session = ' AND d.session_id ='.$session_id; |
|
417 | - } |
|
413 | + $condition_session = ''; |
|
414 | + if (!empty($session_id)) { |
|
415 | + $session_id = intval($session_id); |
|
416 | + $condition_session = ' AND d.session_id ='.$session_id; |
|
417 | + } |
|
418 | 418 | |
419 | - $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size |
|
419 | + $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size |
|
420 | 420 | FROM '.$table_doc.' d, '.$table_prop.' p |
421 | 421 | WHERE |
422 | 422 | d.c_id = '.$course_id.' AND |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | p.ref = d.id AND p.visibility != 2 AND |
426 | 426 | d.id = '.$resource_item.$condition_session.' |
427 | 427 | ORDER BY path'; |
428 | - $db_result = Database::query($sql); |
|
429 | - while ($obj = Database::fetch_object($db_result)) { |
|
428 | + $db_result = Database::query($sql); |
|
429 | + while ($obj = Database::fetch_object($db_result)) { |
|
430 | 430 | $doc = new Document( |
431 | 431 | $obj->id, |
432 | 432 | $obj->path, |
@@ -450,25 +450,25 @@ discard block |
||
450 | 450 | } |
451 | 451 | $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties; |
452 | 452 | } |
453 | - } |
|
454 | - } |
|
455 | - } |
|
456 | - } |
|
453 | + } |
|
454 | + } |
|
455 | + } |
|
456 | + } |
|
457 | 457 | |
458 | - if (is_array($course->resources)) { |
|
459 | - foreach ($course->resources as $type => $resources) { |
|
458 | + if (is_array($course->resources)) { |
|
459 | + foreach ($course->resources as $type => $resources) { |
|
460 | 460 | |
461 | - switch ($type) { |
|
462 | - case RESOURCE_SURVEYQUESTION: |
|
463 | - foreach($resources as $id => $obj) { |
|
464 | - if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
|
461 | + switch ($type) { |
|
462 | + case RESOURCE_SURVEYQUESTION: |
|
463 | + foreach($resources as $id => $obj) { |
|
464 | + if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
|
465 | 465 | is_array($_POST['resource'][RESOURCE_SURVEY]) && |
466 | 466 | !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY])) |
467 | 467 | ) { |
468 | - unset($course->resources[$type][$id]); |
|
469 | - } |
|
470 | - } |
|
471 | - break; |
|
468 | + unset($course->resources[$type][$id]); |
|
469 | + } |
|
470 | + } |
|
471 | + break; |
|
472 | 472 | case RESOURCE_FORUMTOPIC: |
473 | 473 | case RESOURCE_FORUMPOST: |
474 | 474 | //Add post from topic |
@@ -520,62 +520,62 @@ discard block |
||
520 | 520 | } |
521 | 521 | } |
522 | 522 | } |
523 | - case RESOURCE_LINKCATEGORY : |
|
524 | - case RESOURCE_FORUMCATEGORY : |
|
525 | - case RESOURCE_QUIZQUESTION : |
|
526 | - case RESOURCE_DOCUMENT: |
|
527 | - // Mark folders to import which are not selected by the user to import, |
|
528 | - // but in which a document was selected. |
|
529 | - $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
530 | - if (!empty($resources) && is_array($resources)) |
|
531 | - foreach ($resources as $id => $obj) { |
|
532 | - if (isset($obj->file_type) && $obj->file_type == 'folder' && |
|
523 | + case RESOURCE_LINKCATEGORY : |
|
524 | + case RESOURCE_FORUMCATEGORY : |
|
525 | + case RESOURCE_QUIZQUESTION : |
|
526 | + case RESOURCE_DOCUMENT: |
|
527 | + // Mark folders to import which are not selected by the user to import, |
|
528 | + // but in which a document was selected. |
|
529 | + $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
530 | + if (!empty($resources) && is_array($resources)) |
|
531 | + foreach ($resources as $id => $obj) { |
|
532 | + if (isset($obj->file_type) && $obj->file_type == 'folder' && |
|
533 | 533 | !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && |
534 | 534 | is_array($documents) |
535 | 535 | ) { |
536 | - foreach ($documents as $id_to_check => $post_value) { |
|
537 | - $obj_to_check = $resources[$id_to_check]; |
|
538 | - $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
539 | - if ($id_to_check != $id && $obj->path == $shared_path_part) { |
|
540 | - $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
|
541 | - break; |
|
542 | - } |
|
543 | - } |
|
544 | - } |
|
545 | - } |
|
546 | - default : |
|
547 | - if (!empty($resources) && is_array($resources)) { |
|
548 | - foreach ($resources as $id => $obj) { |
|
549 | - $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
|
550 | - // check if document is in a quiz (audio/video) |
|
551 | - if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
|
552 | - foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
536 | + foreach ($documents as $id_to_check => $post_value) { |
|
537 | + $obj_to_check = $resources[$id_to_check]; |
|
538 | + $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
539 | + if ($id_to_check != $id && $obj->path == $shared_path_part) { |
|
540 | + $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
|
541 | + break; |
|
542 | + } |
|
543 | + } |
|
544 | + } |
|
545 | + } |
|
546 | + default : |
|
547 | + if (!empty($resources) && is_array($resources)) { |
|
548 | + foreach ($resources as $id => $obj) { |
|
549 | + $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
|
550 | + // check if document is in a quiz (audio/video) |
|
551 | + if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
|
552 | + foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
553 | 553 | $quiz = $quiz->obj; |
554 | - if (isset($quiz->media) && $quiz->media == $id) { |
|
555 | - $resource_is_used_elsewhere = true; |
|
556 | - } |
|
557 | - } |
|
558 | - } |
|
559 | - if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) { |
|
560 | - unset($course->resources[$type][$id]); |
|
561 | - } |
|
562 | - } |
|
563 | - } |
|
564 | - } |
|
565 | - } |
|
566 | - } |
|
567 | - |
|
568 | - return $course; |
|
569 | - } |
|
570 | - |
|
571 | - /** |
|
572 | - * Display the form session export |
|
573 | - * @param array $hidden_fiels Hidden fields to add to the form. |
|
574 | - * @param boolean the document array will be serialize. This is used in the course_copy.php file |
|
575 | - */ |
|
576 | - public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
|
577 | - { |
|
578 | - ?> |
|
554 | + if (isset($quiz->media) && $quiz->media == $id) { |
|
555 | + $resource_is_used_elsewhere = true; |
|
556 | + } |
|
557 | + } |
|
558 | + } |
|
559 | + if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) { |
|
560 | + unset($course->resources[$type][$id]); |
|
561 | + } |
|
562 | + } |
|
563 | + } |
|
564 | + } |
|
565 | + } |
|
566 | + } |
|
567 | + |
|
568 | + return $course; |
|
569 | + } |
|
570 | + |
|
571 | + /** |
|
572 | + * Display the form session export |
|
573 | + * @param array $hidden_fiels Hidden fields to add to the form. |
|
574 | + * @param boolean the document array will be serialize. This is used in the course_copy.php file |
|
575 | + */ |
|
576 | + public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
|
577 | + { |
|
578 | + ?> |
|
579 | 579 | <script> |
580 | 580 | function exp(item) { |
581 | 581 | el = document.getElementById('div_'+item); |
@@ -617,64 +617,64 @@ discard block |
||
617 | 617 | </script> |
618 | 618 | <?php |
619 | 619 | |
620 | - //get destination course title |
|
621 | - if(!empty($hidden_fields['destination_course'])) { |
|
622 | - if (!empty($hidden_fields['destination_session'])) { |
|
623 | - $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
624 | - } else { |
|
625 | - $sessionTitle = null; |
|
626 | - } |
|
620 | + //get destination course title |
|
621 | + if(!empty($hidden_fields['destination_course'])) { |
|
622 | + if (!empty($hidden_fields['destination_session'])) { |
|
623 | + $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
624 | + } else { |
|
625 | + $sessionTitle = null; |
|
626 | + } |
|
627 | 627 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
628 | - echo '<h3>'; |
|
629 | - echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
630 | - echo '</h3>'; |
|
631 | - } |
|
632 | - |
|
633 | - echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
|
634 | - echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
635 | - echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
|
636 | - echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
637 | - foreach ($list_course as $course){ |
|
638 | - foreach ($course->resources as $type => $resources) { |
|
639 | - if (count($resources) > 0) { |
|
640 | - echo '<img id="img_'.$course->code.'" src="../img/1.gif" onclick="javascript:exp('."'$course->code'".');" />'; |
|
641 | - echo '<b onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />'; |
|
642 | - echo '<div id="div_'.$course->code.'">'; |
|
643 | - echo '<blockquote>'; |
|
628 | + echo '<h3>'; |
|
629 | + echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
630 | + echo '</h3>'; |
|
631 | + } |
|
632 | + |
|
633 | + echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
|
634 | + echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
635 | + echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
|
636 | + echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
637 | + foreach ($list_course as $course){ |
|
638 | + foreach ($course->resources as $type => $resources) { |
|
639 | + if (count($resources) > 0) { |
|
640 | + echo '<img id="img_'.$course->code.'" src="../img/1.gif" onclick="javascript:exp('."'$course->code'".');" />'; |
|
641 | + echo '<b onclick="javascript:exp('."'$course->code'".');" > '.$course->code.'</b><br />'; |
|
642 | + echo '<div id="div_'.$course->code.'">'; |
|
643 | + echo '<blockquote>'; |
|
644 | 644 | |
645 | 645 | echo '<div class="btn-group">'; |
646 | - echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>"; |
|
646 | + echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>"; |
|
647 | 647 | echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>"; |
648 | - echo '</div><br />'; |
|
648 | + echo '</div><br />'; |
|
649 | 649 | |
650 | - foreach ($resources as $id => $resource) { |
|
651 | - echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">'; |
|
650 | + foreach ($resources as $id => $resource) { |
|
651 | + echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">'; |
|
652 | 652 | echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>'; |
653 | - $resource->show(); |
|
654 | - echo '</label>'; |
|
655 | - } |
|
656 | - echo '</blockquote>'; |
|
657 | - echo '</div>'; |
|
658 | - echo '<script type="text/javascript">exp('."'$course->code'".')</script>'; |
|
659 | - } |
|
660 | - } |
|
661 | - } |
|
662 | - if ($avoid_serialize) { |
|
663 | - //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
|
664 | - // this is a known issue of serialize |
|
665 | - $course->resources['document']= null; |
|
666 | - } |
|
667 | - echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
668 | - if (is_array($hidden_fields)) { |
|
669 | - foreach ($hidden_fields as $key => $value) { |
|
670 | - echo "\n"; |
|
671 | - echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
672 | - } |
|
673 | - } |
|
674 | - echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>'; |
|
675 | - CourseSelectForm :: display_hidden_quiz_questions($course); |
|
676 | - CourseSelectForm :: display_hidden_scorm_directories($course); |
|
677 | - echo '</form>'; |
|
678 | - echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
679 | - } |
|
653 | + $resource->show(); |
|
654 | + echo '</label>'; |
|
655 | + } |
|
656 | + echo '</blockquote>'; |
|
657 | + echo '</div>'; |
|
658 | + echo '<script type="text/javascript">exp('."'$course->code'".')</script>'; |
|
659 | + } |
|
660 | + } |
|
661 | + } |
|
662 | + if ($avoid_serialize) { |
|
663 | + //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
|
664 | + // this is a known issue of serialize |
|
665 | + $course->resources['document']= null; |
|
666 | + } |
|
667 | + echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
668 | + if (is_array($hidden_fields)) { |
|
669 | + foreach ($hidden_fields as $key => $value) { |
|
670 | + echo "\n"; |
|
671 | + echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
672 | + } |
|
673 | + } |
|
674 | + echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>'; |
|
675 | + CourseSelectForm :: display_hidden_quiz_questions($course); |
|
676 | + CourseSelectForm :: display_hidden_scorm_directories($course); |
|
677 | + echo '</form>'; |
|
678 | + echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
679 | + } |
|
680 | 680 | } |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | |
137 | 137 | //get destination course title |
138 | 138 | if (!empty($hidden_fields['destination_course'])) { |
139 | - $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name( |
|
139 | + $sessionTitle = !empty($hidden_fields['destination_session']) ? ' ('.api_get_session_name( |
|
140 | 140 | $hidden_fields['destination_session'] |
141 | - ) . ')' : null; |
|
141 | + ).')' : null; |
|
142 | 142 | |
143 | 143 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
144 | 144 | echo '<h3>'; |
145 | - echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
145 | + echo get_lang('DestinationCourse').' : '.$course_infos['title'].' ('.$course_infos['code'].') '.$sessionTitle; |
|
146 | 146 | echo '</h3>'; |
147 | 147 | } |
148 | 148 | echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>'; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
299 | 299 | (when there are directories with hundred/thousand of files) */ |
300 | 300 | // this is a known issue of serialize |
301 | - $course->resources['document']= null; |
|
301 | + $course->resources['document'] = null; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | Display::display_warning_message(get_lang('NoDataAvailable')); |
316 | 316 | } else { |
317 | 317 | if (!empty($hidden_fields['destination_session'])) { |
318 | - echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
318 | + echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
319 | 319 | get_lang('Ok').'</button>'; |
320 | 320 | } else { |
321 | 321 | if ($recycleOption) { |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | static function display_hidden_quiz_questions($course) |
341 | 341 | { |
342 | - if(is_array($course->resources)){ |
|
342 | + if (is_array($course->resources)) { |
|
343 | 343 | foreach ($course->resources as $type => $resources) { |
344 | 344 | if (count($resources) > 0) { |
345 | 345 | switch ($type) { |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | */ |
360 | 360 | static function display_hidden_scorm_directories($course) |
361 | 361 | { |
362 | - if (is_array($course->resources)){ |
|
362 | + if (is_array($course->resources)) { |
|
363 | 363 | foreach ($course->resources as $type => $resources) { |
364 | 364 | if (count($resources) > 0) { |
365 | - switch($type) { |
|
365 | + switch ($type) { |
|
366 | 366 | case RESOURCE_SCORM: |
367 | 367 | foreach ($resources as $id => $resource) { |
368 | 368 | echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | if (is_array($resource)) { |
409 | 409 | $resource = array_keys($resource); |
410 | 410 | |
411 | - foreach ($resource as $resource_item) { |
|
411 | + foreach ($resource as $resource_item) { |
|
412 | 412 | |
413 | 413 | $condition_session = ''; |
414 | 414 | if (!empty($session_id)) { |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | tool = '".RESOURCE_DOCUMENT."' AND |
445 | 445 | ref = $resource_item "; |
446 | 446 | $res = Database::query($sql); |
447 | - $all_properties = array (); |
|
448 | - while ($item_property = Database::fetch_array($res,'ASSOC')) { |
|
447 | + $all_properties = array(); |
|
448 | + while ($item_property = Database::fetch_array($res, 'ASSOC')) { |
|
449 | 449 | $all_properties[] = $item_property; |
450 | 450 | } |
451 | 451 | $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | |
461 | 461 | switch ($type) { |
462 | 462 | case RESOURCE_SURVEYQUESTION: |
463 | - foreach($resources as $id => $obj) { |
|
463 | + foreach ($resources as $id => $obj) { |
|
464 | 464 | if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
465 | 465 | is_array($_POST['resource'][RESOURCE_SURVEY]) && |
466 | 466 | !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY])) |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | ) { |
536 | 536 | foreach ($documents as $id_to_check => $post_value) { |
537 | 537 | $obj_to_check = $resources[$id_to_check]; |
538 | - $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
538 | + $shared_path_part = substr($obj_to_check->path, 0, strlen($obj->path)); |
|
539 | 539 | if ($id_to_check != $id && $obj->path == $shared_path_part) { |
540 | 540 | $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
541 | 541 | break; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
550 | 550 | // check if document is in a quiz (audio/video) |
551 | 551 | if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
552 | - foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
552 | + foreach ($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
553 | 553 | $quiz = $quiz->obj; |
554 | 554 | if (isset($quiz->media) && $quiz->media == $id) { |
555 | 555 | $resource_is_used_elsewhere = true; |
@@ -618,15 +618,15 @@ discard block |
||
618 | 618 | <?php |
619 | 619 | |
620 | 620 | //get destination course title |
621 | - if(!empty($hidden_fields['destination_course'])) { |
|
621 | + if (!empty($hidden_fields['destination_course'])) { |
|
622 | 622 | if (!empty($hidden_fields['destination_session'])) { |
623 | - $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
623 | + $sessionTitle = ' ('.api_get_session_name($hidden_fields['destination_session']).')'; |
|
624 | 624 | } else { |
625 | 625 | $sessionTitle = null; |
626 | 626 | } |
627 | 627 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
628 | 628 | echo '<h3>'; |
629 | - echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
629 | + echo get_lang('DestinationCourse').' : '.$course_infos['title'].$sessionTitle; |
|
630 | 630 | echo '</h3>'; |
631 | 631 | } |
632 | 632 | |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
635 | 635 | echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.api_get_path(WEB_CODE_PATH).'img/progress_bar.gif\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
636 | 636 | echo '<input type="hidden" name="action" value="course_select_form"/>'; |
637 | - foreach ($list_course as $course){ |
|
637 | + foreach ($list_course as $course) { |
|
638 | 638 | foreach ($course->resources as $type => $resources) { |
639 | 639 | if (count($resources) > 0) { |
640 | 640 | echo '<img id="img_'.$course->code.'" src="../img/1.gif" onclick="javascript:exp('."'$course->code'".');" />'; |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | if ($avoid_serialize) { |
663 | 663 | //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
664 | 664 | // this is a known issue of serialize |
665 | - $course->resources['document']= null; |
|
665 | + $course->resources['document'] = null; |
|
666 | 666 | } |
667 | 667 | echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
668 | 668 | if (is_array($hidden_fields)) { |
@@ -527,14 +527,15 @@ |
||
527 | 527 | // Mark folders to import which are not selected by the user to import, |
528 | 528 | // but in which a document was selected. |
529 | 529 | $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
530 | - if (!empty($resources) && is_array($resources)) |
|
531 | - foreach ($resources as $id => $obj) { |
|
530 | + if (!empty($resources) && is_array($resources)) { |
|
531 | + foreach ($resources as $id => $obj) { |
|
532 | 532 | if (isset($obj->file_type) && $obj->file_type == 'folder' && |
533 | 533 | !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && |
534 | 534 | is_array($documents) |
535 | 535 | ) { |
536 | 536 | foreach ($documents as $id_to_check => $post_value) { |
537 | 537 | $obj_to_check = $resources[$id_to_check]; |
538 | + } |
|
538 | 539 | $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
539 | 540 | if ($id_to_check != $id && $obj->path == $shared_path_part) { |
540 | 541 | $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
@@ -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 | } |
@@ -50,9 +50,6 @@ |
||
50 | 50 | * @param int $id |
51 | 51 | * @param string $title |
52 | 52 | * @param string $content |
53 | - * @param string $date |
|
54 | - * @param string $hour |
|
55 | - * @param int $duration |
|
56 | 53 | */ |
57 | 54 | public function __construct( |
58 | 55 | $id, |
@@ -66,19 +66,19 @@ |
||
66 | 66 | $attachment_comment = null, |
67 | 67 | $all_day = 0 |
68 | 68 | ) { |
69 | - parent::__construct($id, RESOURCE_EVENT); |
|
69 | + parent::__construct($id, RESOURCE_EVENT); |
|
70 | 70 | |
71 | - $this->title = $title; |
|
72 | - $this->content = $content; |
|
73 | - $this->start_date = $start_date; |
|
74 | - $this->end_date = $end_date; |
|
75 | - $this->all_day = $all_day; |
|
71 | + $this->title = $title; |
|
72 | + $this->content = $content; |
|
73 | + $this->start_date = $start_date; |
|
74 | + $this->end_date = $end_date; |
|
75 | + $this->all_day = $all_day; |
|
76 | 76 | |
77 | - $this->attachment_path = $attachment_path; |
|
78 | - $this->attachment_filename = $attachment_filename; |
|
79 | - $this->attachment_size = $attachment_size; |
|
80 | - $this->attachment_comment = $attachment_comment; |
|
81 | - } |
|
77 | + $this->attachment_path = $attachment_path; |
|
78 | + $this->attachment_filename = $attachment_filename; |
|
79 | + $this->attachment_size = $attachment_size; |
|
80 | + $this->attachment_comment = $attachment_comment; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Show this Event |
@@ -115,6 +115,9 @@ |
||
115 | 115 | $this->answers[] = $answer; |
116 | 116 | } |
117 | 117 | |
118 | + /** |
|
119 | + * @param QuizQuestionOption $option_obj |
|
120 | + */ |
|
118 | 121 | public function add_option($option_obj) |
119 | 122 | { |
120 | 123 | $this->question_options[$option_obj->obj->id] = $option_obj; |
@@ -128,7 +128,7 @@ |
||
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Resturns the type of this resource |
131 | - * @return constant The type. |
|
131 | + * @return integer The type. |
|
132 | 132 | */ |
133 | 133 | public function get_type() |
134 | 134 | { |