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';
37 parent::__construct();
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';
66 $this->
object->flushMatchingPairs();
67 $this->
object->flushTerms();
68 $this->
object->flushDefinitions();
71 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php';
72 foreach (
$_POST[
'terms'][
'answer'] as
$index => $answer) {
74 if (strlen($_FILES[
'terms'][
'name'][
'image'][
$index])) {
77 if ($this->object->setImageFile(
78 $_FILES[
'terms'][
'tmp_name'][
'image'][$index],
79 $this->object->getEncryptedFilename(
$name)
87 $this->
object->addTerm(
92 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php';
93 foreach (
$_POST[
'definitions'][
'answer'] as
$index => $answer) {
95 if (strlen($_FILES[
'definitions'][
'name'][
'image'][
$index])) {
97 $name = $_FILES[
'definitions'][
'name'][
'image'][
$index];
98 if ($this->object->setImageFile(
99 $_FILES[
'definitions'][
'tmp_name'][
'image'][$index],
100 $this->object->getEncryptedFilename(
$name)
108 $this->
object->addDefinition(
114 if (is_array(
$_POST[
'pairs'][
'points'])) {
115 require_once
'./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php';
116 foreach (
$_POST[
'pairs'][
'points'] as
$index => $points) {
119 $this->
object->addMatchingPair(
120 $this->object->getTermWithIdentifier($term_id),
121 $this->
object->getDefinitionWithIdentifier($definition_id),
130 if (!$this->object->getSelfAssessmentEditingMode()) {
131 $this->
object->setShuffle(
$_POST[
"shuffle"]);
133 $this->
object->setShuffle(1);
135 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"]);
136 $this->
object->setMatchingMode(
$_POST[
'matching_mode']);
148 $position = key(
$_POST[
'cmd'][
'removeimageterms']);
149 $this->
object->removeTermImage($position);
162 $position = key(
$_POST[
'cmd'][
'removeimagedefinitions']);
163 $this->
object->removeDefinitionImage($position);
170 $position = key(
$_POST[
"cmd"][
"addterms"]);
171 $this->
object->insertTerm($position + 1);
178 $position = key(
$_POST[
"cmd"][
"removeterms"]);
179 $this->
object->deleteTerm($position);
186 $position = key(
$_POST[
"cmd"][
"adddefinitions"]);
187 $this->
object->insertDefinition($position + 1);
194 $position = key(
$_POST[
"cmd"][
"removedefinitions"]);
195 $this->
object->deleteDefinition($position);
202 $position = key(
$_POST[
"cmd"][
"addpairs"]);
203 $this->
object->insertMatchingPair($position + 1);
210 $position = key(
$_POST[
"cmd"][
"removepairs"]);
211 $this->
object->deleteMatchingPair($position);
220 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
222 $this->editForm =
$form;
224 $form->setFormAction($this->ctrl->getFormAction($this));
226 $form->setMultipart(
true);
227 $form->setTableWidth(
"100%");
228 $form->setId(
"matching");
240 $form->setValuesByPost();
242 $form->setValuesByPost();
245 $terms =
$form->getItemByPostVar(
'terms');
246 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
255 $this->tpl->setVariable(
"QUESTION_DATA",
$form->getHTML());
262 return $this->ctrl->getCmd() ==
'uploaddefinitions';
267 return $this->ctrl->getCmd() ==
'uploadterms';
286 $numDefinitions = count($form->
getItemByPostVar(
'definitions')->getValues());
288 if ($numTerms >= $numDefinitions) {
298 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
300 if ($this->object->getSelfAssessmentEditingMode()) {
304 $definitions->setRequired(
true);
305 $definitions->setQuestionObject($this->
object);
306 $definitions->setTextName($this->lng->txt(
'definition_text'));
307 $definitions->setImageName($this->lng->txt(
'definition_image'));
308 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
309 if (!count($this->object->getDefinitions())) {
312 $definitionvalues = $this->
object->getDefinitions();
313 $definitions->setValues($definitionvalues);
315 $definitions->checkInput();
320 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
322 if ($this->object->getSelfAssessmentEditingMode()) {
325 $terms->setRequired(
true);
326 $terms->setQuestionObject($this->
object);
327 $terms->setTextName($this->lng->txt(
'term_text'));
328 $terms->setImageName($this->lng->txt(
'term_image'));
329 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
330 if (!count($this->object->getTerms())) {
333 $termvalues = $this->
object->getTerms();
334 $terms->setValues($termvalues);
336 $terms->checkInput();
341 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
344 $pairs->setTerms($this->object->getTerms());
345 $pairs->setDefinitions($this->object->getDefinitions());
346 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
347 if (count($this->object->getMatchingPairs()) == 0) {
350 $pairs->setPairs($this->object->getMatchingPairs());
360 $hidden->setValue($matchingtype);
363 if (!$this->object->getSelfAssessmentEditingMode()) {
365 $shuffle =
new ilSelectInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle");
366 $shuffle_options = array(
367 0 => $this->lng->txt(
"no"),
368 1 => $this->lng->txt(
"matching_shuffle_terms_definitions"),
369 2 => $this->lng->txt(
"matching_shuffle_terms"),
370 3 => $this->lng->txt(
"matching_shuffle_definitions")
373 $shuffle->setValue($this->object->getShuffle() != null ? $this->
object->getShuffle() : 1);
374 $shuffle->setRequired(
false);
377 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry"),
"thumb_geometry");
378 $geometry->
setValue($this->object->getThumbGeometry());
379 $geometry->setRequired(
true);
380 $geometry->setMaxLength(6);
381 $geometry->setMinValue(20);
382 $geometry->setSize(6);
383 $geometry->setInfo($this->lng->txt(
"thumb_geometry_info"));
388 $mode =
new ilRadioGroupInputGUI($this->lng->txt(
'qpl_qst_inp_matching_mode'),
'matching_mode');
392 $this->lng->txt(
'qpl_qst_inp_matching_mode_one_on_one'),
395 $mode->addOption($modeONEonONE);
398 $this->lng->txt(
'qpl_qst_inp_matching_mode_all_on_all'),
401 $mode->addOption($modeALLonALL);
403 $mode->
setValue($this->object->getMatchingMode());
434 $graphicalOutput =
false,
435 $result_output =
false,
436 $show_question_only =
true,
437 $show_feedback =
false,
438 $show_correct_solution =
false,
439 $show_manual_scoring =
false,
440 $show_question_text =
true 443 include_once
"./Services/UICore/classes/class.ilTemplate.php";
444 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
445 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
447 $solutions = array();
448 if (($active_id > 0) && (!$show_correct_solution)) {
449 include_once
"./Modules/Test/classes/class.ilObjTest.php";
451 $solution_script .=
"";
453 foreach ($this->object->getMaximumScoringMatchingPairs() as $pair) {
454 $solutions[] = array(
455 "value1" => $pair->term->identifier,
456 "value2" => $pair->definition->identifier,
457 'points' => $pair->points
464 foreach ($solutions as $solution) {
465 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
466 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
467 $points = $solution[
'points'];
469 if (is_object($definition)) {
470 if (strlen($definition->picture)) {
471 if (strlen($definition->text)) {
472 $template->setCurrentBlock(
'definition_image_text');
478 $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture
481 $template->setCurrentBlock(
'definition_image');
482 $template->setVariable(
'ANSWER_IMAGE_URL', $answerImageSrc);
485 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
486 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
490 $template->setCurrentBlock(
'definition_text');
491 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
495 if (is_object($term)) {
496 if (strlen($term->picture)) {
497 if (strlen($term->text)) {
498 $template->setCurrentBlock(
'term_image_text');
504 $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture
507 $template->setCurrentBlock(
'term_image');
508 $template->setVariable(
'ANSWER_IMAGE_URL', $answerImageSrc);
511 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
512 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
517 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text,
true));
522 if (($active_id > 0) && (!$show_correct_solution)) {
523 if ($graphicalOutput) {
526 foreach ($this->object->getMatchingPairs() as $pair) {
535 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
540 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
546 if ($result_output) {
547 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
548 $template->setCurrentBlock(
"result_output");
549 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
554 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
558 $questiontext = $this->
object->getQuestion();
559 if ($show_question_text ==
true) {
560 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext,
true));
566 if ($show_feedback) {
569 $feedback .= strlen($fb) ? $fb :
'';
573 $feedback .= strlen($fb) ? $fb :
'';
575 if (strlen($feedback)) {
581 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
582 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
585 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
587 $solutionoutput = $solutiontemplate->get();
588 if (!$show_question_only) {
592 return $solutionoutput;
595 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
600 if ($DIC[
'ilBrowser']->isMobile() || $DIC[
'ilBrowser']->isIpad()) {
601 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
604 $this->tpl->addJavaScript(
'./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
606 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/jquery-ui-1-10-3-fixed.js');
608 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/ilMatchingQuestion.js');
611 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html",
true,
true,
"Modules/TestQuestionPool");
613 foreach ($solutions as $defId => $terms) {
614 foreach ($terms as $termId) {
615 $template->setCurrentBlock(
"matching_data");
616 $template->setVariable(
"DEFINITION_ID", $defId);
617 $template->setVariable(
"TERM_ID", $termId);
623 $terms = $this->
object->getTerms();
624 $definitions = $this->
object->getDefinitions();
625 switch ($this->object->getShuffle()) {
627 $seed = $this->
object->getShuffler()->getSeed();
628 $this->
object->getShuffler()->setSeed($seed .
'1');
629 $terms = $this->
object->getShuffler()->shuffle($terms);
630 $this->
object->getShuffler()->setSeed($seed .
'2');
631 $definitions = $this->
object->getShuffler()->shuffle($definitions);
632 $this->
object->getShuffler()->setSeed($seed);
635 $terms = $this->
object->getShuffler()->shuffle($terms);
638 $definitions = $this->
object->getShuffler()->shuffle($definitions);
644 foreach ($definitions as $definition) {
645 if (strlen($definition->picture)) {
646 $template->setCurrentBlock(
"definition_picture");
647 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
648 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
649 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
650 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
651 if (!@file_exists($thumb)) {
652 $this->
object->rebuildThumbnails();
654 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
655 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
656 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
657 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text,
true,
true) :
'');
658 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
662 $template->setCurrentBlock(
"definition_text");
663 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true,
true));
668 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
669 $template->setVariable(
"QUESTION_ID", $this->object->getId());
672 $template->setCurrentBlock(
"definition_data");
673 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
679 foreach ($terms as $term) {
680 if (strlen($term->picture)) {
681 $template->setCurrentBlock(
"term_picture");
682 $template->setVariable(
"TERM_ID", $term->identifier);
683 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
684 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
685 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
686 if (!@file_exists($thumb)) {
687 $this->
object->rebuildThumbnails();
689 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
690 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
691 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
692 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
693 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text,
true,
true) :
'');
698 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true,
true));
702 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
706 $template->setVariable(
"TERM_ID", $term->identifier);
710 $template->setVariable(
'MATCHING_MODE', $this->object->getMatchingMode());
712 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
714 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
718 if (!$show_question_only) {
723 return $questionoutput;
731 protected function sortDefinitionsBySolution(array $solution, array $definitions)
734 $handled_defintions = array();
735 foreach ($solution as $solution_values) {
736 $id = $solution_values[
'value2'];
737 if (!isset($handled_defintions[
$id])) {
738 $neworder[] = $this->
object->getDefinitionWithIdentifier($id);
739 $handled_defintions[
$id] =
$id;
743 foreach ($definitions as $definition) {
747 if (!isset($handled_defintions[$definition->identifier])) {
748 $neworder[] = $definition;
756 public function getTestOutput($active_id,
$pass, $is_postponed =
false, $user_post_solution =
false, $inlineFeedback =
false)
760 if ($DIC[
'ilBrowser']->isMobile() || $DIC[
'ilBrowser']->isIpad()) {
761 require_once
'Services/jQuery/classes/class.iljQueryUtil.php';
764 $this->tpl->addJavaScript(
'./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
766 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/jquery-ui-1-10-3-fixed.js');
768 $this->tpl->addJavaScript(
'Modules/TestQuestionPool/js/ilMatchingQuestion.js');
771 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html",
true,
true,
"Modules/TestQuestionPool");
776 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 777 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 779 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 782 if (is_array($user_post_solution)) {
783 $solutions = array();
784 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term) {
785 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
789 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
794 foreach ($solutions as $idx => $solution_value) {
795 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1)) {
796 $template->setCurrentBlock(
"matching_data");
797 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
798 $template->setVariable(
"DEFINITION_ID", $solution_value[
"value2"]);
806 $terms = $this->
object->getTerms();
807 $definitions = $this->
object->getDefinitions();
808 switch ($this->object->getShuffle()) {
810 $seed = $this->
object->getShuffler()->getSeed();
811 $this->
object->getShuffler()->setSeed($seed .
'1');
812 $terms = $this->
object->getShuffler()->shuffle($terms);
813 if (count($solutions)) {
814 $definitions = $this->sortDefinitionsBySolution($solutions, $definitions);
816 $this->
object->getShuffler()->setSeed($seed .
'2');
817 $definitions = $this->
object->getShuffler()->shuffle($definitions);
819 $this->
object->getShuffler()->setSeed($seed);
822 $terms = $this->
object->getShuffler()->shuffle($terms);
825 if (count($solutions)) {
826 $definitions = $this->sortDefinitionsBySolution($solutions, $definitions);
828 $definitions = $this->
object->getShuffler()->shuffle($definitions);
835 foreach ($definitions as $definition) {
836 if (strlen($definition->picture)) {
837 $template->setCurrentBlock(
"definition_picture");
838 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
839 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
840 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
841 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
842 if (!@file_exists($thumb)) {
843 $this->
object->rebuildThumbnails();
845 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
846 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
847 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
848 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text,
true,
true) :
'');
849 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
853 $template->setCurrentBlock(
"definition_text");
854 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true,
true));
859 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
860 $template->setVariable(
"QUESTION_ID", $this->object->getId());
863 $template->setCurrentBlock(
"definition_data");
864 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
870 foreach ($terms as $term) {
871 if (strlen($term->picture)) {
872 $template->setCurrentBlock(
"term_picture");
873 $template->setVariable(
"TERM_ID", $term->identifier);
874 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
875 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
876 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->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_PREVIEW", $this->lng->txt(
'preview'));
884 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text,
true,
true) :
'');
889 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true,
true));
893 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
897 $template->setVariable(
'TERM_ID', $term->identifier);
901 $template->setVariable(
'MATCHING_MODE', $this->object->getMatchingMode());
903 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
905 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
931 $rbacsystem = $DIC[
'rbacsystem'];
932 $ilTabs = $DIC[
'ilTabs'];
934 $ilTabs->clearTargets();
936 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
937 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
938 $q_type = $this->
object->getQuestionType();
940 if (strlen($q_type)) {
941 $classname = $q_type .
"GUI";
942 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
943 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
947 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
951 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
952 array(
"edit",
"insert",
"exec_pg"),
962 $force_active =
false;
963 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
966 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
972 array(
"editQuestion",
"save",
"saveEdit",
"removeimageterms",
"uploadterms",
"removeimagedefinitions",
"uploaddefinitions",
973 "addpairs",
"removepairs",
"addterms",
"removeterms",
"adddefinitions",
"removedefinitions",
"originalSyncForm"),
993 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1005 $matches = array_values($this->object->matchingpairs);
1007 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
1011 $feedback =
'<table class="test_specific_feedback"><tbody>';
1013 foreach ($matches as $idx => $ans) {
1014 if (!isset($userSolution[$ans->definition->identifier])) {
1018 if (!is_array($userSolution[$ans->definition->identifier])) {
1022 if (!in_array($ans->term->identifier, $userSolution[$ans->definition->identifier])) {
1026 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
1027 $this->object->getId(),
1031 $feedback .=
'<tr><td>"' . $ans->definition->text .
'" ' . $this->lng->txt(
"matches") .
' "';
1032 $feedback .= $ans->term->text .
'"</td><td>';
1033 $feedback .= $fb .
'</td> </tr>';
1036 $feedback .=
'</tbody></table>';
1037 return $this->
object->prepareTextareaOutput($feedback,
true);
1083 if (!($pair->points > 0)) {
1087 if (!is_object($term)) {
1091 if ($pair->definition->identifier != $definition->identifier) {
1095 if ($pair->term->identifier != $term->identifier) {
1104 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $picture;
1105 return '<img src="' . $thumbweb .
'" alt="' . $picture .
'" title="' . $picture .
'"/>';
1112 if (strlen($elem->text)) {
1113 $html .= $elem->text;
1116 if (strlen($elem->picture)) {
1125 $answersByActiveAndPass = array();
1127 foreach ($relevantAnswers as
$row) {
1128 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
1130 if (!isset($answersByActiveAndPass[
$key])) {
1131 $answersByActiveAndPass[
$key] = array();
1134 $answersByActiveAndPass[
$key][$row[
'value1']] = $row[
'value2'];
1139 foreach ($answersByActiveAndPass as
$key => $matchingPairs) {
1140 foreach ($matchingPairs as $termId => $defId) {
1141 $hash = md5($termId .
':' . $defId);
1143 if (!isset($answers[$hash])) {
1145 $this->object->getTermWithIdentifier($termId)
1149 $this->object->getDefinitionWithIdentifier($defId)
1152 $answers[$hash] = array(
1153 'answer' => $termHtml . $defHtml,
1154 'term' => $termHtml,
1155 'definition' => $defHtml,
1160 $answers[$hash][
'frequency']++;
1176 require_once
'Modules/TestQuestionPool/classes/tables/class.ilMatchingQuestionAnswerFreqStatTableGUI.php';
1179 $table->setQuestionIndex($questionIndex);
1188 require_once
'Modules/TestQuestionPool/classes/forms/class.ilAssMatchingPairCorrectionsInputGUI.php';
1191 $pairs->setTerms($this->object->getTerms());
1192 $pairs->setDefinitions($this->object->getDefinitions());
1193 $pairs->setPairs($this->object->getMatchingPairs());
1204 foreach ($this->object->getMatchingPairs() as $idx => $matchingPair) {
1205 $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)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
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.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
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...
if(!array_key_exists('StateId', $_REQUEST)) $id
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.
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)
setValue($a_value)
Set Value.
writeQuestionGenericPostData()
getAnswerStatisticMatchingElemHtml($elem)
__construct($id=-1)
assMatchingQuestionGUI constructor
if(isset($_POST['submit'])) $form
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.
special template class to simplify handling of ITX/PEAR
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)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
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.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
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
getAnswersFrequency($relevantAnswers, $questionIndex)
addBackTab(ilTabsGUI $ilTabs)
editQuestion($checkonly=false)
Class for matching question definitions.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
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...
if(empty($password)) $table
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
getSpecificFeedbackOutput($userSolution)
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.