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);
349 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
352 $pairs->setTerms($this->object->getTerms());
353 $pairs->setDefinitions($this->object->getDefinitions());
354 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
355 if (count($this->object->getMatchingPairs()) == 0)
359 $pairs->setPairs($this->object->getMatchingPairs());
360 $form->addItem($pairs);
368 $form->setValuesByPost();
369 $errors = !$form->checkInput();
370 $form->setValuesByPost();
371 if ((!
$errors) && (count($terms->getValues()) < (count($definitions->getValues()))))
374 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
377 if (
$errors) $checkonly =
false;
380 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
386 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $user_post_solution);
387 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
388 $this->tpl->setVariable(
"FORMACTION", $formaction);
407 $graphicalOutput = FALSE,
408 $result_output = FALSE,
409 $show_question_only = TRUE,
410 $show_feedback = FALSE,
411 $show_correct_solution = FALSE,
412 $show_manual_scoring = FALSE
416 include_once
"./classes/class.ilTemplate.php";
417 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
418 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
420 $solutions = array();
421 if (($active_id > 0) && (!$show_correct_solution))
423 include_once
"./Modules/Test/classes/class.ilObjTest.php";
424 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
425 $solution_script .=
"";
429 foreach ($this->object->getMatchingPairs() as $pair)
431 array_push($solutions, array(
"value1" => $pair->term->identifier,
"value2" => $pair->definition->identifier));
436 foreach ($solutions as $solution)
438 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
439 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
441 if (is_object($definition))
443 if (strlen($definition->picture))
445 $template->setCurrentBlock(
'definition_image');
446 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
447 $template->setVariable(
'ANSWER_IMAGE_ALT', (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
ilUtil::prepareFormOutput($definition->picture));
448 $template->setVariable(
'ANSWER_IMAGE_TITLE', (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
ilUtil::prepareFormOutput($definition->picture));
449 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
450 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
452 $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));
453 $template->parseCurrentBlock();
457 $template->setCurrentBlock(
'definition_text');
459 $template->parseCurrentBlock();
462 if (is_object($term))
464 if (strlen($term->picture))
466 $template->setCurrentBlock(
'term_image');
467 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
468 $template->setVariable(
'ANSWER_IMAGE_ALT', (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
ilUtil::prepareFormOutput($term->picture));
469 $template->setVariable(
'ANSWER_IMAGE_TITLE', (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
ilUtil::prepareFormOutput($term->picture));
470 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
471 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
472 $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));
474 $template->parseCurrentBlock();
478 $template->setCurrentBlock(
'term_text');
480 $template->parseCurrentBlock();
484 if (($active_id > 0) && (!$show_correct_solution))
486 if ($graphicalOutput)
490 foreach ($this->object->getMatchingPairs() as $pair)
492 if (is_object($term))
if (($pair->definition->identifier == $definition->identifier) && ($pair->term->identifier == $term->identifier))
$ok =
true;
496 $template->setCurrentBlock(
"icon_ok");
498 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
499 $template->parseCurrentBlock();
503 $template->setCurrentBlock(
"icon_ok");
505 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
506 $template->parseCurrentBlock();
514 foreach ($this->object->getMatchingPairs() as $pair)
516 foreach ($solutions as $solution)
518 if (($solution[
'value2'] == $pair->definition->identifier) && ($solution[
'value1'] == $pair->term->identifier))
524 $resulttext = (
$points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
525 $template->setCurrentBlock(
"result_output");
526 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext,
$points));
527 $template->parseCurrentBlock();
530 $template->setCurrentBlock(
"row");
531 if ($this->object->getEstimatedElementHeight() > 0)
533 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
535 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
536 $template->parseCurrentBlock();
539 $questiontext = $this->
object->getQuestion();
540 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
541 $questionoutput = $template->get();
543 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
544 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
546 $solutionoutput = $solutiontemplate->get();
547 if (!$show_question_only)
552 return $solutionoutput;
560 include_once
"./classes/class.ilTemplate.php";
561 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
564 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
566 if (array_key_exists(
'js',
$_GET))
568 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
570 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
571 if ($ilUser->getPref(
"tst_javascript") == 1)
574 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
575 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
576 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
577 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
582 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
583 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
584 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
585 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
587 $jsswitch = $jstemplate->get();
588 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
592 $terms = $this->
object->getTerms();
593 $definitions = $this->
object->getDefinitions();
594 switch ($this->object->getShuffle())
597 $terms = $this->
object->pcArrayShuffle($terms);
598 $definitions = $this->
object->pcArrayShuffle($definitions);
601 $terms = $this->
object->pcArrayShuffle($terms);
604 $definitions = $this->
object->pcArrayShuffle($definitions);
608 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
613 foreach ($definitions as $definition)
615 if (strlen($definition->picture))
617 $template->setCurrentBlock(
"definition_picture");
618 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
619 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
620 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
621 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
622 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
623 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
624 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
625 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
626 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ?
ilUtil::htmlentitiesOutsideHTMLTags($this->object->prepareTextareaOutput($definition->text, TRUE)) :
'');
627 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
629 $template->parseCurrentBlock();
633 $template->setCurrentBlock(
"definition_text");
635 $template->parseCurrentBlock();
638 $template->setCurrentBlock(
"droparea");
639 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
640 $template->setVariable(
"QUESTION_ID", $this->object->getId());
641 if ($this->object->getEstimatedElementHeight() > 0)
643 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
645 $template->parseCurrentBlock();
647 $template->setCurrentBlock(
"init_dropareas");
648 $template->setVariable(
"COUNTER", $counter++);
649 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
650 $template->parseCurrentBlock();
656 foreach ($terms as $term)
658 if (strlen($term->picture))
660 $template->setCurrentBlock(
"term_picture");
661 $template->setVariable(
"TERM_ID", $term->identifier);
662 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
663 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
664 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
665 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
666 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
667 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
668 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
669 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
672 $template->parseCurrentBlock();
676 $template->setCurrentBlock(
"term_text");
677 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
679 $template->parseCurrentBlock();
681 $template->setCurrentBlock(
"draggable");
682 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
683 if ($this->object->getEstimatedElementHeight() > 0)
685 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
687 $template->parseCurrentBlock();
689 $template->setCurrentBlock(
"init_draggables");
690 $template->setVariable(
"COUNTER", $counter++);
691 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
692 $template->parseCurrentBlock();
695 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
697 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
699 $questiontext = $this->
object->getQuestion();
700 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
701 $questionoutput = $jsswitch . $template->get();
702 if (!$show_question_only)
707 return $questionoutput;
715 include_once
"./classes/class.ilTemplate.php";
716 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
719 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
721 if (array_key_exists(
'js',
$_GET))
723 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
725 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
726 if ($ilUser->getPref(
"tst_javascript") == 1)
729 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
730 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
731 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
732 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
737 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
738 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
739 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
740 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
742 $jsswitch = $jstemplate->get();
743 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
752 $terms = $this->
object->getTerms();
753 $definitions = $this->
object->getDefinitions();
754 switch ($this->object->getShuffle())
757 $terms = $this->
object->pcArrayShuffle($terms);
758 $definitions = $this->
object->pcArrayShuffle($definitions);
761 $terms = $this->
object->pcArrayShuffle($terms);
764 $definitions = $this->
object->pcArrayShuffle($definitions);
768 for ($i = 0; $i < count($definitions); $i++)
770 $definition = $definitions[$i];
771 if (is_object($definition))
773 if (strlen($definition->picture))
775 $template->setCurrentBlock(
'definition_image');
776 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
777 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
778 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
779 $template->setVariable(
'ANSWER_IMAGE_ALT', (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
ilUtil::prepareFormOutput($definition->picture));
780 $template->setVariable(
'ANSWER_IMAGE_TITLE', (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
ilUtil::prepareFormOutput($definition->picture));
781 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
782 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
784 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::htmlentitiesOutsideHTMLTags($this->object->prepareTextareaOutput($definition->text, TRUE)) : $this->lng->txt(
'definition') .
' ' . ($i+1));
785 $template->parseCurrentBlock();
789 $template->setCurrentBlock(
'definition_text');
791 $template->parseCurrentBlock();
795 $template->setCurrentBlock(
'option');
796 $template->setVariable(
"VALUE_OPTION", 0);
798 $template->parseCurrentBlock();
800 foreach ($terms as $term)
802 $template->setCurrentBlock(
'option');
803 $template->setVariable(
"VALUE_OPTION", $term->identifier);
804 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($j) .
': ' . $this->object->prepareTextareaOutput($term->text, TRUE) : $this->lng->txt(
'term') .
' ' . ($j));
805 $template->parseCurrentBlock();
809 $template->setCurrentBlock(
'row');
810 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
811 if ($this->object->getEstimatedElementHeight() > 0)
813 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
815 $template->setVariable(
"QUESTION_ID", $this->object->getId());
816 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
817 $template->parseCurrentBlock();
821 foreach ($terms as $term)
823 if (strlen($term->picture))
825 $template->setCurrentBlock(
'term_image');
826 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
827 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
828 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
829 $template->setVariable(
'ANSWER_IMAGE_ALT', (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
ilUtil::prepareFormOutput($term->picture));
830 $template->setVariable(
'ANSWER_IMAGE_TITLE', (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
ilUtil::prepareFormOutput($term->picture));
831 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
832 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
833 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::htmlentitiesOutsideHTMLTags($this->object->prepareTextareaOutput($term->text, TRUE)) : $this->lng->txt(
'term') .
' ' . ($i+1));
835 $template->parseCurrentBlock();
839 $template->setCurrentBlock(
'term_text');
841 $template->parseCurrentBlock();
843 $template->touchBlock(
'terms');
847 $questiontext = $this->
object->getQuestion();
848 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
851 $questionoutput = $jsswitch . $template->get();
852 if (!$show_question_only)
857 return $questionoutput;
863 foreach ($solution as $solution_values)
865 $id = $solution_values[
'value2'];
866 array_push($neworder, $this->object->getDefinitionWithIdentifier($id));
874 include_once
"./classes/class.ilTemplate.php";
875 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
880 include_once
"./Modules/Test/classes/class.ilObjTest.php";
885 if (is_array($user_post_solution))
887 $solutions = array();
888 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
890 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
895 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
898 foreach ($solutions as $idx => $solution_value)
902 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1))
904 $template->setCurrentBlock(
"restoreposition");
905 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
906 $template->setVariable(
"PICTURE_DEFINITION_ID", $solution_value[
"value2"]);
907 $template->parseCurrentBlock();
914 $terms = $this->
object->getTerms();
915 $definitions = $this->
object->getDefinitions();
916 switch ($this->object->getShuffle())
919 $terms = $this->
object->pcArrayShuffle($terms);
920 if (count($solutions))
926 $definitions = $this->
object->pcArrayShuffle($definitions);
930 $terms = $this->
object->pcArrayShuffle($terms);
933 if (count($solutions))
939 $definitions = $this->
object->pcArrayShuffle($definitions);
944 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
949 foreach ($definitions as $definition)
951 if (strlen($definition->picture))
953 $template->setCurrentBlock(
"definition_picture");
954 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
955 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
956 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
957 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
958 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
959 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
960 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
961 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
962 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ?
ilUtil::prepareFormOutput($definition->text) :
'');
963 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
965 $template->parseCurrentBlock();
969 $template->setCurrentBlock(
"definition_text");
971 $template->parseCurrentBlock();
974 $template->setCurrentBlock(
"droparea");
975 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
976 $template->setVariable(
"QUESTION_ID", $this->object->getId());
977 if ($this->object->getEstimatedElementHeight() > 0)
979 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
981 $template->parseCurrentBlock();
983 $template->setCurrentBlock(
"init_dropareas");
984 $template->setVariable(
"COUNTER", $counter++);
985 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
986 $template->parseCurrentBlock();
992 foreach ($terms as $term)
994 if (strlen($term->picture))
996 $template->setCurrentBlock(
"term_picture");
997 $template->setVariable(
"TERM_ID", $term->identifier);
998 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
999 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
1000 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
1001 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1002 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
1003 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
1004 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
1005 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1008 $template->parseCurrentBlock();
1012 $template->setCurrentBlock(
"term_text");
1014 $template->parseCurrentBlock();
1016 $template->setCurrentBlock(
"draggable");
1017 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1018 if ($this->object->getEstimatedElementHeight() > 0)
1020 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1022 $template->parseCurrentBlock();
1024 $template->setCurrentBlock(
"init_draggables");
1025 $template->setVariable(
"COUNTER", $counter++);
1026 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1027 $template->parseCurrentBlock();
1030 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
1032 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
1034 $questiontext = $this->
object->getQuestion();
1035 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1036 $questionoutput = $template->get();
1037 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1048 include_once
"./classes/class.ilTemplate.php";
1049 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1054 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1059 if (is_array($user_post_solution))
1061 $solutions = array();
1062 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
1064 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
1069 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1075 $terms = $this->
object->getTerms();
1076 $definitions = $this->
object->getDefinitions();
1077 switch ($this->object->getShuffle())
1080 $terms = $this->
object->pcArrayShuffle($terms);
1081 if (count($solutions))
1087 $definitions = $this->
object->pcArrayShuffle($definitions);
1091 $terms = $this->
object->pcArrayShuffle($terms);
1094 if (count($solutions))
1100 $definitions = $this->
object->pcArrayShuffle($definitions);
1104 $maxcount = max(count($terms), count($definitions));
1105 for ($i = 0; $i < count($definitions); $i++)
1107 $definition = $definitions[$i];
1108 if (is_object($definition))
1110 if (strlen($definition->picture))
1112 $template->setCurrentBlock(
'definition_image');
1113 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
1116 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
1117 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1119 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
1120 $template->parseCurrentBlock();
1124 $template->setCurrentBlock(
'definition_text');
1126 $template->parseCurrentBlock();
1130 $template->setCurrentBlock(
'option');
1131 $template->setVariable(
"VALUE_OPTION", 0);
1133 $template->parseCurrentBlock();
1135 foreach ($terms as $term)
1137 $template->setCurrentBlock(
'option');
1138 $template->setVariable(
"VALUE_OPTION", $term->identifier);
1139 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($j) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($j));
1140 foreach ($solutions as $solution)
1142 if ($solution[
"value1"] == $term->identifier && $solution[
"value2"] == $definition->identifier)
1144 $template->setVariable(
"SELECTED_OPTION",
" selected=\"selected\"");
1147 $template->parseCurrentBlock();
1151 $template->setCurrentBlock(
'row');
1152 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
1153 if ($this->object->getEstimatedElementHeight() > 0)
1155 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1157 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1158 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
1159 $template->parseCurrentBlock();
1162 foreach ($terms as $term)
1164 if (strlen($term->picture))
1166 $template->setCurrentBlock(
'term_image');
1167 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
1170 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
1171 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1172 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
1174 $template->parseCurrentBlock();
1178 $template->setCurrentBlock(
'term_text');
1180 $template->parseCurrentBlock();
1182 $template->touchBlock(
'terms');
1185 $questiontext = $this->
object->getQuestion();
1186 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1190 $questiontext = $this->
object->getQuestion();
1191 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1192 $questionoutput = $template->get();
1193 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1216 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1218 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
1219 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
1220 $this->
object->cleanupMediaObjectUsage();
1231 global $rbacsystem, $ilTabs;
1233 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
1234 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1235 $q_type = $this->
object->getQuestionType();
1237 if (strlen($q_type))
1239 $classname = $q_type .
"GUI";
1240 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1241 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1246 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1249 $ilTabs->addTarget(
"edit_content",
1250 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1251 array(
"edit",
"insert",
"exec_pg"),
1252 "",
"", $force_active);
1256 $ilTabs->addTarget(
"preview",
1257 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1259 "ilPageObjectGUI",
"", $force_active);
1262 $force_active =
false;
1263 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1266 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1268 $ilTabs->addTarget(
"edit_properties",
1270 array(
"editQuestion",
"save",
"saveEdit",
"removeimageterms",
"uploadterms",
"removeimagedefinitions",
"uploaddefinitions",
1271 "addpairs",
"removepairs",
"addterms",
"removeterms",
"adddefinitions",
"removedefinitions",
"originalSyncForm"),
1272 $classname,
"", $force_active);
1277 $ilTabs->addTarget(
"feedback",
1278 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1279 array(
"feedback",
"saveFeedback"),
1285 $ilTabs->addTarget(
"solution_hint",
1286 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
1287 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
1288 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
1298 $ilTabs->addTarget(
"statistics",
1299 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1300 array(
"assessment"),
1304 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1308 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1312 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));