5 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
31 include_once
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
36 $this->
object->loadFromDb($id);
53 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
56 $this->
object->setTitle(
$_POST[
"title"]);
57 $this->
object->setAuthor(
$_POST[
"author"]);
58 $this->
object->setComment(
$_POST[
"comment"]);
59 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
60 $questiontext =
$_POST[
"question"];
61 $this->
object->setQuestion($questiontext);
64 $this->
object->setShuffle(
$_POST[
"shuffle"]);
68 $this->
object->setShuffle(1);
70 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"]);
71 $this->
object->setElementHeight(
$_POST[
"element_height"]);
74 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
77 $this->
object->setEstimatedWorkingTime(
84 $this->
object->flushMatchingPairs();
85 $this->
object->flushTerms();
86 $this->
object->flushDefinitions();
90 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
91 foreach (
$_POST[
'terms'][
'answer'] as $index => $answer)
94 if (strlen($_FILES[
'terms'][
'name'][
'image'][$index]))
97 $name = $_FILES[
'terms'][
'name'][
'image'][$index];
98 if ($this->object->setImageFile($_FILES[
'terms'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename($name)))
100 $filename = $this->
object->getEncryptedFilename($name);
110 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
111 foreach (
$_POST[
'definitions'][
'answer'] as $index => $answer)
114 if (strlen($_FILES[
'definitions'][
'name'][
'image'][$index]))
117 $name = $_FILES[
'definitions'][
'name'][
'image'][$index];
118 if ($this->object->setImageFile($_FILES[
'definitions'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename($name)))
120 $filename = $this->
object->getEncryptedFilename($name);
131 if (is_array(
$_POST[
'pairs'][
'points']))
133 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
134 foreach (
$_POST[
'pairs'][
'points'] as $index => $points)
136 $term_id =
$_POST[
'pairs'][
'term'][$index];
137 $definition_id =
$_POST[
'pairs'][
'definition'][$index];
138 $this->
object->addMatchingPair($this->object->getTermWithIdentifier($term_id), $this->
object->getDefinitionWithIdentifier($definition_id), $points);
155 $position = key(
$_POST[
'cmd'][
'uploadterms']);
165 $position = key(
$_POST[
'cmd'][
'removeimageterms']);
167 $this->
object->removeTermImage($position);
177 $position = key(
$_POST[
'cmd'][
'uploaddefinitions']);
187 $position = key(
$_POST[
'cmd'][
'removeimagedefinitions']);
189 $this->
object->removeDefinitionImage($position);
196 $position = key(
$_POST[
"cmd"][
"addterms"]);
197 $this->
object->insertTerm($position+1);
204 $position = key(
$_POST[
"cmd"][
"removeterms"]);
205 $this->
object->deleteTerm($position);
212 $position = key(
$_POST[
"cmd"][
"adddefinitions"]);
213 $this->
object->insertDefinition($position+1);
220 $position = key(
$_POST[
"cmd"][
"removedefinitions"]);
221 $this->
object->deleteDefinition($position);
228 $position = key(
$_POST[
"cmd"][
"addpairs"]);
229 $this->
object->insertMatchingPair($position+1);
236 $position = key(
$_POST[
"cmd"][
"removepairs"]);
237 $this->
object->deleteMatchingPair($position);
251 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
253 $form->setFormAction($this->ctrl->getFormAction($this));
255 $form->setMultipart(
true);
256 $form->setTableWidth(
"100%");
257 $form->setId(
"matching");
261 $hidden->setValue($matchingtype);
262 $form->addItem($hidden);
270 $shuffle =
new ilSelectInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle");
271 $shuffle_options = array(
272 0 => $this->lng->txt(
"no"),
273 1 => $this->lng->txt(
"matching_shuffle_terms_definitions"),
274 2 => $this->lng->txt(
"matching_shuffle_terms"),
275 3 => $this->lng->txt(
"matching_shuffle_definitions")
278 $shuffle->setValue($this->object->getShuffle());
279 $shuffle->setRequired(FALSE);
280 $form->addItem($shuffle);
282 $element_height =
new ilNumberInputGUI($this->lng->txt(
"element_height"),
"element_height");
283 $element_height->
setValue($this->object->getElementHeight());
284 $element_height->setRequired(
false);
285 $element_height->setMaxLength(6);
286 $element_height->setMinValue(20);
287 $element_height->setSize(6);
288 $element_height->setInfo($this->lng->txt(
"element_height_info"));
289 $form->addItem($element_height);
291 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry"),
"thumb_geometry");
292 $geometry->
setValue($this->object->getThumbGeometry());
293 $geometry->setRequired(
true);
294 $geometry->setMaxLength(6);
295 $geometry->setMinValue(20);
296 $geometry->setSize(6);
297 $geometry->setInfo($this->lng->txt(
"thumb_geometry_info"));
298 $form->addItem($geometry);
302 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
305 $definitions->setRequired(
true);
306 $definitions->setQuestionObject($this->
object);
307 $definitions->setTextName($this->lng->txt(
'definition_text'));
308 $definitions->setImageName($this->lng->txt(
'definition_image'));
309 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
311 $definitionvalues = $this->
object->getDefinitions();
312 $definitions->setValues($definitionvalues);
313 $form->addItem($definitions);
316 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
319 $terms->setRequired(
true);
320 $terms->setQuestionObject($this->
object);
321 $terms->setTextName($this->lng->txt(
'term_text'));
322 $terms->setImageName($this->lng->txt(
'term_image'));
323 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
325 $termvalues = $this->
object->getTerms();
326 $terms->setValues($termvalues);
327 $form->addItem($terms);
330 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
333 $pairs->setTerms($this->object->getTerms());
334 $pairs->setDefinitions($this->object->getDefinitions());
335 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
336 if (count($this->object->getMatchingPairs()) == 0)
340 $pairs->setPairs($this->object->getMatchingPairs());
341 $form->addItem($pairs);
349 $form->setValuesByPost();
350 $errors = !$form->checkInput();
351 $form->setValuesByPost();
356 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
359 if (
$errors) $checkonly =
false;
362 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
373 $numDefinitions = count($form->
getItemByPostVar(
'definitions')->getValues());
375 if($numTerms >= $numDefinitions)
385 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $user_post_solution);
386 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
387 $this->tpl->setVariable(
"FORMACTION", $formaction);
406 $graphicalOutput = FALSE,
407 $result_output = FALSE,
408 $show_question_only = TRUE,
409 $show_feedback = FALSE,
410 $show_correct_solution = FALSE,
411 $show_manual_scoring = FALSE
415 include_once
"./classes/class.ilTemplate.php";
416 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
417 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
419 $solutions = array();
420 if (($active_id > 0) && (!$show_correct_solution))
422 include_once
"./Modules/Test/classes/class.ilObjTest.php";
423 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
424 $solution_script .=
"";
428 foreach ($this->object->getMatchingPairs() as $pair)
430 if( $pair->points <= 0 )
435 $solutions[] = array(
436 "value1" => $pair->term->identifier,
437 "value2" => $pair->definition->identifier,
438 'points' => $pair->points
445 foreach ($solutions as $solution)
447 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
448 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
449 $points = $solution[
'points'];
451 if (is_object($definition))
453 if (strlen($definition->picture))
455 $template->setCurrentBlock(
'definition_image');
456 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
459 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
460 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
462 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
463 $template->parseCurrentBlock();
467 $template->setCurrentBlock(
'definition_text');
468 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
469 $template->parseCurrentBlock();
472 if (is_object($term))
474 if (strlen($term->picture))
476 $template->setCurrentBlock(
'term_image');
477 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
480 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
481 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
482 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
484 $template->parseCurrentBlock();
488 $template->setCurrentBlock(
'term_text');
489 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
490 $template->parseCurrentBlock();
494 if (($active_id > 0) && (!$show_correct_solution))
496 if ($graphicalOutput)
500 foreach ($this->object->getMatchingPairs() as $pair)
510 $template->setCurrentBlock(
"icon_ok");
512 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
513 $template->parseCurrentBlock();
517 $template->setCurrentBlock(
"icon_ok");
519 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
520 $template->parseCurrentBlock();
527 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
528 $template->setCurrentBlock(
"result_output");
529 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
530 $template->parseCurrentBlock();
533 $template->setCurrentBlock(
"row");
534 if ($this->object->getEstimatedElementHeight() > 0)
536 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
538 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
539 $template->parseCurrentBlock();
542 $questiontext = $this->
object->getQuestion();
543 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
544 $questionoutput = $template->get();
546 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
547 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
549 $solutionoutput = $solutiontemplate->get();
550 if (!$show_question_only)
555 return $solutionoutput;
563 include_once
"./classes/class.ilTemplate.php";
564 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
567 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
569 if (array_key_exists(
'js',
$_GET))
571 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
573 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
574 if ($ilUser->getPref(
"tst_javascript") == 1)
577 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
578 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
579 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
580 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
585 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
586 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
587 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
588 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
590 $jsswitch = $jstemplate->get();
591 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
595 $terms = $this->
object->getTerms();
596 $definitions = $this->
object->getDefinitions();
597 switch ($this->object->getShuffle())
600 $terms = $this->
object->pcArrayShuffle($terms);
601 $definitions = $this->
object->pcArrayShuffle($definitions);
604 $terms = $this->
object->pcArrayShuffle($terms);
607 $definitions = $this->
object->pcArrayShuffle($definitions);
611 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
616 foreach ($definitions as $definition)
618 if (strlen($definition->picture))
620 $template->setCurrentBlock(
"definition_picture");
621 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
622 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
623 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
624 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
625 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
626 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
627 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
628 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
629 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
'');
630 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
632 $template->parseCurrentBlock();
636 $template->setCurrentBlock(
"definition_text");
637 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
638 $template->parseCurrentBlock();
641 $template->setCurrentBlock(
"droparea");
642 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
643 $template->setVariable(
"QUESTION_ID", $this->object->getId());
644 if ($this->object->getEstimatedElementHeight() > 0)
646 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
648 $template->parseCurrentBlock();
650 $template->setCurrentBlock(
"init_dropareas");
651 $template->setVariable(
"COUNTER", $counter++);
652 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
653 $template->parseCurrentBlock();
659 foreach ($terms as $term)
661 if (strlen($term->picture))
663 $template->setCurrentBlock(
"term_picture");
664 $template->setVariable(
"TERM_ID", $term->identifier);
665 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
666 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
667 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
668 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
669 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
670 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
671 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
672 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
673 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
'');
675 $template->parseCurrentBlock();
679 $template->setCurrentBlock(
"term_text");
680 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text, TRUE));
681 $template->parseCurrentBlock();
683 $template->setCurrentBlock(
"draggable");
684 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
685 if ($this->object->getEstimatedElementHeight() > 0)
687 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
689 $template->parseCurrentBlock();
691 $template->setCurrentBlock(
"init_draggables");
692 $template->setVariable(
"COUNTER", $counter++);
693 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
694 $template->parseCurrentBlock();
697 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
699 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
701 $questiontext = $this->
object->getQuestion();
702 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
703 $questionoutput = $jsswitch . $template->get();
704 if (!$show_question_only)
709 return $questionoutput;
717 include_once
"./classes/class.ilTemplate.php";
718 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
721 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
723 if (array_key_exists(
'js',
$_GET))
725 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
727 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
728 if ($ilUser->getPref(
"tst_javascript") == 1)
731 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
732 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
733 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
734 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
739 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
740 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
741 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
742 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
744 $jsswitch = $jstemplate->get();
745 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
754 $terms = $this->
object->getTerms();
755 $definitions = $this->
object->getDefinitions();
756 switch ($this->object->getShuffle())
759 $terms = $this->
object->pcArrayShuffle($terms);
760 $definitions = $this->
object->pcArrayShuffle($definitions);
763 $terms = $this->
object->pcArrayShuffle($terms);
766 $definitions = $this->
object->pcArrayShuffle($definitions);
770 for ($i = 0; $i < count($definitions); $i++)
772 $definition = $definitions[$i];
773 if (is_object($definition))
775 if (strlen($definition->picture))
777 $template->setCurrentBlock(
'definition_image');
778 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $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) .
': ' . $this->object->prepareTextareaOutput($definition->text, TRUE) : $this->lng->txt(
'definition') .
' ' . ($i+1));
785 $template->parseCurrentBlock();
789 $template->setCurrentBlock(
'definition_text');
790 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
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) .
': ' .
ilUtil::prepareFormOutput($term->text) : $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 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
829 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
830 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
831 $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));
833 $template->parseCurrentBlock();
837 $template->setCurrentBlock(
'term_text');
838 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
839 $template->parseCurrentBlock();
841 $template->touchBlock(
'terms');
845 $questiontext = $this->
object->getQuestion();
846 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
849 $questionoutput = $jsswitch . $template->get();
850 if (!$show_question_only)
855 return $questionoutput;
861 foreach ($solution as $solution_values)
863 $id = $solution_values[
'value2'];
864 array_push($neworder, $this->object->getDefinitionWithIdentifier($id));
872 include_once
"./classes/class.ilTemplate.php";
873 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
878 include_once
"./Modules/Test/classes/class.ilObjTest.php";
883 if (is_array($user_post_solution))
885 $solutions = array();
886 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
888 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
893 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
896 foreach ($solutions as $idx => $solution_value)
900 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1))
902 $template->setCurrentBlock(
"restoreposition");
903 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
904 $template->setVariable(
"PICTURE_DEFINITION_ID", $solution_value[
"value2"]);
905 $template->parseCurrentBlock();
912 $terms = $this->
object->getTerms();
913 $definitions = $this->
object->getDefinitions();
914 switch ($this->object->getShuffle())
917 $terms = $this->
object->pcArrayShuffle($terms);
918 if (count($solutions))
924 $definitions = $this->
object->pcArrayShuffle($definitions);
928 $terms = $this->
object->pcArrayShuffle($terms);
931 if (count($solutions))
937 $definitions = $this->
object->pcArrayShuffle($definitions);
942 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
947 foreach ($definitions as $definition)
949 if (strlen($definition->picture))
951 $template->setCurrentBlock(
"definition_picture");
952 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
953 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
954 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
955 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
956 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
957 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
958 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
959 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
960 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ?
ilUtil::prepareFormOutput($definition->text) :
'');
961 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
963 $template->parseCurrentBlock();
967 $template->setCurrentBlock(
"definition_text");
968 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
969 $template->parseCurrentBlock();
972 $template->setCurrentBlock(
"droparea");
973 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
974 $template->setVariable(
"QUESTION_ID", $this->object->getId());
975 if ($this->object->getEstimatedElementHeight() > 0)
977 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
979 $template->parseCurrentBlock();
981 $template->setCurrentBlock(
"init_dropareas");
982 $template->setVariable(
"COUNTER", $counter++);
983 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
984 $template->parseCurrentBlock();
990 foreach ($terms as $term)
992 if (strlen($term->picture))
994 $template->setCurrentBlock(
"term_picture");
995 $template->setVariable(
"TERM_ID", $term->identifier);
996 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
997 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
998 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
999 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1000 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
1001 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
1002 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
1003 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1006 $template->parseCurrentBlock();
1010 $template->setCurrentBlock(
"term_text");
1011 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true));
1012 $template->parseCurrentBlock();
1014 $template->setCurrentBlock(
"draggable");
1015 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1016 if ($this->object->getEstimatedElementHeight() > 0)
1018 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1020 $template->parseCurrentBlock();
1022 $template->setCurrentBlock(
"init_draggables");
1023 $template->setVariable(
"COUNTER", $counter++);
1024 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1025 $template->parseCurrentBlock();
1028 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
1030 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
1032 $questiontext = $this->
object->getQuestion();
1033 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1034 $questionoutput = $template->get();
1035 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1046 include_once
"./classes/class.ilTemplate.php";
1047 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1052 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1057 if (is_array($user_post_solution))
1059 $solutions = array();
1060 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
1062 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
1067 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1073 $terms = $this->
object->getTerms();
1074 $definitions = $this->
object->getDefinitions();
1075 switch ($this->object->getShuffle())
1078 $terms = $this->
object->pcArrayShuffle($terms);
1079 if (count($solutions))
1085 $definitions = $this->
object->pcArrayShuffle($definitions);
1089 $terms = $this->
object->pcArrayShuffle($terms);
1092 if (count($solutions))
1098 $definitions = $this->
object->pcArrayShuffle($definitions);
1102 $maxcount = max(count($terms), count($definitions));
1103 for ($i = 0; $i < count($definitions); $i++)
1105 $definition = $definitions[$i];
1106 if (is_object($definition))
1108 if (strlen($definition->picture))
1110 $template->setCurrentBlock(
'definition_image');
1111 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
1114 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
1115 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1117 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
1118 $template->parseCurrentBlock();
1122 $template->setCurrentBlock(
'definition_text');
1123 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
1124 $template->parseCurrentBlock();
1128 $template->setCurrentBlock(
'option');
1129 $template->setVariable(
"VALUE_OPTION", 0);
1131 $template->parseCurrentBlock();
1133 foreach ($terms as $term)
1135 $template->setCurrentBlock(
'option');
1136 $template->setVariable(
"VALUE_OPTION", $term->identifier);
1137 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($j) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($j));
1138 foreach ($solutions as $solution)
1140 if ($solution[
"value1"] == $term->identifier && $solution[
"value2"] == $definition->identifier)
1142 $template->setVariable(
"SELECTED_OPTION",
" selected=\"selected\"");
1145 $template->parseCurrentBlock();
1149 $template->setCurrentBlock(
'row');
1150 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
1151 if ($this->object->getEstimatedElementHeight() > 0)
1153 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1155 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1156 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
1157 $template->parseCurrentBlock();
1161 foreach ($terms as $term)
1163 if (strlen($term->picture))
1165 $template->setCurrentBlock(
'term_image');
1166 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
1169 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
1170 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1171 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
1173 $template->parseCurrentBlock();
1177 $template->setCurrentBlock(
'term_text');
1178 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text,
true));
1179 $template->parseCurrentBlock();
1181 $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))
1309 global $___test_express_mode;
1311 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
1312 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1316 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
1321 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
1327 if( !($pair->points > 0) )
1332 if( !is_object($term) )
1337 if( $pair->definition->identifier != $definition->identifier )
1342 if( $pair->term->identifier != $term->identifier )