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';
45 parent::__construct();
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
552 include_once
"./Services/UICore/classes/class.ilTemplate.php";
553 $template =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
555 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
558 $solutions = array();
560 if (($active_id > 0) && (!$show_correct_solution))
562 $solutions = $this->
object->getSolutionValues($active_id,
$pass);
563 $user_order = array();
564 foreach ($solutions as $solution)
566 if(strchr( $solution[
'value2'],
':') ==
true)
568 $current_solution = explode(
':', $solution[
'value2']);
570 $user_order[$solution[
"value1"]][
'index'] = $solution[
"value1"];
571 $user_order[$solution[
"value1"]][
'random_id'] = $current_solution[0];
572 $user_order[$solution[
"value1"]][
'depth'] = $current_solution[1];
574 $answer_text = $this->
object->lookupAnswerTextByRandomId($current_solution[0], $this->object->getId());
575 $user_order[$solution[
"value1"]][
'answertext'] = $answer_text;
578 if( count($user_order) )
580 foreach($this->object->answers as $k => $a)
583 if($k == $user_order[$k][
'index'] && $a->getOrderingDepth() == $user_order[$k][
'depth'] && $a->getAnswerText() == $user_order[$k][
'answertext'])
588 $user_order[$k][
'ok'] =
$ok;
591 $solution_output = $user_order;
595 $expected_solution = array();
596 foreach ($this->object->answers as $index => $answer)
598 $expected_solution[$index][
'index'] = $index;
599 $expected_solution[$index][
'random_id'] = $answer->getRandomId();
600 $expected_solution[$index][
'depth'] = 0;
603 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
607 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
610 shuffle($expected_solution);
611 $solution_output = $expected_solution;
616 foreach ($this->object->answers as $index => $answer)
619 $expected_solution[$index][
'index'] = $index;
620 $expected_solution[$index][
'random_id'] = $answer->getRandomId();
621 $expected_solution[$index][
'depth'] = $answer->getOrderingDepth();
624 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
628 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
631 $solution_output = $expected_solution;
634 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
635 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
637 $answers_gui =
new ilNestedOrderingGUI($this->lng->txt(
"answers"),
"answers", $graphicalOutput);
639 $no_js_for_cmds = array(
'outParticipantsPassDetails',
'outCorrectSolution',
'showManScoringParticipantScreen');
642 if(in_array($this->ctrl->getCmd(), $no_js_for_cmds))
644 $answers_gui->setPerformJavascript(
false);
648 $answers_gui->setPerformJavascript(
true);
651 $answers_gui->setOrderingType($this->object->getOrderingType());
655 $answers_gui->setImagePath($this->object->getImagePath());
656 $answers_gui->setImagePathWeb($this->object->getImagePathWeb());
657 $answers_gui->setThumbPrefix($this->object->getThumbPrefix());
660 $solution_html = $answers_gui->getSolutionHTML($solution_output);
662 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
664 $questiontext = $this->
object->getQuestion();
665 if ($show_question_text==
true)
667 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
669 $questionoutput = $template->get();
677 $feedback .= strlen($fb) ? $fb :
'';
681 $feedback .= strlen($fb) ? $fb :
'';
683 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
685 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
687 $solutionoutput = $solutiontemplate->get();
688 if (!$show_question_only)
696 $keys = array_keys($this->object->answers);
699 include_once
"./Services/UICore/classes/class.ilTemplate.php";
700 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
701 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
704 $solutions = array();
705 if (($active_id > 0) && (!$show_correct_solution))
707 $solutions = $this->
object->getSolutionValues($active_id,
$pass);
709 if( !count($solutions) )
711 foreach ($this->object->answers as $index => $answer)
713 array_push($solutions, array(
"value1" => $index,
"value2" => $index+1));
721 foreach ($this->object->answers as $index => $answer)
723 array_push($solutions, array(
"value1" => $index,
"value2" => $index+1));
726 foreach ($keys as $idx)
728 if (!$show_correct_solution)
730 foreach($solutions as $index => $item)
732 if($item[
'value2'] == $idx+1)
734 $answer = $this->
object->answers[$item[
'value1']];
740 $answer = $this->
object->answers[$idx];
746 if (($active_id > 0) && (!$show_correct_solution))
748 if ($graphicalOutput)
751 foreach ($solutions as $solution)
753 $sol[$solution[
"value1"]] = $solution[
"value2"];
756 $sol = array_keys($sol);
758 foreach ($this->object->answers as $k => $a)
763 $ans = array_keys($ans);
765 foreach ($ans as $arr_idx => $ans_idx)
767 if ($ans_idx == $idx)
769 if ($ans_idx == $sol[$arr_idx])
778 $template->setCurrentBlock(
"icon_ok");
780 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
781 $template->parseCurrentBlock();
785 $template->setCurrentBlock(
"icon_ok");
787 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
788 $template->parseCurrentBlock();
792 if ($this->object->getOrderingType() ==
OQ_PICTURES)
794 $template->setCurrentBlock(
"ordering_row_standard_pictures");
795 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
796 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
797 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
798 $template->setVariable(
"THUMB_HREF", $thumbweb);
799 list($width, $height, $type, $attr) = getimagesize($thumb);
800 $template->setVariable(
"ATTR", $attr);
801 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
802 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"enlarge"));
803 $template->parseCurrentBlock();
807 $template->setCurrentBlock(
"ordering_row_standard_text");
808 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
809 $template->parseCurrentBlock();
811 $template->setCurrentBlock(
"ordering_row_standard");
814 $answer = $this->
object->answers[$idx];
815 $points = $answer->getPoints();
816 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
817 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
819 foreach ($solutions as $solution)
821 if (strcmp($solution[
"value1"], $idx) == 0)
823 $template->setVariable(
"ANSWER_ORDER", $solution[
"value2"]);
826 $template->parseCurrentBlock();
828 $questiontext = $this->
object->getQuestion();
829 if ($show_question_text==
true)
831 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
833 $questionoutput = $template->get();
835 if (strlen($feedback))
841 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
842 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
844 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
846 $solutionoutput = $solutiontemplate->get();
847 if (!$show_question_only)
854 return $solutionoutput;
857 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
864 include_once
"./Services/UICore/classes/class.ilTemplate.php";
865 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
873 $answerArray = array();
874 $shuffleAnswers =
false;
876 foreach((array)$this->
getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
878 list($randomId, $depth) = explode(
':', $val2);
881 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
884 $answerArray[] = $answ;
886 $jssolutions[$val2] = $val1;
891 foreach((array)$this->
getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
893 $jssolutions[$val2] = $val1;
899 $answerArray = $this->
object->answers;
900 $shuffleAnswers =
true;
907 $keys = array_keys($this->object->answers);
910 $keys = $this->
object->getShuffler()->shuffle($keys);
915 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
918 $this->tpl->addJavaScript(
'./Services/jQuery/js/jquery.ui.touch-punch.min.js');
923 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
924 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
927 $answers->setObjAnswersArray($answerArray, $shuffleAnswers);
931 $answers->setImagePath($this->object->getImagePath());
932 $answers->setImagePathWeb($this->object->getImagePathWeb());
933 $answers->setThumbPrefix($this->object->getThumbPrefix());
936 $template->setCurrentBlock(
'nested_ordering_output');
937 $template->setVariable(
'NESTED_ORDERING',$answers->getHtml());
938 $template->parseCurrentBlock();
939 $questiontext = $this->
object->getQuestion();
940 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
941 $questionoutput = $template->get();
942 if (!$show_question_only)
947 return $questionoutput;
952 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/ordering.js");
954 $template->setCurrentBlock(
'form_submit_register');
955 $template->touchBlock(
'form_submit_register');
956 $template->parseCurrentBlock();
958 if(count($jssolutions))
961 $initial_order = array();
962 foreach($jssolutions as $key => $value)
964 if(is_object($this->object->getAnswer($value)))
966 $initial_order[] =
'id_' . $this->
object->getAnswer($value)->getRandomID();
970 $template->setVariable(
'INITIAL_ORDER', json_encode($initial_order));
974 $template->setVariable(
'INITIAL_ORDER', json_encode(array()));
977 foreach ($keys as $idx)
979 $answer = $this->
object->answers[$idx];
980 if ($this->object->getOrderingType() ==
OQ_PICTURES)
982 $template->setCurrentBlock(
"ordering_row_javascript_pictures");
983 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
984 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
985 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
986 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
987 $template->setVariable(
"THUMB_HREF", $thumbweb);
988 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
989 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"thumbnail"));
991 $template->setVariable(
"ENLARGE_ALT", $this->lng->txt(
"enlarge"));
992 $template->setVariable(
"ENLARGE_TITLE", $this->lng->txt(
"enlarge"));
993 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
994 $template->parseCurrentBlock();
998 $template->setCurrentBlock(
"ordering_row_javascript_text");
999 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
1000 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1001 $template->parseCurrentBlock();
1004 if ($this->object->getOrderingType() ==
OQ_PICTURES)
1006 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_pictures"));
1010 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_definitions"));
1013 $questiontext = $this->
object->getQuestion();
1014 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1015 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1016 $questionoutput = $template->get();
1017 if (!$show_question_only)
1020 $questionoutput = $this->
getILIASPage($questionoutput);
1022 return $questionoutput;
1028 $randomIdToAnswerMap = array();
1030 foreach($this->object->answers as $answer)
1032 $randomIdToAnswerMap[$answer->getRandomId()] = $answer;
1035 return $randomIdToAnswerMap;
1039 function getTestOutput($active_id,
$pass, $is_postponed = FALSE, $user_post_solution = FALSE, $inlineFeedback =
false)
1047 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1048 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1053 if (is_array($user_post_solution))
1059 $keys = array_keys($this->object->answers);
1060 $keys = $this->
object->getShuffler()->shuffle($keys);
1066 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
1069 $this->tpl->addJavaScript(
'./Services/jQuery/js/jquery.ui.touch-punch.min.js');
1076 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
1077 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
1080 $answerGUI->setOrderingType($this->object->getOrderingType());
1084 $answerArray = array();
1085 $shuffleAnswers =
false;
1087 if( is_array($user_post_solution) && isset($user_post_solution[
'answers_ordering__participant']) )
1089 $answers_ordering =
$_POST[
'answers_ordering__participant'];
1090 $user_solution_hierarchy = json_decode($answers_ordering);
1091 $with_random_id =
true;
1092 $this->
object->setLeveledOrdering($user_solution_hierarchy, $with_random_id);
1094 foreach($this->object->leveled_ordering as $randomId => $depth)
1097 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
1100 $answerArray[] = $answ;
1106 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 1108 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 1110 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 1116 if( count($solutions) )
1118 foreach($solutions as $solution)
1120 list($randomId, $depth) = explode(
':', $solution[
'value2']);
1123 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
1126 $answerArray[] = $answ;
1131 $answerArray = $this->
object->answers;
1132 $shuffleAnswers =
true;
1136 $answerGUI->setObjAnswersArray($answerArray, $shuffleAnswers);
1140 $answerGUI->setImagePath($this->object->getImagePath());
1141 $answerGUI->setImagePathWeb($this->object->getImagePathWeb());
1142 $answerGUI->setThumbPrefix($this->object->getThumbPrefix());
1145 $template->setCurrentBlock(
'nested_ordering_output');
1146 $template->setVariable(
'NESTED_ORDERING',$answerGUI->getHtml($shuffleAnswers));
1147 $template->parseCurrentBlock();
1148 $questiontext = $this->
object->getQuestion();
1149 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1150 $questionoutput = $template->get();
1151 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1156 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/ordering.js");
1159 $this->tpl->setVariable(
"ON_SUBMIT",
"return $('div.ilVerticalOrderingQuestion').ilOrderingQuestion('saveOrder');");
1167 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 1168 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 1170 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 1173 if (is_array($user_post_solution))
1175 $solutions = array();
1176 foreach ($user_post_solution as $key => $value)
1178 if (preg_match(
"/order_(\d+)/", $key, $matches))
1180 foreach ($this->object->getAnswers() as $answeridx => $answer)
1182 if ($answer->getRandomID() == $matches[1])
1184 array_push($solutions, array(
"value1" => $answeridx,
"value2" => $value));
1197 $jssolutions = array();
1198 foreach ($solutions as $idx => $solution_value)
1200 if ((strcmp($solution_value[
"value2"],
"") != 0) && (strcmp($solution_value[
"value1"],
"") != 0))
1202 $jssolutions[$solution_value[
"value2"]] = $solution_value[
"value1"];
1205 if(count($jssolutions))
1207 ksort($jssolutions);
1208 $initial_order = array();
1209 foreach($jssolutions as $key => $value)
1211 if(is_object($this->object->getAnswer($value)))
1213 $initial_order[] =
'id_' . $this->
object->getAnswer($value)->getRandomID();
1217 $template->setVariable(
'INITIAL_ORDER', json_encode($initial_order));
1221 $template->setVariable(
'INITIAL_ORDER', json_encode(array()));
1225 foreach ($keys as $idx)
1227 $answer = $this->
object->answers[$idx];
1228 if ($this->object->getOrderingType() ==
OQ_PICTURES)
1230 $template->setCurrentBlock(
"ordering_row_javascript_pictures");
1231 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
1232 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1233 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1234 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1235 $template->setVariable(
"THUMB_HREF", $thumbweb);
1236 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
1237 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"thumbnail"));
1239 $template->setVariable(
"ENLARGE_ALT", $this->lng->txt(
"enlarge"));
1240 $template->setVariable(
"ENLARGE_TITLE", $this->lng->txt(
"enlarge"));
1241 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1242 $template->parseCurrentBlock();
1246 $template->setCurrentBlock(
"ordering_row_javascript_text");
1247 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
1248 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1249 $template->parseCurrentBlock();
1252 if($this->object->getOrderingType() ==
OQ_PICTURES)
1254 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_pictures"));
1258 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_definitions"));
1261 $questiontext = $this->
object->getQuestion();
1262 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1263 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1264 $questionoutput = $template->get();
1265 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1266 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/ordering.js");
1280 global $rbacsystem, $ilTabs;
1282 $ilTabs->clearTargets();
1284 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1285 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1286 $q_type = $this->
object->getQuestionType();
1288 if (strlen($q_type))
1290 $classname = $q_type .
"GUI";
1291 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1292 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1297 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1300 $ilTabs->addTarget(
"edit_page",
1301 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1302 array(
"edit",
"insert",
"exec_pg"),
1303 "",
"", $force_active);
1309 $force_active =
false;
1310 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1313 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1314 $commands =
$_POST[
"cmd"];
1315 if (is_array($commands))
1317 foreach ($commands as $key => $value)
1319 if (preg_match(
"/^delete_.*/", $key, $matches))
1321 $force_active =
true;
1326 $ilTabs->addTarget(
"edit_question",
1328 array(
"orderNestedTerms",
"orderNestedPictures",
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"changeToPictures",
"uploadanswers",
"changeToText",
"upanswers",
"downanswers",
"originalSyncForm"),
1329 $classname,
"", $force_active);
1344 $ilTabs->addTarget(
"statistics",
1345 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1346 array(
"assessment"),
1355 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists($this->object->getAnswers()) )
1360 $output =
'<table class="test_specific_feedback"><tbody>';
1362 foreach($this->object->getAnswers() as $idx => $answer)
1364 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1365 $this->object->getId(), $idx
1368 $output .=
"<tr><td>{$answer->getAnswerText()}</td><td>{$feedback}</td></tr>";
1371 $output .=
'</tbody></table>';
1373 return $this->
object->prepareTextareaOutput($output, TRUE);
1378 if(is_array($child->children))
1380 foreach($child->children as $grand_child)
1383 $this->leveled_ordering[] = $ordering_depth;
1390 $this->leveled_ordering[] = $ordering_depth;
1396 foreach($new_hierarchy as $id)
1398 $ordering_depth = 0;
1399 $this->leveled_ordering[] = $ordering_depth;
1401 if(is_array($id->children))
1403 foreach($id->children as $child)
1415 $res = $ilDB->queryF(
'SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC',
1416 array(
'integer'), array($this->object->getId()));
1417 while(
$row = $ilDB->fetchAssoc(
$res))
1419 $this->old_ordering_depth[] =
$row[
'depth'];
1463 $this->
aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
1468 $passdata = array();
1469 foreach($relevant_answers_chosen as $answer_chosen)
1471 $passdata[$answer_chosen[
'active_fi'].
'-'. $answer_chosen[
'pass']][$answer_chosen[
'value2']] = $answer_chosen[
'value1'];
1474 $variants = array();
1475 foreach($passdata as $key =>
$data)
1477 $hash = md5(implode(
'-',
$data));
1479 foreach ($variants as $vkey => $variant)
1481 if ($variant[
'hash'] == $hash)
1483 $variant[
'count']++;
1489 $variants[$key][
'hash'] = $hash;
1490 $variants[$key][
'count'] = 1;
1494 $aggregate = array();
1495 foreach ($variants as $key => $variant_entry)
1497 $variant = $passdata[$key];
1499 foreach($variant as $variant_key => $variant_line)
1502 $aggregated_info_for_answer[
'count'] = $variant_entry[
'count'];
1503 foreach ($answers_defined_on_question as $answer)
1506 $aggregated_info_for_answer[$i .
' - ' . $answer->getAnswerText()]
1507 = $passdata[$key][$i];
1511 $aggregate[] = $aggregated_info_for_answer;
1523 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
1525 foreach ($aggregate as $line_data)
1527 $tpl->setCurrentBlock(
'aggregaterow' );
1528 $count = array_shift($line_data);
1530 foreach($line_data as $key => $line)
1532 $html .=
'<li>'. ++$line .
' - ' .$key.
'</li>';
1535 $tpl->setVariable(
'COUNT', $count );
1538 $tpl->parseCurrentBlock();
isTestPresentationContext()
__construct($id=-1)
assOrderingQuestionGUI constructor
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
static initjQueryUI()
Init jQuery UI (see included_components.txt for included components)
getTestOutput($active_id, $pass, $is_postponed=FALSE, $user_post_solution=FALSE, $inlineFeedback=false)
getSolutionOutput( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
Get the question solution output.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
Class for ordering question answers.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
renderAggregateView($aggregate)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
getTestOutputSolutions($activeId, $pass)
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
populateTaxonomyFormSection(ilPropertyFormGUI $form)
setClearAnswersOnWritingPostDataEnabled($clearAnswersOnWritingPostDataEnabled)
$clearAnswersOnWritingPostDataEnabled
writePostData($always=false)
Evaluates a posted edit form and writes the form data in the question object.
populateCommandButtons(ilPropertyFormGUI $form)
writeQuestionGenericPostData()
const OQ_PICTURES
Ordering question constants.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
special template class to simplify handling of ITX/PEAR
isClearAnswersOnWritingPostDataEnabled()
Ordering question GUI representation.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
const CSS_CLASS_FEEDBACK_WRONG
setInstanceId($instanceId)
Basic GUI class for assessment questions.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
setOrderingType($a_ordering_type)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
setLeveledOrdering($new_hierarchy)
saveTaxonomyAssignments()
getDepthRecursive($child, $ordering_depth)
getAnswerImageFileUploadWizardFormProperty()
addBackTab(ilTabsGUI $ilTabs)
getSpecificFeedbackOutput($active_id, $pass)
Class for ordering questions.
static initjQuery($a_tpl=null)
Init jQuery.
Interface ilGuiAnswerScoringAdjustable.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
This class represents a text wizard property in a property form.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.