24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
50 include_once
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
55 $this->
object->loadFromDb($id);
72 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
75 $this->
object->setTitle(
$_POST[
"title"]);
76 $this->
object->setAuthor(
$_POST[
"author"]);
77 $this->
object->setComment(
$_POST[
"comment"]);
78 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
79 $questiontext =
$_POST[
"question"];
80 $this->
object->setQuestion($questiontext);
83 $this->
object->setShuffle(
$_POST[
"shuffle"]);
87 $this->
object->setShuffle(1);
89 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"]);
90 $this->
object->setElementHeight(
$_POST[
"element_height"]);
93 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
96 $this->
object->setEstimatedWorkingTime(
103 $this->
object->flushMatchingPairs();
104 $this->
object->flushTerms();
105 $this->
object->flushDefinitions();
109 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
110 foreach (
$_POST[
'terms'][
'answer'] as $index => $answer)
113 if (strlen($_FILES[
'terms'][
'name'][
'image'][$index]))
116 $name = $_FILES[
'terms'][
'name'][
'image'][$index];
117 if ($this->object->setImageFile($_FILES[
'terms'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename(
$name)))
129 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
130 foreach (
$_POST[
'definitions'][
'answer'] as $index => $answer)
133 if (strlen($_FILES[
'definitions'][
'name'][
'image'][$index]))
136 $name = $_FILES[
'definitions'][
'name'][
'image'][$index];
137 if ($this->object->setImageFile($_FILES[
'definitions'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename(
$name)))
150 if (is_array(
$_POST[
'pairs'][
'points']))
152 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
155 $term_id =
$_POST[
'pairs'][
'term'][$index];
156 $definition_id =
$_POST[
'pairs'][
'definition'][$index];
157 $this->
object->addMatchingPair($this->object->getTermWithIdentifier($term_id), $this->
object->getDefinitionWithIdentifier($definition_id),
$points);
174 $position = key(
$_POST[
'cmd'][
'uploadterms']);
184 $position = key(
$_POST[
'cmd'][
'removeimageterms']);
186 $this->
object->removeTermImage($position);
196 $position = key(
$_POST[
'cmd'][
'uploaddefinitions']);
206 $position = key(
$_POST[
'cmd'][
'removeimagedefinitions']);
208 $this->
object->removeDefinitionImage($position);
215 $position = key(
$_POST[
"cmd"][
"addterms"]);
216 $this->
object->insertTerm($position+1);
223 $position = key(
$_POST[
"cmd"][
"removeterms"]);
224 $this->
object->deleteTerm($position);
231 $position = key(
$_POST[
"cmd"][
"adddefinitions"]);
232 $this->
object->insertDefinition($position+1);
239 $position = key(
$_POST[
"cmd"][
"removedefinitions"]);
240 $this->
object->deleteDefinition($position);
247 $position = key(
$_POST[
"cmd"][
"addpairs"]);
248 $this->
object->insertMatchingPair($position+1);
255 $position = key(
$_POST[
"cmd"][
"removepairs"]);
256 $this->
object->deleteMatchingPair($position);
267 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
270 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
272 $form->setFormAction($this->ctrl->getFormAction($this));
274 $form->setMultipart(
true);
275 $form->setTableWidth(
"100%");
276 $form->setId(
"matching");
280 $hidden->setValue($matchingtype);
281 $form->addItem($hidden);
289 $shuffle =
new ilSelectInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle");
290 $shuffle_options = array(
291 0 => $this->lng->txt(
"no"),
292 1 => $this->lng->txt(
"matching_shuffle_terms_definitions"),
293 2 => $this->lng->txt(
"matching_shuffle_terms"),
294 3 => $this->lng->txt(
"matching_shuffle_definitions")
297 $shuffle->setValue($this->object->getShuffle());
298 $shuffle->setRequired(FALSE);
299 $form->addItem($shuffle);
301 $element_height =
new ilNumberInputGUI($this->lng->txt(
"element_height"),
"element_height");
302 $element_height->
setValue($this->object->getElementHeight());
303 $element_height->setRequired(
false);
304 $element_height->setMaxLength(6);
305 $element_height->setMinValue(20);
306 $element_height->setSize(6);
307 $element_height->setInfo($this->lng->txt(
"element_height_info"));
308 $form->addItem($element_height);
310 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry"),
"thumb_geometry");
311 $geometry->
setValue($this->object->getThumbGeometry());
312 $geometry->setRequired(
true);
313 $geometry->setMaxLength(6);
314 $geometry->setMinValue(20);
315 $geometry->setSize(6);
316 $geometry->setInfo($this->lng->txt(
"thumb_geometry_info"));
317 $form->addItem($geometry);
321 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
324 $definitions->setRequired(
true);
325 $definitions->setQuestionObject($this->
object);
326 $definitions->setTextName($this->lng->txt(
'definition_text'));
327 $definitions->setImageName($this->lng->txt(
'definition_image'));
328 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
330 $definitionvalues = $this->
object->getDefinitions();
331 $definitions->setValues($definitionvalues);
332 $form->addItem($definitions);
335 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
338 $terms->setRequired(
true);
339 $terms->setQuestionObject($this->
object);
340 $terms->setTextName($this->lng->txt(
'term_text'));
341 $terms->setImageName($this->lng->txt(
'term_image'));
342 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
344 $termvalues = $this->
object->getTerms();
345 $terms->setValues($termvalues);
346 $form->addItem($terms);
348 include_once(
"./Services/Form/classes/class.ilAdditionalCharactersGUI.php");
351 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
354 $pairs->setTerms($this->object->getTerms());
355 $pairs->setDefinitions($this->object->getDefinitions());
356 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
357 if (count($this->object->getMatchingPairs()) == 0)
361 $pairs->setPairs($this->object->getMatchingPairs());
362 $form->addItem($pairs);
370 $form->setValuesByPost();
371 $errors = !$form->checkInput();
372 $form->setValuesByPost();
373 if ((!
$errors) && (count($terms->getValues()) < (count($definitions->getValues()))))
376 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
379 if (
$errors) $checkonly =
false;
382 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
388 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $user_post_solution);
389 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
390 $this->tpl->setVariable(
"FORMACTION", $formaction);
409 $graphicalOutput = FALSE,
410 $result_output = FALSE,
411 $show_question_only = TRUE,
412 $show_feedback = FALSE,
413 $show_correct_solution = FALSE,
414 $show_manual_scoring = FALSE
418 include_once
"./classes/class.ilTemplate.php";
419 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
420 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
422 $solutions = array();
423 if (($active_id > 0) && (!$show_correct_solution))
425 include_once
"./Modules/Test/classes/class.ilObjTest.php";
426 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
427 $solution_script .=
"";
431 foreach ($this->object->getMatchingPairs() as $pair)
433 if( $pair->points <= 0 )
438 $solutions[] = array(
439 "value1" => $pair->term->identifier,
440 "value2" => $pair->definition->identifier,
441 'points' => $pair->points
448 foreach ($solutions as $solution)
450 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
451 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
453 if (is_object($definition))
455 if (strlen($definition->picture))
457 $template->setCurrentBlock(
'definition_image');
458 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
461 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
462 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
464 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
465 $template->parseCurrentBlock();
469 $template->setCurrentBlock(
'definition_text');
470 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
471 $template->parseCurrentBlock();
474 if (is_object($term))
476 if (strlen($term->picture))
478 $template->setCurrentBlock(
'term_image');
479 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
482 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
483 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
484 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
486 $template->parseCurrentBlock();
490 $template->setCurrentBlock(
'term_text');
491 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
492 $template->parseCurrentBlock();
496 if (($active_id > 0) && (!$show_correct_solution))
498 if ($graphicalOutput)
502 foreach ($this->object->getMatchingPairs() as $pair)
504 if (is_object($term))
if (($pair->definition->identifier == $definition->identifier) && ($pair->term->identifier == $term->identifier))
$ok =
true;
508 $template->setCurrentBlock(
"icon_ok");
510 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
511 $template->parseCurrentBlock();
515 $template->setCurrentBlock(
"icon_ok");
517 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
518 $template->parseCurrentBlock();
552 $resulttext = (
$points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
553 $template->setCurrentBlock(
"result_output");
554 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext,
$points));
555 $template->parseCurrentBlock();
558 $template->setCurrentBlock(
"row");
559 if ($this->object->getEstimatedElementHeight() > 0)
561 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
563 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
564 $template->parseCurrentBlock();
567 $questiontext = $this->
object->getQuestion();
568 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
569 $questionoutput = $template->get();
571 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
572 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
574 $solutionoutput = $solutiontemplate->get();
575 if (!$show_question_only)
580 return $solutionoutput;
588 include_once
"./classes/class.ilTemplate.php";
589 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
592 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
594 if (array_key_exists(
'js',
$_GET))
596 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
598 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
599 if ($ilUser->getPref(
"tst_javascript") == 1)
602 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
603 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
604 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
605 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
610 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
611 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
612 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
613 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
615 $jsswitch = $jstemplate->get();
616 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
620 $terms = $this->
object->getTerms();
621 $definitions = $this->
object->getDefinitions();
622 switch ($this->object->getShuffle())
625 $terms = $this->
object->pcArrayShuffle($terms);
626 $definitions = $this->
object->pcArrayShuffle($definitions);
629 $terms = $this->
object->pcArrayShuffle($terms);
632 $definitions = $this->
object->pcArrayShuffle($definitions);
636 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
641 foreach ($definitions as $definition)
643 if (strlen($definition->picture))
645 $template->setCurrentBlock(
"definition_picture");
646 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
647 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
648 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
649 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
650 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
651 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
652 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
653 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
654 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
'');
655 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
657 $template->parseCurrentBlock();
661 $template->setCurrentBlock(
"definition_text");
662 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
663 $template->parseCurrentBlock();
666 $template->setCurrentBlock(
"droparea");
667 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
668 $template->setVariable(
"QUESTION_ID", $this->object->getId());
669 if ($this->object->getEstimatedElementHeight() > 0)
671 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
673 $template->parseCurrentBlock();
675 $template->setCurrentBlock(
"init_dropareas");
676 $template->setVariable(
"COUNTER", $counter++);
677 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
678 $template->parseCurrentBlock();
684 foreach ($terms as $term)
686 if (strlen($term->picture))
688 $template->setCurrentBlock(
"term_picture");
689 $template->setVariable(
"TERM_ID", $term->identifier);
690 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
691 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
692 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
693 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
694 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
695 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
696 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
697 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
698 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
'');
700 $template->parseCurrentBlock();
704 $template->setCurrentBlock(
"term_text");
705 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text, TRUE));
706 $template->parseCurrentBlock();
708 $template->setCurrentBlock(
"draggable");
709 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
710 if ($this->object->getEstimatedElementHeight() > 0)
712 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
714 $template->parseCurrentBlock();
716 $template->setCurrentBlock(
"init_draggables");
717 $template->setVariable(
"COUNTER", $counter++);
718 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
719 $template->parseCurrentBlock();
722 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
724 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
726 $questiontext = $this->
object->getQuestion();
727 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
728 $questionoutput = $jsswitch . $template->get();
729 if (!$show_question_only)
734 return $questionoutput;
742 include_once
"./classes/class.ilTemplate.php";
743 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
746 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
748 if (array_key_exists(
'js',
$_GET))
750 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
752 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
753 if ($ilUser->getPref(
"tst_javascript") == 1)
756 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
757 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
758 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
759 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
764 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
765 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
766 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
767 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
769 $jsswitch = $jstemplate->get();
770 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
779 $terms = $this->
object->getTerms();
780 $definitions = $this->
object->getDefinitions();
781 switch ($this->object->getShuffle())
784 $terms = $this->
object->pcArrayShuffle($terms);
785 $definitions = $this->
object->pcArrayShuffle($definitions);
788 $terms = $this->
object->pcArrayShuffle($terms);
791 $definitions = $this->
object->pcArrayShuffle($definitions);
795 for ($i = 0; $i < count($definitions); $i++)
797 $definition = $definitions[$i];
798 if (is_object($definition))
800 if (strlen($definition->picture))
802 $template->setCurrentBlock(
'definition_image');
803 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
806 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
807 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
809 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' . $this->object->prepareTextareaOutput($definition->text, TRUE) : $this->lng->txt(
'definition') .
' ' . ($i+1));
810 $template->parseCurrentBlock();
814 $template->setCurrentBlock(
'definition_text');
815 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
816 $template->parseCurrentBlock();
820 $template->setCurrentBlock(
'option');
821 $template->setVariable(
"VALUE_OPTION", 0);
823 $template->parseCurrentBlock();
825 foreach ($terms as $term)
827 $template->setCurrentBlock(
'option');
828 $template->setVariable(
"VALUE_OPTION", $term->identifier);
829 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($j) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($j));
830 $template->parseCurrentBlock();
834 $template->setCurrentBlock(
'row');
835 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
836 if ($this->object->getEstimatedElementHeight() > 0)
838 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
840 $template->setVariable(
"QUESTION_ID", $this->object->getId());
841 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
842 $template->parseCurrentBlock();
846 foreach ($terms as $term)
848 if (strlen($term->picture))
850 $template->setCurrentBlock(
'term_image');
851 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
854 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
855 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
856 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' . $this->object->prepareTextareaOutput($term->text, TRUE) : $this->lng->txt(
'term') .
' ' . ($i+1));
858 $template->parseCurrentBlock();
862 $template->setCurrentBlock(
'term_text');
863 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
864 $template->parseCurrentBlock();
866 $template->touchBlock(
'terms');
870 $questiontext = $this->
object->getQuestion();
871 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
874 $questionoutput = $jsswitch . $template->get();
875 if (!$show_question_only)
880 return $questionoutput;
886 foreach ($solution as $solution_values)
888 $id = $solution_values[
'value2'];
889 array_push($neworder, $this->object->getDefinitionWithIdentifier($id));
897 include_once
"./classes/class.ilTemplate.php";
898 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
903 include_once
"./Modules/Test/classes/class.ilObjTest.php";
908 if (is_array($user_post_solution))
910 $solutions = array();
911 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
913 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
918 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
921 foreach ($solutions as $idx => $solution_value)
925 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1))
927 $template->setCurrentBlock(
"restoreposition");
928 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
929 $template->setVariable(
"PICTURE_DEFINITION_ID", $solution_value[
"value2"]);
930 $template->parseCurrentBlock();
937 $terms = $this->
object->getTerms();
938 $definitions = $this->
object->getDefinitions();
939 switch ($this->object->getShuffle())
942 $terms = $this->
object->pcArrayShuffle($terms);
943 if (count($solutions))
949 $definitions = $this->
object->pcArrayShuffle($definitions);
953 $terms = $this->
object->pcArrayShuffle($terms);
956 if (count($solutions))
962 $definitions = $this->
object->pcArrayShuffle($definitions);
967 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
972 foreach ($definitions as $definition)
974 if (strlen($definition->picture))
976 $template->setCurrentBlock(
"definition_picture");
977 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
978 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
979 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
980 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
981 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
982 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
983 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
984 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
985 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ?
ilUtil::prepareFormOutput($definition->text) :
'');
986 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
988 $template->parseCurrentBlock();
992 $template->setCurrentBlock(
"definition_text");
993 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
994 $template->parseCurrentBlock();
997 $template->setCurrentBlock(
"droparea");
998 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
999 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1000 if ($this->object->getEstimatedElementHeight() > 0)
1002 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1004 $template->parseCurrentBlock();
1006 $template->setCurrentBlock(
"init_dropareas");
1007 $template->setVariable(
"COUNTER", $counter++);
1008 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
1009 $template->parseCurrentBlock();
1015 foreach ($terms as $term)
1017 if (strlen($term->picture))
1019 $template->setCurrentBlock(
"term_picture");
1020 $template->setVariable(
"TERM_ID", $term->identifier);
1021 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
1022 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
1023 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
1024 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1025 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
1026 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
1027 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
1028 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1031 $template->parseCurrentBlock();
1035 $template->setCurrentBlock(
"term_text");
1036 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true));
1037 $template->parseCurrentBlock();
1039 $template->setCurrentBlock(
"draggable");
1040 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1041 if ($this->object->getEstimatedElementHeight() > 0)
1043 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1045 $template->parseCurrentBlock();
1047 $template->setCurrentBlock(
"init_draggables");
1048 $template->setVariable(
"COUNTER", $counter++);
1049 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1050 $template->parseCurrentBlock();
1053 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
1055 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
1057 $questiontext = $this->
object->getQuestion();
1058 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1059 $questionoutput = $template->get();
1060 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1071 include_once
"./classes/class.ilTemplate.php";
1072 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1077 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1082 if (is_array($user_post_solution))
1084 $solutions = array();
1085 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
1087 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
1092 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1098 $terms = $this->
object->getTerms();
1099 $definitions = $this->
object->getDefinitions();
1100 switch ($this->object->getShuffle())
1103 $terms = $this->
object->pcArrayShuffle($terms);
1104 if (count($solutions))
1110 $definitions = $this->
object->pcArrayShuffle($definitions);
1114 $terms = $this->
object->pcArrayShuffle($terms);
1117 if (count($solutions))
1123 $definitions = $this->
object->pcArrayShuffle($definitions);
1127 $maxcount = max(count($terms), count($definitions));
1128 for ($i = 0; $i < count($definitions); $i++)
1130 $definition = $definitions[$i];
1131 if (is_object($definition))
1133 if (strlen($definition->picture))
1135 $template->setCurrentBlock(
'definition_image');
1136 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
1139 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
1140 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1142 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
1143 $template->parseCurrentBlock();
1147 $template->setCurrentBlock(
'definition_text');
1148 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
1149 $template->parseCurrentBlock();
1153 $template->setCurrentBlock(
'option');
1154 $template->setVariable(
"VALUE_OPTION", 0);
1156 $template->parseCurrentBlock();
1158 foreach ($terms as $term)
1160 $template->setCurrentBlock(
'option');
1161 $template->setVariable(
"VALUE_OPTION", $term->identifier);
1162 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($j) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($j));
1163 foreach ($solutions as $solution)
1165 if ($solution[
"value1"] == $term->identifier && $solution[
"value2"] == $definition->identifier)
1167 $template->setVariable(
"SELECTED_OPTION",
" selected=\"selected\"");
1170 $template->parseCurrentBlock();
1174 $template->setCurrentBlock(
'row');
1175 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
1176 if ($this->object->getEstimatedElementHeight() > 0)
1178 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1180 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1181 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
1182 $template->parseCurrentBlock();
1186 foreach ($terms as $term)
1188 if (strlen($term->picture))
1190 $template->setCurrentBlock(
'term_image');
1191 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
1194 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
1195 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1196 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
1198 $template->parseCurrentBlock();
1202 $template->setCurrentBlock(
'term_text');
1203 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text,
true));
1204 $template->parseCurrentBlock();
1206 $template->touchBlock(
'terms');
1210 $questiontext = $this->
object->getQuestion();
1211 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1215 $questiontext = $this->
object->getQuestion();
1216 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1217 $questionoutput = $template->get();
1218 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1241 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1243 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
1244 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
1245 $this->
object->cleanupMediaObjectUsage();
1256 global $rbacsystem, $ilTabs;
1258 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
1259 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1260 $q_type = $this->
object->getQuestionType();
1262 if (strlen($q_type))
1264 $classname = $q_type .
"GUI";
1265 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1266 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1271 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1274 $ilTabs->addTarget(
"edit_content",
1275 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1276 array(
"edit",
"insert",
"exec_pg"),
1277 "",
"", $force_active);
1281 $ilTabs->addTarget(
"preview",
1282 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1284 "ilPageObjectGUI",
"", $force_active);
1287 $force_active =
false;
1288 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1291 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1293 $ilTabs->addTarget(
"edit_properties",
1295 array(
"editQuestion",
"save",
"saveEdit",
"removeimageterms",
"uploadterms",
"removeimagedefinitions",
"uploaddefinitions",
1296 "addpairs",
"removepairs",
"addterms",
"removeterms",
"adddefinitions",
"removedefinitions",
"originalSyncForm"),
1297 $classname,
"", $force_active);
1302 $ilTabs->addTarget(
"feedback",
1303 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1304 array(
"feedback",
"saveFeedback"),
1310 $ilTabs->addTarget(
"solution_hint",
1311 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
1312 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
1313 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
1323 $ilTabs->addTarget(
"statistics",
1324 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1325 array(
"assessment"),
1329 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1333 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1337 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));