Passed
Push — 1.10.x ( 751682...677ec8 )
by Yannick
50:57
created
main/coursecopy/classes/Course.class.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -327,6 +327,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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')) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseArchiver.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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')) {
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseBuilder.class.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseRestorer.class.php 4 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,6 +84,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     */
Please login to merge, or discard this patch.
Indentation   +724 added lines, -724 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,10 +317,10 @@  discard block
 block discarded – undo
317 317
                     $my_session_id = $session_id;
318 318
                 }
319 319
 
320
-		    	if ($document->file_type == FOLDER) {
321
-		    		$visibility = $document->item_properties[0]['visibility'];
320
+                if ($document->file_type == FOLDER) {
321
+                    $visibility = $document->item_properties[0]['visibility'];
322 322
 
323
-		    		$new = substr($document->path, 8);
323
+                    $new = substr($document->path, 8);
324 324
 
325 325
                     $folderList = explode('/', $new);
326 326
                     $tempFolder = '';
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                             }
377 377
                         }
378 378
                     }
379
-		    	} elseif ($document->file_type == DOCUMENT) {
379
+                } elseif ($document->file_type == DOCUMENT) {
380 380
                     //Checking if folder exists in the database otherwise we created it
381 381
                     $dir_to_create = dirname($document->path);
382 382
 
@@ -421,19 +421,19 @@  discard block
 block discarded – undo
421 421
                         }
422 422
                     }
423 423
 
424
-					if (file_exists($path.$document->path)) {
425
-						switch ($this->file_option) {
426
-							case FILE_OVERWRITE :
424
+                    if (file_exists($path.$document->path)) {
425
+                        switch ($this->file_option) {
426
+                            case FILE_OVERWRITE :
427 427
                                 $origin_path = $this->course->backup_path.'/'.$document->path;
428 428
 
429
-								if (file_exists($origin_path)) {
430
-        						    copy($origin_path, $path.$document->path);
429
+                                if (file_exists($origin_path)) {
430
+                                    copy($origin_path, $path.$document->path);
431 431
                                     $sql = "SELECT id FROM $table
432 432
                                             WHERE
433 433
                                                 c_id = ".$this->destination_course_id." AND
434 434
                                                 path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'";
435 435
 
436
-        						    $res = Database::query($sql);
436
+                                    $res = Database::query($sql);
437 437
                                     $count = Database::num_rows($res);
438 438
 
439 439
                                     if ($count == 0) {
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
                                             'session_id' => $my_session_id,
448 448
                                         ];
449 449
 
450
-    									$document_id = Database::insert($table, $params);
450
+                                        $document_id = Database::insert($table, $params);
451 451
 
452 452
                                         if ($document_id) {
453 453
                                             $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
@@ -538,84 +538,84 @@  discard block
 block discarded – undo
538 538
                                             ],
539 539
                                         ]
540 540
                                     );
541
-								}
541
+                                }
542 542
 
543
-								break;
544
-							case FILE_SKIP :
545
-								$sql = "SELECT id FROM $table
543
+                                break;
544
+                            case FILE_SKIP :
545
+                                $sql = "SELECT id FROM $table
546 546
 								        WHERE
547 547
 								            c_id = ".$this->destination_course_id." AND
548 548
 								            path='/".self::DBUTF8escapestring(substr($document->path, 9))."'";
549
-								$res = Database::query($sql);
550
-								$obj = Database::fetch_object($res);
551
-								$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
552
-								break;
553
-							case FILE_RENAME :
554
-								$i = 1;
555
-								$ext = explode('.', basename($document->path));
556
-								if (count($ext) > 1) {
557
-									$ext = array_pop($ext);
558
-									$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
559
-									$ext = '.'.$ext;
560
-								} else {
561
-									$ext = '';
562
-									$file_name_no_ext = $document->path;
563
-								}
564
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
565
-								$file_exists = file_exists($path.$new_file_name);
566
-								while ($file_exists) {
567
-									$i ++;
568
-									$new_file_name = $file_name_no_ext.'_'.$i.$ext;
569
-									$file_exists = file_exists($path.$new_file_name);
570
-								}
571
-
572
-								if (!empty($session_id)) {
573
-
574
-									$document_path = explode('/',$document->path,3);
575
-									$course_path = $path;
576
-									$orig_base_folder = $document_path[1];
577
-									$orig_base_path   = $course_path.$document_path[0].'/'.$document_path[1];
578
-
579
-									if (is_dir($orig_base_path)) {
580
-
581
-										$new_base_foldername = $orig_base_folder;
582
-										$new_base_path = $orig_base_path;
583
-
584
-										if ($_SESSION['orig_base_foldername'] != $new_base_foldername) {
585
-											unset($_SESSION['new_base_foldername']);
586
-											unset($_SESSION['orig_base_foldername']);
587
-											unset($_SESSION['new_base_path']);
588
-										}
589
-
590
-										$folder_exists = file_exists($new_base_path);
591
-										if ($folder_exists) {
592
-											$_SESSION['orig_base_foldername'] = $new_base_foldername; 		// e.g: carpeta1 in session
593
-											$x = '';
594
-											while ($folder_exists) {
595
-												$x = $x + 1;
596
-												$new_base_foldername = $document_path[1].'_'.$x;
597
-												$new_base_path = $orig_base_path.'_'.$x;
549
+                                $res = Database::query($sql);
550
+                                $obj = Database::fetch_object($res);
551
+                                $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
552
+                                break;
553
+                            case FILE_RENAME :
554
+                                $i = 1;
555
+                                $ext = explode('.', basename($document->path));
556
+                                if (count($ext) > 1) {
557
+                                    $ext = array_pop($ext);
558
+                                    $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
559
+                                    $ext = '.'.$ext;
560
+                                } else {
561
+                                    $ext = '';
562
+                                    $file_name_no_ext = $document->path;
563
+                                }
564
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
565
+                                $file_exists = file_exists($path.$new_file_name);
566
+                                while ($file_exists) {
567
+                                    $i ++;
568
+                                    $new_file_name = $file_name_no_ext.'_'.$i.$ext;
569
+                                    $file_exists = file_exists($path.$new_file_name);
570
+                                }
571
+
572
+                                if (!empty($session_id)) {
573
+
574
+                                    $document_path = explode('/',$document->path,3);
575
+                                    $course_path = $path;
576
+                                    $orig_base_folder = $document_path[1];
577
+                                    $orig_base_path   = $course_path.$document_path[0].'/'.$document_path[1];
578
+
579
+                                    if (is_dir($orig_base_path)) {
580
+
581
+                                        $new_base_foldername = $orig_base_folder;
582
+                                        $new_base_path = $orig_base_path;
583
+
584
+                                        if ($_SESSION['orig_base_foldername'] != $new_base_foldername) {
585
+                                            unset($_SESSION['new_base_foldername']);
586
+                                            unset($_SESSION['orig_base_foldername']);
587
+                                            unset($_SESSION['new_base_path']);
588
+                                        }
589
+
590
+                                        $folder_exists = file_exists($new_base_path);
591
+                                        if ($folder_exists) {
592
+                                            $_SESSION['orig_base_foldername'] = $new_base_foldername; 		// e.g: carpeta1 in session
593
+                                            $x = '';
594
+                                            while ($folder_exists) {
595
+                                                $x = $x + 1;
596
+                                                $new_base_foldername = $document_path[1].'_'.$x;
597
+                                                $new_base_path = $orig_base_path.'_'.$x;
598 598
                                                 if ($_SESSION['new_base_foldername'] == $new_base_foldername) {
599 599
                                                     break;
600 600
                                                 }
601
-												$folder_exists = file_exists($new_base_path);
602
-											}
603
-											$_SESSION['new_base_foldername'] = $new_base_foldername;
604
-											$_SESSION['new_base_path'] = $new_base_path;
605
-										}
601
+                                                $folder_exists = file_exists($new_base_path);
602
+                                            }
603
+                                            $_SESSION['new_base_foldername'] = $new_base_foldername;
604
+                                            $_SESSION['new_base_path'] = $new_base_path;
605
+                                        }
606 606
 
607
-										if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
608
-											$new_base_foldername = $_SESSION['new_base_foldername'];
609
-											$new_base_path = $_SESSION['new_base_path'];
610
-										}
607
+                                        if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
608
+                                            $new_base_foldername = $_SESSION['new_base_foldername'];
609
+                                            $new_base_path = $_SESSION['new_base_path'];
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
-										$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
616
+                                        $path_title = '/'.$new_base_foldername.'/'.$document_path[2];
617 617
 
618
-										copy_folder_course_session(
618
+                                        copy_folder_course_session(
619 619
                                             $basedir_dest_path,
620 620
                                             $base_path_document,
621 621
                                             $session_id,
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
                                             'session_id' => $my_session_id,
658 658
                                         ];
659 659
 
660
-										$document_id = Database::insert($table, $params);
660
+                                        $document_id = Database::insert($table, $params);
661 661
 
662 662
                                         if ($document_id) {
663 663
                                             $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
                                             $my_session_id
679 679
                                         );
680 680
 
681
-									} else {
681
+                                    } else {
682 682
 
683
-									    if (file_exists($path.$document->path)) {
683
+                                        if (file_exists($path.$document->path)) {
684 684
                                             copy($path.$document->path, $path.$new_file_name);
685
-									    }
685
+                                        }
686 686
 
687 687
                                         //Replace old course code with the new destination code see BT#1985
688 688
                                         if (file_exists($path.$new_file_name)) {
@@ -733,10 +733,10 @@  discard block
 block discarded – undo
733 733
                                                 $my_session_id
734 734
                                             );
735 735
                                         }
736
-									}
737
-								} else {
736
+                                    }
737
+                                } else {
738 738
 
739
-									copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
739
+                                    copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
740 740
 
741 741
                                     //Replace old course code with the new destination code see BT#1985
742 742
                                     if (file_exists($path.$new_file_name)) {
@@ -787,20 +787,20 @@  discard block
 block discarded – undo
787 787
                                         null,
788 788
                                         $my_session_id
789 789
                                     );
790
-								}
791
-								break;
792
-
793
-						} // end switch
794
-					} else {
795
-					    // end if file exists
796
-						//make sure the source file actually exists
797
-						if (is_file($this->course->backup_path.'/'.$document->path) &&
790
+                                }
791
+                                break;
792
+
793
+                        } // end switch
794
+                    } else {
795
+                        // end if file exists
796
+                        //make sure the source file actually exists
797
+                        if (is_file($this->course->backup_path.'/'.$document->path) &&
798 798
                             is_readable($this->course->backup_path.'/'.$document->path) &&
799 799
                             is_dir(dirname($path.$document->path)) &&
800 800
                             is_writeable(dirname($path.$document->path))
801 801
                         ) {
802
-						    //echo 'Copying';
803
-							copy($this->course->backup_path.'/'.$document->path, $path.$document->path);
802
+                            //echo 'Copying';
803
+                            copy($this->course->backup_path.'/'.$document->path, $path.$document->path);
804 804
 
805 805
                             //Replace old course code with the new destination code see BT#1985
806 806
                             if (file_exists($path.$document->path)) {
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
                                 Database::query($sql);
839 839
                             }
840 840
 
841
-							$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
841
+                            $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
842 842
                             api_item_property_update(
843 843
                                 $course_info,
844 844
                                 TOOL_DOCUMENT,
@@ -851,78 +851,78 @@  discard block
 block discarded – undo
851 851
                                 null,
852 852
                                 $my_session_id
853 853
                             );
854
-						} else {
855
-						    //echo 'not Copying';
856
-							if (is_file($this->course->backup_path.'/'.$document->path) && is_readable($this->course->backup_path.'/'.$document->path)) {
857
-								error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found');
858
-							}
859
-							if (!is_dir(dirname($path.$document->path))) {
860
-								error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found');
861
-							}
862
-							if (!is_writeable(dirname($path.$document->path))) {
863
-								error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable');
864
-							}
865
-						}
866
-					} // end file doesn't exist
867
-				}
868
-			} // end for each
869
-
870
-    		// Delete sessions for the copy the new folder in session
871
-    		unset($_SESSION['new_base_foldername']);
872
-    		unset($_SESSION['orig_base_foldername']);
873
-    		unset($_SESSION['new_base_path']);
874
-		}
875
-	}
876
-
877
-	/**
878
-	 * Restore scorm documents
879
-	 * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
854
+                        } else {
855
+                            //echo 'not Copying';
856
+                            if (is_file($this->course->backup_path.'/'.$document->path) && is_readable($this->course->backup_path.'/'.$document->path)) {
857
+                                error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found');
858
+                            }
859
+                            if (!is_dir(dirname($path.$document->path))) {
860
+                                error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found');
861
+                            }
862
+                            if (!is_writeable(dirname($path.$document->path))) {
863
+                                error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable');
864
+                            }
865
+                        }
866
+                    } // end file doesn't exist
867
+                }
868
+            } // end for each
869
+
870
+            // Delete sessions for the copy the new folder in session
871
+            unset($_SESSION['new_base_foldername']);
872
+            unset($_SESSION['orig_base_foldername']);
873
+            unset($_SESSION['new_base_path']);
874
+        }
875
+    }
876
+
877
+    /**
878
+     * Restore scorm documents
879
+     * TODO @TODO check that the restore function with renaming doesn't break the scorm structure!
880 880
      * see #7029
881
-	 */
882
-	public function restore_scorm_documents()
881
+     */
882
+    public function restore_scorm_documents()
883 883
     {
884
-		$perm = api_get_permissions_for_new_directories();
884
+        $perm = api_get_permissions_for_new_directories();
885 885
 
886
-		if ($this->course->has_resources(RESOURCE_SCORM)) {
887
-			$resources = $this->course->resources;
886
+        if ($this->course->has_resources(RESOURCE_SCORM)) {
887
+            $resources = $this->course->resources;
888 888
 
889
-			foreach ($resources[RESOURCE_SCORM] as $document) {
890
-				$path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
889
+            foreach ($resources[RESOURCE_SCORM] as $document) {
890
+                $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/';
891 891
 
892
-				@mkdir(dirname($path.$document->path), $perm, true);
892
+                @mkdir(dirname($path.$document->path), $perm, true);
893 893
 
894
-				if (file_exists($path.$document->path)) {
895
-					switch ($this->file_option) {
896
-						case FILE_OVERWRITE:
897
-							rmdirr($path.$document->path);
894
+                if (file_exists($path.$document->path)) {
895
+                    switch ($this->file_option) {
896
+                        case FILE_OVERWRITE:
897
+                            rmdirr($path.$document->path);
898 898
                             copyDirTo(
899 899
                                 $this->course->backup_path . '/' . $document->path,
900 900
                                 $path . dirname($document->path),
901 901
                                 false
902 902
                             );
903
-							break;
904
-						case FILE_SKIP:
905
-							break;
903
+                            break;
904
+                        case FILE_SKIP:
905
+                            break;
906 906
                         case FILE_RENAME:
907
-							$i = 1;
908
-							$ext = explode('.', basename($document->path));
909
-							if (count($ext) > 1) {
910
-								$ext = array_pop($ext);
911
-								$file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
912
-								$ext = '.'.$ext;
913
-							} else {
914
-								$ext = '';
915
-								$file_name_no_ext = $document->path;
916
-							}
917
-
918
-							$new_file_name = $file_name_no_ext.'_'.$i.$ext;
919
-							$file_exists = file_exists($path.$new_file_name);
920
-
921
-							while ($file_exists) {
922
-								$i ++;
923
-								$new_file_name = $file_name_no_ext.'_'.$i.$ext;
924
-								$file_exists = file_exists($path.$new_file_name);
925
-							}
907
+                            $i = 1;
908
+                            $ext = explode('.', basename($document->path));
909
+                            if (count($ext) > 1) {
910
+                                $ext = array_pop($ext);
911
+                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
912
+                                $ext = '.'.$ext;
913
+                            } else {
914
+                                $ext = '';
915
+                                $file_name_no_ext = $document->path;
916
+                            }
917
+
918
+                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
919
+                            $file_exists = file_exists($path.$new_file_name);
920
+
921
+                            while ($file_exists) {
922
+                                $i ++;
923
+                                $new_file_name = $file_name_no_ext.'_'.$i.$ext;
924
+                                $file_exists = file_exists($path.$new_file_name);
925
+                            }
926 926
 
927 927
                             rename(
928 928
                                 $this->course->backup_path . '/' . $document->path,
@@ -938,30 +938,30 @@  discard block
 block discarded – undo
938 938
                                 $this->course->backup_path . '/' . $document->path
939 939
                             );
940 940
 
941
-							break;
942
-					} // end switch
943
-				} else {
941
+                            break;
942
+                    } // end switch
943
+                } else {
944 944
                     // end if file exists
945 945
                     copyDirTo(
946 946
                         $this->course->backup_path . '/' . $document->path,
947 947
                         $path . dirname($document->path),
948 948
                         false
949 949
                     );
950
-				}
951
-			} // end for each
952
-		}
953
-	}
954
-
955
-	/**
956
-	 * Restore forums
957
-	 */
958
-	public function restore_forums($sessionId = 0)
950
+                }
951
+            } // end for each
952
+        }
953
+    }
954
+
955
+    /**
956
+     * Restore forums
957
+     */
958
+    public function restore_forums($sessionId = 0)
959 959
     {
960
-		if ($this->course->has_resources(RESOURCE_FORUM)) {
960
+        if ($this->course->has_resources(RESOURCE_FORUM)) {
961 961
             $sessionId = intval($sessionId);
962
-			$table_forum = Database::get_course_table(TABLE_FORUM);
963
-			$resources = $this->course->resources;
964
-			foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
962
+            $table_forum = Database::get_course_table(TABLE_FORUM);
963
+            $resources = $this->course->resources;
964
+            foreach ($resources[RESOURCE_FORUM] as $id => $forum) {
965 965
                 $params = (array)$forum->obj;
966 966
                 $cat_id = '';
967 967
                 if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) &&
@@ -1007,33 +1007,33 @@  discard block
 block discarded – undo
1007 1007
                     Database::query($sql);
1008 1008
                 }
1009 1009
 
1010
-				$this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1011
-
1012
-				$forum_topics = 0;
1013
-				if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1014
-					foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1015
-						if ($topic->obj->forum_id == $id) {
1016
-							$this->restore_topic($topic_id, $new_id, $sessionId);
1017
-							$forum_topics ++;
1018
-						}
1019
-					}
1020
-				}
1021
-				if ($forum_topics > 0) {
1022
-					$sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1010
+                $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id;
1011
+
1012
+                $forum_topics = 0;
1013
+                if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) {
1014
+                    foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) {
1015
+                        if ($topic->obj->forum_id == $id) {
1016
+                            $this->restore_topic($topic_id, $new_id, $sessionId);
1017
+                            $forum_topics ++;
1018
+                        }
1019
+                    }
1020
+                }
1021
+                if ($forum_topics > 0) {
1022
+                    $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics."
1023 1023
                             WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id;
1024
-					Database::query($sql);
1025
-				}
1026
-			}
1027
-		}
1028
-	}
1029
-
1030
-	/**
1031
-	 * Restore forum-categories
1032
-	 */
1024
+                    Database::query($sql);
1025
+                }
1026
+            }
1027
+        }
1028
+    }
1029
+
1030
+    /**
1031
+     * Restore forum-categories
1032
+     */
1033 1033
     public function restore_forum_category($my_id = null, $sessionId = 0)
1034 1034
     {
1035
-		$forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1036
-		$resources = $this->course->resources;
1035
+        $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY);
1036
+        $resources = $this->course->resources;
1037 1037
         if (!empty($resources[RESOURCE_FORUMCATEGORY])) {
1038 1038
             foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) {
1039 1039
                 if (!empty($my_id)) {
@@ -1080,15 +1080,15 @@  discard block
 block discarded – undo
1080 1080
                 }
1081 1081
             }
1082 1082
         }
1083
-	}
1083
+    }
1084 1084
 
1085
-	/**
1086
-	 * Restore a forum-topic
1087
-	 */
1085
+    /**
1086
+     * Restore a forum-topic
1087
+     */
1088 1088
     public function restore_topic($thread_id, $forum_id, $sessionId = 0)
1089 1089
     {
1090
-		$table = Database :: get_course_table(TABLE_FORUM_THREAD);
1091
-		$topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1090
+        $table = Database :: get_course_table(TABLE_FORUM_THREAD);
1091
+        $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id];
1092 1092
 
1093 1093
         $params = (array)$topic->obj;
1094 1094
         $params = self::DBUTF8_array($params);
@@ -1124,27 +1124,27 @@  discard block
 block discarded – undo
1124 1124
             $sessionId
1125 1125
         );
1126 1126
 
1127
-		$this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1127
+        $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id;
1128 1128
 
1129
-		$topic_replies = -1;
1129
+        $topic_replies = -1;
1130 1130
 
1131
-		foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1132
-			if ($post->obj->thread_id == $thread_id) {
1133
-				$topic_replies++;
1134
-				$this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1135
-			}
1136
-		}
1137
-		return $new_id;
1138
-	}
1131
+        foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) {
1132
+            if ($post->obj->thread_id == $thread_id) {
1133
+                $topic_replies++;
1134
+                $this->restore_post($post_id, $new_id, $forum_id, $sessionId);
1135
+            }
1136
+        }
1137
+        return $new_id;
1138
+    }
1139 1139
 
1140
-	/**
1141
-	 * Restore a forum-post
1142
-	 * @TODO Restore tree-structure of posts. For example: attachments to posts.
1143
-	 */
1140
+    /**
1141
+     * Restore a forum-post
1142
+     * @TODO Restore tree-structure of posts. For example: attachments to posts.
1143
+     */
1144 1144
     public function restore_post($id, $topic_id, $forum_id, $sessionId = 0)
1145 1145
     {
1146
-		$table_post = Database :: get_course_table(TABLE_FORUM_POST);
1147
-		$post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1146
+        $table_post = Database :: get_course_table(TABLE_FORUM_POST);
1147
+        $post = $this->course->resources[RESOURCE_FORUMPOST][$id];
1148 1148
         $params = (array) $post->obj;
1149 1149
         $params['c_id'] = $this->destination_course_id;
1150 1150
         $params['forum_id'] = $forum_id;
@@ -1179,37 +1179,37 @@  discard block
 block discarded – undo
1179 1179
             null,
1180 1180
             $sessionId
1181 1181
         );
1182
-		$this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1182
+        $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id;
1183 1183
 
1184
-		return $new_id;
1185
-	}
1184
+        return $new_id;
1185
+    }
1186 1186
 
1187
-	/**
1188
-	 * Restore links
1189
-	 */
1187
+    /**
1188
+     * Restore links
1189
+     */
1190 1190
     public function restore_links($session_id = 0)
1191 1191
     {
1192
-		if ($this->course->has_resources(RESOURCE_LINK)) {
1193
-			$link_table = Database :: get_course_table(TABLE_LINK);
1194
-			$resources = $this->course->resources;
1192
+        if ($this->course->has_resources(RESOURCE_LINK)) {
1193
+            $link_table = Database :: get_course_table(TABLE_LINK);
1194
+            $resources = $this->course->resources;
1195 1195
 
1196
-			foreach ($resources[RESOURCE_LINK] as $id => $link) {
1196
+            foreach ($resources[RESOURCE_LINK] as $id => $link) {
1197 1197
                 $cat_id = $this->restore_link_category(
1198 1198
                     $link->category_id,
1199 1199
                     $session_id
1200 1200
                 );
1201
-				$sql = "SELECT MAX(display_order)
1201
+                $sql = "SELECT MAX(display_order)
1202 1202
 				        FROM $link_table
1203 1203
 				        WHERE
1204 1204
 				            c_id = ".$this->destination_course_id." AND
1205 1205
 				            category_id='" . intval($cat_id). "'";
1206
-				$result = Database::query($sql);
1207
-    			list($max_order) = Database::fetch_array($result);
1206
+                $result = Database::query($sql);
1207
+                list($max_order) = Database::fetch_array($result);
1208 1208
 
1209 1209
                 $params = [];
1210
-    			if (!empty($session_id)) {
1210
+                if (!empty($session_id)) {
1211 1211
                     $params['session_id'] = $session_id;
1212
-    			}
1212
+                }
1213 1213
 
1214 1214
                 $params['c_id'] = $this->destination_course_id;
1215 1215
                 $params['url'] = self::DBUTF8($link->url);
@@ -1238,9 +1238,9 @@  discard block
 block discarded – undo
1238 1238
                     }
1239 1239
                     $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id;
1240 1240
                 }
1241
-			}
1242
-		}
1243
-	}
1241
+            }
1242
+        }
1243
+    }
1244 1244
 
1245 1245
     /**
1246 1246
      * Restore a link-category
@@ -1284,21 +1284,21 @@  discard block
 block discarded – undo
1284 1284
         return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id;
1285 1285
     }
1286 1286
 
1287
-	/**
1288
-	 * Restore tool intro
1289
-	 */
1287
+    /**
1288
+     * Restore tool intro
1289
+     */
1290 1290
     public function restore_tool_intro($sessionId = 0)
1291 1291
     {
1292
-		if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1292
+        if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) {
1293 1293
             $sessionId = intval($sessionId);
1294
-			$tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1295
-			$resources = $this->course->resources;
1296
-			foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1297
-				$sql = "DELETE FROM ".$tool_intro_table."
1294
+            $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO);
1295
+            $resources = $this->course->resources;
1296
+            foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) {
1297
+                $sql = "DELETE FROM ".$tool_intro_table."
1298 1298
 				        WHERE
1299 1299
 				            c_id = ".$this->destination_course_id." AND
1300 1300
 				            id='".self::DBUTF8escapestring($tool_intro->id)."'";
1301
-				Database::query($sql);
1301
+                Database::query($sql);
1302 1302
 
1303 1303
                 $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1304 1304
                     $tool_intro->intro_text,
@@ -1326,21 +1326,21 @@  discard block
 block discarded – undo
1326 1326
 
1327 1327
                     $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id;
1328 1328
                 }
1329
-			}
1330
-		}
1331
-	}
1329
+            }
1330
+        }
1331
+    }
1332 1332
 
1333
-	/**
1334
-	 * Restore events
1335
-	 */
1333
+    /**
1334
+     * Restore events
1335
+     */
1336 1336
     public function restore_events($sessionId = 0)
1337 1337
     {
1338
-		if ($this->course->has_resources(RESOURCE_EVENT)) {
1338
+        if ($this->course->has_resources(RESOURCE_EVENT)) {
1339 1339
             $sessionId = intval($sessionId);
1340
-			$table = Database :: get_course_table(TABLE_AGENDA);
1341
-			$resources = $this->course->resources;
1342
-			foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1343
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1340
+            $table = Database :: get_course_table(TABLE_AGENDA);
1341
+            $resources = $this->course->resources;
1342
+            foreach ($resources[RESOURCE_EVENT] as $id => $event) {
1343
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1344 1344
                 $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1345 1345
                     $event->content,
1346 1346
                     $this->course->code,
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
                     'end_date' => $event->end_date,
1359 1359
                     'session_id' => $sessionId,
1360 1360
                 ];
1361
-				$new_event_id = Database::insert($table, $params);
1361
+                $new_event_id = Database::insert($table, $params);
1362 1362
 
1363 1363
                 if ($new_event_id) {
1364 1364
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id";
@@ -1371,30 +1371,30 @@  discard block
 block discarded – undo
1371 1371
                     $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id;
1372 1372
                 }
1373 1373
 
1374
-				// Copy event attachment
1374
+                // Copy event attachment
1375 1375
 
1376
-				$origin_path = $this->course->backup_path.'/upload/calendar/';
1377
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1376
+                $origin_path = $this->course->backup_path.'/upload/calendar/';
1377
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/';
1378 1378
 
1379
-				if (!empty($this->course->orig)) {
1379
+                if (!empty($this->course->orig)) {
1380 1380
 
1381
-					$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1382
-					$sql = 'SELECT path, comment, size, filename
1381
+                    $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1382
+                    $sql = 'SELECT path, comment, size, filename
1383 1383
 					        FROM '.$table_attachment.'
1384 1384
 					        WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id;
1385
-					$attachment_event = Database::query($sql);
1386
-					$attachment_event = Database::fetch_object($attachment_event);
1385
+                    $attachment_event = Database::query($sql);
1386
+                    $attachment_event = Database::fetch_object($attachment_event);
1387 1387
 
1388
-					if (file_exists($origin_path.$attachment_event->path) &&
1388
+                    if (file_exists($origin_path.$attachment_event->path) &&
1389 1389
                         !is_dir($origin_path.$attachment_event->path)
1390 1390
                     ) {
1391
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1392
-						$copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1393
-						//$copy_result = true;
1394
-						if ($copy_result) {
1395
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1391
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1392
+                        $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename);
1393
+                        //$copy_result = true;
1394
+                        if ($copy_result) {
1395
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1396 1396
 
1397
-							$params = [
1397
+                            $params = [
1398 1398
                                 'c_id' => $this->destination_course_id,
1399 1399
                                 'path' => self::DBUTF8($new_filename),
1400 1400
                                 'comment' => self::DBUTF8($attachment_event->comment),
@@ -1408,17 +1408,17 @@  discard block
 block discarded – undo
1408 1408
                                 Database::query($sql);
1409 1409
                             }
1410 1410
                         }
1411
-					}
1412
-				} else {
1413
-					// get the info of the file
1414
-					if (!empty($event->attachment_path) &&
1411
+                    }
1412
+                } else {
1413
+                    // get the info of the file
1414
+                    if (!empty($event->attachment_path) &&
1415 1415
                         is_file($origin_path.$event->attachment_path) &&
1416 1416
                         is_readable($origin_path.$event->attachment_path)
1417 1417
                     ) {
1418
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1419
-						$copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1420
-						if ($copy_result) {
1421
-							$table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1418
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1419
+                        $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename);
1420
+                        if ($copy_result) {
1421
+                            $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
1422 1422
 
1423 1423
                             $params = [
1424 1424
                                 'c_id' => $this->destination_course_id,
@@ -1434,23 +1434,23 @@  discard block
 block discarded – undo
1434 1434
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id";
1435 1435
                                 Database::query($sql);
1436 1436
                             }
1437
-						}
1438
-					}
1439
-				}
1440
-			}
1441
-		}
1442
-	}
1443
-
1444
-	/**
1445
-	 * Restore course-description
1446
-	 */
1437
+                        }
1438
+                    }
1439
+                }
1440
+            }
1441
+        }
1442
+    }
1443
+
1444
+    /**
1445
+     * Restore course-description
1446
+     */
1447 1447
     public function restore_course_descriptions($session_id = 0)
1448 1448
     {
1449
-		if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1450
-			$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1451
-			$resources = $this->course->resources;
1452
-			foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1453
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1449
+        if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
1450
+            $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
1451
+            $resources = $this->course->resources;
1452
+            foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) {
1453
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1454 1454
                 $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1455 1455
                     $cd->content,
1456 1456
                     $this->course->code,
@@ -1460,10 +1460,10 @@  discard block
 block discarded – undo
1460 1460
                 );
1461 1461
 
1462 1462
                 $params = [];
1463
-				if (!empty($session_id)) {
1464
-					$session_id = intval($session_id);
1463
+                if (!empty($session_id)) {
1464
+                    $session_id = intval($session_id);
1465 1465
                     $params['session_id'] = $session_id;
1466
-				}
1466
+                }
1467 1467
                 $params['c_id'] = $this->destination_course_id;
1468 1468
                 $params['description_type'] = self::DBUTF8($cd->description_type);
1469 1469
                 $params['title'] = self::DBUTF8($cd->title);
@@ -1479,22 +1479,22 @@  discard block
 block discarded – undo
1479 1479
                     }
1480 1480
                     $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id;
1481 1481
                 }
1482
-			}
1483
-		}
1484
-	}
1482
+            }
1483
+        }
1484
+    }
1485 1485
 
1486
-	/**
1487
-	 * Restore announcements
1488
-	 */
1486
+    /**
1487
+     * Restore announcements
1488
+     */
1489 1489
     public function restore_announcements($sessionId = 0)
1490 1490
     {
1491
-		if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1491
+        if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
1492 1492
             $sessionId = intval($sessionId);
1493
-			$table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1494
-			$resources = $this->course->resources;
1495
-			foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1493
+            $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
1494
+            $resources = $this->course->resources;
1495
+            foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) {
1496 1496
 
1497
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
1497
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
1498 1498
                 $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1499 1499
                     $announcement->content,
1500 1500
                     $this->course->code,
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
                     'session_id' => $sessionId,
1514 1514
                 ];
1515 1515
 
1516
-				$new_announcement_id = Database::insert($table, $params);
1516
+                $new_announcement_id = Database::insert($table, $params);
1517 1517
 
1518 1518
                 if ($new_announcement_id) {
1519 1519
                     $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id";
@@ -1525,32 +1525,32 @@  discard block
 block discarded – undo
1525 1525
                     $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id;
1526 1526
                 }
1527 1527
 
1528
-				$origin_path = $this->course->backup_path.'/upload/announcements/';
1529
-				$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1528
+                $origin_path = $this->course->backup_path.'/upload/announcements/';
1529
+                $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/';
1530 1530
 
1531
-				// Copy announcement attachment file
1532
-				if (!empty($this->course->orig)) {
1531
+                // Copy announcement attachment file
1532
+                if (!empty($this->course->orig)) {
1533 1533
 
1534
-					$table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1535
-					$sql = 'SELECT path, comment, size, filename
1534
+                    $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1535
+                    $sql = 'SELECT path, comment, size, filename
1536 1536
 					        FROM '.$table_attachment.'
1537 1537
 					        WHERE
1538 1538
 					            c_id = '.$this->destination_course_id.' AND
1539 1539
 					            announcement_id = '.$id;
1540
-					$attachment_event = Database::query($sql);
1541
-					$attachment_event = Database::fetch_object($attachment_event);
1540
+                    $attachment_event = Database::query($sql);
1541
+                    $attachment_event = Database::fetch_object($attachment_event);
1542 1542
 
1543
-					if (file_exists($origin_path.$attachment_event->path) &&
1543
+                    if (file_exists($origin_path.$attachment_event->path) &&
1544 1544
                         !is_dir($origin_path.$attachment_event->path)
1545 1545
                     ) {
1546
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1546
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1547 1547
                         $copy_result = copy(
1548 1548
                             $origin_path.$attachment_event->path,
1549 1549
                             $destination_path.$new_filename
1550 1550
                         );
1551 1551
 
1552
-						if ($copy_result) {
1553
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1552
+                        if ($copy_result) {
1553
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1554 1554
 
1555 1555
                             $params = [
1556 1556
                                 'c_id' => $this->destination_course_id,
@@ -1567,20 +1567,20 @@  discard block
 block discarded – undo
1567 1567
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1568 1568
                                 Database::query($sql);
1569 1569
                             }
1570
-						}
1571
-					}
1572
-				} else {
1573
-					// get the info of the file
1574
-					if (!empty($announcement->attachment_path) &&
1570
+                        }
1571
+                    }
1572
+                } else {
1573
+                    // get the info of the file
1574
+                    if (!empty($announcement->attachment_path) &&
1575 1575
                         is_file($origin_path.$announcement->attachment_path) &&
1576 1576
                         is_readable($origin_path.$announcement->attachment_path)
1577 1577
                     ) {
1578
-						$new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1579
-						$copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1578
+                        $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php
1579
+                        $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename);
1580 1580
 
1581
-						if ($copy_result) {
1582
-							$table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1583
-							/*$sql = "INSERT INTO ".$table_attachment." SET
1581
+                        if ($copy_result) {
1582
+                            $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
1583
+                            /*$sql = "INSERT INTO ".$table_attachment." SET
1584 1584
 							        c_id = ".$this->destination_course_id." ,
1585 1585
 							        path = '".self::DBUTF8escapestring($new_filename)."',
1586 1586
 							        comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."',
@@ -1603,12 +1603,12 @@  discard block
 block discarded – undo
1603 1603
                                 $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId";
1604 1604
                                 Database::query($sql);
1605 1605
                             }
1606
-						}
1607
-					}
1608
-				}
1609
-			}
1610
-		}
1611
-	}
1606
+                        }
1607
+                    }
1608
+                }
1609
+            }
1610
+        }
1611
+    }
1612 1612
 
1613 1613
     /**
1614 1614
      * Restore Quiz
@@ -1619,13 +1619,13 @@  discard block
 block discarded – undo
1619 1619
         $session_id = 0,
1620 1620
         $respect_base_content = false
1621 1621
     ) {
1622
-		if ($this->course->has_resources(RESOURCE_QUIZ)) {
1623
-			$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1624
-			$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1625
-			$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1626
-			$resources = $this->course->resources;
1622
+        if ($this->course->has_resources(RESOURCE_QUIZ)) {
1623
+            $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
1624
+            $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
1625
+            $table_doc = Database :: get_course_table(TABLE_DOCUMENT);
1626
+            $resources = $this->course->resources;
1627 1627
 
1628
-			foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1628
+            foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
1629 1629
 
1630 1630
                 if (isset($quiz->obj)) {
1631 1631
                     //For new imports
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
                     $quiz->obj = $quiz;
1636 1636
                 }
1637 1637
 
1638
-				$doc = '';
1638
+                $doc = '';
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()) {
@@ -1643,14 +1643,14 @@  discard block
 block discarded – undo
1643 1643
                                 WHERE
1644 1644
                                     c_id = " . $this->destination_course_id . "  AND
1645 1645
                                     id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
1646
-						$doc = Database::query($sql);
1647
-						$doc = Database::fetch_object($doc);
1648
-						$doc = str_replace('/audio/', '', $doc->path);
1649
-					}
1650
-				}
1651
-
1652
-				if ($id != -1) {
1653
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1646
+                        $doc = Database::query($sql);
1647
+                        $doc = Database::fetch_object($doc);
1648
+                        $doc = str_replace('/audio/', '', $doc->path);
1649
+                    }
1650
+                }
1651
+
1652
+                if ($id != -1) {
1653
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1654 1654
                     $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1655 1655
                         $quiz->description,
1656 1656
                         $this->course->code,
@@ -1659,13 +1659,13 @@  discard block
 block discarded – undo
1659 1659
                         $this->course->info['path']
1660 1660
                     );
1661 1661
 
1662
-					global $_custom;
1663
-					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1662
+                    global $_custom;
1663
+                    if (isset($_custom['exercises_clean_dates_when_restoring']) &&
1664 1664
                         $_custom['exercises_clean_dates_when_restoring']
1665 1665
                     ) {
1666
-						$quiz->start_time = null;
1667
-						$quiz->end_time   = null;
1668
-					}
1666
+                        $quiz->start_time = null;
1667
+                        $quiz->end_time   = null;
1668
+                    }
1669 1669
 
1670 1670
                     $params = array(
1671 1671
                         'c_id' => $this->destination_course_id,
@@ -1697,10 +1697,10 @@  discard block
 block discarded – undo
1697 1697
                         }
1698 1698
                         $params['session_id'] = $my_session_id;
1699 1699
                     } else {
1700
-        				if (!empty($session_id)) {
1701
-        					$session_id = intval($session_id);
1700
+                        if (!empty($session_id)) {
1701
+                            $session_id = intval($session_id);
1702 1702
                             $params['session_id'] = $session_id;
1703
-    				    }
1703
+                        }
1704 1704
                     }
1705 1705
                     $new_id = Database::insert($table_qui, $params);
1706 1706
 
@@ -1709,15 +1709,15 @@  discard block
 block discarded – undo
1709 1709
                         Database::query($sql);
1710 1710
                     }
1711 1711
 
1712
-				} else {
1713
-					// $id = -1 identifies the fictionary test for collecting
1714
-					// orphan questions. We do not store it in the database.
1715
-					$new_id = -1;
1716
-				}
1712
+                } else {
1713
+                    // $id = -1 identifies the fictionary test for collecting
1714
+                    // orphan questions. We do not store it in the database.
1715
+                    $new_id = -1;
1716
+                }
1717 1717
 
1718
-				$this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1718
+                $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id;
1719 1719
 
1720
-				$order = 0;
1720
+                $order = 0;
1721 1721
                 if (!empty($quiz->question_ids)) {
1722 1722
                     foreach ($quiz->question_ids as $index => $question_id) {
1723 1723
                         $qid = $this->restore_quiz_question($question_id);
@@ -1730,30 +1730,30 @@  discard block
 block discarded – undo
1730 1730
                         Database::query($sql);
1731 1731
                     }
1732 1732
                 }
1733
-			}
1734
-		}
1735
-	}
1733
+            }
1734
+        }
1735
+    }
1736 1736
 
1737
-	/**
1738
-	 * Restore quiz-questions
1737
+    /**
1738
+     * Restore quiz-questions
1739 1739
      * @params int question id
1740
-	 */
1740
+     */
1741 1741
     public function restore_quiz_question($id)
1742 1742
     {
1743
-		$resources = $this->course->resources;
1743
+        $resources = $this->course->resources;
1744 1744
         $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null;
1745 1745
 
1746
-		$new_id = 0;
1746
+        $new_id = 0;
1747 1747
 
1748
-		if (is_object($question)) {
1749
-			if ($question->is_restored()) {
1750
-				return $question->destination_id;
1751
-			}
1752
-			$table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1753
-			$table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1748
+        if (is_object($question)) {
1749
+            if ($question->is_restored()) {
1750
+                return $question->destination_id;
1751
+            }
1752
+            $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
1753
+            $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
1754 1754
             $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
1755 1755
 
1756
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
1756
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
1757 1757
             $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1758 1758
                 $question->description,
1759 1759
                 $this->course->code,
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
                 'extra' => self::DBUTF8($question->extra),
1775 1775
             ];
1776 1776
 
1777
-			$new_id = Database::insert($table_que, $params);
1777
+            $new_id = Database::insert($table_que, $params);
1778 1778
 
1779 1779
             if ($new_id) {
1780 1780
 
@@ -1815,7 +1815,7 @@  discard block
 block discarded – undo
1815 1815
 
1816 1816
                 foreach ($temp as $index => $answer) {
1817 1817
                     //id = '".$index."',
1818
-					$params = [
1818
+                    $params = [
1819 1819
                         'c_id' => $this->destination_course_id,
1820 1820
                         'question_id' => $new_id,
1821 1821
                         'answer' => self::DBUTF8($answer['answer']),
@@ -1832,12 +1832,12 @@  discard block
 block discarded – undo
1832 1832
                         $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId";
1833 1833
                         Database::query($sql);
1834 1834
                     }
1835
-				}
1836
-			} else {
1835
+                }
1836
+            } else {
1837 1837
                 $correct_answers = array();
1838
-				foreach ($question->answers as $index => $answer) {
1838
+                foreach ($question->answers as $index => $answer) {
1839 1839
 
1840
-					// check resources inside html from ckeditor tool and copy correct urls into recipient course
1840
+                    // check resources inside html from ckeditor tool and copy correct urls into recipient course
1841 1841
                     $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
1842 1842
                         $answer['answer'],
1843 1843
                         $this->course->code,
@@ -1876,8 +1876,8 @@  discard block
 block discarded – undo
1876 1876
                     }
1877 1877
 
1878 1878
                     $correct_answers[$answerId] = $answer['correct'];
1879
-				}
1880
-			}
1879
+                }
1880
+            }
1881 1881
 
1882 1882
             //Current course id
1883 1883
             $course_id = api_get_course_int_id();
@@ -1974,12 +1974,12 @@  discard block
 block discarded – undo
1974 1974
                     }
1975 1975
                 }
1976 1976
             }
1977
-			$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
1978
-		}
1979
-		return $new_id;
1980
-	}
1977
+            $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
1978
+        }
1979
+        return $new_id;
1980
+    }
1981 1981
 
1982
-	/**
1982
+    /**
1983 1983
      * @todo : add session id when used for session
1984 1984
      */
1985 1985
     public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
@@ -2059,21 +2059,21 @@  discard block
 block discarded – undo
2059 2059
         $sessionId = intval($sessionId);
2060 2060
 
2061 2061
         if ($this->course->has_resources(RESOURCE_SURVEY)) {
2062
-			$table_sur = Database :: get_course_table(TABLE_SURVEY);
2063
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2064
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2065
-			$resources = $this->course->resources;
2066
-			foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2062
+            $table_sur = Database :: get_course_table(TABLE_SURVEY);
2063
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2064
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2065
+            $resources = $this->course->resources;
2066
+            foreach ($resources[RESOURCE_SURVEY] as $id => $survey) {
2067 2067
 
2068
-				$sql = 'SELECT survey_id FROM '.$table_sur.'
2068
+                $sql = 'SELECT survey_id FROM '.$table_sur.'
2069 2069
                         WHERE
2070 2070
                             c_id = '.$this->destination_course_id.' AND
2071 2071
                             code = "'.self::DBUTF8escapestring($survey->code).'" AND
2072 2072
                             lang = "'.self::DBUTF8escapestring($survey->lang).'" ';
2073 2073
 
2074
-				$result_check = Database::query($sql);
2074
+                $result_check = Database::query($sql);
2075 2075
 
2076
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2076
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2077 2077
                 $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2078 2078
                     $survey->title,
2079 2079
                     $this->course->code,
@@ -2127,20 +2127,20 @@  discard block
 block discarded – undo
2127 2127
                     'session_id' => $sessionId,
2128 2128
                 ];
2129 2129
 
2130
-				//An existing survey exists with the same code and the same language
2131
-				if (Database::num_rows($result_check) == 1) {
2132
-					switch ($this->file_option) {
2133
-						case FILE_SKIP:
2134
-							//Do nothing
2135
-							break;
2136
-						case FILE_RENAME:
2137
-							$survey_code = $survey->code.'_';
2138
-							$i=1;
2139
-							$temp_survey_code = $survey_code.$i;
2140
-							while (!$this->is_survey_code_available($temp_survey_code)) {
2141
-								$temp_survey_code = $survey_code.++$i;
2142
-							}
2143
-							$survey_code = $temp_survey_code;
2130
+                //An existing survey exists with the same code and the same language
2131
+                if (Database::num_rows($result_check) == 1) {
2132
+                    switch ($this->file_option) {
2133
+                        case FILE_SKIP:
2134
+                            //Do nothing
2135
+                            break;
2136
+                        case FILE_RENAME:
2137
+                            $survey_code = $survey->code.'_';
2138
+                            $i=1;
2139
+                            $temp_survey_code = $survey_code.$i;
2140
+                            while (!$this->is_survey_code_available($temp_survey_code)) {
2141
+                                $temp_survey_code = $survey_code.++$i;
2142
+                            }
2143
+                            $survey_code = $temp_survey_code;
2144 2144
 
2145 2145
                             $params['code'] = $survey_code;
2146 2146
                             $new_id = Database::insert($table_sur, $params);
@@ -2159,25 +2159,25 @@  discard block
 block discarded – undo
2159 2159
                                     Database::query($sql);
2160 2160
                                 }
2161 2161
                             }
2162
-							break;
2163
-						case FILE_OVERWRITE:
2164
-							// Delete the existing survey with the same code and language and import the one of the source course
2165
-							// getting the information of the survey (used for when the survey is shared)
2162
+                            break;
2163
+                        case FILE_OVERWRITE:
2164
+                            // Delete the existing survey with the same code and language and import the one of the source course
2165
+                            // getting the information of the survey (used for when the survey is shared)
2166 2166
 
2167
-							$sql = "SELECT * FROM $table_sur
2167
+                            $sql = "SELECT * FROM $table_sur
2168 2168
 							        WHERE
2169 2169
 							            c_id = ".$this->destination_course_id." AND
2170 2170
 							            survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'";
2171
-							$result = Database::query($sql);
2172
-							$survey_data = Database::fetch_array($result,'ASSOC');
2171
+                            $result = Database::query($sql);
2172
+                            $survey_data = Database::fetch_array($result,'ASSOC');
2173 2173
 
2174
-							// if the survey is shared => also delete the shared content
2175
-							if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2174
+                            // if the survey is shared => also delete the shared content
2175
+                            if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) {
2176 2176
                                 SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id);
2177
-							}
2178
-							SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2177
+                            }
2178
+                            SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id);
2179 2179
 
2180
-							// Insert the new source survey
2180
+                            // Insert the new source survey
2181 2181
                             $new_id = Database::insert($table_sur, $params);
2182 2182
 
2183 2183
                             if ($new_id) {
@@ -2198,11 +2198,11 @@  discard block
 block discarded – undo
2198 2198
                                     Database::query($sql);
2199 2199
                                 }
2200 2200
                             }
2201
-							break;
2202
-						default:
2203
-							break;
2204
-					}
2205
-				} else {
2201
+                            break;
2202
+                        default:
2203
+                            break;
2204
+                    }
2205
+                } else {
2206 2206
                     // No existing survey with the same language and the same code, we just copy the survey
2207 2207
                     $new_id = Database::insert($table_sur, $params);
2208 2208
 
@@ -2224,43 +2224,43 @@  discard block
 block discarded – undo
2224 2224
                             Database::query($sql);
2225 2225
                         }
2226 2226
                     }
2227
-				}
2228
-			}
2229
-		}
2230
-	}
2231
-
2232
-	/**
2233
-	 * Check availability of a survey code
2234
-	 */
2227
+                }
2228
+            }
2229
+        }
2230
+    }
2231
+
2232
+    /**
2233
+     * Check availability of a survey code
2234
+     */
2235 2235
     public function is_survey_code_available($survey_code)
2236 2236
     {
2237
-		$table_sur = Database :: get_course_table(TABLE_SURVEY);
2238
-		$sql = "SELECT * FROM $table_sur
2237
+        $table_sur = Database :: get_course_table(TABLE_SURVEY);
2238
+        $sql = "SELECT * FROM $table_sur
2239 2239
 		        WHERE
2240 2240
 		            c_id = ".$this->destination_course_id." AND
2241 2241
 		            code='".self::DBUTF8escapestring($survey_code)."'";
2242
-		$result = Database::query($sql);
2243
-		if (Database::num_rows($result) > 0) return false; else return true;
2244
-	}
2242
+        $result = Database::query($sql);
2243
+        if (Database::num_rows($result) > 0) return false; else return true;
2244
+    }
2245 2245
 
2246
-	/**
2247
-	 * Restore survey-questions
2248
-	 */
2246
+    /**
2247
+     * Restore survey-questions
2248
+     */
2249 2249
     public function restore_survey_question($id, $survey_id)
2250 2250
     {
2251
-		$resources = $this->course->resources;
2252
-		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
2251
+        $resources = $this->course->resources;
2252
+        $question = $resources[RESOURCE_SURVEYQUESTION][$id];
2253 2253
 
2254
-		$new_id=0;
2254
+        $new_id=0;
2255 2255
 
2256
-		if (is_object($question)) {
2257
-			if ($question->is_restored()) {
2258
-				return $question->destination_id;
2259
-			}
2260
-			$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2261
-			$table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2256
+        if (is_object($question)) {
2257
+            if ($question->is_restored()) {
2258
+                return $question->destination_id;
2259
+            }
2260
+            $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2261
+            $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2262 2262
 
2263
-			// check resources inside html from ckeditor tool and copy correct urls into recipient course
2263
+            // check resources inside html from ckeditor tool and copy correct urls into recipient course
2264 2264
             $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2265 2265
                 $question->survey_question,
2266 2266
                 $this->course->code,
@@ -2314,10 +2314,10 @@  discard block
 block discarded – undo
2314 2314
                 }
2315 2315
                 $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id;
2316 2316
             }
2317
-		}
2317
+        }
2318 2318
 
2319
-		return $new_id;
2320
-	}
2319
+        return $new_id;
2320
+    }
2321 2321
 
2322 2322
     /**
2323 2323
      * Restoring learning paths
@@ -2328,20 +2328,20 @@  discard block
 block discarded – undo
2328 2328
     {
2329 2329
         $session_id = intval($session_id);
2330 2330
 
2331
-		if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2331
+        if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
2332 2332
             $table_main = Database::get_course_table(TABLE_LP_MAIN);
2333 2333
             $table_item = Database::get_course_table(TABLE_LP_ITEM);
2334 2334
             $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
2335 2335
 
2336
-			$resources = $this->course->resources;
2336
+            $resources = $this->course->resources;
2337 2337
 
2338
-			$origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2339
-			$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2338
+            $origin_path = $this->course->backup_path.'/upload/learning_path/images/';
2339
+            $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/';
2340 2340
 
2341
-			foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2341
+            foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
2342 2342
 
2343
-				$condition_session = "";
2344
-				if (!empty($session_id)) {
2343
+                $condition_session = "";
2344
+                if (!empty($session_id)) {
2345 2345
                     if ($respect_base_content) {
2346 2346
                         $my_session_id = $lp->session_id;
2347 2347
                         if (!empty($lp->session_id)) {
@@ -2352,21 +2352,21 @@  discard block
 block discarded – undo
2352 2352
                         $session_id = intval($session_id);
2353 2353
                         $condition_session = $session_id;
2354 2354
                     }
2355
-				}
2356
-
2357
-				// Adding the author's image
2358
-				if (!empty($lp->preview_image)) {
2359
-					$new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2360
-					if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2361
-						$copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2362
-						//$copy_result = true;
2363
-						if ($copy_result) {
2364
-							$lp->preview_image = $new_filename;
2365
-						} else {
2366
-							$lp->preview_image ='';
2367
-						}
2368
-					}
2369
-				}
2355
+                }
2356
+
2357
+                // Adding the author's image
2358
+                if (!empty($lp->preview_image)) {
2359
+                    $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image));
2360
+                    if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) {
2361
+                        $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename);
2362
+                        //$copy_result = true;
2363
+                        if ($copy_result) {
2364
+                            $lp->preview_image = $new_filename;
2365
+                        } else {
2366
+                            $lp->preview_image ='';
2367
+                        }
2368
+                    }
2369
+                }
2370 2370
 
2371 2371
                 if ($this->add_text_in_items) {
2372 2372
                     $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix');
@@ -2413,7 +2413,7 @@  discard block
 block discarded – undo
2413 2413
                     $params['session_id'] = $condition_session;
2414 2414
                 }
2415 2415
 
2416
-				$new_lp_id = Database::insert($table_main, $params);
2416
+                $new_lp_id = Database::insert($table_main, $params);
2417 2417
 
2418 2418
                 if ($new_lp_id) {
2419 2419
 
@@ -2474,13 +2474,13 @@  discard block
 block discarded – undo
2474 2474
                 $old_refs = array();
2475 2475
                 $prerequisite_ids = array();
2476 2476
 
2477
-				foreach ($lp->get_items() as $index => $item) {
2478
-					// we set the ref code here and then we update in a for loop
2479
-					$ref = $item['ref'];
2477
+                foreach ($lp->get_items() as $index => $item) {
2478
+                    // we set the ref code here and then we update in a for loop
2479
+                    $ref = $item['ref'];
2480 2480
 
2481
-					// Dealing with path the same way as ref as some data has
2481
+                    // Dealing with path the same way as ref as some data has
2482 2482
                     // been put into path when it's a local resource
2483
-					// Only fix the path for no scos
2483
+                    // Only fix the path for no scos
2484 2484
                     if ($item['item_type'] == 'sco') {
2485 2485
                         $path = $item['path'];
2486 2486
                     } else {
@@ -2509,128 +2509,128 @@  discard block
 block discarded – undo
2509 2509
                         'launch_data' => self::DBUTF8($item['launch_data']),
2510 2510
                     ];
2511 2511
 
2512
-					$new_item_id = Database::insert($table_item, $params);
2512
+                    $new_item_id = Database::insert($table_item, $params);
2513 2513
 
2514 2514
                     $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id";
2515 2515
                     Database::query($sql);
2516 2516
 
2517
-					//save a link between old and new item IDs
2518
-					$new_item_ids[$item['id']] = $new_item_id;
2519
-					//save a reference of items that need a parent_item_id refresh
2520
-					$parent_item_ids[$new_item_id] = $item['parent_item_id'];
2521
-					//save a reference of items that need a previous_item_id refresh
2522
-					$previous_item_ids[$new_item_id] = $item['previous_item_id'];
2523
-					//save a reference of items that need a next_item_id refresh
2524
-					$next_item_ids[$new_item_id] = $item['next_item_id'];
2525
-
2526
-					if (!empty($item['prerequisite'])) {
2527
-						if ($lp->lp_type =='2') {
2528
-							// if is an sco
2529
-							$old_prerequisite[$new_item_id]= $item['prerequisite'];
2530
-						} else {
2531
-							$old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2532
-						}
2533
-					}
2534
-
2535
-					if (!empty($ref)) {
2536
-						if ($lp->lp_type =='2') {
2537
-							// if is an sco
2538
-							$old_refs[$new_item_id]= $ref;
2539
-						} else {
2517
+                    //save a link between old and new item IDs
2518
+                    $new_item_ids[$item['id']] = $new_item_id;
2519
+                    //save a reference of items that need a parent_item_id refresh
2520
+                    $parent_item_ids[$new_item_id] = $item['parent_item_id'];
2521
+                    //save a reference of items that need a previous_item_id refresh
2522
+                    $previous_item_ids[$new_item_id] = $item['previous_item_id'];
2523
+                    //save a reference of items that need a next_item_id refresh
2524
+                    $next_item_ids[$new_item_id] = $item['next_item_id'];
2525
+
2526
+                    if (!empty($item['prerequisite'])) {
2527
+                        if ($lp->lp_type =='2') {
2528
+                            // if is an sco
2529
+                            $old_prerequisite[$new_item_id]= $item['prerequisite'];
2530
+                        } else {
2531
+                            $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']];
2532
+                        }
2533
+                    }
2534
+
2535
+                    if (!empty($ref)) {
2536
+                        if ($lp->lp_type =='2') {
2537
+                            // if is an sco
2538
+                            $old_refs[$new_item_id]= $ref;
2539
+                        } else {
2540 2540
                             $old_refs[$new_item_id]= $new_item_ids[$ref];
2541
-						}
2542
-					}
2541
+                        }
2542
+                    }
2543 2543
 
2544
-					$prerequisite_ids[$new_item_id] = $item['prerequisite'];
2545
-				}
2544
+                    $prerequisite_ids[$new_item_id] = $item['prerequisite'];
2545
+                }
2546 2546
 
2547
-				// Updating prerequisites
2548
-				foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2549
-					if($my_old_prerequisite != ''){
2550
-						$sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2547
+                // Updating prerequisites
2548
+                foreach ($old_prerequisite  as $key=>$my_old_prerequisite) {
2549
+                    if($my_old_prerequisite != ''){
2550
+                        $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."'
2551 2551
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2552
-						Database::query($sql);
2553
-					}
2554
-				}
2555
-
2556
-				// Updating refs
2557
-				foreach ($old_refs  as $key=>$my_old_ref) {
2558
-					if ($my_old_ref != '') {
2559
-						$sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2552
+                        Database::query($sql);
2553
+                    }
2554
+                }
2555
+
2556
+                // Updating refs
2557
+                foreach ($old_refs  as $key=>$my_old_ref) {
2558
+                    if ($my_old_ref != '') {
2559
+                        $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."'
2560 2560
 						        WHERE c_id = ".$this->destination_course_id." AND id = '".$key."'  ";
2561
-						Database::query($sql);
2562
-					}
2563
-				}
2564
-
2565
-				foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2566
-					$parent_new_id = 0;
2567
-					if($parent_item_old_id != 0){
2568
-						$parent_new_id = $new_item_ids[$parent_item_old_id];
2569
-					}
2570
-					$sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2561
+                        Database::query($sql);
2562
+                    }
2563
+                }
2564
+
2565
+                foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) {
2566
+                    $parent_new_id = 0;
2567
+                    if($parent_item_old_id != 0){
2568
+                        $parent_new_id = $new_item_ids[$parent_item_old_id];
2569
+                    }
2570
+                    $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."'
2571 2571
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2572
-					Database::query($sql);
2573
-				}
2574
-				foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2575
-					$previous_new_id = 0;
2576
-					if($previous_item_old_id != 0){
2577
-						$previous_new_id = $new_item_ids[$previous_item_old_id];
2578
-					}
2579
-					$sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2572
+                    Database::query($sql);
2573
+                }
2574
+                foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) {
2575
+                    $previous_new_id = 0;
2576
+                    if($previous_item_old_id != 0){
2577
+                        $previous_new_id = $new_item_ids[$previous_item_old_id];
2578
+                    }
2579
+                    $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."'
2580 2580
 					        WHERE  c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2581
-					Database::query($sql);
2582
-				}
2583
-
2584
-				foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2585
-					$next_new_id = 0;
2586
-					if($next_item_old_id != 0){
2587
-						$next_new_id = $new_item_ids[$next_item_old_id];
2588
-					}
2589
-					$sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2581
+                    Database::query($sql);
2582
+                }
2583
+
2584
+                foreach ($next_item_ids as $new_item_id => $next_item_old_id) {
2585
+                    $next_new_id = 0;
2586
+                    if($next_item_old_id != 0){
2587
+                        $next_new_id = $new_item_ids[$next_item_old_id];
2588
+                    }
2589
+                    $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."'
2590 2590
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2591
-					Database::query($sql);
2592
-				}
2593
-
2594
-				foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2595
-					$prerequisite_new_id = 0;
2596
-					if($prerequisite_old_id != 0){
2597
-						$prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2598
-					}
2599
-					$sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2591
+                    Database::query($sql);
2592
+                }
2593
+
2594
+                foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) {
2595
+                    $prerequisite_new_id = 0;
2596
+                    if($prerequisite_old_id != 0){
2597
+                        $prerequisite_new_id = $new_item_ids[$prerequisite_old_id];
2598
+                    }
2599
+                    $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."'
2600 2600
 					        WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'";
2601
-					Database::query($sql);
2602
-				}
2603
-				$this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2604
-			}
2605
-		}
2606
-	}
2607
-
2608
-	/**
2609
-	 * Restore works
2601
+                    Database::query($sql);
2602
+                }
2603
+                $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id;
2604
+            }
2605
+        }
2606
+    }
2607
+
2608
+    /**
2609
+     * Restore works
2610 2610
      * @deprecated use restore_works
2611 2611
      *
2612
-	 */
2613
-	public function restore_student_publication($sessionId = 0)
2612
+     */
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);
2617
-		$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
2618
-		$item_property_table  	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
2616
+        $work_assignment_table  = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
2617
+        $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
2618
+        $item_property_table  	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
2619 2619
 
2620
-		// Query in student publication
2621
-		$sql = 'SELECT * FROM '.$work_table.'
2620
+        // Query in student publication
2621
+        $sql = 'SELECT * FROM '.$work_table.'
2622 2622
 		        WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) ';
2623 2623
 
2624
-		$result = Database::query($sql);
2625
-		$folders = Database::store_result($result, 'ASSOC');
2624
+        $result = Database::query($sql);
2625
+        $folders = Database::store_result($result, 'ASSOC');
2626 2626
 
2627
-		foreach ($folders  as $folder) {
2628
-		    $old_id = $folder['id'];
2627
+        foreach ($folders  as $folder) {
2628
+            $old_id = $folder['id'];
2629 2629
             unset($folder['id']);
2630
-			$folder['c_id'] = $this->destination_course_id;
2630
+            $folder['c_id'] = $this->destination_course_id;
2631 2631
             $folder['parent_id'] = 0;
2632 2632
             $folder['session_id'] = $sessionId;
2633
-			$new_id = Database::insert($work_table, $folder);
2633
+            $new_id = Database::insert($work_table, $folder);
2634 2634
 
2635 2635
             if ($new_id) {
2636 2636
                 //query in item property
@@ -2689,21 +2689,21 @@  discard block
 block discarded – undo
2689 2689
                     }
2690 2690
                 }
2691 2691
             }
2692
-		}
2692
+        }
2693 2693
 
2694
-		$destination = '../../courses/'.$this->course->destination_path.'/work/';
2695
-		$origin = '../../courses/'.$this->course->info['path'].'/work/';
2696
-		self::allow_create_all_directory($origin,$destination,false);
2697
-	}
2694
+        $destination = '../../courses/'.$this->course->destination_path.'/work/';
2695
+        $origin = '../../courses/'.$this->course->info['path'].'/work/';
2696
+        self::allow_create_all_directory($origin,$destination,false);
2697
+    }
2698 2698
 
2699 2699
     /**
2700
-    * copy all directory and sub directory
2701
-    * @param string The path origin
2702
-    * @param string The path destination
2703
-    * @param boolean Option Overwrite
2704
-    * @return void()
2705
-    * @deprecated
2706
-    */
2700
+     * copy all directory and sub directory
2701
+     * @param string The path origin
2702
+     * @param string The path destination
2703
+     * @param boolean Option Overwrite
2704
+     * @return void()
2705
+     * @deprecated
2706
+     */
2707 2707
     public function allow_create_all_directory($source, $dest, $overwrite = false)
2708 2708
     {
2709 2709
         if (!is_dir($dest)) {
@@ -2714,14 +2714,14 @@  discard block
 block discarded – undo
2714 2714
                 if ($file != '.' && $file != '..') {
2715 2715
                     $path = $source . '/' . $file;
2716 2716
                     if (is_file($path)) {
2717
-                       /* if (!is_file($dest . '/' . $file) || $overwrite)
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 2721
                     } elseif(is_dir($path)) {
2722 2722
                         if (!is_dir($dest . '/' . $file))
2723 2723
                         mkdir($dest . '/' . $file);
2724
-                       self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2724
+                        self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2725 2725
                     }
2726 2726
                 }
2727 2727
             }
@@ -2729,12 +2729,12 @@  discard block
 block discarded – undo
2729 2729
         }
2730 2730
     }
2731 2731
 
2732
-	/**
2733
-	 * Gets the new ID of one specific tool item from the tool name and the old ID
2734
-	 * @param	string	Tool name
2735
-	 * @param	integer	Old ID
2736
-	 * @return	integer	New ID
2737
-	 */
2732
+    /**
2733
+     * Gets the new ID of one specific tool item from the tool name and the old ID
2734
+     * @param	string	Tool name
2735
+     * @param	integer	Old ID
2736
+     * @return	integer	New ID
2737
+     */
2738 2738
     public function get_new_id($tool, $ref)
2739 2739
     {
2740 2740
         // Check if the value exist in the current array.
@@ -2756,25 +2756,25 @@  discard block
 block discarded – undo
2756 2756
         }
2757 2757
 
2758 2758
         return '';
2759
-	}
2759
+    }
2760 2760
 
2761
-	/**
2762
-	 * Restore glossary
2763
-	 */
2761
+    /**
2762
+     * Restore glossary
2763
+     */
2764 2764
     public function restore_glossary($session_id = 0)
2765 2765
     {
2766
-		if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2767
-			$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2768
-			$resources = $this->course->resources;
2769
-			foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2766
+        if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
2767
+            $table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
2768
+            $resources = $this->course->resources;
2769
+            foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
2770 2770
 
2771 2771
                 $params = [];
2772
-    			if (!empty($session_id)) {
2773
-    				$session_id = intval($session_id);
2772
+                if (!empty($session_id)) {
2773
+                    $session_id = intval($session_id);
2774 2774
                     $params['session_id'] = $session_id;
2775
-    			}
2775
+                }
2776 2776
 
2777
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2777
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2778 2778
                 $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2779 2779
                     $glossary->description,
2780 2780
                     $this->course->code,
@@ -2808,27 +2808,27 @@  discard block
 block discarded – undo
2808 2808
 
2809 2809
                     $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id;
2810 2810
                 }
2811
-			}
2812
-		}
2813
-	}
2811
+            }
2812
+        }
2813
+    }
2814 2814
 
2815 2815
     /**
2816 2816
      * @param int $session_id
2817 2817
      */
2818 2818
     public function restore_wiki($session_id = 0)
2819 2819
     {
2820
-		if ($this->course->has_resources(RESOURCE_WIKI)) {
2821
-			// wiki table of the target course
2822
-			$table_wiki = Database :: get_course_table(TABLE_WIKI);
2823
-			$table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2820
+        if ($this->course->has_resources(RESOURCE_WIKI)) {
2821
+            // wiki table of the target course
2822
+            $table_wiki = Database :: get_course_table(TABLE_WIKI);
2823
+            $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF);
2824 2824
 
2825
-			// storing all the resources that have to be copied in an array
2826
-			$resources = $this->course->resources;
2825
+            // storing all the resources that have to be copied in an array
2826
+            $resources = $this->course->resources;
2827 2827
 
2828
-			foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2829
-				// the sql statement to insert the groups from the old course to the new course
2828
+            foreach ($resources[RESOURCE_WIKI] as $id => $wiki) {
2829
+                // the sql statement to insert the groups from the old course to the new course
2830 2830
 
2831
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2831
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2832 2832
                 $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2833 2833
                     $wiki->content,
2834 2834
                     $this->course->code,
@@ -2851,7 +2851,7 @@  discard block
 block discarded – undo
2851 2851
                     'session_id' => !empty($session_id) ? intval($session_id) : 0,
2852 2852
                 ];
2853 2853
 
2854
-				$new_id = Database::insert($table_wiki, $params);
2854
+                $new_id = Database::insert($table_wiki, $params);
2855 2855
 
2856 2856
                 if ($new_id) {
2857 2857
 
@@ -2882,9 +2882,9 @@  discard block
 block discarded – undo
2882 2882
 
2883 2883
                     Database::insert($table_wiki_conf, $params);
2884 2884
                 }
2885
-			}
2886
-		}
2887
-	}
2885
+            }
2886
+        }
2887
+    }
2888 2888
 
2889 2889
     /**
2890 2890
      * Restore Thematics
@@ -2892,15 +2892,15 @@  discard block
 block discarded – undo
2892 2892
      */
2893 2893
     public function restore_thematic($session_id = 0)
2894 2894
     {
2895
-		if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2895
+        if ($this->course->has_resources(RESOURCE_THEMATIC)) {
2896 2896
             $table_thematic = Database:: get_course_table(TABLE_THEMATIC);
2897 2897
             $table_thematic_advance = Database:: get_course_table(TABLE_THEMATIC_ADVANCE);
2898 2898
             $table_thematic_plan = Database:: get_course_table(TABLE_THEMATIC_PLAN);
2899 2899
 
2900
-			$resources = $this->course->resources;
2901
-			foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2900
+            $resources = $this->course->resources;
2901
+            foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) {
2902 2902
 
2903
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2903
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2904 2904
                 $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2905 2905
                     $thematic->params['content'],
2906 2906
                     $this->course->code,
@@ -2908,13 +2908,13 @@  discard block
 block discarded – undo
2908 2908
                     $this->course->backup_path,
2909 2909
                     $this->course->info['path']
2910 2910
                 );
2911
-				$thematic->params['c_id']  = $this->destination_course_id;
2912
-				unset($thematic->params['id']);
2911
+                $thematic->params['c_id']  = $this->destination_course_id;
2912
+                unset($thematic->params['id']);
2913 2913
                 unset($thematic->params['iid']);
2914 2914
 
2915
-				$last_id = Database::insert($table_thematic, $thematic->params, false);
2915
+                $last_id = Database::insert($table_thematic, $thematic->params, false);
2916 2916
 
2917
-				if ($last_id) {
2917
+                if ($last_id) {
2918 2918
 
2919 2919
                     $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id";
2920 2920
                     Database::query($sql);
@@ -2927,19 +2927,19 @@  discard block
 block discarded – undo
2927 2927
                         api_get_user_id()
2928 2928
                     );
2929 2929
 
2930
-					foreach ($thematic->thematic_advance_list as $thematic_advance) {
2931
-						unset($thematic_advance['id']);
2930
+                    foreach ($thematic->thematic_advance_list as $thematic_advance) {
2931
+                        unset($thematic_advance['id']);
2932 2932
                         unset($thematic_advance['iid']);
2933
-						$thematic_advance['attendance_id'] = 0;
2934
-						$thematic_advance['thematic_id'] = $last_id;
2935
-						$thematic_advance['c_id']  = $this->destination_course_id;
2933
+                        $thematic_advance['attendance_id'] = 0;
2934
+                        $thematic_advance['thematic_id'] = $last_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,
2939 2939
                             false
2940 2940
                         );
2941 2941
 
2942
-						if ($my_id) {
2942
+                        if ($my_id) {
2943 2943
 
2944 2944
                             $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id";
2945 2945
                             Database::query($sql);
@@ -2951,17 +2951,17 @@  discard block
 block discarded – undo
2951 2951
                                 "ThematicAdvanceAdded",
2952 2952
                                 api_get_user_id()
2953 2953
                             );
2954
-						}
2955
-					}
2954
+                        }
2955
+                    }
2956 2956
 
2957
-					foreach($thematic->thematic_plan_list as $thematic_plan) {
2958
-						unset($thematic_plan['id']);
2957
+                    foreach($thematic->thematic_plan_list as $thematic_plan) {
2958
+                        unset($thematic_plan['id']);
2959 2959
                         unset($thematic_plan['iid']);
2960
-						$thematic_plan['thematic_id'] = $last_id;
2961
-						$thematic_plan['c_id'] = $this->destination_course_id;
2962
-						$my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
2960
+                        $thematic_plan['thematic_id'] = $last_id;
2961
+                        $thematic_plan['c_id'] = $this->destination_course_id;
2962
+                        $my_id = Database::insert($table_thematic_plan, $thematic_plan, false);
2963 2963
 
2964
-						if ($my_id) {
2964
+                        if ($my_id) {
2965 2965
 
2966 2966
                             $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id";
2967 2967
                             Database::query($sql);
@@ -2973,12 +2973,12 @@  discard block
 block discarded – undo
2973 2973
                                 "ThematicPlanAdded",
2974 2974
                                 api_get_user_id()
2975 2975
                             );
2976
-						}
2977
-					}
2978
-				}
2979
-			}
2980
-		}
2981
-	}
2976
+                        }
2977
+                    }
2978
+                }
2979
+            }
2980
+        }
2981
+    }
2982 2982
 
2983 2983
     /**
2984 2984
      * Restore Attendance
@@ -2986,14 +2986,14 @@  discard block
 block discarded – undo
2986 2986
      */
2987 2987
     public function restore_attendance($session_id = 0)
2988 2988
     {
2989
-		if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
2990
-			$table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
2991
-			$table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
2989
+        if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
2990
+            $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
2991
+            $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR);
2992 2992
 
2993
-			$resources = $this->course->resources;
2994
-			foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
2993
+            $resources = $this->course->resources;
2994
+            foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) {
2995 2995
 
2996
-				// check resources inside html from ckeditor tool and copy correct urls into recipient course
2996
+                // check resources inside html from ckeditor tool and copy correct urls into recipient course
2997 2997
                 $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
2998 2998
                     $obj->params['description'],
2999 2999
                     $this->course->code,
@@ -3005,11 +3005,11 @@  discard block
 block discarded – undo
3005 3005
                 unset($obj->params['id']);
3006 3006
                 unset($obj->params['iid']);
3007 3007
 
3008
-				$obj->params['c_id'] = $this->destination_course_id;
3008
+                $obj->params['c_id'] = $this->destination_course_id;
3009 3009
 
3010
-				$last_id = Database::insert($table_attendance, $obj->params);
3010
+                $last_id = Database::insert($table_attendance, $obj->params);
3011 3011
 
3012
-				if (is_numeric($last_id)) {
3012
+                if (is_numeric($last_id)) {
3013 3013
 
3014 3014
                     $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id";
3015 3015
                     Database::query($sql);
@@ -3023,11 +3023,11 @@  discard block
 block discarded – undo
3023 3023
                     );
3024 3024
 
3025 3025
                     foreach ($obj->attendance_calendar as $attendance_calendar) {
3026
-						unset($attendance_calendar['id']);
3026
+                        unset($attendance_calendar['id']);
3027 3027
                         unset($attendance_calendar['iid']);
3028 3028
 
3029
-						$attendance_calendar['attendance_id'] = $last_id;
3030
-						$attendance_calendar['c_id'] = $this->destination_course_id;
3029
+                        $attendance_calendar['attendance_id'] = $last_id;
3030
+                        $attendance_calendar['c_id'] = $this->destination_course_id;
3031 3031
                         $attendanceCalendarId = Database::insert(
3032 3032
                             $table_attendance_calendar,
3033 3033
                             $attendance_calendar
@@ -3035,11 +3035,11 @@  discard block
 block discarded – undo
3035 3035
 
3036 3036
                         $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId";
3037 3037
                         Database::query($sql);
3038
-					}
3039
-				}
3040
-			}
3041
-		}
3042
-	}
3038
+                    }
3039
+                }
3040
+            }
3041
+        }
3042
+    }
3043 3043
 
3044 3044
     /**
3045 3045
      * Restore Works
@@ -3181,11 +3181,11 @@  discard block
 block discarded – undo
3181 3181
      */
3182 3182
     public function DBUTF8($str)
3183 3183
     {
3184
-		if (UTF8_CONVERT) {
3184
+        if (UTF8_CONVERT) {
3185 3185
             $str = utf8_encode($str);
3186 3186
         }
3187
-		return $str;
3188
-	}
3187
+        return $str;
3188
+    }
3189 3189
 
3190 3190
     /**
3191 3191
      * @param string $str
@@ -3196,8 +3196,8 @@  discard block
 block discarded – undo
3196 3196
         if (UTF8_CONVERT) {
3197 3197
             $str = utf8_encode($str);
3198 3198
         }
3199
-		return Database::escape_string($str);
3200
-	}
3199
+        return Database::escape_string($str);
3200
+    }
3201 3201
 
3202 3202
     /**
3203 3203
      * @param array $array
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -512,7 +512,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 }
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseSelectForm.class.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'".');" />&nbsp;';
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'".');" />&nbsp;';
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -527,14 +527,15 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
main/coursecopy/classes/DummyCourseCreator.class.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -280,6 +280,7 @@
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Indentation   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -20,289 +20,289 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
main/coursecopy/classes/Event.class.php 2 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -50,9 +50,6 @@
 block discarded – undo
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,
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -66,19 +66,19 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
main/coursecopy/classes/QuizQuestion.class.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -115,6 +115,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
main/coursecopy/classes/Resource.class.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.