4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
46 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php";
50 $this->
object->loadFromDb($id);
54 $this->clearAnswersOnWritingPostDataEnabled =
false;
82 $this->
object->saveToDb();
94 $this->
object->setOrderingType(
OQ_TERMS);
96 $this->
object->saveToDb();
110 $this->
object->saveToDb();
119 $this->
object->saveToDb();
127 $position = key(
$_POST[
"cmd"][
"addanswers"]);
128 $this->
object->addAnswer(
"", $position+1);
135 $position = key(
$_POST[
'cmd'][
'removeimageanswers']);
137 $this->
object->removeAnswerImage($position);
144 $position = key(
$_POST[
"cmd"][
"removeanswers"]);
145 $this->
object->deleteAnswer($position);
152 $position = key(
$_POST[
"cmd"][
"upanswers"]);
153 $this->
object->moveAnswerUp($position);
160 $position = key(
$_POST[
"cmd"][
"downanswers"]);
161 $this->
object->moveAnswerDown($position);
170 include_once
"./Modules/TestQuestionPool/classes/class.ilImageWizardInputGUI.php";
173 $answers->setQuestionObject($this->
object);
174 $answers->setInfo($this->lng->txt(
'ordering_answer_sequence_info'));
175 $answers->setAllowMove(TRUE);
176 $answervalues = array();
177 foreach ($this->object->getAnswers() as $index => $answervalue)
179 $answervalues[$index] = $answervalue->getAnswertext();
181 $answers->setValues($answervalues);
187 $this->lng->loadLanguageModule(
'form');
191 if( !$inp->checkInput() )
193 $this->uploadAlert = $inp->getAlert();
203 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"] );
204 $this->
object->setElementHeight(
$_POST[
"element_height"] );
206 $this->
object->setPoints(
$_POST[
"points"]);
211 $ordering_type = $this->
object->getOrderingType();
213 $this->
object->flushAnswers();
222 $answers =
$_POST[
"answers"];
223 if (is_array( $answers ))
226 $answers_ordering =
$_POST[
'answers_ordering__default'];
227 $new_hierarchy = json_decode( $answers_ordering );
231 if (!is_array( $new_hierarchy ))
242 if(is_array($answers[
'imagename']))
244 foreach($answers[
'imagename'] as $index => $answer)
250 $this->
object->addAnswer($answer, -1, $this->leveled_ordering[$counter]);
256 foreach($answers as $index => $answer)
262 $this->
object->addAnswer($answer, -1, $this->leveled_ordering[$counter]);
270 if (is_array(
$_POST[
'answers'][
'count'] ))
272 foreach (array_keys(
$_POST[
'answers'][
'count'] ) as $index)
276 $this->
object->addAnswer(
"" );
280 $picturefile =
$_POST[
'answers'][
'imagename'][$index];
281 $file_org_name = $_FILES[
'answers'][
'name'][
'image'][$index];
282 $file_temp_name = $_FILES[
'answers'][
'tmp_name'][
'image'][$index];
285 if (strlen( $file_temp_name ))
288 $suffix = strtolower( array_pop( explode(
".", $file_org_name ) ) );
289 if (in_array( $suffix, array(
"jpg",
"jpeg",
"png",
"gif" ) ))
292 $filename = $this->
object->createNewImageFileName( $file_org_name );
294 if ($this->object->setImageFile( $file_temp_name,
$filename, $picturefile ))
301 $this->
object->addAnswer( $picturefile );
304 else if(is_array(
$_POST[
'answers']))
306 foreach(
$_POST[
'answers'] as $random_id => $text_value)
308 $this->
object->addAnswer( $text_value );
316 $orderingtype = $this->
object->getOrderingType();
318 if (count($this->object->getAnswers()) == 0)
320 $this->
object->addAnswer();
324 $header->setTitle($this->lng->txt(
'oq_header_ordering_elements'));
330 if ($this->uploadAlert !== null)
332 $answerImageUpload->setAlert( $this->uploadAlert );
334 $form->
addItem( $answerImageUpload );
338 require_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
341 $answers->setObjAnswersArray( $this->object->getAnswers() );
345 $answers->setImagePath( $this->object->getImagePath() );
346 $answers->setImagePathWeb( $this->object->getImagePathWeb() );
347 $answers->setThumbPrefix( $this->object->getThumbPrefix() );
349 $answers->setInfo( $this->lng->txt(
'ordering_answer_sequence_info' ) );
355 $answervalues = array();
356 foreach ($this->object->getAnswers() as $index => $answervalue)
358 $answervalues[$index] = $answervalue->getAnswertext();
360 ksort( $answervalues );
361 $answers->setValues( $answervalues );
362 $answers->setAllowMove( TRUE );
363 $answers->setRequired( TRUE );
365 $answers->setInfo( $this->lng->txt(
'ordering_answer_sequence_info' ) );
374 $orderingtype = $this->
object->getOrderingType();
382 if (!$this->object->getSelfAssessmentEditingMode())
384 $element_height =
new ilNumberInputGUI($this->lng->txt(
"element_height" ),
"element_height");
385 $element_height->
setValue( $this->object->getElementHeight() );
386 $element_height->setRequired(
false );
387 $element_height->setMaxLength( 6 );
388 $element_height->setMinValue( 20 );
389 $element_height->setSize( 6 );
390 $element_height->setInfo( $this->lng->txt(
"element_height_info" ) );
391 $form->
addItem( $element_height );
396 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry" ),
"thumb_geometry");
397 $geometry->
setValue( $this->object->getThumbGeometry() );
398 $geometry->setRequired(
true );
399 $geometry->setMaxLength( 6 );
400 $geometry->setMinValue( 20 );
401 $geometry->setSize( 6 );
402 $geometry->setInfo( $this->lng->txt(
"thumb_geometry_info" ) );
409 $points->setValue( $this->object->getPoints() );
410 $points->setRequired( TRUE );
411 $points->setSize( 3 );
412 $points->setMinValue( 0 );
413 $points->setMinvalueShouldBeGreater(
true );
421 return $this->ctrl->getCmd() ==
'uploadanswers';
434 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
437 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
456 $orderingtype = $this->
object->getOrderingType();
458 require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php";
460 $form->setFormAction($this->ctrl->getFormAction($this));
462 $form->setMultipart(($orderingtype ==
OQ_PICTURES) ? TRUE : FALSE);
463 $form->setTableWidth(
"100%");
464 $form->setId(
"ordering");
470 if (
true || !$this->object->getSelfAssessmentEditingMode())
480 $form->setValuesByPost();
481 $errors = !$form->checkInput();
482 $form->setValuesByPost();
483 if (
$errors) $checkonly =
false;
486 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
492 switch( $this->object->getOrderingType() )
496 $form->
addCommandButton(
"changeToPictures", $this->lng->txt(
"oq_btn_use_order_pictures"));
497 $form->
addCommandButton(
"orderNestedTerms", $this->lng->txt(
"oq_btn_nest_terms"));
502 $form->
addCommandButton(
"changeToText", $this->lng->txt(
"oq_btn_use_order_terms"));
503 $form->
addCommandButton(
"orderNestedPictures", $this->lng->txt(
"oq_btn_nest_pictures"));
508 $form->
addCommandButton(
"changeToPictures", $this->lng->txt(
"oq_btn_use_order_pictures"));
509 $form->
addCommandButton(
"changeToText", $this->lng->txt(
"oq_btn_define_terms"));
514 $form->
addCommandButton(
"changeToText", $this->lng->txt(
"oq_btn_use_order_terms"));
515 $form->
addCommandButton(
"changeToPictures", $this->lng->txt(
"oq_btn_define_pictures"));
538 $graphicalOutput = FALSE,
539 $result_output = FALSE,
540 $show_question_only = TRUE,
541 $show_feedback = FALSE,
542 $show_correct_solution = FALSE,
543 $show_manual_scoring = FALSE,
544 $show_question_text = TRUE
550 $keys = array_keys($this->object->answers);
553 include_once
"./Services/UICore/classes/class.ilTemplate.php";
554 $template =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
556 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
559 $solutions = array();
561 if (($active_id > 0) && (!$show_correct_solution))
563 $solutions = $this->
object->getSolutionValues($active_id,
$pass);
564 $user_order = array();
565 foreach ($solutions as $solution)
567 if(strchr( $solution[
'value2'],
':') ==
true)
569 $current_solution = explode(
':', $solution[
'value2']);
571 $user_order[$solution[
"value1"]][
'index'] = $solution[
"value1"];
572 $user_order[$solution[
"value1"]][
'random_id'] = $current_solution[0];
573 $user_order[$solution[
"value1"]][
'depth'] = $current_solution[1];
575 $answer_text = $this->
object->lookupAnswerTextByRandomId($current_solution[0]);
576 $user_order[$solution[
"value1"]][
'answertext'] = $answer_text;
579 foreach ($this->object->answers as $k => $a)
582 if ($k == $user_order[$k][
'index']
583 && $a->getOrderingDepth() == $user_order[$k][
'depth']
584 && $a->getAnswerText() == $user_order[$k][
'answertext'])
589 $user_order[$k][
'ok'] =
$ok;
592 $solution_output = $user_order;
596 foreach ($this->object->answers as $index => $answer)
599 $expected_solution[$index][
'index'] = $index;
600 $expected_solution[$index][
'random_id'] = $answer->getRandomId();
601 $expected_solution[$index][
'depth'] = $answer->getOrderingDepth();
604 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
608 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
611 $solution_output = $expected_solution;
614 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
615 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
617 $answers_gui =
new ilNestedOrderingGUI($this->lng->txt(
"answers"),
"answers", $graphicalOutput);
619 $no_js_for_cmds = array(
'outParticipantsPassDetails',
'outCorrectSolution',
'showManScoringParticipantScreen');
622 if(in_array($this->ctrl->getCmd(), $no_js_for_cmds))
624 $answers_gui->setPerformJavascript(
false);
628 $answers_gui->setPerformJavascript(
true);
631 $answers_gui->setOrderingType($this->object->getOrderingType());
635 $answers_gui->setImagePath($this->object->getImagePath());
636 $answers_gui->setImagePathWeb($this->object->getImagePathWeb());
637 $answers_gui->setThumbPrefix($this->object->getThumbPrefix());
640 $solution_html = $answers_gui->getSolutionHTML($solution_output);
642 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
644 $questiontext = $this->
object->getQuestion();
645 if ($show_question_text==
true)
647 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
649 $questionoutput = $template->get();
655 $feedback .= strlen($fb) ? $fb :
'';
658 $feedback .= strlen($fb) ? $fb :
'';
660 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
662 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
664 $solutionoutput = $solutiontemplate->get();
665 if (!$show_question_only)
673 $keys = array_keys($this->object->answers);
676 include_once
"./Services/UICore/classes/class.ilTemplate.php";
677 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
678 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
681 $solutions = array();
682 if (($active_id > 0) && (!$show_correct_solution))
684 $solutions = $this->
object->getSolutionValues($active_id,
$pass);
688 foreach ($this->object->answers as $index => $answer)
690 array_push($solutions, array(
"value1" => $index,
"value2" => $index+1));
693 foreach ($keys as $idx)
695 if (!$show_correct_solution)
697 foreach($solutions as $index => $item)
699 if($item[
'value2'] == $idx+1)
701 $answer = $this->
object->answers[$item[
'value1']];
707 $answer = $this->
object->answers[$idx];
713 if (($active_id > 0) && (!$show_correct_solution))
715 if ($graphicalOutput)
718 foreach ($solutions as $solution)
720 $sol[$solution[
"value1"]] = $solution[
"value2"];
723 $sol = array_keys($sol);
725 foreach ($this->object->answers as $k => $a)
730 $ans = array_keys($ans);
732 foreach ($ans as $arr_idx => $ans_idx)
734 if ($ans_idx == $idx)
736 if ($ans_idx == $sol[$arr_idx])
745 $template->setCurrentBlock(
"icon_ok");
747 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
748 $template->parseCurrentBlock();
752 $template->setCurrentBlock(
"icon_ok");
754 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
755 $template->parseCurrentBlock();
759 if ($this->object->getOrderingType() ==
OQ_PICTURES)
761 $template->setCurrentBlock(
"ordering_row_standard_pictures");
762 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
763 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
764 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
765 $template->setVariable(
"THUMB_HREF", $thumbweb);
766 list($width, $height, $type, $attr) = getimagesize($thumb);
767 $template->setVariable(
"ATTR", $attr);
768 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
769 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"enlarge"));
770 $template->parseCurrentBlock();
774 $template->setCurrentBlock(
"ordering_row_standard_text");
775 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
776 $template->parseCurrentBlock();
778 $template->setCurrentBlock(
"ordering_row_standard");
781 $answer = $this->
object->answers[$idx];
782 $points = $answer->getPoints();
783 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
784 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
786 foreach ($solutions as $solution)
788 if (strcmp($solution[
"value1"], $idx) == 0)
790 $template->setVariable(
"ANSWER_ORDER", $solution[
"value2"]);
793 $template->parseCurrentBlock();
795 $questiontext = $this->
object->getQuestion();
796 if ($show_question_text==
true)
798 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
800 $questionoutput = $template->get();
802 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
803 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
805 $solutionoutput = $solutiontemplate->get();
806 if (!$show_question_only)
813 return $solutionoutput;
816 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
823 include_once
"./Services/UICore/classes/class.ilTemplate.php";
824 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
832 $answerArray = array();
833 $shuffleAnswers =
false;
835 foreach((array)$this->
getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
837 list($randomId, $depth) = explode(
':', $val2);
840 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
843 $answerArray[] = $answ;
845 $jssolutions[$val2] = $val1;
850 foreach((array)$this->
getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
852 $jssolutions[$val2] = $val1;
858 $answerArray = $this->
object->answers;
859 $shuffleAnswers =
true;
866 $keys = array_keys($this->object->answers);
874 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
875 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
878 $answers->setObjAnswersArray($answerArray, $shuffleAnswers);
882 $answers->setImagePath($this->object->getImagePath());
883 $answers->setImagePathWeb($this->object->getImagePathWeb());
884 $answers->setThumbPrefix($this->object->getThumbPrefix());
887 $template->setCurrentBlock(
'nested_ordering_output');
888 $template->setVariable(
'NESTED_ORDERING',$answers->getHtml());
889 $template->parseCurrentBlock();
890 $questiontext = $this->
object->getQuestion();
891 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
892 $questionoutput = $template->get();
893 if (!$show_question_only)
898 return $questionoutput;
903 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/ordering.js");
905 $template->setCurrentBlock(
'form_submit_register');
906 $template->touchBlock(
'form_submit_register');
907 $template->parseCurrentBlock();
909 if(count($jssolutions))
912 $initial_order = array();
913 foreach($jssolutions as $key => $value)
915 if(is_object($this->object->getAnswer($value)))
917 $initial_order[] =
'id_' . $this->
object->getAnswer($value)->getRandomID();
921 $template->setVariable(
'INITIAL_ORDER', json_encode($initial_order));
925 $template->setVariable(
'INITIAL_ORDER', json_encode(array()));
928 foreach ($keys as $idx)
930 $answer = $this->
object->answers[$idx];
931 if ($this->object->getOrderingType() ==
OQ_PICTURES)
933 $template->setCurrentBlock(
"ordering_row_javascript_pictures");
934 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
935 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
936 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
937 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
938 $template->setVariable(
"THUMB_HREF", $thumbweb);
939 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
940 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"thumbnail"));
942 $template->setVariable(
"ENLARGE_ALT", $this->lng->txt(
"enlarge"));
943 $template->setVariable(
"ENLARGE_TITLE", $this->lng->txt(
"enlarge"));
944 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
945 $template->parseCurrentBlock();
949 $template->setCurrentBlock(
"ordering_row_javascript_text");
950 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
951 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
952 $template->parseCurrentBlock();
955 if ($this->object->getOrderingType() ==
OQ_PICTURES)
957 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_pictures"));
961 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_definitions"));
964 $questiontext = $this->
object->getQuestion();
965 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
966 $template->setVariable(
"QUESTION_ID", $this->object->getId());
967 $questionoutput = $template->get();
968 if (!$show_question_only)
973 return $questionoutput;
979 $randomIdToAnswerMap = array();
981 foreach($this->object->answers as $answer)
983 $randomIdToAnswerMap[$answer->getRandomId()] = $answer;
986 return $randomIdToAnswerMap;
996 include_once
"./Services/UICore/classes/class.ilTemplate.php";
997 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1002 if (is_array($user_post_solution))
1008 $keys = array_keys($this->object->answers);
1018 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
1019 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
1022 $answerGUI->setOrderingType($this->object->getOrderingType());
1026 $answerArray = array();
1027 $shuffleAnswers =
false;
1029 if( is_array($user_post_solution) && isset($user_post_solution[
'answers_ordering__participant']) )
1031 $answers_ordering =
$_POST[
'answers_ordering__participant'];
1032 $user_solution_hierarchy = json_decode($answers_ordering);
1033 $with_random_id =
true;
1034 $this->
object->setLeveledOrdering($user_solution_hierarchy, $with_random_id);
1036 foreach($this->object->leveled_ordering as $randomId => $depth)
1039 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
1042 $answerArray[] = $answ;
1047 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1054 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1056 if( count($solutions) )
1058 foreach($solutions as $solution)
1060 list($randomId, $depth) = explode(
':', $solution[
'value2']);
1063 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
1066 $answerArray[] = $answ;
1071 $answerArray = $this->
object->answers;
1072 $shuffleAnswers =
true;
1076 $answerGUI->setObjAnswersArray($answerArray, $shuffleAnswers);
1080 $answerGUI->setImagePath($this->object->getImagePath());
1081 $answerGUI->setImagePathWeb($this->object->getImagePathWeb());
1082 $answerGUI->setThumbPrefix($this->object->getThumbPrefix());
1085 $template->setCurrentBlock(
'nested_ordering_output');
1086 $template->setVariable(
'NESTED_ORDERING',$answerGUI->getHtml($shuffleAnswers));
1087 $template->parseCurrentBlock();
1088 $questiontext = $this->
object->getQuestion();
1089 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1090 $questionoutput = $template->get();
1091 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1096 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/ordering.js");
1099 $this->tpl->setVariable(
"ON_SUBMIT",
"return $('div.ilVerticalOrderingQuestion').ilOrderingQuestion('saveOrder');");
1106 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1111 if (is_array($user_post_solution))
1113 $solutions = array();
1114 foreach ($user_post_solution as $key => $value)
1116 if (preg_match(
"/order_(\d+)/", $key, $matches))
1118 foreach ($this->object->getAnswers() as $answeridx => $answer)
1120 if ($answer->getRandomID() == $matches[1])
1122 array_push($solutions, array(
"value1" => $answeridx,
"value2" => $value));
1130 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1133 $jssolutions = array();
1134 foreach ($solutions as $idx => $solution_value)
1136 if ((strcmp($solution_value[
"value2"],
"") != 0) && (strcmp($solution_value[
"value1"],
"") != 0))
1138 $jssolutions[$solution_value[
"value2"]] = $solution_value[
"value1"];
1141 if(count($jssolutions))
1143 ksort($jssolutions);
1144 $initial_order = array();
1145 foreach($jssolutions as $key => $value)
1147 if(is_object($this->object->getAnswer($value)))
1149 $initial_order[] =
'id_' . $this->
object->getAnswer($value)->getRandomID();
1153 $template->setVariable(
'INITIAL_ORDER', json_encode($initial_order));
1157 $template->setVariable(
'INITIAL_ORDER', json_encode(array()));
1161 foreach ($keys as $idx)
1163 $answer = $this->
object->answers[$idx];
1164 if ($this->object->getOrderingType() ==
OQ_PICTURES)
1166 $template->setCurrentBlock(
"ordering_row_javascript_pictures");
1167 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
1168 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1169 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1170 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1171 $template->setVariable(
"THUMB_HREF", $thumbweb);
1172 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
1173 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"thumbnail"));
1175 $template->setVariable(
"ENLARGE_ALT", $this->lng->txt(
"enlarge"));
1176 $template->setVariable(
"ENLARGE_TITLE", $this->lng->txt(
"enlarge"));
1177 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1178 $template->parseCurrentBlock();
1182 $template->setCurrentBlock(
"ordering_row_javascript_text");
1183 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
1184 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1185 $template->parseCurrentBlock();
1188 if($this->object->getOrderingType() ==
OQ_PICTURES)
1190 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_pictures"));
1194 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_definitions"));
1197 $questiontext = $this->
object->getQuestion();
1198 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1199 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1200 $questionoutput = $template->get();
1201 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1202 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/ordering.js");
1216 global $rbacsystem, $ilTabs;
1218 $ilTabs->clearTargets();
1220 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1221 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1222 $q_type = $this->
object->getQuestionType();
1224 if (strlen($q_type))
1226 $classname = $q_type .
"GUI";
1227 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1228 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1233 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1236 $ilTabs->addTarget(
"edit_page",
1237 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1238 array(
"edit",
"insert",
"exec_pg"),
1239 "",
"", $force_active);
1245 $force_active =
false;
1246 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1249 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1250 $commands =
$_POST[
"cmd"];
1251 if (is_array($commands))
1253 foreach ($commands as $key => $value)
1255 if (preg_match(
"/^delete_.*/", $key, $matches))
1257 $force_active =
true;
1262 $ilTabs->addTarget(
"edit_question",
1264 array(
"orderNestedTerms",
"orderNestedPictures",
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"changeToPictures",
"uploadanswers",
"changeToText",
"upanswers",
"downanswers",
"originalSyncForm"),
1265 $classname,
"", $force_active);
1280 $ilTabs->addTarget(
"statistics",
1281 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1282 array(
"assessment"),
1291 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists($this->object->getAnswers()) )
1296 $output =
'<table class="test_specific_feedback"><tbody>';
1298 foreach($this->object->getAnswers() as $idx => $answer)
1300 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1301 $this->object->getId(), $idx
1304 $output .=
"<tr><td>{$answer->getAnswerText()}</td><td>{$feedback}</td></tr>";
1307 $output .=
'</tbody></table>';
1309 return $this->
object->prepareTextareaOutput($output, TRUE);
1314 if(is_array($child->children))
1316 foreach($child->children as $grand_child)
1319 $this->leveled_ordering[] = $ordering_depth;
1326 $this->leveled_ordering[] = $ordering_depth;
1332 foreach($new_hierarchy as $id)
1334 $ordering_depth = 0;
1335 $this->leveled_ordering[] = $ordering_depth;
1337 if(is_array($id->children))
1339 foreach($id->children as $child)
1351 $res = $ilDB->queryF(
'SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC',
1352 array(
'integer'), array($this->object->getId()));
1353 while(
$row = $ilDB->fetchAssoc(
$res))
1355 $this->old_ordering_depth[] =
$row[
'depth'];
1399 $this->
aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
1404 $passdata = array();
1405 foreach($relevant_answers_chosen as $answer_chosen)
1407 $passdata[$answer_chosen[
'active_fi'].
'-'. $answer_chosen[
'pass']][$answer_chosen[
'value2']] = $answer_chosen[
'value1'];
1410 $variants = array();
1411 foreach($passdata as $key => $data)
1413 $hash = md5(implode(
'-', $data));
1415 foreach ($variants as $vkey => $variant)
1417 if ($variant[
'hash'] == $hash)
1419 $variant[
'count']++;
1425 $variants[$key][
'hash'] = $hash;
1426 $variants[$key][
'count'] = 1;
1430 $aggregate = array();
1431 foreach ($variants as $key => $variant_entry)
1433 $variant = $passdata[$key];
1435 foreach($variant as $variant_key => $variant_line)
1438 $aggregated_info_for_answer[
'count'] = $variant_entry[
'count'];
1439 foreach ($answers_defined_on_question as $answer)
1442 $aggregated_info_for_answer[$i .
' - ' . $answer->getAnswerText()]
1443 = $passdata[$key][$i];
1447 $aggregate[] = $aggregated_info_for_answer;
1459 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
1461 foreach ($aggregate as $line_data)
1463 $tpl->setCurrentBlock(
'aggregaterow' );
1464 $count = array_shift($line_data);
1466 foreach($line_data as $key => $line)
1468 $html .=
'<li>'. ++$line .
' - ' .$key.
'</li>';
1471 $tpl->setVariable(
'COUNT', $count );
1472 $tpl->setVariable(
'OPTION', $html );
1474 $tpl->parseCurrentBlock();