@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | |
169 | - /** |
|
170 | - * abstract function which creates the form to create / edit the answers of the question |
|
171 | - * @param the formvalidator instance |
|
172 | - * @param the answers number to display |
|
173 | - */ |
|
174 | - function processAnswersCreation($form) |
|
169 | + /** |
|
170 | + * abstract function which creates the form to create / edit the answers of the question |
|
171 | + * @param the formvalidator instance |
|
172 | + * @param the answers number to display |
|
173 | + */ |
|
174 | + function processAnswersCreation($form) |
|
175 | 175 | { |
176 | 176 | $questionWeighting = $nbrGoodAnswers = 0; |
177 | 177 | $objAnswer = new Answer($this->id); |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | // sets the total weighting of the question |
202 | 202 | $this->updateWeighting($questionWeighting); |
203 | 203 | $this->save(); |
204 | - } |
|
204 | + } |
|
205 | 205 | |
206 | - function return_header($feedback_type = null, $counter = null, $score = null) |
|
206 | + function return_header($feedback_type = null, $counter = null, $score = null) |
|
207 | 207 | { |
208 | - $header = parent::return_header($feedback_type, $counter, $score); |
|
209 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
208 | + $header = parent::return_header($feedback_type, $counter, $score); |
|
209 | + $header .= '<table class="'.$this->question_table_class .'"> |
|
210 | 210 | <tr> |
211 | 211 | <th>'.get_lang("Choice").'</th> |
212 | 212 | <th>'. get_lang("ExpectedChoice").'</th> |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $header .= '<th>'.get_lang("Comment").'</th>'; |
215 | 215 | $header .= '</tr>'; |
216 | 216 | return $header; |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | 220 | } |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | if (isset($_SESSION['gradebook'])){ |
175 | - $gradebook= $_SESSION['gradebook']; |
|
175 | + $gradebook= $_SESSION['gradebook']; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | if (!empty($gradebook) && $gradebook=='view') { |
179 | - $interbreadcrumb[]= array ('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook')); |
|
179 | + $interbreadcrumb[]= array ('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook')); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | // if admin of course |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | echo '</div>'; |
228 | 228 | |
229 | 229 | if ($displayMessage != "") { |
230 | - Display::display_confirmation_message($displayMessage); |
|
231 | - $displayMessage = ""; |
|
230 | + Display::display_confirmation_message($displayMessage); |
|
231 | + $displayMessage = ""; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | // Form |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | // Title |
237 | 237 | echo '<legend>'.$nameTools.' - '.$titleAdd.'</legend>'; |
238 | 238 | if (isset($type)) { |
239 | - echo '<input type="hidden" name="type" value="1">'; |
|
239 | + echo '<input type="hidden" name="type" value="1">'; |
|
240 | 240 | } |
241 | 241 | echo '<input type="hidden" name="fromExercise" value="'.$fromExercise.'">'; |
242 | 242 | |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | foreach ($course_list as $item) { |
284 | 284 | $courseItemId = $item['real_id']; |
285 | 285 | $courseInfo = api_get_course_info_by_id($courseItemId); |
286 | - $course_select_list[$courseItemId] = ""; |
|
287 | - if ($courseItemId == api_get_course_int_id()) { |
|
288 | - $course_select_list[$courseItemId] = "> "; |
|
289 | - } |
|
290 | - $course_select_list[$courseItemId] .= $courseInfo['title']; |
|
286 | + $course_select_list[$courseItemId] = ""; |
|
287 | + if ($courseItemId == api_get_course_int_id()) { |
|
288 | + $course_select_list[$courseItemId] = "> "; |
|
289 | + } |
|
290 | + $course_select_list[$courseItemId] .= $courseInfo['title']; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | $select_course_html = Display::select( |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | // no course selected, reset menu test / difficult� / type de reponse |
305 | 305 | reset_menu_exo_lvl_type(); |
306 | 306 | } else { |
307 | - $course_info = api_get_course_info_by_id($selected_course); |
|
307 | + $course_info = api_get_course_info_by_id($selected_course); |
|
308 | 308 | } |
309 | 309 | // If course has changed, reset the menu default |
310 | 310 | if ($course_id_changed) { |
311 | - reset_menu_exo_lvl_type(); |
|
311 | + reset_menu_exo_lvl_type(); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | $course_id = $course_info['real_id']; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | |
358 | 358 | if ($exercise_id_changed == 1) { |
359 | - reset_menu_lvl_type(); |
|
359 | + reset_menu_lvl_type(); |
|
360 | 360 | } |
361 | 361 | $select_exercise_html = Display::select( |
362 | 362 | 'exerciseId', |
@@ -434,19 +434,19 @@ discard block |
||
434 | 434 | // if we have selected an exercise in the list-box 'Filter' |
435 | 435 | |
436 | 436 | if ($exerciseId > 0) { |
437 | - $where = ''; |
|
438 | - $from = ''; |
|
439 | - if (isset($courseCategoryId) && $courseCategoryId > 0) { |
|
440 | - $from = ", $TBL_COURSE_REL_CATEGORY crc "; |
|
441 | - $where .= " AND crc.c_id=$selected_course AND crc.question_id=qu.id AND crc.category_id=$courseCategoryId"; |
|
442 | - } |
|
443 | - if (isset($exerciseLevel) && $exerciseLevel != -1) { |
|
444 | - $where .= ' AND level='.$exerciseLevel; |
|
445 | - } |
|
446 | - if (isset($answerType) && $answerType > 0) { |
|
447 | - $where .= ' AND type='.$answerType; |
|
448 | - } |
|
449 | - $sql = "SELECT DISTINCT |
|
437 | + $where = ''; |
|
438 | + $from = ''; |
|
439 | + if (isset($courseCategoryId) && $courseCategoryId > 0) { |
|
440 | + $from = ", $TBL_COURSE_REL_CATEGORY crc "; |
|
441 | + $where .= " AND crc.c_id=$selected_course AND crc.question_id=qu.id AND crc.category_id=$courseCategoryId"; |
|
442 | + } |
|
443 | + if (isset($exerciseLevel) && $exerciseLevel != -1) { |
|
444 | + $where .= ' AND level='.$exerciseLevel; |
|
445 | + } |
|
446 | + if (isset($answerType) && $answerType > 0) { |
|
447 | + $where .= ' AND type='.$answerType; |
|
448 | + } |
|
449 | + $sql = "SELECT DISTINCT |
|
450 | 450 | id, |
451 | 451 | question, |
452 | 452 | type, |
@@ -468,22 +468,22 @@ discard block |
||
468 | 468 | $mainQuestionList[] = $row; |
469 | 469 | } |
470 | 470 | } elseif ($exerciseId == -1) { |
471 | - // If we have selected the option 'Orphan questions' in the list-box 'Filter' |
|
472 | - $level_where = ''; |
|
473 | - $from = ''; |
|
474 | - if (isset($courseCategoryId) && $courseCategoryId > 0) { |
|
475 | - $from = " INNER JOIN $TBL_COURSE_REL_CATEGORY crc ON crc.question_id=q.id AND crc.c_id= q.c_id "; |
|
476 | - $level_where .= " AND |
|
471 | + // If we have selected the option 'Orphan questions' in the list-box 'Filter' |
|
472 | + $level_where = ''; |
|
473 | + $from = ''; |
|
474 | + if (isset($courseCategoryId) && $courseCategoryId > 0) { |
|
475 | + $from = " INNER JOIN $TBL_COURSE_REL_CATEGORY crc ON crc.question_id=q.id AND crc.c_id= q.c_id "; |
|
476 | + $level_where .= " AND |
|
477 | 477 | crc.c_id = $selected_course AND |
478 | 478 | crc.category_id = $courseCategoryId"; |
479 | - } |
|
480 | - if (isset($exerciseLevel) && $exerciseLevel!= -1 ) { |
|
481 | - $level_where = ' AND level='.$exerciseLevel; |
|
482 | - } |
|
483 | - $answer_where = ''; |
|
484 | - if (isset($answerType) && $answerType >0 -1 ) { |
|
485 | - $answer_where = ' AND type='.$answerType; |
|
486 | - } |
|
479 | + } |
|
480 | + if (isset($exerciseLevel) && $exerciseLevel!= -1 ) { |
|
481 | + $level_where = ' AND level='.$exerciseLevel; |
|
482 | + } |
|
483 | + $answer_where = ''; |
|
484 | + if (isset($answerType) && $answerType >0 -1 ) { |
|
485 | + $answer_where = ' AND type='.$answerType; |
|
486 | + } |
|
487 | 487 | |
488 | 488 | // @todo fix this query with the new id field |
489 | 489 | $sql = " ( |
@@ -525,24 +525,24 @@ discard block |
||
525 | 525 | $mainQuestionList[] = $row; |
526 | 526 | } |
527 | 527 | } else { |
528 | - // All tests for selected course |
|
528 | + // All tests for selected course |
|
529 | 529 | // If we have not selected any option in the list-box 'Filter' |
530 | - $filter = ''; |
|
531 | - $from = ''; |
|
530 | + $filter = ''; |
|
531 | + $from = ''; |
|
532 | 532 | |
533 | - if (isset($courseCategoryId) && $courseCategoryId > 0) { |
|
534 | - $from = ", $TBL_COURSE_REL_CATEGORY crc "; |
|
535 | - $filter .= " AND |
|
533 | + if (isset($courseCategoryId) && $courseCategoryId > 0) { |
|
534 | + $from = ", $TBL_COURSE_REL_CATEGORY crc "; |
|
535 | + $filter .= " AND |
|
536 | 536 | crc.c_id = $selected_course AND |
537 | 537 | crc.question_id = qu.id AND |
538 | 538 | crc.category_id = $courseCategoryId"; |
539 | - } |
|
540 | - if (isset($exerciseLevel) && $exerciseLevel != -1) { |
|
541 | - $filter .= ' AND level='.$exerciseLevel.' '; |
|
542 | - } |
|
543 | - if (isset($answerType) && $answerType > 0) { |
|
544 | - $filter .= ' AND qu.type='.$answerType.' '; |
|
545 | - } |
|
539 | + } |
|
540 | + if (isset($exerciseLevel) && $exerciseLevel != -1) { |
|
541 | + $filter .= ' AND level='.$exerciseLevel.' '; |
|
542 | + } |
|
543 | + if (isset($answerType) && $answerType > 0) { |
|
544 | + $filter .= ' AND qu.type='.$answerType.' '; |
|
545 | + } |
|
546 | 546 | |
547 | 547 | if (!empty($session_id) && $session_id != '-1') { |
548 | 548 | $mainQuestionList = array(); |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $mainQuestionList[] = $row; |
645 | 645 | } |
646 | 646 | } |
647 | - // forces the value to 0 |
|
647 | + // forces the value to 0 |
|
648 | 648 | $exerciseId = 0; |
649 | 649 | } |
650 | 650 | |
@@ -670,33 +670,33 @@ discard block |
||
670 | 670 | // |
671 | 671 | if ($fromExercise <= 0) { |
672 | 672 | // NOT IN A TEST - IN THE COURSE |
673 | - if ($selected_course == api_get_course_int_id()) { |
|
674 | - $actionLabel = get_lang('Modify'); |
|
675 | - $actionIcon1 = "edit"; |
|
676 | - $actionIcon2 = "delete"; |
|
673 | + if ($selected_course == api_get_course_int_id()) { |
|
674 | + $actionLabel = get_lang('Modify'); |
|
675 | + $actionIcon1 = "edit"; |
|
676 | + $actionIcon2 = "delete"; |
|
677 | 677 | // We are in the course, question title can be a link to the question edit page |
678 | - $questionTagA = 1; |
|
678 | + $questionTagA = 1; |
|
679 | 679 | } else { // NOT IN A TEST - NOT IN THE COURSE |
680 | - $actionLabel = get_lang('Reuse'); |
|
681 | - $actionIcon1 = get_lang('MustBeInATest'); |
|
682 | - $actionIcon2 = ""; |
|
680 | + $actionLabel = get_lang('Reuse'); |
|
681 | + $actionIcon1 = get_lang('MustBeInATest'); |
|
682 | + $actionIcon2 = ""; |
|
683 | 683 | // We are not in this course, to messy if we link to the question in another course |
684 | - $questionTagA = 0; |
|
685 | - } |
|
684 | + $questionTagA = 0; |
|
685 | + } |
|
686 | 686 | } else { |
687 | 687 | // IN A TEST - IN THE COURSE |
688 | - if ($selected_course == api_get_course_int_id()) { |
|
689 | - $actionLabel = get_lang('Reuse'); |
|
690 | - $actionIcon1 = "add"; |
|
691 | - $actionIcon2 = ""; |
|
692 | - $questionTagA = 1; |
|
688 | + if ($selected_course == api_get_course_int_id()) { |
|
689 | + $actionLabel = get_lang('Reuse'); |
|
690 | + $actionIcon1 = "add"; |
|
691 | + $actionIcon2 = ""; |
|
692 | + $questionTagA = 1; |
|
693 | 693 | } else { |
694 | 694 | // IN A TEST - NOT IN THE COURSE |
695 | - $actionLabel = get_lang('Reuse'); |
|
696 | - $actionIcon1 = "clone"; |
|
697 | - $actionIcon2 = ""; |
|
698 | - $questionTagA = 0; |
|
699 | - } |
|
695 | + $actionLabel = get_lang('Reuse'); |
|
696 | + $actionIcon1 = "clone"; |
|
697 | + $actionIcon2 = ""; |
|
698 | + $questionTagA = 0; |
|
699 | + } |
|
700 | 700 | } |
701 | 701 | // Display table |
702 | 702 | $header = array( |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | ); |
790 | 790 | |
791 | 791 | if (!$nbrQuestions) { |
792 | - echo get_lang('NoQuestion'); |
|
792 | + echo get_lang('NoQuestion'); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | Display::display_footer(); |
@@ -801,9 +801,9 @@ discard block |
||
801 | 801 | */ |
802 | 802 | function reset_menu_lvl_type() |
803 | 803 | { |
804 | - global $exerciseLevel, $answerType; |
|
805 | - $answerType = -1; |
|
806 | - $exerciseLevel = -1; |
|
804 | + global $exerciseLevel, $answerType; |
|
805 | + $answerType = -1; |
|
806 | + $exerciseLevel = -1; |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -813,10 +813,10 @@ discard block |
||
813 | 813 | */ |
814 | 814 | function reset_menu_exo_lvl_type() |
815 | 815 | { |
816 | - global $exerciseId, $courseCategoryId; |
|
817 | - reset_menu_lvl_type(); |
|
818 | - $exerciseId = 0; |
|
819 | - $courseCategoryId = 0; |
|
816 | + global $exerciseId, $courseCategoryId; |
|
817 | + reset_menu_lvl_type(); |
|
818 | + $exerciseId = 0; |
|
819 | + $courseCategoryId = 0; |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -838,17 +838,17 @@ discard block |
||
838 | 838 | $in_questionname, |
839 | 839 | $sessionId |
840 | 840 | ) { |
841 | - $res = $in_questionname; |
|
841 | + $res = $in_questionname; |
|
842 | 842 | $sessionIcon = null; |
843 | - if ($in_addA) { |
|
843 | + if ($in_addA) { |
|
844 | 844 | if (!empty($sessionId) && $sessionId != -1) { |
845 | 845 | $sessionIcon = ' '.Display::return_icon('star.png', get_lang('Session')); |
846 | 846 | } |
847 | - $res = "<a href='admin.php?".api_get_cidreq()."&editQuestion=$in_questionid&type=$in_questiontype&fromExercise=$in_fromex'>". |
|
847 | + $res = "<a href='admin.php?".api_get_cidreq()."&editQuestion=$in_questionid&type=$in_questiontype&fromExercise=$in_fromex'>". |
|
848 | 848 | $res.$sessionIcon. |
849 | 849 | "</a>"; |
850 | - } |
|
851 | - return $res; |
|
850 | + } |
|
851 | + return $res; |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -878,16 +878,16 @@ discard block |
||
878 | 878 | $in_session_id, |
879 | 879 | $in_exercise_id |
880 | 880 | ) { |
881 | - $res = ""; |
|
882 | - $getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id"; |
|
883 | - switch ($in_action) { |
|
884 | - case "delete" : |
|
885 | - $res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&delete=$in_questionid' onclick='return confirm_your_choice()'>"; |
|
886 | - $res .= Display::return_icon("delete.png", get_lang('Delete')); |
|
887 | - $res .= "</a>"; |
|
888 | - break; |
|
889 | - case "edit" : |
|
890 | - $res = get_a_tag_for_question( |
|
881 | + $res = ""; |
|
882 | + $getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id"; |
|
883 | + switch ($in_action) { |
|
884 | + case "delete" : |
|
885 | + $res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&delete=$in_questionid' onclick='return confirm_your_choice()'>"; |
|
886 | + $res .= Display::return_icon("delete.png", get_lang('Delete')); |
|
887 | + $res .= "</a>"; |
|
888 | + break; |
|
889 | + case "edit" : |
|
890 | + $res = get_a_tag_for_question( |
|
891 | 891 | 1, |
892 | 892 | $from_exercise, |
893 | 893 | $in_questionid, |
@@ -895,33 +895,33 @@ discard block |
||
895 | 895 | Display::return_icon("edit.png", get_lang('Modify')), |
896 | 896 | $in_session_id |
897 | 897 | ); |
898 | - break; |
|
899 | - case "add": |
|
900 | - // add if question is not already in test |
|
901 | - $myObjEx = new Exercise(); |
|
902 | - $myObjEx->read($from_exercise); |
|
903 | - if (!$myObjEx->isInList($in_questionid)) { |
|
904 | - $res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&recup=$in_questionid&fromExercise=$from_exercise'>"; |
|
905 | - $res .= Display::return_icon("view_more_stats.gif", get_lang('InsertALinkToThisQuestionInTheExercise')); |
|
906 | - $res .= "</a>"; |
|
898 | + break; |
|
899 | + case "add": |
|
900 | + // add if question is not already in test |
|
901 | + $myObjEx = new Exercise(); |
|
902 | + $myObjEx->read($from_exercise); |
|
903 | + if (!$myObjEx->isInList($in_questionid)) { |
|
904 | + $res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&recup=$in_questionid&fromExercise=$from_exercise'>"; |
|
905 | + $res .= Display::return_icon("view_more_stats.gif", get_lang('InsertALinkToThisQuestionInTheExercise')); |
|
906 | + $res .= "</a>"; |
|
907 | 907 | } else { |
908 | - $res = "-"; |
|
909 | - } |
|
910 | - unset($myObjEx); |
|
911 | - break; |
|
912 | - case "clone": |
|
908 | + $res = "-"; |
|
909 | + } |
|
910 | + unset($myObjEx); |
|
911 | + break; |
|
912 | + case "clone": |
|
913 | 913 | $url = api_get_self()."?".api_get_cidreq().$getParams."&question_copy=$in_questionid&course_id=$in_selected_course&fromExercise=$from_exercise"; |
914 | 914 | $res = Display::url( |
915 | 915 | Display::return_icon('cd.gif', get_lang('ReUseACopyInCurrentTest')), |
916 | 916 | $url |
917 | 917 | ); |
918 | - break; |
|
919 | - default : |
|
920 | - $res = $in_action; |
|
921 | - break; |
|
922 | - } |
|
918 | + break; |
|
919 | + default : |
|
920 | + $res = $in_action; |
|
921 | + break; |
|
922 | + } |
|
923 | 923 | |
924 | - return $res; |
|
924 | + return $res; |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -930,14 +930,14 @@ discard block |
||
930 | 930 | */ |
931 | 931 | function get_question_type_for_question($in_selectedcourse, $in_questionid) |
932 | 932 | { |
933 | - $myObjQuestion = Question::read($in_questionid, $in_selectedcourse); |
|
933 | + $myObjQuestion = Question::read($in_questionid, $in_selectedcourse); |
|
934 | 934 | $questionType = null; |
935 | 935 | if (!empty($myObjQuestion)) { |
936 | 936 | list($typeImg, $typeExpl) = $myObjQuestion->get_type_icon_html(); |
937 | 937 | $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), 32), array()); |
938 | 938 | unset($myObjQuestion); |
939 | 939 | } |
940 | - return $questionType; |
|
940 | + return $questionType; |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | /** |
@@ -946,6 +946,6 @@ discard block |
||
946 | 946 | */ |
947 | 947 | function get_question_categorie_for_question($in_courseid, $in_questionid) |
948 | 948 | { |
949 | - $cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid); |
|
950 | - return $cat; |
|
949 | + $cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid); |
|
950 | + return $cat; |
|
951 | 951 | } |
@@ -447,7 +447,7 @@ |
||
447 | 447 | $position = $row_max->max_position + 1; |
448 | 448 | |
449 | 449 | // Insert a new answer |
450 | - $params = [ |
|
450 | + $params = [ |
|
451 | 451 | 'c_id' => $course_id, |
452 | 452 | 'id' => $id, |
453 | 453 | 'question_id' => $question_id, |
@@ -28,10 +28,10 @@ |
||
28 | 28 | $content = ReadFileCont($full_file_path.$user_id.'.t.html'); |
29 | 29 | |
30 | 30 | if ($content == '') { |
31 | - $content = ReadFileCont($full_file_path); |
|
31 | + $content = ReadFileCont($full_file_path); |
|
32 | 32 | // Do not move this like: |
33 | - $mit = "function Finish(){"; |
|
34 | - $js_content = " |
|
33 | + $mit = "function Finish(){"; |
|
34 | + $js_content = " |
|
35 | 35 | // Code added - start |
36 | 36 | var SaveScoreVariable = 0; |
37 | 37 | function mySaveScore() { |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | 13 | |
14 | - /** |
|
15 | - * @param string $filename |
|
16 | - */ |
|
17 | - function mime_content_type($filename) { |
|
18 | - return DocumentManager::file_get_mime_type((string)$filename); |
|
19 | - } |
|
14 | + /** |
|
15 | + * @param string $filename |
|
16 | + */ |
|
17 | + function mime_content_type($filename) { |
|
18 | + return DocumentManager::file_get_mime_type((string)$filename); |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | case MCUA : |
35 | 35 | $answer = new AikenAnswerMultipleChoice($this->id); |
36 | - return $answer; |
|
36 | + return $answer; |
|
37 | 37 | default : |
38 | 38 | $answer = null; |
39 | 39 | break; |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | } |
43 | 43 | function createAnswersForm($form) |
44 | 44 | { |
45 | - return true; |
|
45 | + return true; |
|
46 | 46 | } |
47 | 47 | function processAnswersCreation($form) |
48 | 48 | { |
49 | - return true; |
|
49 | + return true; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 |
@@ -281,7 +281,7 @@ |
||
281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
284 | - //TAGS for chamilo >= 1.10 |
|
284 | + //TAGS for chamilo >= 1.10 |
|
285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -74,10 +74,10 @@ |
||
74 | 74 | Display::display_introduction_section( |
75 | 75 | TOOL_QUIZ, |
76 | 76 | array( |
77 | - 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/', |
|
77 | + 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/', |
|
78 | 78 | 'CreateDocumentDir' => '../../..'.api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/', |
79 | - 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/' |
|
80 | - ) |
|
79 | + 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/' |
|
80 | + ) |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | // Display Forms or dialog box(if needed) |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param Ims2Question $question Ims2Question object we want to export. |
36 | 36 | */ |
37 | - function ImsAssessmentItem($question) |
|
38 | - { |
|
37 | + function ImsAssessmentItem($question) |
|
38 | + { |
|
39 | 39 | $this->question = $question; |
40 | 40 | $this->answer = $this->question->setAnswer(); |
41 | 41 | $this->questionIdent = "QST_" . $question->id ; |
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Start the XML flow. |
|
46 | - * |
|
47 | - * This opens the <item> block, with correct attributes. |
|
48 | - * |
|
49 | - */ |
|
50 | - function start_item() |
|
51 | - { |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Start the XML flow. |
|
46 | + * |
|
47 | + * This opens the <item> block, with correct attributes. |
|
48 | + * |
|
49 | + */ |
|
50 | + function start_item() |
|
51 | + { |
|
52 | 52 | $string = '<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" |
53 | 53 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
54 | 54 | xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 imsqti_v2p1.xsd" |
@@ -56,55 +56,55 @@ discard block |
||
56 | 56 | title="'.htmlspecialchars(formatExerciseQtiTitle($this->question->selectTitle())).'">'."\n"; |
57 | 57 | |
58 | 58 | return $string; |
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * End the XML flow, closing the </item> tag. |
|
63 | - * |
|
64 | - */ |
|
65 | - function end_item() |
|
66 | - { |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * End the XML flow, closing the </item> tag. |
|
63 | + * |
|
64 | + */ |
|
65 | + function end_item() |
|
66 | + { |
|
67 | 67 | return "</assessmentItem>\n"; |
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Start the itemBody |
|
72 | - * |
|
73 | - */ |
|
74 | - function start_item_body() |
|
75 | - { |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Start the itemBody |
|
72 | + * |
|
73 | + */ |
|
74 | + function start_item_body() |
|
75 | + { |
|
76 | 76 | return ' <itemBody>' . "\n"; |
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * End the itemBody part. |
|
81 | - * |
|
82 | - */ |
|
83 | - function end_item_body() |
|
84 | - { |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * End the itemBody part. |
|
81 | + * |
|
82 | + */ |
|
83 | + function end_item_body() |
|
84 | + { |
|
85 | 85 | return " </itemBody>\n"; |
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * add the response processing template used. |
|
90 | - * |
|
91 | - */ |
|
92 | - |
|
93 | - function add_response_processing() |
|
94 | - { |
|
95 | - return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Export the question as an IMS/QTI Item. |
|
100 | - * |
|
101 | - * This is a default behaviour, some classes may want to override this. |
|
102 | - * |
|
103 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | - * @return string string, the XML flow for an Item. |
|
105 | - */ |
|
106 | - function export($standalone = false) |
|
107 | - { |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * add the response processing template used. |
|
90 | + * |
|
91 | + */ |
|
92 | + |
|
93 | + function add_response_processing() |
|
94 | + { |
|
95 | + return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Export the question as an IMS/QTI Item. |
|
100 | + * |
|
101 | + * This is a default behaviour, some classes may want to override this. |
|
102 | + * |
|
103 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | + * @return string string, the XML flow for an Item. |
|
105 | + */ |
|
106 | + function export($standalone = false) |
|
107 | + { |
|
108 | 108 | $head = $foot = ""; |
109 | 109 | |
110 | 110 | if ($standalone) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | .$foot; |
132 | 132 | |
133 | 133 | return $res; |
134 | - } |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | function export_presentation() |
194 | 194 | { |
195 | 195 | $out = "<presentation_material><flow_mat><material>\n" |
196 | - . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | - . "</material></flow_mat></presentation_material>\n"; |
|
196 | + . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | + . "</material></flow_mat></presentation_material>\n"; |
|
198 | 198 | return $out; |
199 | 199 | } |
200 | 200 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | $out = ''; |
209 | 209 | if ($n = $this->exercise->getShuffle()) { |
210 | 210 | $out.= "<selection_ordering>" |
211 | - . " <selection>\n" |
|
212 | - . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | - . " </selection>\n" |
|
214 | - . ' <order order_type="Random" />' |
|
215 | - . "\n</selection_ordering>\n"; |
|
211 | + . " <selection>\n" |
|
212 | + . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | + . " </selection>\n" |
|
214 | + . ' <order order_type="Random" />' |
|
215 | + . "\n</selection_ordering>\n"; |
|
216 | 216 | } else { |
217 | 217 | $out.= '<selection_ordering sequence_type="Normal">' . "\n" |
218 | - . " <selection />\n" |
|
219 | - . "</selection_ordering>\n"; |
|
218 | + . " <selection />\n" |
|
219 | + . "</selection_ordering>\n"; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | return $out; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | $out = ""; |
232 | 232 | foreach ($this->exercise->selectQuestionList() as $q) { |
233 | - $out .= export_question_qti($q, false); |
|
233 | + $out .= export_question_qti($q, false); |
|
234 | 234 | } |
235 | 235 | return $out; |
236 | 236 | } |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | $head = $foot = ""; |
248 | 248 | if ($standalone) { |
249 | 249 | $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n" |
250 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | - . "<questestinterop>\n"; |
|
250 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | + . "<questestinterop>\n"; |
|
252 | 252 | $foot = "</questestinterop>\n"; |
253 | 253 | } |
254 | 254 | $out = $head |
255 | - . $this->start_section() |
|
256 | - . $this->export_duration() |
|
257 | - . $this->export_presentation() |
|
258 | - . $this->export_ordering() |
|
259 | - . $this->export_questions() |
|
260 | - . $this->end_section() |
|
261 | - . $foot; |
|
255 | + . $this->start_section() |
|
256 | + . $this->export_duration() |
|
257 | + . $this->export_presentation() |
|
258 | + . $this->export_ordering() |
|
259 | + . $this->export_questions() |
|
260 | + . $this->end_section() |
|
261 | + . $foot; |
|
262 | 262 | |
263 | 263 | return $out; |
264 | 264 | } |
@@ -304,97 +304,97 @@ discard block |
||
304 | 304 | * @param $question The Question object we want to export. |
305 | 305 | * @author Anamd Tihon |
306 | 306 | */ |
307 | - function ImsItem($question) |
|
308 | - { |
|
307 | + function ImsItem($question) |
|
308 | + { |
|
309 | 309 | $this->question = $question; |
310 | 310 | $this->answer = $question->answer; |
311 | 311 | $this->questionIdent = "QST_" . $question->selectId() ; |
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Start the XML flow. |
|
316 | - * |
|
317 | - * This opens the <item> block, with correct attributes. |
|
318 | - * |
|
319 | - * @author Amand Tihon <[email protected]> |
|
320 | - */ |
|
321 | - function start_item() |
|
322 | - { |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Start the XML flow. |
|
316 | + * |
|
317 | + * This opens the <item> block, with correct attributes. |
|
318 | + * |
|
319 | + * @author Amand Tihon <[email protected]> |
|
320 | + */ |
|
321 | + function start_item() |
|
322 | + { |
|
323 | 323 | return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n"; |
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * End the XML flow, closing the </item> tag. |
|
328 | - * |
|
329 | - * @author Amand Tihon <[email protected]> |
|
330 | - */ |
|
331 | - function end_item() |
|
332 | - { |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * End the XML flow, closing the </item> tag. |
|
328 | + * |
|
329 | + * @author Amand Tihon <[email protected]> |
|
330 | + */ |
|
331 | + function end_item() |
|
332 | + { |
|
333 | 333 | return "</item>\n"; |
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Create the opening, with the question itself. |
|
338 | - * |
|
339 | - * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | - * In between, the export_responses from the subclass should have been called. |
|
341 | - * |
|
342 | - * @author Amand Tihon <[email protected]> |
|
343 | - */ |
|
344 | - function start_presentation() |
|
345 | - { |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Create the opening, with the question itself. |
|
338 | + * |
|
339 | + * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | + * In between, the export_responses from the subclass should have been called. |
|
341 | + * |
|
342 | + * @author Amand Tihon <[email protected]> |
|
343 | + */ |
|
344 | + function start_presentation() |
|
345 | + { |
|
346 | 346 | return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
347 | - . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * End the </presentation> part, opened by export_header. |
|
352 | - * |
|
353 | - * @author Amand Tihon <[email protected]> |
|
354 | - */ |
|
355 | - function end_presentation() |
|
356 | - { |
|
347 | + . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * End the </presentation> part, opened by export_header. |
|
352 | + * |
|
353 | + * @author Amand Tihon <[email protected]> |
|
354 | + */ |
|
355 | + function end_presentation() |
|
356 | + { |
|
357 | 357 | return "</flow></presentation>\n"; |
358 | - } |
|
359 | - |
|
360 | - /** |
|
361 | - * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | - * |
|
363 | - * @author Amand Tihon <[email protected]> |
|
364 | - */ |
|
365 | - function start_processing() |
|
366 | - { |
|
358 | + } |
|
359 | + |
|
360 | + /** |
|
361 | + * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | + * |
|
363 | + * @author Amand Tihon <[email protected]> |
|
364 | + */ |
|
365 | + function start_processing() |
|
366 | + { |
|
367 | 367 | return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * End the response processing part. |
|
372 | - * |
|
373 | - * @author Amand Tihon <[email protected]> |
|
374 | - */ |
|
375 | - function end_processing() |
|
376 | - { |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * End the response processing part. |
|
372 | + * |
|
373 | + * @author Amand Tihon <[email protected]> |
|
374 | + */ |
|
375 | + function end_processing() |
|
376 | + { |
|
377 | 377 | return "</resprocessing>\n"; |
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Export the question as an IMS/QTI Item. |
|
382 | - * |
|
383 | - * This is a default behaviour, some classes may want to override this. |
|
384 | - * |
|
385 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | - * @return string string, the XML flow for an Item. |
|
387 | - * @author Amand Tihon <[email protected]> |
|
388 | - */ |
|
389 | - function export($standalone = False) |
|
390 | - { |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Export the question as an IMS/QTI Item. |
|
382 | + * |
|
383 | + * This is a default behaviour, some classes may want to override this. |
|
384 | + * |
|
385 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | + * @return string string, the XML flow for an Item. |
|
387 | + * @author Amand Tihon <[email protected]> |
|
388 | + */ |
|
389 | + function export($standalone = False) |
|
390 | + { |
|
391 | 391 | global $charset; |
392 | 392 | $head = $foot = ""; |
393 | 393 | |
394 | 394 | if ($standalone) { |
395 | 395 | $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n" |
396 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | - . "<questestinterop>\n"; |
|
396 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | + . "<questestinterop>\n"; |
|
398 | 398 | $foot = "</questestinterop>\n"; |
399 | 399 | } |
400 | 400 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | . $this->answer->imsExportFeedback($this->questionIdent) |
410 | 410 | . $this->end_item() |
411 | 411 | . $foot; |
412 | - } |
|
412 | + } |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | $question->type = $qst->type; |
448 | 448 | $question->question = $qst->question; |
449 | 449 | $question->description = $qst->description; |
450 | - $question->weighting=$qst->weighting; |
|
451 | - $question->position=$qst->position; |
|
452 | - $question->picture=$qst->picture; |
|
450 | + $question->weighting=$qst->weighting; |
|
451 | + $question->position=$qst->position; |
|
452 | + $question->picture=$qst->picture; |
|
453 | 453 | $ims = new ImsAssessmentItem($question); |
454 | 454 | |
455 | 455 | return $ims->export($standalone); |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | |
56 | 56 | function createAnswersForm($form) |
57 | 57 | { |
58 | - return true; |
|
58 | + return true; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | function processAnswersCreation($form) |
62 | 62 | { |
63 | - return true; |
|
63 | + return true; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | public function imsExportResponses($questionIdent, $questionStatment) |
77 | 77 | { |
78 | 78 | // @todo getAnswersList() converts the answers using api_html_entity_decode() |
79 | - $this->answerList = $this->getAnswersList(true); |
|
79 | + $this->answerList = $this->getAnswersList(true); |
|
80 | 80 | $out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
81 | 81 | $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n"; |
82 | - if (is_array($this->answerList)) { |
|
83 | - foreach ($this->answerList as $current_answer) { |
|
84 | - $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
82 | + if (is_array($this->answerList)) { |
|
83 | + foreach ($this->answerList as $current_answer) { |
|
84 | + $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
85 | 85 | <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>'; |
86 | - if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | - $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
86 | + if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | + $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
88 | 88 | <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]> |
89 | 89 | </feedbackInline>'; |
90 | - } |
|
91 | - $out .= '</simpleChoice>'. "\n"; |
|
92 | - } |
|
93 | - } |
|
90 | + } |
|
91 | + $out .= '</simpleChoice>'. "\n"; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | $out .= ' </choiceInteraction>'. "\n"; |
95 | 95 | |
96 | 96 | return $out; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function imsExportResponsesDeclaration($questionIdent) |
104 | 104 | { |
105 | - $this->answerList = $this->getAnswersList(true); |
|
106 | - $type = $this->getQuestionType(); |
|
105 | + $this->answerList = $this->getAnswersList(true); |
|
106 | + $type = $this->getQuestionType(); |
|
107 | 107 | if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
108 | 108 | |
109 | 109 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | // Match the correct answers. |
112 | 112 | |
113 | 113 | $out .= ' <correctResponse>'. "\n"; |
114 | - if (is_array($this->answerList)) { |
|
115 | - foreach($this->answerList as $current_answer) { |
|
116 | - if ($current_answer['correct']) { |
|
117 | - $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
114 | + if (is_array($this->answerList)) { |
|
115 | + foreach($this->answerList as $current_answer) { |
|
116 | + if ($current_answer['correct']) { |
|
117 | + $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $out .= ' </correctResponse>'. "\n"; |
122 | 122 | |
123 | 123 | //Add the grading |
124 | 124 | |
125 | 125 | $out .= ' <mapping>'. "\n"; |
126 | - if (is_array($this->answerList)) { |
|
127 | - foreach($this->answerList as $current_answer) { |
|
128 | - if (isset($current_answer['grade'])) { |
|
129 | - $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
126 | + if (is_array($this->answerList)) { |
|
127 | + foreach($this->answerList as $current_answer) { |
|
128 | + if (isset($current_answer['grade'])) { |
|
129 | + $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | $out .= ' </mapping>'. "\n"; |
134 | 134 | $out .= ' </responseDeclaration>'. "\n"; |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function imsExportResponses($questionIdent, $questionStatment) |
152 | 152 | { |
153 | - $this->answerList = $this->getAnswersList(true); |
|
153 | + $this->answerList = $this->getAnswersList(true); |
|
154 | 154 | $text = ''; |
155 | 155 | $text .= $this->answerText; |
156 | 156 | if (is_array($this->answerList)) { |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function imsExportResponsesDeclaration($questionIdent) |
173 | 173 | { |
174 | - $this->answerList = $this->getAnswersList(true); |
|
175 | - $this->gradeList = $this->getGradesList(); |
|
174 | + $this->answerList = $this->getAnswersList(true); |
|
175 | + $this->gradeList = $this->getGradesList(); |
|
176 | 176 | $out = ''; |
177 | - if (is_array($this->answerList)) { |
|
178 | - foreach ($this->answerList as $answer) { |
|
179 | - $answerKey = $answer['id']; |
|
180 | - $answer = $answer['answer']; |
|
181 | - $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | - $out .= ' <correctResponse>'. "\n"; |
|
177 | + if (is_array($this->answerList)) { |
|
178 | + foreach ($this->answerList as $answer) { |
|
179 | + $answerKey = $answer['id']; |
|
180 | + $answer = $answer['answer']; |
|
181 | + $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | + $out .= ' <correctResponse>'. "\n"; |
|
183 | 183 | $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n"; |
184 | - $out .= ' </correctResponse>'. "\n"; |
|
185 | - if (isset($this->gradeList[$answerKey])) { |
|
186 | - $out .= ' <mapping>'. "\n"; |
|
187 | - $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | - $out .= ' </mapping>'. "\n"; |
|
189 | - } |
|
190 | - |
|
191 | - $out .= ' </responseDeclaration>'. "\n"; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $out; |
|
184 | + $out .= ' </correctResponse>'. "\n"; |
|
185 | + if (isset($this->gradeList[$answerKey])) { |
|
186 | + $out .= ' <mapping>'. "\n"; |
|
187 | + $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | + $out .= ' </mapping>'. "\n"; |
|
189 | + } |
|
190 | + |
|
191 | + $out .= ' </responseDeclaration>'. "\n"; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $out; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function imsExportResponses($questionIdent, $questionStatment) |
209 | 209 | { |
210 | - $this->answerList = $this->getAnswersList(true); |
|
211 | - $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
210 | + $this->answerList = $this->getAnswersList(true); |
|
211 | + $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
212 | 212 | |
213 | 213 | $out = ""; |
214 | 214 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | //add left column |
219 | 219 | |
220 | 220 | $out .= ' <simpleMatchSet>'. "\n"; |
221 | - if (is_array($this->leftList)) { |
|
222 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | - $out .= ' |
|
221 | + if (is_array($this->leftList)) { |
|
222 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | + $out .= ' |
|
224 | 224 | <simpleAssociableChoice identifier="left_'.$leftKey.'" > |
225 | 225 | <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]> |
226 | 226 | </simpleAssociableChoice>'. "\n"; |
227 | - } |
|
228 | - } |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | $out .= ' </simpleMatchSet>'. "\n"; |
231 | 231 | |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | |
236 | 236 | $i = 0; |
237 | 237 | |
238 | - if (is_array($this->rightList)) { |
|
239 | - foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | - $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
238 | + if (is_array($this->rightList)) { |
|
239 | + foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | + $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
241 | 241 | <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]> |
242 | 242 | </simpleAssociableChoice>'. "\n"; |
243 | - $i++; |
|
244 | - } |
|
245 | - } |
|
243 | + $i++; |
|
244 | + } |
|
245 | + } |
|
246 | 246 | $out .= ' </simpleMatchSet>'. "\n"; |
247 | 247 | $out .= '</matchInteraction>'. "\n"; |
248 | 248 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function imsExportResponsesDeclaration($questionIdent) |
256 | 256 | { |
257 | - $this->answerList = $this->getAnswersList(true); |
|
257 | + $this->answerList = $this->getAnswersList(true); |
|
258 | 258 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n"; |
259 | 259 | $out .= ' <correctResponse>' . "\n"; |
260 | 260 | |
261 | 261 | $gradeArray = array(); |
262 | - if (is_array($this->leftList)) { |
|
263 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | - $i=0; |
|
265 | - foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | - if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | - $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | - |
|
269 | - $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | - } |
|
271 | - $i++; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
262 | + if (is_array($this->leftList)) { |
|
263 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | + $i=0; |
|
265 | + foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | + if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | + $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | + |
|
269 | + $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | + } |
|
271 | + $i++; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | $out .= ' </correctResponse>'. "\n"; |
276 | 276 | $out .= ' <mapping>' . "\n"; |
277 | 277 | if (is_array($gradeArray)) { |
278 | - foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | - $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | - } |
|
278 | + foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | + $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | $out .= ' </mapping>' . "\n"; |
283 | 283 | $out .= ' </responseDeclaration>'. "\n"; |
@@ -298,49 +298,49 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
300 | 300 | { |
301 | - $this->answerList = $this->getAnswersList(true); |
|
302 | - $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | - $mimetype = mime_content_type($questionMedia); |
|
304 | - if(empty($mimetype)){ |
|
305 | - $mimetype = 'image/jpeg'; |
|
306 | - } |
|
307 | - |
|
308 | - $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | - $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | - $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | - $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
301 | + $this->answerList = $this->getAnswersList(true); |
|
302 | + $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | + $mimetype = mime_content_type($questionMedia); |
|
304 | + if(empty($mimetype)){ |
|
305 | + $mimetype = 'image/jpeg'; |
|
306 | + } |
|
307 | + |
|
308 | + $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | + $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | + $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | + $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
312 | 312 | if (is_array($this->answerList)) { |
313 | - foreach ($this->answerList as $key=>$answer) { |
|
314 | - $key = $answer['id']; |
|
315 | - $answerTxt = $answer['answer']; |
|
316 | - $len = api_strlen($answerTxt); |
|
317 | - //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | - $coords = ''; |
|
319 | - $type = 'default'; |
|
320 | - switch($answer['hotspot_type']){ |
|
321 | - case 'square': |
|
322 | - $type = 'rect'; |
|
323 | - $res = array(); |
|
324 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | - $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | - break; |
|
327 | - case 'circle': |
|
328 | - $type = 'circle'; |
|
329 | - $res = array(); |
|
330 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | - $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | - break; |
|
333 | - case 'poly': |
|
334 | - $type = 'poly'; |
|
335 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | - break; |
|
337 | - case 'delineation' : |
|
338 | - $type = 'delineation'; |
|
339 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | - break; |
|
341 | - } |
|
342 | - $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | - } |
|
313 | + foreach ($this->answerList as $key=>$answer) { |
|
314 | + $key = $answer['id']; |
|
315 | + $answerTxt = $answer['answer']; |
|
316 | + $len = api_strlen($answerTxt); |
|
317 | + //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | + $coords = ''; |
|
319 | + $type = 'default'; |
|
320 | + switch($answer['hotspot_type']){ |
|
321 | + case 'square': |
|
322 | + $type = 'rect'; |
|
323 | + $res = array(); |
|
324 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | + $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | + break; |
|
327 | + case 'circle': |
|
328 | + $type = 'circle'; |
|
329 | + $res = array(); |
|
330 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | + $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | + break; |
|
333 | + case 'poly': |
|
334 | + $type = 'poly'; |
|
335 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | + break; |
|
337 | + case 'delineation' : |
|
338 | + $type = 'delineation'; |
|
339 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | + break; |
|
341 | + } |
|
342 | + $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | + } |
|
344 | 344 | } |
345 | 345 | $text .= ' </graphicOrderInteraction>'."\n"; |
346 | 346 | $out = $text; |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function imsExportResponsesDeclaration($questionIdent) |
355 | 355 | { |
356 | - $this->answerList = $this->getAnswersList(true); |
|
357 | - $this->gradeList = $this->getGradesList(); |
|
356 | + $this->answerList = $this->getAnswersList(true); |
|
357 | + $this->gradeList = $this->getGradesList(); |
|
358 | 358 | $out = ''; |
359 | 359 | $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n"; |
360 | 360 | $out .= ' <correctResponse>'. "\n"; |
361 | 361 | |
362 | - if (is_array($this->answerList)) { |
|
363 | - foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | - $answerKey = $answer['id']; |
|
365 | - $answer = $answer['answer']; |
|
366 | - $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | - } |
|
368 | - } |
|
362 | + if (is_array($this->answerList)) { |
|
363 | + foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | + $answerKey = $answer['id']; |
|
365 | + $answer = $answer['answer']; |
|
366 | + $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | + } |
|
368 | + } |
|
369 | 369 | $out .= ' </correctResponse>'. "\n"; |
370 | 370 | $out .= ' </responseDeclaration>'. "\n"; |
371 | 371 | |
372 | - return $out; |
|
372 | + return $out; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * Export the question part as a matrix-choice, with only one possible answer per line. |
385 | 385 | */ |
386 | 386 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
387 | - { |
|
388 | - return ''; |
|
389 | - } |
|
387 | + { |
|
388 | + return ''; |
|
389 | + } |
|
390 | 390 | /** |
391 | 391 | * |
392 | 392 | */ |
393 | 393 | public function imsExportResponsesDeclaration($questionIdent) |
394 | 394 | { |
395 | - return ''; |
|
395 | + return ''; |
|
396 | 396 | } |
397 | 397 | } |