Completed
Push — 1.10.x ( 71e5e5...da67d2 )
by Yannick
43:55
created
main/exercice/export/exercise_import.inc.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     // used to specify the question directory where files could be found in relation in any question
77 77
     global $questionTempDir;
78 78
 
79
-    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'qti2';
79
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH).'qti2';
80 80
     $baseWorkDir = $archive_path;
81 81
 
82 82
     if (!is_dir($baseWorkDir)) {
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 
120 120
     // parse every subdirectory to search xml question files
121 121
     while (false !== ($file = readdir($exerciseHandle))) {
122
-        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
122
+        if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") {
123 123
             // Find each manifest for each question repository found
124
-            $questionHandle = opendir($baseWorkDir . '/' . $file);
124
+            $questionHandle = opendir($baseWorkDir.'/'.$file);
125 125
             while (false !== ($questionFile = readdir($questionHandle))) {
126 126
                 if (preg_match('/.xml$/i', $questionFile)) {
127 127
                     $result = qti_parse_file($baseWorkDir, $file, $questionFile);
128
-                    $filePath = $baseWorkDir . $file;
128
+                    $filePath = $baseWorkDir.$file;
129 129
                     $file_found = true;
130 130
                 }
131 131
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
             // Else ignore file
135 135
             $result = qti_parse_file($baseWorkDir, '', $file);
136
-            $filePath = $baseWorkDir . '/' . $file;
136
+            $filePath = $baseWorkDir.'/'.$file;
137 137
             $file_found = true;
138 138
         }
139 139
     }
@@ -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'));
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
     if ($record_item_body) {
353 353
 
354 354
         if ((!in_array($current_element, $non_HTML_tag_to_avoid))) {
355
-            $current_question_item_body .= "<" . $name;
355
+            $current_question_item_body .= "<".$name;
356 356
             foreach ($attributes as $attribute_name => $attribute_value) {
357
-                $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\"";
357
+                $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\"";
358 358
             }
359 359
             $current_question_item_body .= ">";
360 360
         } else {
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
             //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced
363 363
 
364 364
             if ($current_element == 'INLINECHOICEINTERACTION') {
365
-                $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**";
365
+                $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**";
366 366
             }
367 367
             if ($current_element == 'TEXTENTRYINTERACTION') {
368 368
                 $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
369
-                $current_question_item_body .= "[" . $correct_answer_value . "]";
369
+                $current_question_item_body .= "[".$correct_answer_value."]";
370 370
 
371 371
             }
372 372
             if ($current_element == 'BR') {
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
     //treat the record of the full content of itembody tag :
484 484
 
485 485
     if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
486
-        $current_question_item_body .= "</" . $name . ">";
486
+        $current_question_item_body .= "</".$name.">";
487 487
     }
488 488
 
489 489
     switch ($name) {
@@ -540,14 +540,14 @@  discard block
 block discarded – undo
540 540
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) {
541 541
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data);
542 542
             } else {
543
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data);
543
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data);
544 544
             }
545 545
             break;
546 546
         case 'FEEDBACKINLINE':
547 547
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) {
548 548
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data);
549 549
             } else {
550
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data);
550
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data);
551 551
             }
552 552
             break;
553 553
         case 'SIMPLEASSOCIABLECHOICE':
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
             $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
571 571
             if ($current_inlinechoice_id == $answer_identifier) {
572 572
                 $current_question_item_body = str_replace(
573
-                    "**claroline_start**" . $current_answer_id . "**claroline_end**",
574
-                    "[" . $data . "]",
573
+                    "**claroline_start**".$current_answer_id."**claroline_end**",
574
+                    "[".$data."]",
575 575
                     $current_question_item_body
576 576
                 );
577 577
             } else {
@@ -630,9 +630,9 @@  discard block
 block discarded – undo
630 630
     if ($record_item_body) {
631 631
 
632 632
         if ((!in_array($current_element, $non_HTML_tag_to_avoid))) {
633
-            $current_question_item_body .= "<" . $name;
633
+            $current_question_item_body .= "<".$name;
634 634
             foreach ($attributes as $attribute_name => $attribute_value) {
635
-                $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\"";
635
+                $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\"";
636 636
             }
637 637
             $current_question_item_body .= ">";
638 638
         } else {
@@ -640,11 +640,11 @@  discard block
 block discarded – undo
640 640
             //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced
641 641
 
642 642
             if ($current_element == 'INLINECHOICEINTERACTION') {
643
-                $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**";
643
+                $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**";
644 644
             }
645 645
             if ($current_element == 'TEXTENTRYINTERACTION') {
646 646
                 $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
647
-                $current_question_item_body .= "[" . $correct_answer_value . "]";
647
+                $current_question_item_body .= "[".$correct_answer_value."]";
648 648
 
649 649
             }
650 650
             if ($current_element == 'BR') {
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
     //treat the record of the full content of itembody tag :
769 769
 
770 770
     if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
771
-        $current_question_item_body .= "</" . $name . ">";
771
+        $current_question_item_body .= "</".$name.">";
772 772
     }
773 773
 
774 774
     switch ($name) {
Please login to merge, or discard this patch.