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';
41 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php";
45 $this->
object->loadFromDb($id);
58 $clearAnswers =
false;
63 $this->
object->saveToDb();
76 $clearAnswers =
false;
79 $this->
object->setOrderingType(
OQ_TERMS);
81 $this->
object->saveToDb();
94 $clearAnswers =
false;
99 $this->
object->saveToDb();
108 $this->
object->saveToDb();
116 $position = key(
$_POST[
"cmd"][
"addanswers"]);
117 $this->
object->addAnswer(
"", $position+1);
124 $position = key(
$_POST[
'cmd'][
'removeimageanswers']);
126 $this->
object->removeAnswerImage($position);
133 $position = key(
$_POST[
"cmd"][
"removeanswers"]);
134 $this->
object->deleteAnswer($position);
141 $position = key(
$_POST[
"cmd"][
"upanswers"]);
142 $this->
object->moveAnswerUp($position);
149 $position = key(
$_POST[
"cmd"][
"downanswers"]);
150 $this->
object->moveAnswerDown($position);
159 include_once
"./Modules/TestQuestionPool/classes/class.ilImageWizardInputGUI.php";
162 $answers->setQuestionObject($this->
object);
163 $answers->setInfo($this->lng->txt(
'ordering_answer_sequence_info'));
164 $answers->setAllowMove(TRUE);
165 $answervalues = array();
166 foreach ($this->object->getAnswers() as $index => $answervalue)
168 $answervalues[$index] = $answervalue->getAnswertext();
170 $answers->setValues($answervalues);
176 $this->lng->loadLanguageModule(
'form');
180 if( !$inp->checkInput() )
182 $this->uploadAlert = $inp->getAlert();
192 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"] );
193 $this->
object->setElementHeight(
$_POST[
"element_height"] );
195 $this->
object->setPoints(
$_POST[
"points"]);
200 $ordering_type = $this->
object->getOrderingType();
202 $this->
object->flushAnswers();
211 $answers =
$_POST[
"answers"];
212 if (is_array( $answers ))
215 $answers_ordering =
$_POST[
'answers_ordering__default'];
216 $new_hierarchy = json_decode( $answers_ordering );
220 if (!is_array( $new_hierarchy ))
231 if(is_array($answers[
'imagename']))
233 foreach($answers[
'imagename'] as $index => $answer)
239 $this->
object->addAnswer($answer, -1, $this->leveled_ordering[$counter]);
245 foreach($answers as $index => $answer)
251 $this->
object->addAnswer($answer, -1, $this->leveled_ordering[$counter]);
259 if (is_array(
$_POST[
'answers'][
'count'] ))
261 foreach (array_keys(
$_POST[
'answers'][
'count'] ) as $index)
265 $this->
object->addAnswer(
"" );
269 $picturefile =
$_POST[
'answers'][
'imagename'][$index];
270 $file_org_name = $_FILES[
'answers'][
'name'][
'image'][$index];
271 $file_temp_name = $_FILES[
'answers'][
'tmp_name'][
'image'][$index];
274 if (strlen( $file_temp_name ))
277 $suffix = strtolower( array_pop( explode(
".", $file_org_name ) ) );
278 if (in_array( $suffix, array(
"jpg",
"jpeg",
"png",
"gif" ) ))
281 $filename = $this->
object->createNewImageFileName( $file_org_name );
283 if ($this->object->setImageFile( $file_temp_name,
$filename, $picturefile ))
290 $this->
object->addAnswer( $picturefile );
293 else if(is_array(
$_POST[
'answers']))
295 foreach(
$_POST[
'answers'] as $random_id => $text_value)
297 $this->
object->addAnswer( $text_value );
305 $orderingtype = $this->
object->getOrderingType();
307 if (count($this->object->getAnswers()) == 0)
309 $this->
object->addAnswer();
313 $header->setTitle($this->lng->txt(
'oq_header_ordering_elements'));
319 if ($this->uploadAlert !== null)
321 $answerImageUpload->setAlert( $this->uploadAlert );
323 $form->
addItem( $answerImageUpload );
327 require_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
330 $answers->setObjAnswersArray( $this->object->getAnswers() );
334 $answers->setImagePath( $this->object->getImagePath() );
335 $answers->setImagePathWeb( $this->object->getImagePathWeb() );
336 $answers->setThumbPrefix( $this->object->getThumbPrefix() );
338 $answers->setInfo( $this->lng->txt(
'ordering_answer_sequence_info' ) );
343 require_once
'./Modules/TestQuestionPool/classes/class.ilOrderingTextWizardInputGUI.php';
345 $answervalues = array();
346 foreach ($this->object->getAnswers() as $index => $answervalue)
348 $answervalues[$index] = $answervalue->getAnswertext();
350 ksort( $answervalues );
351 $answers->setValues( $answervalues );
352 $answers->setAllowMove( TRUE );
353 $answers->setRequired( TRUE );
355 $answers->setInfo( $this->lng->txt(
'ordering_answer_sequence_info' ) );
369 $wizard_gui->setDisableActions(
true );
370 $wizard_gui->setDisableText(
true );
376 $wizard_gui->setDisableActions(
true);
377 $wizard_gui->setDisableUpload(
true);
383 $wizard_gui->setDisabled(
true);
390 $orderingtype = $this->
object->getOrderingType();
398 if (!$this->object->getSelfAssessmentEditingMode())
400 $element_height =
new ilNumberInputGUI($this->lng->txt(
"element_height" ),
"element_height");
401 $element_height->
setValue( $this->object->getElementHeight() );
402 $element_height->setRequired(
false );
403 $element_height->setMaxLength( 6 );
404 $element_height->setMinValue( 20 );
405 $element_height->setSize( 6 );
406 $element_height->setInfo( $this->lng->txt(
"element_height_info" ) );
407 $form->
addItem( $element_height );
412 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry" ),
"thumb_geometry");
413 $geometry->
setValue( $this->object->getThumbGeometry() );
414 $geometry->setRequired(
true );
415 $geometry->setMaxLength( 6 );
416 $geometry->setMinValue( 20 );
417 $geometry->setSize( 6 );
418 $geometry->setInfo( $this->lng->txt(
"thumb_geometry_info" ) );
425 $points->setValue( $this->object->getPoints() );
426 $points->setRequired( TRUE );
427 $points->setSize( 3 );
428 $points->setMinValue( 0 );
429 $points->setMinvalueShouldBeGreater(
true );
437 return $this->ctrl->getCmd() ==
'uploadanswers';
450 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
471 $orderingtype = $this->
object->getOrderingType();
473 require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php";
479 $form->
setId(
"ordering");
485 if (
true || !$this->object->getSelfAssessmentEditingMode())
498 if (
$errors) $checkonly =
false;
501 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->
getHTML());
507 switch( $this->object->getOrderingType() )
511 $form->
addCommandButton(
"changeToPictures", $this->lng->txt(
"oq_btn_use_order_pictures"));
512 $form->
addCommandButton(
"orderNestedTerms", $this->lng->txt(
"oq_btn_nest_terms"));
517 $form->
addCommandButton(
"changeToText", $this->lng->txt(
"oq_btn_use_order_terms"));
518 $form->
addCommandButton(
"orderNestedPictures", $this->lng->txt(
"oq_btn_nest_pictures"));
523 $form->
addCommandButton(
"changeToPictures", $this->lng->txt(
"oq_btn_use_order_pictures"));
524 $form->
addCommandButton(
"changeToText", $this->lng->txt(
"oq_btn_define_terms"));
529 $form->
addCommandButton(
"changeToText", $this->lng->txt(
"oq_btn_use_order_terms"));
530 $form->
addCommandButton(
"changeToPictures", $this->lng->txt(
"oq_btn_define_pictures"));
537 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $user_post_solution);
538 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
539 $this->tpl->setVariable(
"FORMACTION", $formaction);
560 $graphicalOutput = FALSE,
561 $result_output = FALSE,
562 $show_question_only = TRUE,
563 $show_feedback = FALSE,
564 $show_correct_solution = FALSE,
565 $show_manual_scoring = FALSE,
566 $show_question_text = TRUE
572 $keys = array_keys($this->object->answers);
575 include_once
"./Services/UICore/classes/class.ilTemplate.php";
576 $template =
new ilTemplate(
"tpl.il_as_qpl_nested_ordering_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
578 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
581 $solutions = array();
583 if (($active_id > 0) && (!$show_correct_solution))
585 $solutions = $this->
object->getSolutionValues($active_id,
$pass);
586 $user_order = array();
587 foreach ($solutions as $solution)
589 if(strchr( $solution[
'value2'],
':') ==
true)
591 $current_solution = explode(
':', $solution[
'value2']);
593 $user_order[$solution[
"value1"]][
'index'] = $solution[
"value1"];
594 $user_order[$solution[
"value1"]][
'random_id'] = $current_solution[0];
595 $user_order[$solution[
"value1"]][
'depth'] = $current_solution[1];
597 $answer_text = $this->
object->lookupAnswerTextByRandomId($current_solution[0]);
598 $user_order[$solution[
"value1"]][
'answertext'] = $answer_text;
601 foreach ($this->object->answers as $k => $a)
604 if ($k == $user_order[$k][
'index']
605 && $a->getOrderingDepth() == $user_order[$k][
'depth']
606 && $a->getAnswerText() == $user_order[$k][
'answertext'])
611 $user_order[$k][
'ok'] =
$ok;
614 $solution_output = $user_order;
618 foreach ($this->object->answers as $index => $answer)
621 $expected_solution[$index][
'index'] = $index;
622 $expected_solution[$index][
'random_id'] = $answer->getRandomId();
623 $expected_solution[$index][
'depth'] = $answer->getOrderingDepth();
626 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
630 $expected_solution[$index][
'answertext'] = $answer->getAnswertext();
633 $solution_output = $expected_solution;
636 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
637 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
639 $answers_gui =
new ilNestedOrderingGUI($this->lng->txt(
"answers"),
"answers", $graphicalOutput);
641 $no_js_for_cmds = array(
'outParticipantsPassDetails',
'outCorrectSolution',
'showManScoringParticipantScreen');
644 if(in_array($this->ctrl->getCmd(), $no_js_for_cmds))
646 $answers_gui->setPerformJavascript(
false);
650 $answers_gui->setPerformJavascript(
true);
653 $answers_gui->setOrderingType($this->object->getOrderingType());
657 $answers_gui->setImagePath($this->object->getImagePath());
658 $answers_gui->setImagePathWeb($this->object->getImagePathWeb());
659 $answers_gui->setThumbPrefix($this->object->getThumbPrefix());
662 $solution_html = $answers_gui->getSolutionHTML($solution_output);
664 $template->setVariable(
'SOLUTION_OUTPUT', $solution_html);
666 $questiontext = $this->
object->getQuestion();
667 if ($show_question_text==
true)
669 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
671 $questionoutput = $template->get();
677 $feedback .= strlen($fb) ? $fb :
'';
680 $feedback .= strlen($fb) ? $fb :
'';
682 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
684 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
686 $solutionoutput = $solutiontemplate->get();
687 if (!$show_question_only)
693 return $solutionoutput;
697 $keys = array_keys($this->object->answers);
700 include_once
"./Services/UICore/classes/class.ilTemplate.php";
701 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
702 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
705 $solutions = array();
706 if (($active_id > 0) && (!$show_correct_solution))
708 $solutions = $this->
object->getSolutionValues($active_id,
$pass);
712 foreach ($this->object->answers as $index => $answer)
714 array_push($solutions, array(
"value1" => $index,
"value2" => $index+1));
717 foreach ($keys as $idx)
719 if (!$show_correct_solution)
721 foreach($solutions as $index => $item)
723 if($item[
'value2'] == $idx+1)
725 $answer = $this->
object->answers[$item[
'value1']];
731 $answer = $this->
object->answers[$idx];
737 if (($active_id > 0) && (!$show_correct_solution))
739 if ($graphicalOutput)
742 foreach ($solutions as $solution)
744 $sol[$solution[
"value1"]] = $solution[
"value2"];
747 $sol = array_keys($sol);
749 foreach ($this->object->answers as $k => $a)
754 $ans = array_keys($ans);
756 foreach ($ans as $arr_idx => $ans_idx)
758 if ($ans_idx == $idx)
760 if ($ans_idx == $sol[$arr_idx])
769 $template->setCurrentBlock(
"icon_ok");
771 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
772 $template->parseCurrentBlock();
776 $template->setCurrentBlock(
"icon_ok");
778 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
779 $template->parseCurrentBlock();
783 if ($this->object->getOrderingType() ==
OQ_PICTURES)
785 $template->setCurrentBlock(
"ordering_row_standard_pictures");
786 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
787 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
788 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
789 $template->setVariable(
"THUMB_HREF", $thumbweb);
790 list($width, $height, $type, $attr) = getimagesize($thumb);
791 $template->setVariable(
"ATTR", $attr);
792 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
793 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"enlarge"));
794 $template->parseCurrentBlock();
798 $template->setCurrentBlock(
"ordering_row_standard_text");
799 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
800 $template->parseCurrentBlock();
802 $template->setCurrentBlock(
"ordering_row_standard");
805 $answer = $this->
object->answers[$idx];
806 $points = $answer->getPoints();
807 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
808 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
810 foreach ($solutions as $solution)
812 if (strcmp($solution[
"value1"], $idx) == 0)
814 $template->setVariable(
"ANSWER_ORDER", $solution[
"value2"]);
817 $template->parseCurrentBlock();
819 $questiontext = $this->
object->getQuestion();
820 if ($show_question_text==
true)
822 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
824 $questionoutput = $template->get();
826 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
827 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
829 $solutionoutput = $solutiontemplate->get();
830 if (!$show_question_only)
834 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
836 return $solutionoutput;
845 $keys = array_keys($this->object->answers);
849 include_once
"./Services/UICore/classes/class.ilTemplate.php";
850 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
857 include_once
"./Services/UICore/classes/class.ilTemplate.php";
858 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
862 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
863 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
864 $answers =
new ilNestedOrderingGUI($this->lng->txt(
"answers"),
"answers");
865 $answers->setOrderingType($this->object->getOrderingType());
866 $answers->setObjAnswersArray($this->object->answers);
870 $answers->setImagePath($this->object->getImagePath());
871 $answers->setImagePathWeb($this->object->getImagePathWeb());
872 $answers->setThumbPrefix($this->object->getThumbPrefix());
875 $template->setCurrentBlock(
'nested_ordering_output');
876 $template->setVariable(
'NESTED_ORDERING',$answers->getHtml());
877 $template->parseCurrentBlock();
878 $questiontext = $this->
object->getQuestion();
879 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
880 $questionoutput = $jsswitch . $template->get();
881 if (!$show_question_only)
886 return $questionoutput;
892 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
894 if (array_key_exists(
'js',
$_GET))
896 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
898 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
899 if ($ilUser->getPref(
"tst_javascript") == 1)
902 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
903 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
904 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
905 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
910 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
911 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
912 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
913 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
915 $jsswitch = $jstemplate->get();
916 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
922 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"head_content",
"tpl.il_as_qpl_ordering_output_javascript.html",
"Modules/TestQuestionPool");
923 $this->tpl->touchBlock(
'head_content');
925 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
931 $this->tpl->setCurrentBlock(
"AdditionalStyle");
932 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
933 $this->tpl->parseCurrentBlock();
939 foreach ($keys as $idx)
941 $answer = $this->
object->answers[$idx];
942 if ($this->object->getOrderingType() ==
OQ_PICTURES)
944 $template->setCurrentBlock(
"ordering_row_standard_pictures");
945 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
946 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
947 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
948 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
949 $template->setVariable(
"THUMB_HREF", $thumbweb);
950 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
951 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"enlarge"));
952 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
953 $template->parseCurrentBlock();
957 $template->setCurrentBlock(
"ordering_row_standard_text");
958 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
959 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
960 $template->parseCurrentBlock();
962 $template->setCurrentBlock(
"ordering_row_standard");
963 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
964 $template->parseCurrentBlock();
969 foreach ($keys as $idx)
971 $answer = $this->
object->answers[$idx];
972 if ($this->object->getOrderingType() ==
OQ_PICTURES)
974 $template->setCurrentBlock(
"ordering_row_javascript_pictures");
975 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
976 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
977 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
978 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
979 $template->setVariable(
"THUMB_HREF", $thumbweb);
980 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
981 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"thumbnail"));
983 $template->setVariable(
"ENLARGE_ALT", $this->lng->txt(
"enlarge"));
984 $template->setVariable(
"ENLARGE_TITLE", $this->lng->txt(
"enlarge"));
985 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
986 $template->parseCurrentBlock();
990 $template->setCurrentBlock(
"ordering_row_javascript_text");
991 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
992 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
993 $template->parseCurrentBlock();
996 $template->setCurrentBlock(
"ordering_with_javascript");
997 if ($this->object->getOrderingType() ==
OQ_PICTURES)
999 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_pictures"));
1003 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_definitions"));
1005 $template->parseCurrentBlock();
1007 $questiontext = $this->
object->getQuestion();
1008 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1009 $questionoutput = $jsswitch . $template->get();
1010 if (!$show_question_only)
1013 $questionoutput = $this->
getILIASPage($questionoutput);
1015 return $questionoutput;
1021 $randomIdToAnswerMap = array();
1023 foreach($this->object->answers as $answer)
1025 $randomIdToAnswerMap[$answer->getRandomId()] = $answer;
1028 return $randomIdToAnswerMap;
1035 if (is_array($user_post_solution))
1041 $keys = array_keys($this->object->answers);
1047 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1049 $template =
new ilTemplate(
"tpl.il_as_qpl_ordering_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1054 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
1055 include_once
'Modules/TestQuestionPool/classes/class.ilNestedOrderingGUI.php';
1056 $answerGUI =
new ilNestedOrderingGUI($this->lng->txt(
"answers"),
"answers");
1057 $answerGUI->setInstanceId(
'participant');
1058 $answerGUI->setOrderingType($this->object->getOrderingType());
1062 $answerArray = array();
1063 $shuffleAnswers =
false;
1065 if( is_array($user_post_solution) && isset($user_post_solution[
'answers_ordering__participant']) )
1067 $answers_ordering =
$_POST[
'answers_ordering__participant'];
1068 $user_solution_hierarchy = json_decode($answers_ordering);
1069 $with_random_id =
true;
1070 $this->
object->setLeveledOrdering($user_solution_hierarchy, $with_random_id);
1072 foreach($this->object->leveled_ordering as $randomId => $depth)
1075 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
1078 $answerArray[] = $answ;
1083 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1090 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1092 if( count($solutions) )
1094 foreach($solutions as $solution)
1096 list($randomId, $depth) = explode(
':', $solution[
'value2']);
1099 $answerMap[$randomId]->getAnswertext(), $randomId, $depth
1102 $answerArray[] = $answ;
1107 $answerArray = $this->
object->answers;
1108 $shuffleAnswers =
true;
1112 $answerGUI->setObjAnswersArray($answerArray, $shuffleAnswers);
1116 $answerGUI->setImagePath($this->object->getImagePath());
1117 $answerGUI->setImagePathWeb($this->object->getImagePathWeb());
1118 $answerGUI->setThumbPrefix($this->object->getThumbPrefix());
1121 $template->setCurrentBlock(
'nested_ordering_output');
1122 $template->setVariable(
'NESTED_ORDERING',$answerGUI->getHtml($shuffleAnswers));
1123 $template->parseCurrentBlock();
1125 $questiontext = $this->
object->getQuestion();
1126 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1127 $questionoutput = $template->get();
1128 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1136 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"head_content",
"tpl.il_as_qpl_ordering_output_javascript.html",
"Modules/TestQuestionPool");
1137 $this->tpl->touchBlock(
"head_content");
1139 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
1145 $this->tpl->setCurrentBlock(
"AdditionalStyle");
1146 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
1147 $this->tpl->parseCurrentBlock();
1151 $this->tpl->setVariable(
"ON_SUBMIT",
"return saveOrder('orderlist');");
1159 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1164 if (is_array($user_post_solution))
1166 $solutions = array();
1167 foreach ($user_post_solution as $key => $value)
1169 if (preg_match(
"/order_(\d+)/", $key, $matches))
1171 foreach ($this->object->getAnswers() as $answeridx => $answer)
1173 if ($answer->getRandomID() == $matches[1])
1175 array_push($solutions, array(
"value1" => $answeridx,
"value2" => $value));
1183 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1188 $solution_script .=
"";
1189 $jssolutions = array();
1190 foreach ($solutions as $idx => $solution_value)
1192 if ((strcmp($solution_value[
"value2"],
"") != 0) && (strcmp($solution_value[
"value1"],
"") != 0))
1194 $jssolutions[$solution_value[
"value2"]] = $solution_value[
"value1"];
1197 if (count($jssolutions))
1199 ksort($jssolutions);
1201 foreach ($jssolutions as $key => $value)
1203 if (is_object($this->object->getAnswer($value)))
1205 $js .=
"initialorder.push('id_" . $this->
object->getAnswer($value)->getRandomID() .
"');";
1208 $js .=
"restoreInitialOrder();";
1212 $template->setCurrentBlock(
"javascript_restore_order");
1213 $template->setVariable(
"RESTORE_ORDER", $js);
1214 $template->parseCurrentBlock();
1221 foreach ($keys as $idx)
1223 $answer = $this->
object->answers[$idx];
1224 if ($this->object->getOrderingType() ==
OQ_PICTURES)
1226 $template->setCurrentBlock(
"ordering_row_standard_pictures");
1227 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
1228 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1229 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1230 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1231 $template->setVariable(
"THUMB_HREF", $thumbweb);
1232 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
1233 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"enlarge"));
1234 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1235 $template->parseCurrentBlock();
1239 $template->setCurrentBlock(
"ordering_row_standard_text");
1240 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
1241 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1242 $template->parseCurrentBlock();
1244 $template->setCurrentBlock(
"ordering_row_standard");
1245 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1246 if (is_array($solutions))
1248 foreach ($solutions as $solution)
1250 if (($solution[
"value1"] == $idx) && (strlen($solution[
"value2"])))
1252 $template->setVariable(
"ANSWER_ORDER",
" value=\"" . $solution[
"value2"] .
"\"");
1256 $template->parseCurrentBlock();
1261 foreach ($keys as $idx)
1263 $answer = $this->
object->answers[$idx];
1264 if ($this->object->getOrderingType() ==
OQ_PICTURES)
1266 $template->setCurrentBlock(
"ordering_row_javascript_pictures");
1267 $template->setVariable(
"PICTURE_HREF", $this->object->getImagePathWeb() . $answer->getAnswertext());
1268 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1269 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $answer->getAnswertext();
1270 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1271 $template->setVariable(
"THUMB_HREF", $thumbweb);
1272 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"thumbnail"));
1273 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"thumbnail"));
1275 $template->setVariable(
"ENLARGE_ALT", $this->lng->txt(
"enlarge"));
1276 $template->setVariable(
"ENLARGE_TITLE", $this->lng->txt(
"enlarge"));
1277 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1278 $template->parseCurrentBlock();
1282 $template->setCurrentBlock(
"ordering_row_javascript_text");
1283 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
1284 $template->setVariable(
"ANSWER_ID", $answer->getRandomID());
1285 $template->parseCurrentBlock();
1288 $template->setCurrentBlock(
"ordering_with_javascript");
1289 if ($this->object->getOrderingType() ==
OQ_PICTURES)
1291 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_pictures"));
1295 $template->setVariable(
"RESET_POSITIONS", $this->lng->txt(
"reset_definitions"));
1297 $template->parseCurrentBlock();
1299 $questiontext = $this->
object->getQuestion();
1300 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1301 $questionoutput = $template->get();
1302 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1316 global $rbacsystem, $ilTabs;
1318 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
1319 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1320 $q_type = $this->
object->getQuestionType();
1322 if (strlen($q_type))
1324 $classname = $q_type .
"GUI";
1325 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1326 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1331 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1334 $ilTabs->addTarget(
"edit_page",
1335 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
1336 array(
"edit",
"insert",
"exec_pg"),
1337 "",
"", $force_active);
1341 $ilTabs->addTarget(
"preview",
1342 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
1344 "ilAssQuestionPageGUI",
"", $force_active);
1347 $force_active =
false;
1348 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1351 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1352 $commands =
$_POST[
"cmd"];
1353 if (is_array($commands))
1355 foreach ($commands as $key => $value)
1357 if (preg_match(
"/^delete_.*/", $key, $matches))
1359 $force_active =
true;
1364 $ilTabs->addTarget(
"edit_question",
1366 array(
"orderNestedTerms",
"orderNestedPictures",
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"changeToPictures",
"uploadanswers",
"changeToText",
"upanswers",
"downanswers",
"originalSyncForm"),
1367 $classname,
"", $force_active);
1378 $ilTabs->addTarget(
"solution_hint",
1379 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
1380 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
1381 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
1391 $ilTabs->addTarget(
"statistics",
1392 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1393 array(
"assessment"),
1397 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1402 global $___test_express_mode;
1404 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
1405 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1409 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
1414 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
1420 $output =
'<table class="ilTstSpecificFeedbackTable"><tbody>';
1422 foreach($this->object->getAnswers() as $idx => $answer)
1424 $feedback = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1425 $this->object->getId(), $idx
1428 $output .=
"<tr><td><b><i>{$answer->getAnswerText()}</i></b></td><td>{$feedback}</td></tr>";
1431 $output .=
'</tbody></table>';
1433 return $this->
object->prepareTextareaOutput($output, TRUE);
1438 if(is_array($child->children))
1440 foreach($child->children as $grand_child)
1443 $this->leveled_ordering[] = $ordering_depth;
1450 $this->leveled_ordering[] = $ordering_depth;
1456 foreach($new_hierarchy as $id)
1458 $ordering_depth = 0;
1459 $this->leveled_ordering[] = $ordering_depth;
1461 if(is_array($id->children))
1463 foreach($id->children as $child)
1475 $res = $ilDB->queryF(
'SELECT depth FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC',
1476 array(
'integer'), array($this->object->getId()));
1477 while(
$row = $ilDB->fetchAssoc(
$res))
1479 $this->old_ordering_depth[] =
$row[
'depth'];
1509 return array(
'element_height',
'thumb_geometry',
'answers');
1514 $element = $form->getItemByPostvar(
'element_height');
1517 $_POST[
'element_height'] = $this->
object->getElementHeight();
1518 $element->setValue( $this->object->getElementHeight() );
1520 $element = $form->getItemByPostvar(
'thumb_geometry');
1524 $_POST[
'thump_geometry'] = $this->
object->getThumbGeometry();
1525 $element->setValue( $this->object->getThumbGeometry() );
1526 $element->setRequired(
false );
1529 $element = $form->getItemByPostvar(
'answers');
1530 $element->setRequired(
false);
1544 foreach($relevant_answers as
$pass)
1546 $passes[$pass[
'active_fi'].
'-'.$pass[
'pass']] =
'-';
1548 $passcount = count($passes);
1549 foreach($relevant_answers as $pass)
1551 $actives[$pass[
'active_fi']] = $pass[
'active_fi'];
1553 $usercount = count($actives);
1554 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_header.html',
true,
true,
"Modules/TestQuestionPool");
1555 $tpl->setVariable(
'HEADERTEXT', $this->lng->txt(
'overview'));
1556 $tpl->setVariable(
'NUMBER_OF_USERS_INFO', $this->lng->txt(
'number_of_users'));
1557 $tpl->setVariable(
'NUMBER_OF_USERS', $usercount);
1558 $tpl->setVariable(
'NUMBER_OF_PASSES_INFO', $this->lng->txt(
'number_of_passes'));
1559 $tpl->setVariable(
'NUMBER_OF_PASSES', $passcount);
1562 $this->
aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
1567 $passdata = array();
1568 foreach($relevant_answers_chosen as $answer_chosen)
1570 $pass_ident = $answer_chosen[
'active_fi'].
'-'. $answer_chosen[
'pass'];
1571 $answers = $passdata[$pass_ident];
1572 if(!strlen($answers))
1578 $answers = explode(
',',$answers);
1580 if($this->object->getOrderingType() ==
OQ_TERMS || $this->
object->getOrderingType() ==
OQ_PICTURES)
1582 $answers[$answer_chosen[
'value2']] = $answer_chosen[
'value1'];
1584 $parts = explode(
':',$answer_chosen[
'value2']);
1587 $answers[$answer_chosen[
'value1']] = implode(
'|', array($depth,$item));
1589 $passdata[$pass_ident] = implode(
',', $answers);
1592 $variants = array();
1593 foreach($passdata as $line_data)
1595 if(isset($variants[$line_data]))
1597 $variants[$line_data]++;
1601 $variants[$line_data] = 1;
1616 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
1617 $tpl->setVariable(
'OPTION_HEADER', $this->lng->txt(
'answer_variant') );
1618 $tpl->setVariable(
'COUNT_HEADER', $this->lng->txt(
'count') );
1619 $tpl->setVariable(
'AGGREGATION_HEADER', $this->lng->txt(
'aggregated_answers_header') );
1620 foreach ($aggregate as $answers => $line_data)
1622 $tpl->setCurrentBlock(
'aggregaterow' );
1623 $html =
'<ul style="list-style: none;">';
1625 $answer_entries = explode(
',',$answers);
1626 foreach($answer_entries as $key => $line)
1631 $answer_parts = explode(
'|', $line );
1632 $line_item = $answer_parts[1];
1633 if(isset($answer_parts[0]))
1635 $indent_level = $answer_parts[0];
1641 for($i = 0; $i < $indent_level; $i++)
1643 $html .=
' <small>></small> ';
1645 $answer_objs = $this->
object->getAnswers();
1646 foreach($answer_objs as $candidate)
1648 if($candidate->getRandomId() == $line_item)
1650 $answer_obj = $candidate;
1656 $answer_obj = $this->
object->getAnswer($line_item);
1662 $html .= $answer_obj->getAnswertext();
1664 $html .=
' <img src="'
1665 . $this->
object->getImagePathWeb()
1666 . $this->
object->getThumbPrefix()
1667 . $answer_obj->getAnswertext()
1673 $tpl->setVariable(
'COUNT', $line_data );
1674 $tpl->setVariable(
'OPTION', $html );
1676 $tpl->parseCurrentBlock();