@@ -905,6 +905,9 @@ |
||
| 905 | 905 | } |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | +/** |
|
| 909 | + * @param string $filePath |
|
| 910 | + */ |
|
| 908 | 911 | function isQtiQuestionBank($filePath) { |
| 909 | 912 | $data = file_get_contents($filePath); |
| 910 | 913 | if (!empty($data)) { |
@@ -76,7 +76,7 @@ discard block |
||
| 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,25 +119,25 @@ discard block |
||
| 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 | - $isQti = isQtiQuestionBank($baseWorkDir . '/' . $file . '/' . $questionFile); |
|
| 127 | + $isQti = isQtiQuestionBank($baseWorkDir.'/'.$file.'/'.$questionFile); |
|
| 128 | 128 | if ($isQti) { |
| 129 | 129 | $result = qti_parse_file($baseWorkDir, $file, $questionFile); |
| 130 | - $filePath = $baseWorkDir . $file; |
|
| 130 | + $filePath = $baseWorkDir.$file; |
|
| 131 | 131 | $file_found = true; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } elseif (preg_match('/.xml$/i', $file)) { |
| 136 | - $isQti = isQtiQuestionBank($baseWorkDir . '/' . $file); |
|
| 136 | + $isQti = isQtiQuestionBank($baseWorkDir.'/'.$file); |
|
| 137 | 137 | //$isManifest = isQtiManifest($baseWorkDir . '/' . $file); |
| 138 | 138 | if ($isQti) { |
| 139 | 139 | $result = qti_parse_file($baseWorkDir, '', $file); |
| 140 | - $filePath = $baseWorkDir . '/' . $file; |
|
| 140 | + $filePath = $baseWorkDir.'/'.$file; |
|
| 141 | 141 | $file_found = true; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $question->type = $question_array['type']; |
| 171 | 171 | $question->setAnswer(); |
| 172 | 172 | if (strlen($question_array['title']) < 50) { |
| 173 | - $question->updateTitle(formatText(strip_tags($question_array['title'])) . '...'); |
|
| 173 | + $question->updateTitle(formatText(strip_tags($question_array['title'])).'...'); |
|
| 174 | 174 | } else { |
| 175 | 175 | $question->updateTitle(formatText(substr(strip_tags($question_array['title']), 0, 50))); |
| 176 | 176 | $question->updateDescription($question_array['title']); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // delete the temp dir where the exercise was unzipped |
| 219 | - my_delete($baseWorkDir . $uploadPath); |
|
| 219 | + my_delete($baseWorkDir.$uploadPath); |
|
| 220 | 220 | return $last_exercise_id; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | global $record_item_body; |
| 245 | 245 | global $questionTempDir; |
| 246 | 246 | |
| 247 | - $questionTempDir = $exercisePath . '/' . $file . '/'; |
|
| 248 | - $questionFilePath = $questionTempDir . $questionFile; |
|
| 247 | + $questionTempDir = $exercisePath.'/'.$file.'/'; |
|
| 248 | + $questionFilePath = $questionTempDir.$questionFile; |
|
| 249 | 249 | |
| 250 | 250 | if (!($fp = fopen($questionFilePath, 'r'))) { |
| 251 | 251 | Display::addFlash(Display::return_message(get_lang('Error opening question\'s XML file'), 'error')); |
@@ -357,9 +357,9 @@ discard block |
||
| 357 | 357 | if ($record_item_body) { |
| 358 | 358 | |
| 359 | 359 | if ((!in_array($current_element, $non_HTML_tag_to_avoid))) { |
| 360 | - $current_question_item_body .= "<" . $name; |
|
| 360 | + $current_question_item_body .= "<".$name; |
|
| 361 | 361 | foreach ($attributes as $attribute_name => $attribute_value) { |
| 362 | - $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\""; |
|
| 362 | + $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\""; |
|
| 363 | 363 | } |
| 364 | 364 | $current_question_item_body .= ">"; |
| 365 | 365 | } else { |
@@ -367,11 +367,11 @@ discard block |
||
| 367 | 367 | //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced |
| 368 | 368 | |
| 369 | 369 | if ($current_element == 'INLINECHOICEINTERACTION') { |
| 370 | - $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**"; |
|
| 370 | + $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**"; |
|
| 371 | 371 | } |
| 372 | 372 | if ($current_element == 'TEXTENTRYINTERACTION') { |
| 373 | 373 | $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
| 374 | - $current_question_item_body .= "[" . $correct_answer_value . "]"; |
|
| 374 | + $current_question_item_body .= "[".$correct_answer_value."]"; |
|
| 375 | 375 | |
| 376 | 376 | } |
| 377 | 377 | if ($current_element == 'BR') { |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | //treat the record of the full content of itembody tag : |
| 489 | 489 | |
| 490 | 490 | if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) { |
| 491 | - $current_question_item_body .= "</" . $name . ">"; |
|
| 491 | + $current_question_item_body .= "</".$name.">"; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | switch ($name) { |
@@ -545,14 +545,14 @@ discard block |
||
| 545 | 545 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { |
| 546 | 546 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); |
| 547 | 547 | } else { |
| 548 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data); |
|
| 548 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); |
|
| 549 | 549 | } |
| 550 | 550 | break; |
| 551 | 551 | case 'FEEDBACKINLINE': |
| 552 | 552 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) { |
| 553 | 553 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data); |
| 554 | 554 | } else { |
| 555 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data); |
|
| 555 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data); |
|
| 556 | 556 | } |
| 557 | 557 | break; |
| 558 | 558 | case 'SIMPLEASSOCIABLECHOICE': |
@@ -575,8 +575,8 @@ discard block |
||
| 575 | 575 | $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
| 576 | 576 | if ($current_inlinechoice_id == $answer_identifier) { |
| 577 | 577 | $current_question_item_body = str_replace( |
| 578 | - "**claroline_start**" . $current_answer_id . "**claroline_end**", |
|
| 579 | - "[" . $data . "]", |
|
| 578 | + "**claroline_start**".$current_answer_id."**claroline_end**", |
|
| 579 | + "[".$data."]", |
|
| 580 | 580 | $current_question_item_body |
| 581 | 581 | ); |
| 582 | 582 | } else { |
@@ -635,9 +635,9 @@ discard block |
||
| 635 | 635 | if ($record_item_body) { |
| 636 | 636 | |
| 637 | 637 | if ((!in_array($current_element, $non_HTML_tag_to_avoid))) { |
| 638 | - $current_question_item_body .= "<" . $name; |
|
| 638 | + $current_question_item_body .= "<".$name; |
|
| 639 | 639 | foreach ($attributes as $attribute_name => $attribute_value) { |
| 640 | - $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\""; |
|
| 640 | + $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\""; |
|
| 641 | 641 | } |
| 642 | 642 | $current_question_item_body .= ">"; |
| 643 | 643 | } else { |
@@ -645,11 +645,11 @@ discard block |
||
| 645 | 645 | //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced |
| 646 | 646 | |
| 647 | 647 | if ($current_element == 'INLINECHOICEINTERACTION') { |
| 648 | - $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**"; |
|
| 648 | + $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**"; |
|
| 649 | 649 | } |
| 650 | 650 | if ($current_element == 'TEXTENTRYINTERACTION') { |
| 651 | 651 | $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
| 652 | - $current_question_item_body .= "[" . $correct_answer_value . "]"; |
|
| 652 | + $current_question_item_body .= "[".$correct_answer_value."]"; |
|
| 653 | 653 | |
| 654 | 654 | } |
| 655 | 655 | if ($current_element == 'BR') { |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | //treat the record of the full content of itembody tag : |
| 774 | 774 | |
| 775 | 775 | if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) { |
| 776 | - $current_question_item_body .= "</" . $name . ">"; |
|
| 776 | + $current_question_item_body .= "</".$name.">"; |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | switch ($name) { |