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';
38 include_once
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
42 $this->
object->loadFromDb($id);
51 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
53 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
67 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
70 $form->setFormAction($this->ctrl->getFormAction($this));
72 $form->setMultipart(
true);
73 $form->setTableWidth(
"100%");
74 $form->setId(
"matching");
78 $form->setValuesByPost();
80 return $form->checkInput();
86 $this->
object->flushMatchingPairs();
87 $this->
object->flushTerms();
88 $this->
object->flushDefinitions();
91 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php';
92 foreach (
$_POST[
'terms'][
'answer'] as
$index => $answer) {
94 if (strlen($_FILES[
'terms'][
'name'][
'image'][
$index])) {
97 if ($this->object->setImageFile(
98 $_FILES[
'terms'][
'tmp_name'][
'image'][$index],
99 $this->object->getEncryptedFilename(
$name)
107 $this->
object->addTerm(
112 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php';
113 foreach (
$_POST[
'definitions'][
'answer'] as
$index => $answer) {
115 if (strlen($_FILES[
'definitions'][
'name'][
'image'][
$index])) {
117 $name = $_FILES[
'definitions'][
'name'][
'image'][
$index];
118 if ($this->object->setImageFile(
119 $_FILES[
'definitions'][
'tmp_name'][
'image'][$index],
120 $this->object->getEncryptedFilename(
$name)
128 $this->
object->addDefinition(
134 if (is_array(
$_POST[
'pairs'][
'points'])) {
135 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php';
136 foreach (
$_POST[
'pairs'][
'points'] as
$index => $points) {
139 $this->
object->addMatchingPair(
140 $this->object->getTermWithIdentifier($term_id),
141 $this->
object->getDefinitionWithIdentifier($definition_id),
150 if (!$this->object->getSelfAssessmentEditingMode()) {
151 $this->
object->setShuffle(
$_POST[
"shuffle"]);
153 $this->
object->setShuffle(1);
155 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"]);
156 $this->
object->setMatchingMode(
$_POST[
'matching_mode']);
168 $position = key(
$_POST[
'cmd'][
'removeimageterms']);
169 $this->
object->removeTermImage($position);
182 $position = key(
$_POST[
'cmd'][
'removeimagedefinitions']);
183 $this->
object->removeDefinitionImage($position);
190 $position = key(
$_POST[
"cmd"][
"addterms"]);
191 $this->
object->insertTerm($position + 1);
198 $position = key(
$_POST[
"cmd"][
"removeterms"]);
199 $this->
object->deleteTerm($position);
206 $position = key(
$_POST[
"cmd"][
"adddefinitions"]);
207 $this->
object->insertDefinition($position + 1);
214 $position = key(
$_POST[
"cmd"][
"removedefinitions"]);
215 $this->
object->deleteDefinition($position);
222 $position = key(
$_POST[
"cmd"][
"addpairs"]);
223 $this->
object->insertMatchingPair($position + 1);
230 $position = key(
$_POST[
"cmd"][
"removepairs"]);
231 $this->
object->deleteMatchingPair($position);
240 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
242 $this->editForm = $form;
244 $form->setFormAction($this->ctrl->getFormAction($this));
246 $form->setMultipart(
true);
247 $form->setTableWidth(
"100%");
248 $form->setId(
"matching");
260 $form->setValuesByPost();
261 $errors = !$form->checkInput();
262 $form->setValuesByPost();
265 $terms = $form->getItemByPostVar(
'terms');
266 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
275 $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
282 return $this->ctrl->getCmd() ==
'uploaddefinitions';
287 return $this->ctrl->getCmd() ==
'uploadterms';
306 $numDefinitions = count($form->
getItemByPostVar(
'definitions')->getValues());
308 if ($numTerms >= $numDefinitions) {
318 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
320 if ($this->object->getSelfAssessmentEditingMode()) {
325 $value->__set(
'text', html_entity_decode($value->__get(
'text')));
329 $definitions->setRequired(
true);
330 $definitions->setQuestionObject($this->
object);
331 $definitions->setTextName($this->lng->txt(
'definition_text'));
332 $definitions->setImageName($this->lng->txt(
'definition_image'));
333 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
334 if (!count($this->object->getDefinitions())) {
337 $definitionvalues = array_map($stripHtmlEntitesFromValues, $this->object->getDefinitions());
338 $definitions->setValues($definitionvalues);
340 $definitions->checkInput();
345 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
347 if ($this->object->getSelfAssessmentEditingMode()) {
350 $terms->setRequired(
true);
351 $terms->setQuestionObject($this->
object);
352 $terms->setTextName($this->lng->txt(
'term_text'));
353 $terms->setImageName($this->lng->txt(
'term_image'));
354 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
355 if (!count($this->object->getTerms())) {
358 $termvalues = array_map($stripHtmlEntitesFromValues, $this->object->getTerms());
359 $terms->setValues($termvalues);
361 $terms->checkInput();
366 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
369 $pairs->setTerms($this->object->getTerms());
370 $pairs->setDefinitions($this->object->getDefinitions());
371 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
372 if (count($this->object->getMatchingPairs()) == 0) {
375 $pairs->setPairs($this->object->getMatchingPairs());
385 $hidden->setValue($matchingtype);
388 if (!$this->object->getSelfAssessmentEditingMode()) {
390 $shuffle =
new ilSelectInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle");
391 $shuffle_options = array(
392 0 => $this->lng->txt(
"no"),
393 1 => $this->lng->txt(
"matching_shuffle_terms_definitions"),
394 2 => $this->lng->txt(
"matching_shuffle_terms"),
395 3 => $this->lng->txt(
"matching_shuffle_definitions")
397 $shuffle->setOptions($shuffle_options);
398 $shuffle->setValue($this->object->getShuffle() != null ? $this->
object->getShuffle() : 1);
399 $shuffle->setRequired(
false);
402 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry"),
"thumb_geometry");
403 $geometry->
setValue($this->object->getThumbGeometry());
404 $geometry->setRequired(
true);
405 $geometry->setMaxLength(6);
406 $geometry->setMinValue(20);
407 $geometry->setSize(6);
408 $geometry->setInfo($this->lng->txt(
"thumb_geometry_info"));
413 $mode =
new ilRadioGroupInputGUI($this->lng->txt(
'qpl_qst_inp_matching_mode'),
'matching_mode');
417 $this->lng->txt(
'qpl_qst_inp_matching_mode_one_on_one'),
420 $mode->addOption($modeONEonONE);
423 $this->lng->txt(
'qpl_qst_inp_matching_mode_all_on_all'),
426 $mode->addOption($modeALLonALL);
428 $mode->
setValue($this->object->getMatchingMode());
459 $graphicalOutput =
false,
460 $result_output =
false,
461 $show_question_only =
true,
462 $show_feedback =
false,
463 $show_correct_solution =
false,
464 $show_manual_scoring =
false,
465 $show_question_text =
true 468 include_once
"./Services/UICore/classes/class.ilTemplate.php";
469 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
470 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
472 $solutions = array();
473 if (($active_id > 0) && (!$show_correct_solution)) {
474 include_once
"./Modules/Test/classes/class.ilObjTest.php";
476 $solution_script .=
"";
478 foreach ($this->object->getMaximumScoringMatchingPairs() as $pair) {
479 $solutions[] = array(
480 "value1" => $pair->term->identifier,
481 "value2" => $pair->definition->identifier,
482 'points' => $pair->points
489 foreach ($solutions as $solution) {
490 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
491 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
492 $points = $solution[
'points'];
494 if (is_object($definition)) {
495 if (strlen($definition->picture)) {
496 if (strlen($definition->text)) {
497 $template->setCurrentBlock(
'definition_image_text');
499 $template->parseCurrentBlock();
503 $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture
506 $template->setCurrentBlock(
'definition_image');
507 $template->setVariable(
'ANSWER_IMAGE_URL', $answerImageSrc);
510 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
511 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
513 $template->parseCurrentBlock();
515 $template->setCurrentBlock(
'definition_text');
516 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
517 $template->parseCurrentBlock();
520 if (is_object($term)) {
521 if (strlen($term->picture)) {
522 if (strlen($term->text)) {
523 $template->setCurrentBlock(
'term_image_text');
525 $template->parseCurrentBlock();
529 $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture
532 $template->setCurrentBlock(
'term_image');
533 $template->setVariable(
'ANSWER_IMAGE_URL', $answerImageSrc);
536 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
537 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
539 $template->parseCurrentBlock();
541 $template->setCurrentBlock(
'term_text');
542 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text,
true));
543 $template->parseCurrentBlock();
547 if (($active_id > 0) && (!$show_correct_solution)) {
548 if ($graphicalOutput) {
551 foreach ($this->object->getMatchingPairs() as $pair) {
558 $template->setCurrentBlock(
"icon_ok");
560 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
561 $template->parseCurrentBlock();
563 $template->setCurrentBlock(
"icon_ok");
565 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
566 $template->parseCurrentBlock();
571 if ($result_output) {
572 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
573 $template->setCurrentBlock(
"result_output");
574 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
575 $template->parseCurrentBlock();
578 $template->setCurrentBlock(
"row");
579 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
580 $template->parseCurrentBlock();
583 if ($show_question_text ==
true) {
584 $template->setVariable(
"QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
587 $questionoutput = $template->get();
590 if ($show_feedback) {
593 $feedback .= strlen($fb) ? $fb :
'';
597 $feedback .= strlen($fb) ? $fb :
'';
599 if (strlen($feedback)) {
605 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
606 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
609 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
611 $solutionoutput = $solutiontemplate->get();
612 if (!$show_question_only) {
616 return $solutionoutput;
619 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
624 if ($DIC[
'ilBrowser']->isMobile() || $DIC[
'ilBrowser']->isIpad()) {
625 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
628 $this->tpl->addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
630 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/ilMatchingQuestion.js');
633 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html",
true,
true,
"Modules/TestQuestionPool");
635 foreach ($solutions as $defId => $terms) {
636 foreach ($terms as $termId) {
637 $template->setCurrentBlock(
"matching_data");
638 $template->setVariable(
"DEFINITION_ID", $defId);
639 $template->setVariable(
"TERM_ID", $termId);
640 $template->parseCurrentBlock();
645 $terms = $this->
object->getTerms();
646 $definitions = $this->
object->getDefinitions();
647 switch ($this->object->getShuffle()) {
649 $seed = $this->
object->getShuffler()->getSeed();
650 $this->
object->getShuffler()->setSeed($seed .
'1');
651 $terms = $this->
object->getShuffler()->shuffle($terms);
652 $this->
object->getShuffler()->setSeed($seed .
'2');
653 $definitions = $this->
object->getShuffler()->shuffle($definitions);
654 $this->
object->getShuffler()->setSeed($seed);
657 $terms = $this->
object->getShuffler()->shuffle($terms);
660 $definitions = $this->
object->getShuffler()->shuffle($definitions);
666 foreach ($definitions as $definition) {
667 if (strlen($definition->picture)) {
668 $template->setCurrentBlock(
"definition_picture");
669 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
670 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
671 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
672 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
673 if (!@file_exists($thumb)) {
674 $this->
object->rebuildThumbnails();
676 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
677 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
678 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
679 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text,
true,
true) :
'');
680 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
682 $template->parseCurrentBlock();
684 $template->setCurrentBlock(
"definition_text");
685 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true,
true));
686 $template->parseCurrentBlock();
689 $template->setCurrentBlock(
"droparea");
690 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
691 $template->setVariable(
"QUESTION_ID", $this->object->getId());
692 $template->parseCurrentBlock();
694 $template->setCurrentBlock(
"definition_data");
695 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
696 $template->parseCurrentBlock();
701 foreach ($terms as $term) {
702 if (strlen($term->picture)) {
703 $template->setCurrentBlock(
"term_picture");
704 $template->setVariable(
"TERM_ID", $term->identifier);
705 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
706 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
707 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
708 if (!@file_exists($thumb)) {
709 $this->
object->rebuildThumbnails();
711 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
712 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
713 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
714 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
715 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text,
true,
true) :
'');
717 $template->parseCurrentBlock();
719 $template->setCurrentBlock(
"term_text");
720 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true,
true));
721 $template->parseCurrentBlock();
723 $template->setCurrentBlock(
"draggable");
724 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
725 $template->parseCurrentBlock();
727 $template->setCurrentBlock(
"term_data");
728 $template->setVariable(
"TERM_ID", $term->identifier);
729 $template->parseCurrentBlock();
732 $template->setVariable(
'MATCHING_MODE', $this->object->getMatchingMode());
734 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
736 $template->setVariable(
"QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
738 $questionoutput = $template->get();
740 if (!$show_question_only) {
745 return $questionoutput;
753 protected function sortDefinitionsBySolution(array $solution, array $definitions)
756 $handled_defintions = array();
757 foreach ($solution as $solution_values) {
758 $id = $solution_values[
'value2'];
759 if (!isset($handled_defintions[$id])) {
760 $neworder[] = $this->
object->getDefinitionWithIdentifier($id);
761 $handled_defintions[$id] = $id;
765 foreach ($definitions as $definition) {
769 if (!isset($handled_defintions[$definition->identifier])) {
770 $neworder[] = $definition;
783 if ($DIC[
'ilBrowser']->isMobile() || $DIC[
'ilBrowser']->isIpad()) {
784 $files[] =
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js';
787 $files[] =
'Modules/TestQuestionPool/js/ilMatchingQuestion.js';
793 public function getTestOutput($active_id,
$pass, $is_postponed =
false, $user_post_solution =
false, $inlineFeedback =
false)
797 if ($DIC[
'ilBrowser']->isMobile() || $DIC[
'ilBrowser']->isIpad()) {
798 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
801 $this->tpl->addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
803 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/ilMatchingQuestion.js');
806 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html",
true,
true,
"Modules/TestQuestionPool");
811 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 812 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 814 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 817 if (is_array($user_post_solution)) {
818 $solutions = array();
819 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term) {
820 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
824 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
829 foreach ($solutions as $idx => $solution_value) {
830 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1)) {
831 $template->setCurrentBlock(
"matching_data");
832 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
833 $template->setVariable(
"DEFINITION_ID", $solution_value[
"value2"]);
834 $template->parseCurrentBlock();
841 $terms = $this->
object->getTerms();
842 $definitions = $this->
object->getDefinitions();
843 switch ($this->object->getShuffle()) {
845 $seed = $this->
object->getShuffler()->getSeed();
846 $this->
object->getShuffler()->setSeed($seed .
'1');
847 $terms = $this->
object->getShuffler()->shuffle($terms);
848 if (count($solutions)) {
849 $definitions = $this->sortDefinitionsBySolution($solutions, $definitions);
851 $this->
object->getShuffler()->setSeed($seed .
'2');
852 $definitions = $this->
object->getShuffler()->shuffle($definitions);
854 $this->
object->getShuffler()->setSeed($seed);
857 $terms = $this->
object->getShuffler()->shuffle($terms);
860 if (count($solutions)) {
861 $definitions = $this->sortDefinitionsBySolution($solutions, $definitions);
863 $definitions = $this->
object->getShuffler()->shuffle($definitions);
870 foreach ($definitions as $definition) {
871 if (strlen($definition->picture)) {
872 $template->setCurrentBlock(
"definition_picture");
873 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
874 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
875 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
876 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
877 if (!@file_exists($thumb)) {
878 $this->
object->rebuildThumbnails();
880 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
881 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
882 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
883 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text,
true,
true) :
'');
884 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
886 $template->parseCurrentBlock();
888 $template->setCurrentBlock(
"definition_text");
889 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true,
true));
890 $template->parseCurrentBlock();
893 $template->setCurrentBlock(
"droparea");
894 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
895 $template->setVariable(
"QUESTION_ID", $this->object->getId());
896 $template->parseCurrentBlock();
898 $template->setCurrentBlock(
"definition_data");
899 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
900 $template->parseCurrentBlock();
905 foreach ($terms as $term) {
906 if (strlen($term->picture)) {
907 $template->setCurrentBlock(
"term_picture");
908 $template->setVariable(
"TERM_ID", $term->identifier);
909 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
910 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
911 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
912 if (!@file_exists($thumb)) {
913 $this->
object->rebuildThumbnails();
915 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
916 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
917 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
918 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
919 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text,
true,
true) :
'');
921 $template->parseCurrentBlock();
923 $template->setCurrentBlock(
"term_text");
924 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true,
true));
925 $template->parseCurrentBlock();
927 $template->setCurrentBlock(
"draggable");
928 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
929 $template->parseCurrentBlock();
931 $template->setCurrentBlock(
'term_data');
932 $template->setVariable(
'TERM_ID', $term->identifier);
933 $template->parseCurrentBlock();
936 $template->setVariable(
'MATCHING_MODE', $this->object->getMatchingMode());
938 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
940 $template->setVariable(
"QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
942 return $this->
outQuestionPage(
"", $is_postponed, $active_id, $template->get());
958 $matches = array_values($this->object->matchingpairs);
960 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
964 $feedback =
'<table class="test_specific_feedback"><tbody>';
966 foreach ($matches as $idx => $ans) {
967 if (!isset($userSolution[$ans->definition->identifier])) {
971 if (!is_array($userSolution[$ans->definition->identifier])) {
975 if (!in_array($ans->term->identifier, $userSolution[$ans->definition->identifier])) {
979 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
980 $this->object->getId(),
984 $feedback .=
'<tr><td>"' . $ans->definition->text .
'" ' . $this->lng->txt(
"matches") .
' "';
985 $feedback .= $ans->term->text .
'"</td><td>';
986 $feedback .= $fb .
'</td> </tr>';
989 $feedback .=
'</tbody></table>';
990 return $this->
object->prepareTextareaOutput($feedback,
true);
1036 if (!($pair->points > 0)) {
1040 if (!is_object($term)) {
1044 if ($pair->definition->identifier != $definition->identifier) {
1048 if ($pair->term->identifier != $term->identifier) {
1057 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $picture;
1058 return '<img src="' . $thumbweb .
'" alt="' . $picture .
'" title="' . $picture .
'"/>';
1065 if (strlen($elem->text)) {
1066 $html .= $elem->text;
1069 if (strlen($elem->picture)) {
1078 $answersByActiveAndPass = array();
1080 foreach ($relevantAnswers as $row) {
1081 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
1083 if (!isset($answersByActiveAndPass[$key])) {
1084 $answersByActiveAndPass[$key] = array();
1087 $answersByActiveAndPass[$key][$row[
'value1']] = $row[
'value2'];
1092 foreach ($answersByActiveAndPass as $key => $matchingPairs) {
1093 foreach ($matchingPairs as $termId => $defId) {
1094 $hash = md5($termId .
':' . $defId);
1096 if (!isset($answers[$hash])) {
1098 $this->object->getTermWithIdentifier($termId)
1102 $this->object->getDefinitionWithIdentifier($defId)
1105 $answers[$hash] = array(
1106 'answer' => $termHtml . $defHtml,
1107 'term' => $termHtml,
1108 'definition' => $defHtml,
1113 $answers[$hash][
'frequency']++;
1129 require_once
'Modules/TestQuestionPool/classes/tables/class.ilMatchingQuestionAnswerFreqStatTableGUI.php';
1132 $table->setQuestionIndex($questionIndex);
1134 $table->initColumns();
1141 require_once
'Modules/TestQuestionPool/classes/forms/class.ilAssMatchingPairCorrectionsInputGUI.php';
1144 $pairs->setTerms($this->object->getTerms());
1145 $pairs->setDefinitions($this->object->getDefinitions());
1146 $pairs->setPairs($this->object->getMatchingPairs());
1157 foreach ($this->object->getMatchingPairs() as $idx => $matchingPair) {
1158 $matchingPair->points = (float) $pairs[$idx]->points;
isTestPresentationContext()
Class for matching question terms.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
writePostData($always=false)
{}
This class represents an option in a radio group.
Class for matching question pairs.
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
const MATCHING_MODE_N_ON_N
getAnswerStatisticImageHtml($picture)
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
const MATCHING_MODE_1_ON_1
getTestOutput($active_id, $pass, $is_postponed=false, $user_post_solution=false, $inlineFeedback=false)
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
isValidTermAndDefinitionAmount(ilPropertyFormGUI $form)
for mode 1:1 terms count must not be less than definitions count for mode n:n this limitation is canc...
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
Matching question GUI representation.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getPresentationJavascripts()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
checkInput()
check input fields
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
setValue($a_value)
Set Value.
writeQuestionGenericPostData()
getAnswerStatisticMatchingElemHtml($elem)
__construct($id=-1)
assMatchingQuestionGUI constructor
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
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)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
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.
isCorrectMatching($pair, $definition, $term)
getAnswerFrequencyTableGUI($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
const CSS_CLASS_FEEDBACK_WRONG
static signFile($path_to_file)
getPreview($show_question_only=false, $showInlineFeedback=false)
Basic GUI class for assessment questions.
setErrorMessage($errormessage)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
saveTaxonomyAssignments()
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
__construct(Container $dic, ilPlugin $plugin)
getAnswersFrequency($relevantAnswers, $questionIndex)
editQuestion($checkonly=false)
Class for matching question definitions.
Interface ilGuiAnswerScoringAdjustable.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
getSpecificFeedbackOutput($userSolution)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.