18 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
47 include_once
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
51 $this->
object->loadFromDb(
$id);
60 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
62 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
75 $this->
object->flushMatchingPairs();
76 $this->
object->flushTerms();
77 $this->
object->flushDefinitions();
79 $uploads = $this->request->getProcessedUploads();
80 $allowed_mime_types = [
'image/jpeg',
'image/png',
'image/gif'];
82 if ($this->request->isset(
'terms')) {
83 $answers = $this->request->raw(
'terms')[
'answer'] ?? [];
84 $terms_image_names = $this->request->raw(
'terms')[
'imagename'] ?? [];
85 $terms_identifiers = $this->request->raw(
'terms')[
'identifier'] ?? [];
87 foreach ($answers as
$index => $answer) {
90 $upload_tmp_name = $this->request->getUploadFilename([
'terms',
'image'],
$index);
92 if (isset($uploads[$upload_tmp_name]) && $uploads[$upload_tmp_name]->isOk() &&
93 in_array($uploads[$upload_tmp_name]->getMimeType(), $allowed_mime_types)) {
95 $name = $uploads[$upload_tmp_name]->getName();
96 if ($this->
object->setImageFile(
97 $uploads[$upload_tmp_name]->getPath(),
98 $this->
object->getEncryptedFilename(
$name)
105 $this->
object->addTerm(
109 $terms_identifiers[
$index] ??
'' 115 if ($this->request->isset(
'definitions')) {
116 $answers = $this->request->raw(
'definitions')[
'answer'] ?? [];
117 $definitions_image_names = $this->request->raw(
'definitions')[
'imagename'] ?? [];
118 $definitions_identifiers = $this->request->raw(
'definitions')[
'identifier'] ?? [];
120 foreach ($answers as
$index => $answer) {
123 $upload_tmp_name = $this->request->getUploadFilename([
'definitions',
'image'],
$index);
125 if (isset($uploads[$upload_tmp_name]) && $uploads[$upload_tmp_name]->isOk() &&
126 in_array($uploads[$upload_tmp_name]->getMimeType(), $allowed_mime_types)) {
128 $name = $uploads[$upload_tmp_name]->getName();
129 if ($this->
object->setImageFile(
130 $uploads[$upload_tmp_name]->getPath(),
131 $this->
object->getEncryptedFilename(
$name)
137 $this->
object->addDefinition(
141 $definitions_identifiers[
$index] ??
'' 147 if ($this->request->isset(
'pairs')) {
148 $points_of_pairs = $this->request->raw(
'pairs')[
'points'] ?? [];
149 $pair_terms = $this->request->raw(
'pairs')[
'term'] ?? [];
150 $pair_definitions = $this->request->raw(
'pairs')[
'definition'] ?? [];
152 foreach ($points_of_pairs as
$index => $points) {
153 $term_id = $pair_terms[
$index] ?? 0;
154 $definition_id = $pair_definitions[
$index] ?? 0;
155 $this->
object->addMatchingPair(
156 $this->
object->getTermWithIdentifier($term_id),
157 $this->
object->getDefinitionWithIdentifier($definition_id),
158 (float) str_replace(
',',
'.', $points)
166 if (!$this->
object->getSelfAssessmentEditingMode()) {
167 $this->
object->setShuffle($_POST[
"shuffle"] ??
'0');
168 $this->
object->setShuffleMode($_POST[
"shuffle"] ??
'0');
170 $this->
object->setShuffle(1);
171 $this->
object->setShuffleMode(1);
173 $this->
object->setThumbGeometry($_POST[
"thumb_geometry"] ?? 0);
174 $this->
object->setMatchingMode($_POST[
'matching_mode']);
186 $position = key($_POST[
'cmd'][
'removeimageterms']);
187 $this->
object->removeTermImage($position);
200 $position = key($_POST[
'cmd'][
'removeimagedefinitions']);
201 $this->
object->removeDefinitionImage($position);
208 $position = key($_POST[
"cmd"][
"addterms"]);
209 $this->
object->insertTerm($position + 1);
216 $position = key($_POST[
"cmd"][
"removeterms"]);
217 $this->
object->deleteTerm($position);
224 $position = key($_POST[
"cmd"][
"adddefinitions"]);
225 $this->
object->insertDefinition($position + 1);
232 $position = key($_POST[
"cmd"][
"removedefinitions"]);
233 $this->
object->deleteDefinition($position);
240 $position = key($_POST[
"cmd"][
"addpairs"]);
241 $this->
object->insertMatchingPair($position + 1);
248 $position = key($_POST[
"cmd"][
"removepairs"]);
249 $this->
object->deleteMatchingPair($position);
258 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
260 $this->editForm = $form;
262 $form->setFormAction($this->
ctrl->getFormAction($this));
264 $form->setMultipart(
true);
265 $form->setTableWidth(
"100%");
266 $form->setId(
"matching");
276 $form->setValuesByPost();
277 $errors = !$form->checkInput();
278 $form->setValuesByPost();
281 $terms = $form->getItemByPostVar(
'terms');
282 $terms->setAlert($this->
lng->txt(
"msg_number_of_terms_too_low"));
283 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
291 $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
298 return $this->
ctrl->getCmd() ==
'uploaddefinitions';
303 return $this->
ctrl->getCmd() ==
'uploadterms';
322 $numDefinitions = count($form->
getItemByPostVar(
'definitions')->getValues());
324 if ($numTerms >= $numDefinitions) {
334 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
336 if ($this->
object->getSelfAssessmentEditingMode()) {
341 return $value->withText(html_entity_decode($value->getText()));
344 $definitions->setRequired(
true);
345 $definitions->setQuestionObject($this->
object);
346 $definitions->setTextName($this->
lng->txt(
'definition_text'));
347 $definitions->setImageName($this->
lng->txt(
'definition_image'));
348 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
349 if (!count($this->
object->getDefinitions())) {
352 $definitionvalues = array_map($stripHtmlEntitesFromValues, $this->
object->getDefinitions());
353 $definitions->setValues($definitionvalues);
355 $definitions->checkInput();
360 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
362 if ($this->
object->getSelfAssessmentEditingMode()) {
365 $terms->setRequired(
true);
366 $terms->setQuestionObject($this->
object);
367 $terms->setTextName($this->
lng->txt(
'term_text'));
368 $terms->setImageName($this->
lng->txt(
'term_image'));
369 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
370 if (0 === count($this->
object->getTerms())) {
376 $termvalues = array_map($stripHtmlEntitesFromValues, $this->
object->getTerms());
377 $terms->setValues($termvalues);
379 $terms->checkInput();
384 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
387 $pairs->setTerms($this->
object->getTerms());
388 $pairs->setDefinitions($this->
object->getDefinitions());
389 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
390 if (count($this->
object->getMatchingPairs()) == 0) {
391 $this->
object->addMatchingPair($termvalues[0], $definitionvalues[0], 0);
394 $pairs->setPairs($this->
object->getMatchingPairs());
404 $hidden->setValue(
'');
407 if (!$this->
object->getSelfAssessmentEditingMode()) {
410 $shuffle_options = array(
411 0 => $this->
lng->txt(
"no"),
412 1 => $this->
lng->txt(
"matching_shuffle_terms_definitions"),
413 2 => $this->
lng->txt(
"matching_shuffle_terms"),
414 3 => $this->
lng->txt(
"matching_shuffle_definitions")
416 $shuffle->setOptions($shuffle_options);
417 $shuffle->setValue($this->
object->getShuffleMode());
418 $shuffle->setRequired(
false);
423 $geometry->setRequired(
true);
424 $geometry->setMaxLength(6);
425 $geometry->setMinValue($this->
object->getMinimumThumbSize());
426 $geometry->setMaxValue($this->
object->getMaximumThumbSize());
427 $geometry->setSize(6);
428 $geometry->setInfo($this->
lng->txt(
'thumb_size_info'));
437 $this->
lng->txt(
'qpl_qst_inp_matching_mode_one_on_one'),
440 $mode->addOption($modeONEonONE);
443 $this->
lng->txt(
'qpl_qst_inp_matching_mode_all_on_all'),
446 $mode->addOption($modeALLonALL);
469 $graphicalOutput =
false,
470 $result_output =
false,
471 $show_question_only =
true,
472 $show_feedback =
false,
473 $show_correct_solution =
false,
474 $show_manual_scoring =
false,
475 $show_question_text =
true 478 include_once
"./Services/UICore/classes/class.ilTemplate.php";
479 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
480 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
482 $solutions = array();
483 if (($active_id > 0) && (!$show_correct_solution)) {
484 include_once
"./Modules/Test/classes/class.ilObjTest.php";
485 $solutions = $this->
object->getSolutionValues($active_id, $pass);
487 foreach ($this->
object->getMaximumScoringMatchingPairs() as $pair) {
488 $solutions[] = array(
489 "value1" => $pair->getTerm()->getIdentifier(),
490 "value2" => $pair->getDefinition()->getIdentifier(),
491 'points' => $pair->getPoints()
498 foreach ($solutions as $solution) {
499 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
500 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
501 $points = $solution[
'points'];
503 if (is_object($definition)) {
504 if (strlen($definition->getPicture())) {
505 if (strlen($definition->getText())) {
506 $template->setCurrentBlock(
'definition_image_text');
507 $template->setVariable(
511 $template->parseCurrentBlock();
515 $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->getPicture()
518 $template->setCurrentBlock(
'definition_image');
519 $template->setVariable(
'ANSWER_IMAGE_URL', $answerImageSrc);
520 $template->setVariable(
523 $definition->getText()
526 $template->setVariable(
527 'ANSWER_IMAGE_TITLE',
529 $definition->getText()
532 $template->setVariable(
'URL_PREVIEW', $this->
object->getImagePathWeb() . $definition->getPicture());
533 $template->setVariable(
"TEXT_PREVIEW", $this->
lng->txt(
'preview'));
535 $template->parseCurrentBlock();
537 $template->setCurrentBlock(
'definition_text');
538 $template->setVariable(
"DEFINITION", $this->
object->prepareTextareaOutput($definition->getText(),
true));
539 $template->parseCurrentBlock();
542 if (is_object($term)) {
543 if (strlen($term->getPicture())) {
544 if (strlen($term->getText())) {
545 $template->setCurrentBlock(
'term_image_text');
547 $template->parseCurrentBlock();
551 $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->getPicture()
554 $template->setCurrentBlock(
'term_image');
555 $template->setVariable(
'ANSWER_IMAGE_URL', $answerImageSrc);
556 $template->setVariable(
562 $template->setVariable(
563 'ANSWER_IMAGE_TITLE',
568 $template->setVariable(
'URL_PREVIEW', $this->
object->getImagePathWeb() . $term->getPicture());
569 $template->setVariable(
"TEXT_PREVIEW", $this->
lng->txt(
'preview'));
571 $template->parseCurrentBlock();
573 $template->setCurrentBlock(
'term_text');
574 $template->setVariable(
"TERM", $this->
object->prepareTextareaOutput($term->getText(),
true));
575 $template->parseCurrentBlock();
579 if (($active_id > 0) && (!$show_correct_solution)) {
580 if ($graphicalOutput) {
583 foreach ($this->
object->getMatchingPairs() as $pair) {
593 $template->setCurrentBlock(
"icon_ok");
594 $template->setVariable(
"ICON_OK", $correctness_icon);
595 $template->parseCurrentBlock();
599 if ($result_output) {
600 $resulttext = ($points == 1) ?
"(%s " . $this->
lng->txt(
"point") .
")" :
"(%s " . $this->
lng->txt(
"points") .
")";
601 $template->setCurrentBlock(
"result_output");
602 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
603 $template->parseCurrentBlock();
606 $template->setCurrentBlock(
"row");
607 $template->setVariable(
"TEXT_MATCHES", $this->
lng->txt(
"matches"));
608 $template->parseCurrentBlock();
611 if ($show_question_text ==
true) {
612 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
615 $questionoutput = $template->get();
618 if ($show_feedback) {
621 $feedback .= strlen($fb) ? $fb :
'';
625 $feedback .= strlen($fb) ? $fb :
'';
627 if (strlen($feedback)) {
633 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
634 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
637 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
639 $solutionoutput = $solutiontemplate->get();
640 if (!$show_question_only) {
644 return $solutionoutput;
647 public function getPreview($show_question_only =
false, $showInlineFeedback =
false): string
652 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
653 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
656 $this->tpl->addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
658 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/ilMatchingQuestion.js');
659 $this->tpl->addOnLoadCode(
'ilMatchingQuestionInit();');
662 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html",
true,
true,
"Modules/TestQuestionPool");
664 foreach ($solutions as $defId => $terms) {
665 foreach ($terms as $termId) {
666 $template->setCurrentBlock(
"matching_data");
667 $template->setVariable(
"DEFINITION_ID", $defId);
668 $template->setVariable(
"TERM_ID", $termId);
669 $template->parseCurrentBlock();
674 $terms = $this->
object->getTerms();
675 $definitions = $this->
object->getDefinitions();
676 switch ($this->
object->getShuffleMode()) {
678 $terms = $this->
object->getShuffler()->transform($terms);
679 $definitions = $this->
object->getShuffler()->transform(
680 $this->
object->getShuffler()->transform($definitions)
684 $terms = $this->
object->getShuffler()->transform($terms);
687 $definitions = $this->
object->getShuffler()->transform($definitions);
693 foreach ($definitions as $definition) {
694 if (strlen($definition->getPicture())) {
695 $template->setCurrentBlock(
"definition_picture");
696 $template->setVariable(
"DEFINITION_ID", $definition->getIdentifier());
697 $template->setVariable(
"IMAGE_HREF", $this->
object->getImagePathWeb() . $definition->getPicture());
698 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->getPicture();
699 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->getPicture();
700 if (!@file_exists($thumb)) {
701 $this->
object->rebuildThumbnails();
703 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
704 $template->setVariable(
"THUMB_ALT", $this->
lng->txt(
"image"));
705 $template->setVariable(
"THUMB_TITLE", $this->
lng->txt(
"image"));
706 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->getText())) ? $this->
object->prepareTextareaOutput($definition->getText(),
true,
true) :
'');
707 $template->setVariable(
"TEXT_PREVIEW", $this->
lng->txt(
'preview'));
709 $template->parseCurrentBlock();
711 $template->setCurrentBlock(
"definition_text");
712 $template->setVariable(
"DEFINITION", $this->
object->prepareTextareaOutput($definition->getText(),
true,
true));
713 $template->parseCurrentBlock();
716 $template->setCurrentBlock(
"droparea");
717 $template->setVariable(
"ID_DROPAREA", $definition->getIdentifier());
718 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
719 $template->parseCurrentBlock();
721 $template->setCurrentBlock(
"definition_data");
722 $template->setVariable(
"DEFINITION_ID", $definition->getIdentifier());
723 $template->parseCurrentBlock();
728 foreach ($terms as $term) {
729 if (strlen($term->getPicture())) {
730 $template->setCurrentBlock(
"term_picture");
731 $template->setVariable(
"TERM_ID", $term->getIdentifier());
732 $template->setVariable(
"IMAGE_HREF", $this->
object->getImagePathWeb() . $term->getPicture());
733 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->getPicture();
734 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->getPicture();
735 if (!@file_exists($thumb)) {
736 $this->
object->rebuildThumbnails();
738 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
739 $template->setVariable(
"THUMB_ALT", $this->
lng->txt(
"image"));
740 $template->setVariable(
"THUMB_TITLE", $this->
lng->txt(
"image"));
741 $template->setVariable(
"TEXT_PREVIEW", $this->
lng->txt(
'preview'));
742 $template->setVariable(
"TEXT_TERM", (strlen($term->getText())) ? $this->
object->prepareTextareaOutput($term->getText(),
true,
true) :
'');
744 $template->parseCurrentBlock();
746 $template->setCurrentBlock(
"term_text");
747 $template->setVariable(
"TERM_TEXT", $this->
object->prepareTextareaOutput($term->getText(),
true,
true));
748 $template->parseCurrentBlock();
750 $template->setCurrentBlock(
"draggable");
751 $template->setVariable(
"ID_DRAGGABLE", $term->getIdentifier());
752 $template->parseCurrentBlock();
754 $template->setCurrentBlock(
"term_data");
755 $template->setVariable(
"TERM_ID", $term->getIdentifier());
756 $template->parseCurrentBlock();
759 $template->setVariable(
'MATCHING_MODE', $this->
object->getMatchingMode());
761 $template->setVariable(
"RESET_BUTTON", $this->
lng->txt(
"reset_terms"));
763 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
765 $questionoutput = $template->get();
767 if (!$show_question_only) {
772 return $questionoutput;
780 protected function sortDefinitionsBySolution(array $solution, array $definitions): array
783 $handled_defintions = array();
784 foreach ($solution as $solution_values) {
785 $id = $solution_values[
'value2'];
786 if (!isset($handled_defintions[
$id])) {
787 $neworder[] = $this->
object->getDefinitionWithIdentifier($id);
788 $handled_defintions[
$id] =
$id;
792 foreach ($definitions as $definition) {
796 if (!isset($handled_defintions[$definition->getIdentifier()])) {
797 $neworder[] = $definition;
810 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
811 $files[] =
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js';
814 $files[] =
'Modules/TestQuestionPool/js/ilMatchingQuestion.js';
820 public function getTestOutput($active_id, $pass, $is_postponed =
false, $user_post_solution =
false, $inlineFeedback =
false): string
824 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
825 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
828 $this->tpl->addJavaScript(
'./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
830 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/ilMatchingQuestion.js');
831 $this->tpl->addOnLoadCode(
'ilMatchingQuestionInit();');
834 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html",
true,
true,
"Modules/TestQuestionPool");
836 $solutions = array();
838 if (is_array($user_post_solution)) {
839 foreach ($user_post_solution[
'matching'][$this->
object->getId()] as $definition => $term) {
840 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
844 $solutions = $this->
object->getTestOutputSolutions($active_id, $pass);
849 foreach ($solutions as $idx => $solution_value) {
850 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1)) {
851 $template->setCurrentBlock(
"matching_data");
852 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
853 $template->setVariable(
"DEFINITION_ID", $solution_value[
"value2"]);
854 $template->parseCurrentBlock();
861 $terms = $this->
object->getTerms();
862 $definitions = $this->
object->getDefinitions();
863 switch ($this->
object->getShuffleMode()) {
865 $terms = $this->
object->getShuffler()->transform($terms);
866 if (count($solutions)) {
867 $definitions = $this->sortDefinitionsBySolution($solutions, $definitions);
869 $definitions = $this->
object->getShuffler()->transform(
870 $this->
object->getShuffler()->transform($definitions)
875 $terms = $this->
object->getShuffler()->transform($terms);
878 if (count($solutions)) {
879 $definitions = $this->sortDefinitionsBySolution($solutions, $definitions);
881 $definitions = $this->
object->getShuffler()->transform($definitions);
888 foreach ($definitions as $definition) {
889 if (strlen($definition->getPicture())) {
890 $template->setCurrentBlock(
"definition_picture");
891 $template->setVariable(
"DEFINITION_ID", $definition->getIdentifier());
892 $template->setVariable(
"IMAGE_HREF", $this->
object->getImagePathWeb() . $definition->getPicture());
893 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->getPicture();
894 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->getPicture();
895 if (!@file_exists($thumb)) {
896 $this->
object->rebuildThumbnails();
898 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
899 $template->setVariable(
"THUMB_ALT", $this->
lng->txt(
"image"));
900 $template->setVariable(
"THUMB_TITLE", $this->
lng->txt(
"image"));
901 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->getText())) ? $this->
object->prepareTextareaOutput($definition->getText(),
true,
true) :
'');
902 $template->setVariable(
"TEXT_PREVIEW", $this->
lng->txt(
'preview'));
904 $template->parseCurrentBlock();
906 $template->setCurrentBlock(
"definition_text");
907 $template->setVariable(
"DEFINITION", $this->
object->prepareTextareaOutput($definition->getText(),
true,
true));
908 $template->parseCurrentBlock();
911 $template->setCurrentBlock(
"droparea");
912 $template->setVariable(
"ID_DROPAREA", $definition->getIdentifier());
913 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
914 $template->parseCurrentBlock();
916 $template->setCurrentBlock(
"definition_data");
917 $template->setVariable(
"DEFINITION_ID", $definition->getIdentifier());
918 $template->parseCurrentBlock();
923 foreach ($terms as $term) {
924 if (strlen($term->getPicture())) {
925 $template->setCurrentBlock(
"term_picture");
926 $template->setVariable(
"TERM_ID", $term->getIdentifier());
927 $template->setVariable(
"IMAGE_HREF", $this->
object->getImagePathWeb() . $term->getPicture());
928 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->getPicture();
929 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->getPicture();
930 if (!@file_exists($thumb)) {
931 $this->
object->rebuildThumbnails();
933 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
934 $template->setVariable(
"THUMB_ALT", $this->
lng->txt(
"image"));
935 $template->setVariable(
"THUMB_TITLE", $this->
lng->txt(
"image"));
936 $template->setVariable(
"TEXT_PREVIEW", $this->
lng->txt(
'preview'));
937 $template->setVariable(
"TEXT_TERM", (strlen($term->getText())) ? $this->
object->prepareTextareaOutput($term->getText(),
true,
true) :
'');
939 $template->parseCurrentBlock();
941 $template->setCurrentBlock(
"term_text");
942 $template->setVariable(
"TERM_TEXT", $this->
object->prepareTextareaOutput($term->getText(),
true,
true));
943 $template->parseCurrentBlock();
945 $template->setCurrentBlock(
"draggable");
946 $template->setVariable(
"ID_DRAGGABLE", $term->getIdentifier());
947 $template->parseCurrentBlock();
949 $template->setCurrentBlock(
'term_data');
950 $template->setVariable(
'TERM_ID', $term->getIdentifier());
951 $template->parseCurrentBlock();
954 $template->setVariable(
'MATCHING_MODE', $this->
object->getMatchingMode());
956 $template->setVariable(
"RESET_BUTTON", $this->
lng->txt(
"reset_terms"));
958 $template->setVariable(
"QUESTIONTEXT", $this->
object->getQuestionForHTMLOutput());
960 return $this->
outQuestionPage(
"", $is_postponed, $active_id, $template->get());
968 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"])) {
976 $matches = array_values($this->
object->matchingpairs);
978 if (!$this->
object->feedbackOBJ->specificAnswerFeedbackExists()) {
982 $feedback =
'<table class="test_specific_feedback"><tbody>';
984 foreach ($matches as $idx => $ans) {
985 if (!isset($userSolution[$ans->getDefinition()->getIdentifier()])) {
989 if (!is_array($userSolution[$ans->getDefinition()->getIdentifier()])) {
993 if (!in_array($ans->getTerm()->getIdentifier(), $userSolution[$ans->getDefinition()->getIdentifier()])) {
997 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1002 $feedback .=
'<tr><td>"' . $ans->getDefinition()->getText() .
'" ' . $this->
lng->txt(
"matches") .
' "';
1003 $feedback .= $ans->getTerm()->getText() .
'"</td><td>';
1004 $feedback .= $fb .
'</td> </tr>';
1007 $feedback .=
'</tbody></table>';
1008 return $this->
object->prepareTextareaOutput($feedback,
true);
1052 if (!($pair->getPoints() > 0)) {
1056 if (!is_object($term)) {
1060 if ($pair->getDefinition()->getIdentifier() != $definition->getIdentifier()) {
1064 if ($pair->getTerm()->getIdentifier() != $term->getIdentifier()) {
1073 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $picture;
1074 return '<img src="' . $thumbweb .
'" alt="' . $picture .
'" title="' . $picture .
'"/>';
1081 if (strlen($elem->getText())) {
1082 $html .= $elem->getText();
1085 if (strlen($elem->getPicture())) {
1094 $answersByActiveAndPass = array();
1096 foreach ($relevantAnswers as $row) {
1097 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
1099 if (!isset($answersByActiveAndPass[
$key])) {
1100 $answersByActiveAndPass[
$key] = array();
1103 $answersByActiveAndPass[
$key][$row[
'value1']] = $row[
'value2'];
1108 foreach ($answersByActiveAndPass as
$key => $matchingPairs) {
1109 foreach ($matchingPairs as $termId => $defId) {
1110 $hash = md5($termId .
':' . $defId);
1112 if (!isset($answers[$hash])) {
1114 $this->
object->getTermWithIdentifier($termId)
1118 $this->
object->getDefinitionWithIdentifier($defId)
1121 $answers[$hash] = array(
1122 'answer' => $termHtml . $defHtml,
1123 'term' => $termHtml,
1124 'definition' => $defHtml,
1129 $answers[$hash][
'frequency']++;
1145 require_once
'Modules/TestQuestionPool/classes/tables/class.ilMatchingQuestionAnswerFreqStatTableGUI.php';
1148 $table->setQuestionIndex($questionIndex);
1150 $table->initColumns();
1157 require_once
'Modules/TestQuestionPool/classes/forms/class.ilAssMatchingPairCorrectionsInputGUI.php';
1160 $pairs->setTerms($this->
object->getTerms());
1161 $pairs->setDefinitions($this->
object->getDefinitions());
1162 $pairs->setPairs($this->
object->getMatchingPairs());
1163 $pairs->setThumbsWebPathWithPrefix($this->
object->getImagePathWeb() . $this->
object->getThumbPrefix());
1172 $pairs = $this->
object->getMatchingPairs();
1175 if ($this->request->isset(
'pairs')) {
1176 $points_of_pairs = $this->request->raw(
'pairs')[
'points'];
1177 $pair_terms = explode(
',', $this->request->raw(
'pairs')[
'term_id']);
1178 $pair_definitions = explode(
',', $this->request->raw(
'pairs')[
'definition_id']);
1180 foreach ($points_of_pairs as $idx => $points) {
1181 $k = implode(
'.', [$pair_terms[$idx],$pair_definitions[$idx]]);
1182 $values[$k] = (float) str_replace(
',',
'.', $points);
1185 foreach ($pairs as $idx => $pair) {
1186 $id = implode(
'.', [
1187 $pair->getTerm()->getIdentifier(),
1188 $pair->getDefinition()->getIdentifier()
1190 $nu_pairs[
$id] = $pair->withPoints($values[
$id]);
1193 $this->
object = $this->
object->withMatchingPairs($nu_pairs);
isTestPresentationContext()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
hasCorrectSolution($activeId, $passIndex)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
generateCorrectnessIconsForCorrectness(int $correctness)
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
const MATCHING_MODE_N_ON_N
getAnswerStatisticImageHtml($picture)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
const MATCHING_MODE_1_ON_1
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
getTestOutput($active_id, $pass, $is_postponed=false, $user_post_solution=false, $inlineFeedback=false)
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)
const CSS_CLASS_FEEDBACK_CORRECT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getPresentationJavascripts()
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
Class for matching questions.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
checkInput()
check input fields
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
setErrorMessage(string $errormessage)
writeQuestionGenericPostData()
getAnswerStatisticMatchingElemHtml($elem)
__construct($id=-1)
assMatchingQuestionGUI constructor
writePostData(bool $always=false)
{}
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
setValue(string $a_value)
getAggregatedAnswersView(array $relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
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)
static initjQueryUI(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
getAnswerFrequencyTableGUI($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
const CSS_CLASS_FEEDBACK_WRONG
getPreview($show_question_only=false, $showInlineFeedback=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
saveTaxonomyAssignments()
getSpecificFeedbackOutput(array $userSolution)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
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)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static signFile(string $path_to_file)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getGenericFeedbackOutput(int $active_id, ?int $pass)