Completed
Push — 1.10.x ( 2fbd07...b13725 )
by Yannick
74:13 queued 27:54
created
main/exercice/export/exercise_import.inc.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     global $questionTempDir;
60 60
     global $resourcesLinks;
61 61
 
62
-    $baseWorkDir = api_get_path(SYS_ARCHIVE_PATH) . 'qti2';
62
+    $baseWorkDir = api_get_path(SYS_ARCHIVE_PATH).'qti2';
63 63
 
64 64
     if (!is_dir($baseWorkDir)) {
65 65
         mkdir($baseWorkDir, api_get_permissions_for_new_directories(), true);
@@ -103,35 +103,35 @@  discard block
 block discarded – undo
103 103
     // The assets-related code is a bit fragile as it has to deal with files renamed by Chamilo and it only works if
104 104
     // the imsmanifest.xml file is read.
105 105
     while (false !== ($file = readdir($exerciseHandle))) {
106
-        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
106
+        if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") {
107 107
             // Find each manifest for each question repository found
108
-            $questionHandle = opendir($baseWorkDir . '/' . $file);
108
+            $questionHandle = opendir($baseWorkDir.'/'.$file);
109 109
             // Only analyse one level of subdirectory - no recursivity here
110 110
             while (false !== ($questionFile = readdir($questionHandle))) {
111 111
                 if (preg_match('/.xml$/i', $questionFile)) {
112
-                    $isQti = isQtiQuestionBank($baseWorkDir . '/' . $file . '/' . $questionFile);
112
+                    $isQti = isQtiQuestionBank($baseWorkDir.'/'.$file.'/'.$questionFile);
113 113
                     if ($isQti) {
114 114
                         $result = qti_parse_file($baseWorkDir, $file, $questionFile);
115
-                        $filePath = $baseWorkDir . $file;
115
+                        $filePath = $baseWorkDir.$file;
116 116
                         $file_found = true;
117 117
                     } else {
118
-                        $isManifest = isQtiManifest($baseWorkDir . '/' . $file . '/' . $questionFile);
118
+                        $isManifest = isQtiManifest($baseWorkDir.'/'.$file.'/'.$questionFile);
119 119
                         if ($isManifest) {
120
-                            $resourcesLinks = qtiProcessManifest($baseWorkDir . '/' . $file . '/' . $questionFile);
120
+                            $resourcesLinks = qtiProcessManifest($baseWorkDir.'/'.$file.'/'.$questionFile);
121 121
                         }
122 122
                     }
123 123
                 }
124 124
             }
125 125
         } elseif (preg_match('/.xml$/i', $file)) {
126
-            $isQti = isQtiQuestionBank($baseWorkDir . '/' . $file);
126
+            $isQti = isQtiQuestionBank($baseWorkDir.'/'.$file);
127 127
             if ($isQti) {
128 128
                 $result = qti_parse_file($baseWorkDir, '', $file);
129
-                $filePath = $baseWorkDir . '/' . $file;
129
+                $filePath = $baseWorkDir.'/'.$file;
130 130
                 $file_found = true;
131 131
             } else {
132
-                $isManifest = isQtiManifest($baseWorkDir . '/' . $file);
132
+                $isManifest = isQtiManifest($baseWorkDir.'/'.$file);
133 133
                 if ($isManifest) {
134
-                    $resourcesLinks = qtiProcessManifest($baseWorkDir . '/' . $file);
134
+                    $resourcesLinks = qtiProcessManifest($baseWorkDir.'/'.$file);
135 135
                 }
136 136
             }
137 137
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             $question->type = $question_array['type'];
166 166
             $question->setAnswer();
167 167
             if (strlen($question_array['title']) < 50) {
168
-                $question->updateTitle(formatText(strip_tags($question_array['title'])) . '...');
168
+                $question->updateTitle(formatText(strip_tags($question_array['title'])).'...');
169 169
             } else {
170 170
                 $question->updateTitle(formatText(substr(strip_tags($question_array['title']), 0, 50)));
171 171
                 $question->updateDescription($question_array['title']);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         }
212 212
 
213 213
         // delete the temp dir where the exercise was unzipped
214
-        my_delete($baseWorkDir . $uploadPath);
214
+        my_delete($baseWorkDir.$uploadPath);
215 215
         return $last_exercise_id;
216 216
     }
217 217
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
     global $record_item_body;
240 240
     global $questionTempDir;
241 241
 
242
-    $questionTempDir = $exercisePath . '/' . $file . '/';
243
-    $questionFilePath = $questionTempDir . $questionFile;
242
+    $questionTempDir = $exercisePath.'/'.$file.'/';
243
+    $questionFilePath = $questionTempDir.$questionFile;
244 244
 
245 245
     if (!($fp = fopen($questionFilePath, 'r'))) {
246 246
         Display::addFlash(Display::return_message(get_lang('Error opening question\'s XML file'), 'error'));
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         $error = xml_get_error_code();
296 296
         Display::addFlash(
297 297
             Display::return_message(
298
-                get_lang('Error reading XML file') . sprintf('[%d:%d]', xml_get_current_line_number($xml_parser), xml_get_current_column_number($xml_parser)),
298
+                get_lang('Error reading XML file').sprintf('[%d:%d]', xml_get_current_line_number($xml_parser), xml_get_current_column_number($xml_parser)),
299 299
                 'error'
300 300
             )
301 301
         );
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
     if ($record_item_body) {
362 362
 
363 363
         if ((!in_array($current_element, $non_HTML_tag_to_avoid))) {
364
-            $current_question_item_body .= "<" . $name;
364
+            $current_question_item_body .= "<".$name;
365 365
             foreach ($attributes as $attribute_name => $attribute_value) {
366
-                $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\"";
366
+                $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\"";
367 367
             }
368 368
             $current_question_item_body .= ">";
369 369
         } else {
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
             //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced
372 372
 
373 373
             if ($current_element == 'INLINECHOICEINTERACTION') {
374
-                $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**";
374
+                $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**";
375 375
             }
376 376
             if ($current_element == 'TEXTENTRYINTERACTION') {
377 377
                 $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
378
-                $current_question_item_body .= "[" . $correct_answer_value . "]";
378
+                $current_question_item_body .= "[".$correct_answer_value."]";
379 379
 
380 380
             }
381 381
             if ($current_element == 'BR') {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
     //treat the record of the full content of itembody tag :
493 493
 
494 494
     if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
495
-        $current_question_item_body .= "</" . $name . ">";
495
+        $current_question_item_body .= "</".$name.">";
496 496
     }
497 497
 
498 498
     switch ($name) {
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) {
551 551
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data);
552 552
             } else {
553
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data);
553
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data);
554 554
             }
555 555
             break;
556 556
         case 'FEEDBACKINLINE':
557 557
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) {
558 558
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data);
559 559
             } else {
560
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data);
560
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data);
561 561
             }
562 562
             break;
563 563
         case 'SIMPLEASSOCIABLECHOICE':
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
             // $resourcesLinks is only defined by qtiProcessManifest()
578 578
             if (isset($resourcesLinks) && isset($resourcesLinks['manifest']) && isset($resourcesLinks['web'])) {
579 579
                 foreach ($resourcesLinks['manifest'] as $key => $value) {
580
-                    $data = preg_replace('|' . $value . '|', $resourcesLinks['web'][$key], $data);
580
+                    $data = preg_replace('|'.$value.'|', $resourcesLinks['web'][$key], $data);
581 581
                 }
582 582
             }
583 583
             $current_question_item_body .= $data;
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
             $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
588 588
             if ($current_inlinechoice_id == $answer_identifier) {
589 589
                 $current_question_item_body = str_replace(
590
-                    "**claroline_start**" . $current_answer_id . "**claroline_end**",
591
-                    "[" . $data . "]",
590
+                    "**claroline_start**".$current_answer_id."**claroline_end**",
591
+                    "[".$data."]",
592 592
                     $current_question_item_body
593 593
                 );
594 594
             } else {
@@ -647,9 +647,9 @@  discard block
 block discarded – undo
647 647
     if ($record_item_body) {
648 648
 
649 649
         if ((!in_array($current_element, $non_HTML_tag_to_avoid))) {
650
-            $current_question_item_body .= "<" . $name;
650
+            $current_question_item_body .= "<".$name;
651 651
             foreach ($attributes as $attribute_name => $attribute_value) {
652
-                $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\"";
652
+                $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\"";
653 653
             }
654 654
             $current_question_item_body .= ">";
655 655
         } else {
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
             //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced
658 658
 
659 659
             if ($current_element == 'INLINECHOICEINTERACTION') {
660
-                $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**";
660
+                $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**";
661 661
             }
662 662
             if ($current_element == 'TEXTENTRYINTERACTION') {
663 663
                 $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
664
-                $current_question_item_body .= "[" . $correct_answer_value . "]";
664
+                $current_question_item_body .= "[".$correct_answer_value."]";
665 665
 
666 666
             }
667 667
             if ($current_element == 'BR') {
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
     //treat the record of the full content of itembody tag :
781 781
 
782 782
     if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
783
-        $current_question_item_body .= "</" . $name . ">";
783
+        $current_question_item_body .= "</".$name.">";
784 784
     }
785 785
 
786 786
     switch ($name) {
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
             // $resourcesLinks is only defined by qtiProcessManifest()
898 898
             if (isset($resourcesLinks) && isset($resourcesLinks['manifest']) && isset($resourcesLinks['web'])) {
899 899
                 foreach ($resourcesLinks['manifest'] as $key=>$value) {
900
-                    $data = preg_replace('|' . $value . '|', $resourcesLinks['web'][$key], $data);
900
+                    $data = preg_replace('|'.$value.'|', $resourcesLinks['web'][$key], $data);
901 901
                 }
902 902
             }
903 903
             if (!empty($current_question_item_body)) {
@@ -971,9 +971,9 @@  discard block
 block discarded – undo
971 971
     $sessionId = api_get_session_id();
972 972
     $courseDir = $course['path'];
973 973
     $sysPath = api_get_path(SYS_COURSE_PATH);
974
-    $exercisesSysPath = $sysPath . $courseDir . '/document/';
974
+    $exercisesSysPath = $sysPath.$courseDir.'/document/';
975 975
     $webPath = api_get_path(WEB_CODE_PATH);
976
-    $exercisesWebPath = $webPath . 'document/document.php?' . api_get_cidreq() . '&action=download&id=';
976
+    $exercisesWebPath = $webPath.'document/document.php?'.api_get_cidreq().'&action=download&id=';
977 977
     $links = array(
978 978
         'manifest' => array(),
979 979
         'system' => array(),
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
     );
982 982
     $tableDocuments = Database::get_course_table(TABLE_DOCUMENT);
983 983
     $countResources = count($xml->resources->resource->file);
984
-    for ($i=0; $i < $countResources; $i++) {
984
+    for ($i = 0; $i < $countResources; $i++) {
985 985
         $file = $xml->resources->resource->file[$i];
986 986
         $href = '';
987 987
         foreach ($file->attributes() as $key => $value) {
@@ -993,17 +993,17 @@  discard block
 block discarded – undo
993 993
         }
994 994
         if (!empty($href)) {
995 995
             $links['manifest'][] = (string) $href;
996
-            $links['system'][] = $exercisesSysPath . strtolower($href);
996
+            $links['system'][] = $exercisesSysPath.strtolower($href);
997 997
             $specialHref = Database::escape_string(preg_replace('/_/', '-', strtolower($href)));
998 998
             $specialHref = preg_replace('/(-){2,8}/', '-', $specialHref);
999 999
 
1000
-            $sql = "SELECT iid FROM " . $tableDocuments . " WHERE c_id = " . $course['real_id'] . " AND session_id = $sessionId AND path = '/" . $specialHref . "'";
1000
+            $sql = "SELECT iid FROM ".$tableDocuments." WHERE c_id = ".$course['real_id']." AND session_id = $sessionId AND path = '/".$specialHref."'";
1001 1001
             $result = Database::query($sql);
1002 1002
             $documentId = 0;
1003 1003
             while ($row = Database::fetch_assoc($result)) {
1004 1004
                 $documentId = $row['iid'];
1005 1005
             }
1006
-            $links['web'][] = $exercisesWebPath . $documentId;
1006
+            $links['web'][] = $exercisesWebPath.$documentId;
1007 1007
         }
1008 1008
     }
1009 1009
     return $links;
Please login to merge, or discard this patch.