@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | class aicc extends learnpath |
13 | 13 | { |
14 | 14 | public $config = array(); |
15 | - public $config_basename = ''; // The configuration files might be multiple and might have |
|
15 | + public $config_basename = ''; // The configuration files might be multiple and might have |
|
16 | 16 | // funny names. We need to keep the name of that file while we |
17 | 17 | // install the content. |
18 | 18 | public $config_files = array(); |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | public $cstlist = array(); |
33 | 33 | public $orelist = array(); |
34 | 34 | |
35 | - public $subdir = ''; // Path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package. |
|
36 | - public $zipname = ''; // Keeps the zipfile safe for the object's life so that we can use it if there is no title available. |
|
37 | - public $lastzipnameindex = 0; // Keeps an index of the number of uses of the zipname so far. |
|
35 | + public $subdir = ''; // Path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package. |
|
36 | + public $zipname = ''; // Keeps the zipfile safe for the object's life so that we can use it if there is no title available. |
|
37 | + public $lastzipnameindex = 0; // Keeps an index of the number of uses of the zipname so far. |
|
38 | 38 | public $config_encoding = 'ISO-8859-1'; |
39 | 39 | public $debug = 0; |
40 | 40 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | //echo '<pre>des:'.print_r($des_params, true).'</pre>'; |
133 | 133 | if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$des_file.' has been parsed', 0); } |
134 | 134 | // Distribute des params into the aicc object. |
135 | - foreach ($des_params as $des){ |
|
135 | + foreach ($des_params as $des) { |
|
136 | 136 | // One AU in AICC is equivalent to one SCO in SCORM (scormItem class). |
137 | 137 | $oDes = new aiccResource('config', $des); |
138 | 138 | $this->deslist[$oDes->identifier] = $oDes; |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | |
243 | 243 | $this->config_encoding = "ISO-8859-1"; // TODO: We may apply detection for this value, see the function api_detect_encoding(). |
244 | 244 | |
245 | - $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)" . |
|
246 | - "VALUES " . |
|
247 | - "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."'," . |
|
248 | - "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."'," . |
|
245 | + $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)". |
|
246 | + "VALUES ". |
|
247 | + "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."',". |
|
248 | + "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."',". |
|
249 | 249 | "'aicc_api.php','".$this->course_creator."',$dsp)"; |
250 | - if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '. $sql, 0); } |
|
250 | + if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '.$sql, 0); } |
|
251 | 251 | Database::query($sql); |
252 | 252 | $lp_id = Database::insert_id(); |
253 | 253 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | $previous = 0; |
278 | 278 | foreach ($this->aulist as $identifier => $dummy) { |
279 | - $oAu =& $this->aulist[$identifier]; |
|
279 | + $oAu = & $this->aulist[$identifier]; |
|
280 | 280 | //echo "Item ".$oAu->identifier; |
281 | 281 | $field_add = ''; |
282 | 282 | $value_add = ''; |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | $parent = 0; // TODO: Deal with the parent. |
295 | 295 | $previous = 0; |
296 | 296 | $prereq = $oAu->prereq_string; |
297 | - $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) " . |
|
298 | - "VALUES " . |
|
299 | - "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."'," . |
|
300 | - "'$path',0,100, $value_add" . |
|
301 | - "$parent, $previous, 0, " . |
|
302 | - "'$prereq', 0,'".(!empty($oAu->parameters)?Database::escape_string($oAu->parameters):'')."'" . |
|
297 | + $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) ". |
|
298 | + "VALUES ". |
|
299 | + "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."',". |
|
300 | + "'$path',0,100, $value_add". |
|
301 | + "$parent, $previous, 0, ". |
|
302 | + "'$prereq', 0,'".(!empty($oAu->parameters) ? Database::escape_string($oAu->parameters) : '')."'". |
|
303 | 303 | ")"; |
304 | 304 | Database::query($sql_item); |
305 | 305 | if ($this->debug > 1) { error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0); } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $zip_file_name = $zip_file_info['name']; |
351 | 351 | |
352 | 352 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); } |
353 | - $course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses |
|
353 | + $course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses |
|
354 | 354 | $course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // The absolute system path of this course. |
355 | 355 | $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/ |
356 | 356 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name, 0); } |
368 | 368 | $new_dir = api_replace_dangerous_char(trim($file_base_name)); |
369 | 369 | $this->subdir = $new_dir; |
370 | - if($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); } |
|
370 | + if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); } |
|
371 | 371 | |
372 | 372 | /* |
373 | 373 | if (check_name_exist($course_sys_dir.$current_dir.'/'.$new_dir)) { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | $subdir_isset = true; |
414 | 414 | } else { |
415 | 415 | if (!$subdir_isset) { |
416 | - if (preg_match('?^.*/aicc$?i',dirname($thisContent['filename']))) { |
|
416 | + if (preg_match('?^.*/aicc$?i', dirname($thisContent['filename']))) { |
|
417 | 417 | //echo "Cutting subdir<br/>"; |
418 | 418 | $this->subdir .= '/'.substr(dirname($thisContent['filename']), 0, -5); |
419 | 419 | } else { |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible! |
517 | 517 | //$safe_file = api_replace_dangerous_char($file, 'strict'); |
518 | 518 | $find_str = array('\\', '.php', '.phtml'); |
519 | - $repl_str = array('/', '.txt', '.txt'); |
|
519 | + $repl_str = array('/', '.txt', '.txt'); |
|
520 | 520 | $safe_file = str_replace($find_str, $repl_str, $file); |
521 | 521 | |
522 | 522 | if ($safe_file != $file) { |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | if ($this->debug > 0) { error_log('In aicc::get_res_path('.$id.') method', 0); } |
718 | 718 | $path = ''; |
719 | 719 | if (isset($this->resources[$id])) { |
720 | - $oRes =& $this->resources[$id]; |
|
720 | + $oRes = & $this->resources[$id]; |
|
721 | 721 | $path = @$oRes->get_path(); |
722 | 722 | } |
723 | 723 | return $path; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | if ($this->debug > 0) { error_log('In aicc::get_res_type('.$id.') method', 0); } |
734 | 734 | $type = ''; |
735 | 735 | if (isset($this->resources[$id])) { |
736 | - $oRes =& $this->resources[$id]; |
|
736 | + $oRes = & $this->resources[$id]; |
|
737 | 737 | $temptype = $oRes->get_scorm_type(); |
738 | 738 | if (!empty($temptype)) { |
739 | 739 | $type = $temptype; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | * Gets the default organisation's title |
747 | 747 | * @return string The organization's title |
748 | 748 | */ |
749 | - function get_title(){ |
|
749 | + function get_title() { |
|
750 | 750 | if ($this->debug > 0) { error_log('In aicc::get_title() method', 0); } |
751 | 751 | $title = ''; |
752 | 752 | if (isset($this->config['organizations']['default'])) { |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | $chr = $data{$i}; |
908 | 908 | switch ($chr) { |
909 | 909 | case $enclosure: |
910 | - if ($enclosed && $data{$i+1} == $enclosure) { |
|
910 | + if ($enclosed && $data{$i + 1} == $enclosure) { |
|
911 | 911 | $fldval .= $chr; |
912 | 912 | ++$i; // Skip the next character. |
913 | 913 | } else |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | $fldval .= $chr; |
922 | 922 | break; |
923 | 923 | case "\r": |
924 | - if (!$enclosed&&$data{$i+1} == "\n") |
|
924 | + if (!$enclosed && $data{$i + 1} == "\n") |
|
925 | 925 | continue; |
926 | 926 | case "\n": |
927 | 927 | if (!$enclosed) { |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | $fldval .= $chr; |
933 | 933 | break; |
934 | 934 | case "\\r": |
935 | - if (!$enclosed&&$data{$i+1} == "\\n") |
|
935 | + if (!$enclosed && $data{$i + 1} == "\\n") |
|
936 | 936 | continue; |
937 | 937 | case "\\n": |
938 | 938 | if (!$enclosed) { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | // Set status to completed for hotpotatoes if score > 80%. |
164 | 164 | if ($my_type == 'hotpotatoes') { |
165 | 165 | if ((empty($status) || $status == 'undefined' || $status == 'not attempted') && $max > 0) { |
166 | - if (($score/$max) > 0.8) { |
|
166 | + if (($score / $max) > 0.8) { |
|
167 | 167 | $myStatus = 'completed'; |
168 | 168 | if ($debug > 1) { |
169 | 169 | error_log('Calling set_status('.$myStatus.') for hotpotatoes', 0); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | error_log('Done calling set_status for hotpotatoes - now '.$myLPI->get_status(false), 0); |
175 | 175 | } |
176 | 176 | } |
177 | - } elseif ($status == 'completed' && $max > 0 && ($score/$max) < 0.8) { |
|
177 | + } elseif ($status == 'completed' && $max > 0 && ($score / $max) < 0.8) { |
|
178 | 178 | $myStatus = 'failed'; |
179 | 179 | if ($debug > 1) { |
180 | 180 | error_log('Calling set_status('.$myStatus.') for hotpotatoes', 0); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $myLPI->current_data = $suspend; |
368 | 368 | } |
369 | 369 | |
370 | - if (isset($location) && $location != '' && $location!='undefined') { |
|
370 | + if (isset($location) && $location != '' && $location != 'undefined') { |
|
371 | 371 | $myLPI->set_lesson_location($location); |
372 | 372 | } |
373 | 373 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | if ((!$is_allowed_to_edit) || ($isStudentView)) { |
41 | 41 | error_log('New LP - User not authorized in lp_edit_item_prereq.php'); |
42 | - header('location:lp_controller.php?action=view&lp_id=' . $learnpath_id); |
|
42 | + header('location:lp_controller.php?action=view&lp_id='.$learnpath_id); |
|
43 | 43 | } |
44 | 44 | $course_id = api_get_course_int_id(); |
45 | 45 | |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | |
56 | 56 | if (!empty($gradebook) && $gradebook == 'view') { |
57 | 57 | $interbreadcrumb[] = array( |
58 | - 'url' => '../gradebook/' . $_SESSION['gradebook_dest'], |
|
58 | + 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], |
|
59 | 59 | 'name' => get_lang('ToolGradebook') |
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
63 | 63 | $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths')); |
64 | -$interbreadcrumb[] = array('url' => api_get_self() . "?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}")); |
|
65 | -$interbreadcrumb[] = array('url' => api_get_self() . "?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep')); |
|
64 | +$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}")); |
|
65 | +$interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep')); |
|
66 | 66 | |
67 | 67 | // Theme calls. |
68 | 68 | $show_learn_path = true; |
@@ -46,9 +46,9 @@ |
||
46 | 46 | $lp_theme_css = $my_style; |
47 | 47 | } |
48 | 48 | |
49 | - $progress_bar = $_SESSION['oLP']->getProgressBar(); |
|
49 | + $progress_bar = $_SESSION['oLP']->getProgressBar(); |
|
50 | 50 | $navigation_bar = $_SESSION['oLP']->get_navigation_bar(); |
51 | - $mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart); |
|
51 | + $mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart); |
|
52 | 52 | } |
53 | 53 | session_write_close(); |
54 | 54 | ?> |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | // View |
108 | 108 | $interbreadcrumb[] = [ |
109 | - 'url' => api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?'.api_get_cidreq(), |
|
109 | + 'url' => api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq(), |
|
110 | 110 | 'name' => get_lang('LearningPaths') |
111 | 111 | ]; |
112 | 112 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | array(), |
118 | 118 | ICON_SIZE_MEDIUM |
119 | 119 | ), |
120 | - api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() |
|
120 | + api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq() |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | $template = new Template(get_lang('StudentScore')); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | // Create the directory |
53 | 53 | $this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
54 | 54 | ///learning_path/ppt_dirname directory |
55 | - $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) -1); |
|
55 | + $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) - 1); |
|
56 | 56 | $this->file_path = $this->created_dir.'/'.api_replace_dangerous_char($file['name']); |
57 | 57 | |
58 | 58 | //var_dump($this->file_name, $this->file_path, $this->base_work_dir, $this->created_dir); |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | $perm = api_get_setting('permissions_for_new_files'); |
90 | 90 | |
91 | 91 | if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php |
92 | - $converter_path = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'); |
|
93 | - $class_path = $converter_path . ';' . $converter_path . '/jodconverter-2.2.2.jar;' . $converter_path . '/jodconverter-cli-2.2.2.jar'; |
|
92 | + $converter_path = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png'); |
|
93 | + $class_path = $converter_path.';'.$converter_path.'/jodconverter-2.2.2.jar;'.$converter_path.'/jodconverter-cli-2.2.2.jar'; |
|
94 | 94 | //$cmd = 'java -cp "'.$class_path.'" DokeosConverter'; |
95 | - $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $class_path . '" DokeosConverter'; |
|
95 | + $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$class_path.'" DokeosConverter'; |
|
96 | 96 | } else { |
97 | - $converter_path = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'; |
|
97 | + $converter_path = api_get_path(SYS_PATH).'main/inc/lib/ppt2png'; |
|
98 | 98 | //$class_path = '-cp .:jodconverter-2.2.1.jar:jodconverter-cli-2.2.1.jar'; |
99 | 99 | $class_path = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar'; |
100 | - $cmd = 'cd ' . $converter_path . ' && java ' . $class_path . ' DokeosConverter'; |
|
100 | + $cmd = 'cd '.$converter_path.' && java '.$class_path.' DokeosConverter'; |
|
101 | 101 | } |
102 | 102 | |
103 | - $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port'); |
|
103 | + $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port'); |
|
104 | 104 | // Call to the function implemented by child. |
105 | 105 | $cmd .= $this->add_command_parameters(); |
106 | 106 | // To allow openoffice to manipulate docs. |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | @chmod($this->base_work_dir.$this->file_path, 0777); |
110 | 110 | |
111 | 111 | $locale = $this->original_locale; // TODO: Improve it because we're not sure this locale is present everywhere. |
112 | - putenv('LC_ALL=' . $locale); |
|
112 | + putenv('LC_ALL='.$locale); |
|
113 | 113 | |
114 | 114 | $files = array(); |
115 | 115 | $return = 0; |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | if (!empty($result['images'])) { |
140 | 140 | foreach ($result['images'] as $image => $img_data) { |
141 | 141 | $image_path = $this->base_work_dir.$this->created_dir; |
142 | - @file_put_contents($image_path . '/' . $image, base64_decode($img_data)); |
|
143 | - @chmod($image_path . '/' . $image, 0777); |
|
142 | + @file_put_contents($image_path.'/'.$image, base64_decode($img_data)); |
|
143 | + @chmod($image_path.'/'.$image, 0777); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -233,38 +233,38 @@ discard block |
||
233 | 233 | $ppt2lpHost = api_get_setting('service_ppt2lp', 'host'); |
234 | 234 | $permissionFile = api_get_permissions_for_new_files(); |
235 | 235 | $permissionFolder = api_get_permissions_for_new_directories(); |
236 | - if (file_exists($this->base_work_dir . '/' . $this->created_dir)) { |
|
236 | + if (file_exists($this->base_work_dir.'/'.$this->created_dir)) { |
|
237 | 237 | |
238 | 238 | return $ids; |
239 | 239 | } |
240 | 240 | |
241 | 241 | if ($ppt2lpHost == 'localhost') { |
242 | 242 | if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php |
243 | - $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'); |
|
244 | - $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar'; |
|
245 | - $cmd = 'java -Dfile.encoding=UTF-8 -jar "' . $classPath . '/jodconverter-2.2.2.jar"'; |
|
243 | + $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png'); |
|
244 | + $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar'; |
|
245 | + $cmd = 'java -Dfile.encoding=UTF-8 -jar "'.$classPath.'/jodconverter-2.2.2.jar"'; |
|
246 | 246 | } else { |
247 | - $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'; |
|
247 | + $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png'; |
|
248 | 248 | $classPath = ' -Dfile.encoding=UTF-8 -jar jodconverter-cli-2.2.2.jar'; |
249 | - $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' '; |
|
249 | + $cmd = 'cd '.$converterPath.' && java '.$classPath.' '; |
|
250 | 250 | } |
251 | 251 | |
252 | - $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port'); |
|
252 | + $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port'); |
|
253 | 253 | // Call to the function implemented by child. |
254 | - $cmd .= ' "' . $this->base_work_dir . '/' . $this->file_path . '" "' . $this->base_work_dir . '/' . $this->created_dir . '"'; |
|
254 | + $cmd .= ' "'.$this->base_work_dir.'/'.$this->file_path.'" "'.$this->base_work_dir.'/'.$this->created_dir.'"'; |
|
255 | 255 | // To allow openoffice to manipulate docs. |
256 | 256 | @chmod($this->base_work_dir, $permissionFolder); |
257 | - @chmod($this->base_work_dir . '/' . $this->file_path, $permissionFile); |
|
257 | + @chmod($this->base_work_dir.'/'.$this->file_path, $permissionFile); |
|
258 | 258 | |
259 | 259 | $locale = $this->original_locale; // TODO: Improve it because we're not sure this locale is present everywhere. |
260 | - putenv('LC_ALL=' . $locale); |
|
260 | + putenv('LC_ALL='.$locale); |
|
261 | 261 | |
262 | 262 | $files = array(); |
263 | 263 | $return = 0; |
264 | 264 | $shell = exec($cmd, $files, $return); |
265 | 265 | // TODO: Chown is not working, root keep user privileges, should be www-data |
266 | - @chown($this->base_work_dir . '/' . $this->created_dir, 'www-data'); |
|
267 | - @chmod($this->base_work_dir . '/' . $this->created_dir, $permissionFile); |
|
266 | + @chown($this->base_work_dir.'/'.$this->created_dir, 'www-data'); |
|
267 | + @chmod($this->base_work_dir.'/'.$this->created_dir, $permissionFile); |
|
268 | 268 | |
269 | 269 | if ($return != 0) { // If the java application returns an error code. |
270 | 270 | switch ($return) { |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | */ |
304 | 304 | } |
305 | 305 | |
306 | - if (file_exists($this->base_work_dir . '/' . $this->created_dir)) { |
|
306 | + if (file_exists($this->base_work_dir.'/'.$this->created_dir)) { |
|
307 | 307 | |
308 | 308 | // Register Files to Document tool |
309 | 309 | $ids[] = add_document( |
310 | 310 | $_course, |
311 | - '/' . $this->created_dir, |
|
311 | + '/'.$this->created_dir, |
|
312 | 312 | 'file', |
313 | - filesize($this->base_work_dir . '/' . $this->created_dir), |
|
313 | + filesize($this->base_work_dir.'/'.$this->created_dir), |
|
314 | 314 | $convertedTitle, |
315 | 315 | sprintf( |
316 | 316 | get_lang('FileConvertedFromXToY'), |
@@ -28,10 +28,10 @@ |
||
28 | 28 | error_log('In xajax_save_objectives('.$lp_id.','.$user_id.','.$view_id.','.$item_id.',"'.(count($objectives) > 0 ? count($objectives) : '').'")', 0); |
29 | 29 | } |
30 | 30 | $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id); |
31 | - $mylpi =& $mylp->items[$item_id]; |
|
32 | - if (is_array($objectives) && count($objectives)>0){ |
|
33 | - foreach ($objectives as $index=>$objective){ |
|
34 | - $mylpi->add_objective($index,$objectives[$index]); |
|
31 | + $mylpi = & $mylp->items[$item_id]; |
|
32 | + if (is_array($objectives) && count($objectives) > 0) { |
|
33 | + foreach ($objectives as $index=>$objective) { |
|
34 | + $mylpi->add_objective($index, $objectives[$index]); |
|
35 | 35 | } |
36 | 36 | $mylpi->write_objectives_to_db(); |
37 | 37 | } |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | $myname = $oOrganization->get_name(); |
310 | 310 | $myname = api_utf8_decode($myname); |
311 | 311 | |
312 | - $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib,display_order, session_id, use_max_score)" . |
|
312 | + $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib,display_order, session_id, use_max_score)". |
|
313 | 313 | "VALUES ($courseId , 2,'".$myname."', '".$oOrganization->get_ref()."','','".$this->subdir."', 0, 'embedded', '".$this->manifest_encoding."', 'scorm_api.php', $dsp, $sessionId, $userMaxScore)"; |
314 | - if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting path: '. $sql, 0); } |
|
314 | + if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting path: '.$sql, 0); } |
|
315 | 315 | |
316 | 316 | Database::query($sql); |
317 | 317 | $lp_id = Database::insert_id(); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $path = ''; |
366 | 366 | $type = 'dir'; |
367 | 367 | if (isset($this->resources[$item['identifierref']])) { |
368 | - $oRes =& $this->resources[$item['identifierref']]; |
|
368 | + $oRes = & $this->resources[$item['identifierref']]; |
|
369 | 369 | $path = @$oRes->get_path(); |
370 | 370 | if (!empty($path)) { |
371 | 371 | $temptype = $oRes->get_scorm_type(); |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | $item['parameters'] = Database::escape_string($item['parameters']); |
417 | 417 | |
418 | 418 | $sql = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,launch_data, parameters) |
419 | - VALUES ($courseId, $lp_id, '$type', '$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, '$prereq', ".$item['rel_order'] .", '".$item['datafromlms']."', '".$item['parameters']."' )"; |
|
419 | + VALUES ($courseId, $lp_id, '$type', '$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, '$prereq', ".$item['rel_order'].", '".$item['datafromlms']."', '".$item['parameters']."' )"; |
|
420 | 420 | |
421 | 421 | Database::query($sql); |
422 | 422 | if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting item : '.$sql, 0); } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | foreach ($specific_fields as $specific_field) { |
451 | 451 | if (isset($_REQUEST[$specific_field['code']])) { |
452 | 452 | $sterms = trim($_REQUEST[$specific_field['code']]); |
453 | - $all_specific_terms .= ' '. $sterms; |
|
453 | + $all_specific_terms .= ' '.$sterms; |
|
454 | 454 | if (!empty($sterms)) { |
455 | 455 | $sterms = explode(',', $sterms); |
456 | 456 | foreach ($sterms as $sterm) { |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
462 | - $body_to_index = $all_specific_terms .' '. $title; |
|
462 | + $body_to_index = $all_specific_terms.' '.$title; |
|
463 | 463 | $ic_slide->addValue("content", $body_to_index); |
464 | 464 | // TODO: Add a comment to say terms separated by commas. |
465 | 465 | $courseid = api_get_course_id(); |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | SE_COURSE_ID => $courseid, |
470 | 470 | SE_TOOL_ID => TOOL_LEARNPATH, |
471 | 471 | SE_DATA => array('lp_id' => $lp_id, 'lp_item'=> $previous, 'document_id' => ''), // TODO: Unify with other lp types. |
472 | - SE_USER => (int)api_get_user_id(), |
|
472 | + SE_USER => (int) api_get_user_id(), |
|
473 | 473 | ); |
474 | 474 | $ic_slide->xapian_data = serialize($xapian_data); |
475 | 475 | $di->addChunk($ic_slide); |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | public function import_package($zip_file_info, $current_dir = '', $courseInfo = array()) |
516 | 516 | { |
517 | 517 | if ($this->debug > 0) { |
518 | - error_log('In scorm::import_package('.print_r($zip_file_info,true).',"'.$current_dir.'") method', 0); |
|
518 | + error_log('In scorm::import_package('.print_r($zip_file_info, true).',"'.$current_dir.'") method', 0); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo; |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | $zip_file_name = $zip_file_info['name']; |
527 | 527 | |
528 | 528 | if ($this->debug > 1) { |
529 | - error_log('New LP - import_package() - zip file path = ' . $zip_file_path . ', zip file name = ' . $zip_file_name, 0); |
|
529 | + error_log('New LP - import_package() - zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | $course_rel_dir = api_get_course_path($courseInfo['code']).'/scorm'; // scorm dir web path starting from /courses |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/ |
535 | 535 | |
536 | 536 | if ($this->debug > 1) { |
537 | - error_log( 'New LP - import_package() - current_dir = ' . $current_dir, 0); |
|
537 | + error_log('New LP - import_package() - current_dir = '.$current_dir, 0); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | // Get name of the zip file without the extension. |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $file_info = pathinfo($zip_file_name); |
543 | 543 | $filename = $file_info['basename']; |
544 | 544 | $extension = $file_info['extension']; |
545 | - $file_base_name = str_replace('.'.$extension,'',$filename); // Filename without its extension. |
|
545 | + $file_base_name = str_replace('.'.$extension, '', $filename); // Filename without its extension. |
|
546 | 546 | $this->zipname = $file_base_name; // Save for later in case we don't have a title. |
547 | 547 | |
548 | 548 | if ($this->debug > 1) { error_log("New LP - base file name is : ".$file_base_name, 0); } |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | $slash_count = substr_count($shortest_path, '/'); |
589 | 589 | foreach ($manifest_list as $manifest_path) { |
590 | 590 | $tmp_slash_count = substr_count($manifest_path, '/'); |
591 | - if ($tmp_slash_count<$slash_count) { |
|
591 | + if ($tmp_slash_count < $slash_count) { |
|
592 | 592 | $shortest_path = $manifest_path; |
593 | 593 | $slash_count = $tmp_slash_count; |
594 | 594 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $this->subdir .= '/'.dirname($shortest_path); // Do not concatenate because already done above. |
598 | 598 | $manifest = $shortest_path; |
599 | 599 | if ($this->debug > 1) { error_log('New LP - Package type is now '.$package_type, 0); } |
600 | - if ($package_type== '') { |
|
600 | + if ($package_type == '') { |
|
601 | 601 | // && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM) |
602 | 602 | if ($this->debug > 1) { error_log('New LP - Package type is empty', 0); } |
603 | 603 | return api_failure::set_failure('not_scorm_content'); |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | $new_dir = '/'.$new_dir; |
614 | 614 | } |
615 | 615 | |
616 | - if ($new_dir[strlen($new_dir)-1] == '/') { |
|
617 | - $new_dir = substr($new_dir,0,-1); |
|
616 | + if ($new_dir[strlen($new_dir) - 1] == '/') { |
|
617 | + $new_dir = substr($new_dir, 0, -1); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /* Uncompressing phase */ |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | if ($file != '.' && $file != '..') { |
656 | 656 | $filetype = 'file'; |
657 | 657 | |
658 | - if (is_dir($course_sys_dir . $new_dir . $file)) { |
|
658 | + if (is_dir($course_sys_dir.$new_dir.$file)) { |
|
659 | 659 | $filetype = 'folder'; |
660 | 660 | } |
661 | 661 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | } |
685 | 685 | } |
686 | 686 | } |
687 | - @rename($course_sys_dir.$new_dir.$file,$course_sys_dir.$new_dir.$safe_file); |
|
687 | + @rename($course_sys_dir.$new_dir.$file, $course_sys_dir.$new_dir.$safe_file); |
|
688 | 688 | if ($this->debug >= 1) { error_log('New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file, 0); } |
689 | 689 | } |
690 | 690 | } |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | if ($this->debug > 0) { error_log('In scorm::get_res_path('.$id.') method', 0); } |
874 | 874 | $path = ''; |
875 | 875 | if (isset($this->resources[$id])) { |
876 | - $oRes =& $this->resources[$id]; |
|
876 | + $oRes = & $this->resources[$id]; |
|
877 | 877 | $path = @$oRes->get_path(); |
878 | 878 | } |
879 | 879 | return $path; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | if ($this->debug > 0) { error_log('In scorm::get_res_type('.$id.') method', 0); } |
890 | 890 | $type = ''; |
891 | 891 | if (isset($this->resources[$id])) { |
892 | - $oRes =& $this->resources[$id]; |
|
892 | + $oRes = & $this->resources[$id]; |
|
893 | 893 | $temptype = $oRes->get_scorm_type(); |
894 | 894 | if (!empty($temptype)) { |
895 | 895 | $type = $temptype; |
@@ -908,9 +908,9 @@ discard block |
||
908 | 908 | $title = ''; |
909 | 909 | if (isset($this->manifest['organizations']['default'])) { |
910 | 910 | $title = $this->organizations[$this->manifest['organizations']['default']]->get_name(); |
911 | - } elseif (count($this->organizations)==1) { |
|
911 | + } elseif (count($this->organizations) == 1) { |
|
912 | 912 | // This will only get one title but so we don't need to know the index. |
913 | - foreach($this->organizations as $id => $value) { |
|
913 | + foreach ($this->organizations as $id => $value) { |
|
914 | 914 | $title = $this->organizations[$id]->get_name(); |
915 | 915 | break; |
916 | 916 | } |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | $a_dir = realpath($dir.'/../../archive/'); |
16 | 16 | $list = scandir($a_dir); |
17 | 17 | // calculate 7 days |
18 | -$t = time()-(86400*7); |
|
18 | +$t = time() - (86400 * 7); |
|
19 | 19 | foreach ($list as $item) { |
20 | - if (substr($item,0,1) == '.') { |
|
20 | + if (substr($item, 0, 1) == '.') { |
|
21 | 21 | continue; |
22 | 22 | } |
23 | 23 | $stat = @stat($a_dir.'/'.$item); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | * Delete a file or recursively delete a directory |
35 | 35 | * @param string $str Path to file or directory |
36 | 36 | */ |
37 | -function recursive_delete($str){ |
|
37 | +function recursive_delete($str) { |
|
38 | 38 | if (is_file($str)) { |
39 | 39 | return @unlink($str); |
40 | 40 | } elseif (is_dir($str)) { |
41 | - $scan = glob(rtrim($str,'/').'/*'); |
|
41 | + $scan = glob(rtrim($str, '/').'/*'); |
|
42 | 42 | foreach ($scan as $index=>$path) { |
43 | 43 | recursive_delete($path); |
44 | 44 | } |