5 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
6 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
32 include_once
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
37 $this->
object->loadFromDb($id);
54 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
57 $this->
object->setTitle(
$_POST[
"title"]);
58 $this->
object->setAuthor(
$_POST[
"author"]);
59 $this->
object->setComment(
$_POST[
"comment"]);
60 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
61 $questiontext =
$_POST[
"question"];
62 $this->
object->setQuestion($questiontext);
65 $this->
object->setShuffle(
$_POST[
"shuffle"]);
69 $this->
object->setShuffle(1);
71 $this->
object->setThumbGeometry(
$_POST[
"thumb_geometry"]);
72 $this->
object->setElementHeight(
$_POST[
"element_height"]);
75 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
78 $this->
object->setEstimatedWorkingTime(
85 $this->
object->flushMatchingPairs();
86 $this->
object->flushTerms();
87 $this->
object->flushDefinitions();
91 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
92 foreach (
$_POST[
'terms'][
'answer'] as $index => $answer)
95 if (strlen($_FILES[
'terms'][
'name'][
'image'][$index]))
98 $name = $_FILES[
'terms'][
'name'][
'image'][$index];
99 if ($this->object->setImageFile($_FILES[
'terms'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename($name)))
101 $filename = $this->
object->getEncryptedFilename($name);
111 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
112 foreach (
$_POST[
'definitions'][
'answer'] as $index => $answer)
115 if (strlen($_FILES[
'definitions'][
'name'][
'image'][$index]))
118 $name = $_FILES[
'definitions'][
'name'][
'image'][$index];
119 if ($this->object->setImageFile($_FILES[
'definitions'][
'tmp_name'][
'image'][$index], $this->object->getEncryptedFilename($name)))
121 $filename = $this->
object->getEncryptedFilename($name);
132 if (is_array(
$_POST[
'pairs'][
'points']))
134 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
135 foreach (
$_POST[
'pairs'][
'points'] as $index => $points)
137 $term_id =
$_POST[
'pairs'][
'term'][$index];
138 $definition_id =
$_POST[
'pairs'][
'definition'][$index];
139 $this->
object->addMatchingPair($this->object->getTermWithIdentifier($term_id), $this->
object->getDefinitionWithIdentifier($definition_id), $points);
156 $position = key(
$_POST[
'cmd'][
'uploadterms']);
166 $position = key(
$_POST[
'cmd'][
'removeimageterms']);
168 $this->
object->removeTermImage($position);
178 $position = key(
$_POST[
'cmd'][
'uploaddefinitions']);
188 $position = key(
$_POST[
'cmd'][
'removeimagedefinitions']);
190 $this->
object->removeDefinitionImage($position);
197 $position = key(
$_POST[
"cmd"][
"addterms"]);
198 $this->
object->insertTerm($position+1);
205 $position = key(
$_POST[
"cmd"][
"removeterms"]);
206 $this->
object->deleteTerm($position);
213 $position = key(
$_POST[
"cmd"][
"adddefinitions"]);
214 $this->
object->insertDefinition($position+1);
221 $position = key(
$_POST[
"cmd"][
"removedefinitions"]);
222 $this->
object->deleteDefinition($position);
229 $position = key(
$_POST[
"cmd"][
"addpairs"]);
230 $this->
object->insertMatchingPair($position+1);
237 $position = key(
$_POST[
"cmd"][
"removepairs"]);
238 $this->
object->deleteMatchingPair($position);
252 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
254 $form->setFormAction($this->ctrl->getFormAction($this));
256 $form->setMultipart(
true);
257 $form->setTableWidth(
"100%");
258 $form->setId(
"matching");
262 $hidden->setValue($matchingtype);
263 $form->addItem($hidden);
271 $shuffle =
new ilSelectInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle");
272 $shuffle_options = array(
273 0 => $this->lng->txt(
"no"),
274 1 => $this->lng->txt(
"matching_shuffle_terms_definitions"),
275 2 => $this->lng->txt(
"matching_shuffle_terms"),
276 3 => $this->lng->txt(
"matching_shuffle_definitions")
279 $shuffle->setValue($this->object->getShuffle() != null ? $this->
object->getShuffle() : 1);
280 $shuffle->setRequired(FALSE);
281 $form->addItem($shuffle);
283 $element_height =
new ilNumberInputGUI($this->lng->txt(
"element_height"),
"element_height");
284 $element_height->
setValue($this->object->getElementHeight());
285 $element_height->setRequired(
false);
286 $element_height->setMaxLength(6);
287 $element_height->setMinValue(20);
288 $element_height->setSize(6);
289 $element_height->setInfo($this->lng->txt(
"element_height_info"));
290 $form->addItem($element_height);
292 $geometry =
new ilNumberInputGUI($this->lng->txt(
"thumb_geometry"),
"thumb_geometry");
293 $geometry->
setValue($this->object->getThumbGeometry());
294 $geometry->setRequired(
true);
295 $geometry->setMaxLength(6);
296 $geometry->setMinValue(20);
297 $geometry->setSize(6);
298 $geometry->setInfo($this->lng->txt(
"thumb_geometry_info"));
299 $form->addItem($geometry);
303 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
306 $definitions->setRequired(
true);
307 $definitions->setQuestionObject($this->
object);
308 $definitions->setTextName($this->lng->txt(
'definition_text'));
309 $definitions->setImageName($this->lng->txt(
'definition_image'));
310 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingDefinition.php";
312 $definitionvalues = $this->
object->getDefinitions();
313 $definitions->setValues($definitionvalues);
314 $definitions->checkInput();
315 $form->addItem($definitions);
318 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingWizardInputGUI.php";
321 $terms->setRequired(
true);
322 $terms->setQuestionObject($this->
object);
323 $terms->setTextName($this->lng->txt(
'term_text'));
324 $terms->setImageName($this->lng->txt(
'term_image'));
325 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
327 $termvalues = $this->
object->getTerms();
328 $terms->setValues($termvalues);
329 $terms->checkInput();
330 $form->addItem($terms);
333 include_once
"./Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php";
336 $pairs->setTerms($this->object->getTerms());
337 $pairs->setDefinitions($this->object->getDefinitions());
338 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingPair.php";
339 if (count($this->object->getMatchingPairs()) == 0)
343 $pairs->setPairs($this->object->getMatchingPairs());
344 $form->addItem($pairs);
352 $form->setValuesByPost();
353 $errors = !$form->checkInput();
354 $form->setValuesByPost();
359 $terms->setAlert($this->lng->txt(
"msg_number_of_terms_too_low"));
362 if (
$errors) $checkonly =
false;
365 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
376 $numDefinitions = count($form->
getItemByPostVar(
'definitions')->getValues());
378 if($numTerms >= $numDefinitions)
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,
415 $show_question_text = TRUE
419 include_once
"./Services/UICore/classes/class.ilTemplate.php";
420 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
421 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
423 $solutions = array();
424 if (($active_id > 0) && (!$show_correct_solution))
426 include_once
"./Modules/Test/classes/class.ilObjTest.php";
427 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
428 $solution_script .=
"";
432 foreach ($this->object->getMatchingPairs() as $pair)
434 if( $pair->points <= 0 )
439 $solutions[] = array(
440 "value1" => $pair->term->identifier,
441 "value2" => $pair->definition->identifier,
442 'points' => $pair->points
449 foreach ($solutions as $solution)
451 $definition = $this->
object->getDefinitionWithIdentifier($solution[
'value2']);
452 $term = $this->
object->getTermWithIdentifier($solution[
'value1']);
453 $points = $solution[
'points'];
455 if (is_object($definition))
457 if (strlen($definition->picture))
459 $template->setCurrentBlock(
'definition_image');
460 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
463 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
464 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
466 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
467 $template->parseCurrentBlock();
471 $template->setCurrentBlock(
'definition_text');
472 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
473 $template->parseCurrentBlock();
476 if (is_object($term))
478 if (strlen($term->picture))
480 $template->setCurrentBlock(
'term_image');
481 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
484 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
485 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
486 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
488 $template->parseCurrentBlock();
492 $template->setCurrentBlock(
'term_text');
493 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
494 $template->parseCurrentBlock();
498 if (($active_id > 0) && (!$show_correct_solution))
500 if ($graphicalOutput)
504 foreach ($this->object->getMatchingPairs() as $pair)
514 $template->setCurrentBlock(
"icon_ok");
516 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
517 $template->parseCurrentBlock();
521 $template->setCurrentBlock(
"icon_ok");
523 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
524 $template->parseCurrentBlock();
531 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
532 $template->setCurrentBlock(
"result_output");
533 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
534 $template->parseCurrentBlock();
537 $template->setCurrentBlock(
"row");
538 if ($this->object->getEstimatedElementHeight() > 0)
540 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
542 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
543 $template->parseCurrentBlock();
546 $questiontext = $this->
object->getQuestion();
547 if ($show_question_text==
true)
549 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
552 $questionoutput = $template->get();
558 $feedback .= strlen($fb) ? $fb :
'';
561 $feedback .= strlen($fb) ? $fb :
'';
563 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
565 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
567 $solutionoutput = $solutiontemplate->get();
568 if (!$show_question_only)
571 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
573 return $solutionoutput;
581 include_once
"./Services/UICore/classes/class.ilTemplate.php";
582 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
585 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
587 if (array_key_exists(
'js',
$_GET))
589 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
591 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
592 if ($ilUser->getPref(
"tst_javascript") == 1)
595 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
596 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
597 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
598 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
603 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
604 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
605 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
606 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
608 $jsswitch = $jstemplate->get();
609 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
613 $terms = $this->
object->getTerms();
614 $definitions = $this->
object->getDefinitions();
615 switch ($this->object->getShuffle())
618 $terms = $this->
object->pcArrayShuffle($terms);
619 $definitions = $this->
object->pcArrayShuffle($definitions);
622 $terms = $this->
object->pcArrayShuffle($terms);
625 $definitions = $this->
object->pcArrayShuffle($definitions);
629 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
634 foreach ($definitions as $definition)
636 if (strlen($definition->picture))
638 $template->setCurrentBlock(
"definition_picture");
639 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
640 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
641 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
642 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
643 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
644 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
645 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
646 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
647 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->object->prepareTextareaOutput($definition->text, TRUE) :
'');
648 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
650 $template->parseCurrentBlock();
654 $template->setCurrentBlock(
"definition_text");
655 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
656 $template->parseCurrentBlock();
659 $template->setCurrentBlock(
"droparea");
660 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
661 $template->setVariable(
"QUESTION_ID", $this->object->getId());
662 if ($this->object->getEstimatedElementHeight() > 0)
664 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
666 $template->parseCurrentBlock();
668 $template->setCurrentBlock(
"init_dropareas");
669 $template->setVariable(
"COUNTER", $counter++);
670 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
671 $template->parseCurrentBlock();
677 foreach ($terms as $term)
679 if (strlen($term->picture))
681 $template->setCurrentBlock(
"term_picture");
682 $template->setVariable(
"TERM_ID", $term->identifier);
683 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
684 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
685 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
686 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
687 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
688 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
689 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
690 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
691 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->object->prepareTextareaOutput($term->text, TRUE) :
'');
693 $template->parseCurrentBlock();
697 $template->setCurrentBlock(
"term_text");
698 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text, TRUE));
699 $template->parseCurrentBlock();
701 $template->setCurrentBlock(
"draggable");
702 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
703 if ($this->object->getEstimatedElementHeight() > 0)
705 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
707 $template->parseCurrentBlock();
709 $template->setCurrentBlock(
"init_draggables");
710 $template->setVariable(
"COUNTER", $counter++);
711 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
712 $template->parseCurrentBlock();
715 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
717 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
719 $questiontext = $this->
object->getQuestion();
720 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
721 $questionoutput = $jsswitch . $template->get();
722 if (!$show_question_only)
727 return $questionoutput;
735 include_once
"./Services/UICore/classes/class.ilTemplate.php";
736 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
739 if (strcmp($this->ctrl->getCmd(),
'preview') == 0)
741 if (array_key_exists(
'js',
$_GET))
743 $ilUser->writePref(
'tst_javascript',
$_GET[
'js']);
745 $jstemplate =
new ilTemplate(
"tpl.il_as_qpl_javascript_switch.html", TRUE, TRUE,
"Modules/TestQuestionPool");
746 if ($ilUser->getPref(
"tst_javascript") == 1)
749 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"disable_javascript"));
750 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"disable_javascript"));
751 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"0");
752 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
757 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_ALT", $this->lng->txt(
"enable_javascript"));
758 $jstemplate->setVariable(
"JAVASCRIPT_IMAGE_TITLE", $this->lng->txt(
"enable_javascript"));
759 $this->ctrl->setParameterByClass($this->ctrl->getCmdClass(),
"js",
"1");
760 $jstemplate->setVariable(
"JAVASCRIPT_URL", $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), $this->ctrl->getCmd()));
762 $jsswitch = $jstemplate->get();
763 if ($ilUser->getPref(
'tst_javascript')) $this->object->setOutputType(
OUTPUT_JAVASCRIPT);
772 $terms = $this->
object->getTerms();
773 $definitions = $this->
object->getDefinitions();
774 switch ($this->object->getShuffle())
777 $terms = $this->
object->pcArrayShuffle($terms);
778 $definitions = $this->
object->pcArrayShuffle($definitions);
781 $terms = $this->
object->pcArrayShuffle($terms);
784 $definitions = $this->
object->pcArrayShuffle($definitions);
788 for ($i = 0; $i < count($definitions); $i++)
790 $definition = $definitions[$i];
791 if (is_object($definition))
793 if (strlen($definition->picture))
795 $template->setCurrentBlock(
'definition_image');
796 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
799 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
800 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
802 $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));
803 $template->parseCurrentBlock();
807 $template->setCurrentBlock(
'definition_text');
808 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text, TRUE));
809 $template->parseCurrentBlock();
813 $template->setCurrentBlock(
'option');
814 $template->setVariable(
"VALUE_OPTION", 0);
816 $template->parseCurrentBlock();
818 foreach ($terms as $term)
820 $template->setCurrentBlock(
'option');
821 $template->setVariable(
"VALUE_OPTION", $term->identifier);
822 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($j) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($j));
823 $template->parseCurrentBlock();
827 $template->setCurrentBlock(
'row');
828 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
829 if ($this->object->getEstimatedElementHeight() > 0)
831 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
833 $template->setVariable(
"QUESTION_ID", $this->object->getId());
834 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
835 $template->parseCurrentBlock();
839 foreach ($terms as $term)
841 if (strlen($term->picture))
843 $template->setCurrentBlock(
'term_image');
844 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
847 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
848 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
849 $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));
851 $template->parseCurrentBlock();
855 $template->setCurrentBlock(
'term_text');
856 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text, TRUE));
857 $template->parseCurrentBlock();
859 $template->touchBlock(
'terms');
863 $questiontext = $this->
object->getQuestion();
864 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
867 $questionoutput = $jsswitch . $template->get();
868 if (!$show_question_only)
873 return $questionoutput;
879 foreach ($solution as $solution_values)
881 $id = $solution_values[
'value2'];
882 array_push($neworder, $this->object->getDefinitionWithIdentifier($id));
890 include_once
"./Services/UICore/classes/class.ilTemplate.php";
891 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_js.html", TRUE, TRUE,
"Modules/TestQuestionPool");
896 include_once
"./Modules/Test/classes/class.ilObjTest.php";
901 if (is_array($user_post_solution))
903 $solutions = array();
904 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
906 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
911 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
914 foreach ($solutions as $idx => $solution_value)
918 if (($solution_value[
"value2"] > -1) && ($solution_value[
"value1"] > -1))
920 $template->setCurrentBlock(
"restoreposition");
921 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
922 $template->setVariable(
"PICTURE_DEFINITION_ID", $solution_value[
"value2"]);
923 $template->parseCurrentBlock();
930 $terms = $this->
object->getTerms();
931 $definitions = $this->
object->getDefinitions();
932 switch ($this->object->getShuffle())
935 $terms = $this->
object->pcArrayShuffle($terms);
936 if (count($solutions))
942 $definitions = $this->
object->pcArrayShuffle($definitions);
946 $terms = $this->
object->pcArrayShuffle($terms);
949 if (count($solutions))
955 $definitions = $this->
object->pcArrayShuffle($definitions);
960 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
965 foreach ($definitions as $definition)
967 if (strlen($definition->picture))
969 $template->setCurrentBlock(
"definition_picture");
970 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
971 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $definition->picture);
972 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture;
973 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $definition->picture;
974 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
975 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
976 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
977 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
978 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ?
ilUtil::prepareFormOutput($definition->text) :
'');
979 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
981 $template->parseCurrentBlock();
985 $template->setCurrentBlock(
"definition_text");
986 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
987 $template->parseCurrentBlock();
990 $template->setCurrentBlock(
"droparea");
991 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
992 $template->setVariable(
"QUESTION_ID", $this->object->getId());
993 if ($this->object->getEstimatedElementHeight() > 0)
995 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
997 $template->parseCurrentBlock();
999 $template->setCurrentBlock(
"init_dropareas");
1000 $template->setVariable(
"COUNTER", $counter++);
1001 $template->setVariable(
"ID_DROPAREA", $definition->identifier);
1002 $template->parseCurrentBlock();
1008 foreach ($terms as $term)
1010 if (strlen($term->picture))
1012 $template->setCurrentBlock(
"term_picture");
1013 $template->setVariable(
"TERM_ID", $term->identifier);
1014 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $term->picture);
1015 $thumbweb = $this->
object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture;
1016 $thumb = $this->
object->getImagePath() . $this->
object->getThumbPrefix() . $term->picture;
1017 if (!@file_exists($thumb)) $this->
object->rebuildThumbnails();
1018 $template->setVariable(
"THUMBNAIL_HREF", $thumbweb);
1019 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
1020 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
1021 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1024 $template->parseCurrentBlock();
1028 $template->setCurrentBlock(
"term_text");
1029 $template->setVariable(
"TERM_TEXT", $this->object->prepareTextareaOutput($term->text,
true));
1030 $template->parseCurrentBlock();
1032 $template->setCurrentBlock(
"draggable");
1033 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1034 if ($this->object->getEstimatedElementHeight() > 0)
1036 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1038 $template->parseCurrentBlock();
1040 $template->setCurrentBlock(
"init_draggables");
1041 $template->setVariable(
"COUNTER", $counter++);
1042 $template->setVariable(
"ID_DRAGGABLE", $term->identifier);
1043 $template->parseCurrentBlock();
1046 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
1048 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
1050 $questiontext = $this->
object->getQuestion();
1051 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1052 $questionoutput = $template->get();
1053 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1064 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1065 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1070 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1075 if (is_array($user_post_solution))
1077 $solutions = array();
1078 foreach ($user_post_solution[
'matching'][$this->object->getId()] as $definition => $term)
1080 array_push($solutions, array(
"value1" => $term,
"value2" => $definition));
1085 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
1091 $terms = $this->
object->getTerms();
1092 $definitions = $this->
object->getDefinitions();
1093 switch ($this->object->getShuffle())
1096 $terms = $this->
object->pcArrayShuffle($terms);
1097 if (count($solutions))
1103 $definitions = $this->
object->pcArrayShuffle($definitions);
1107 $terms = $this->
object->pcArrayShuffle($terms);
1110 if (count($solutions))
1116 $definitions = $this->
object->pcArrayShuffle($definitions);
1120 $maxcount = max(count($terms), count($definitions));
1121 for ($i = 0; $i < count($definitions); $i++)
1123 $definition = $definitions[$i];
1124 if (is_object($definition))
1126 if (strlen($definition->picture))
1128 $template->setCurrentBlock(
'definition_image');
1129 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $definition->picture);
1132 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $definition->picture);
1133 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1135 $template->setVariable(
"TEXT_DEFINITION", (strlen($definition->text)) ? $this->lng->txt(
'definition') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($definition->text) : $this->lng->txt(
'definition') .
' ' . ($i+1));
1136 $template->parseCurrentBlock();
1140 $template->setCurrentBlock(
'definition_text');
1141 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($definition->text,
true));
1142 $template->parseCurrentBlock();
1146 $template->setCurrentBlock(
'option');
1147 $template->setVariable(
"VALUE_OPTION", 0);
1149 $template->parseCurrentBlock();
1151 foreach ($terms as $term)
1153 $template->setCurrentBlock(
'option');
1154 $template->setVariable(
"VALUE_OPTION", $term->identifier);
1155 $template->setVariable(
"TEXT_OPTION", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($j) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($j));
1156 foreach ($solutions as $solution)
1158 if ($solution[
"value1"] == $term->identifier && $solution[
"value2"] == $definition->identifier)
1160 $template->setVariable(
"SELECTED_OPTION",
" selected=\"selected\"");
1163 $template->parseCurrentBlock();
1167 $template->setCurrentBlock(
'row');
1168 $template->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
1169 if ($this->object->getEstimatedElementHeight() > 0)
1171 $template->setVariable(
"ELEMENT_HEIGHT",
" style=\"height: " . $this->object->getEstimatedElementHeight() .
"px;\"");
1173 $template->setVariable(
"QUESTION_ID", $this->object->getId());
1174 $template->setVariable(
"DEFINITION_ID", $definition->identifier);
1175 $template->parseCurrentBlock();
1179 foreach ($terms as $term)
1181 if (strlen($term->picture))
1183 $template->setCurrentBlock(
'term_image');
1184 $template->setVariable(
'ANSWER_IMAGE_URL', $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $term->picture);
1187 $template->setVariable(
'URL_PREVIEW', $this->object->getImagePathWeb() . $term->picture);
1188 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
1189 $template->setVariable(
"TEXT_TERM", (strlen($term->text)) ? $this->lng->txt(
'term') .
' ' . ($i+1) .
': ' .
ilUtil::prepareFormOutput($term->text) : $this->lng->txt(
'term') .
' ' . ($i+1));
1191 $template->parseCurrentBlock();
1195 $template->setCurrentBlock(
'term_text');
1196 $template->setVariable(
"TERM", $this->object->prepareTextareaOutput($term->text,
true));
1197 $template->parseCurrentBlock();
1199 $template->touchBlock(
'terms');
1203 $questiontext = $this->
object->getQuestion();
1204 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1208 $questiontext = $this->
object->getQuestion();
1209 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1210 $questionoutput = $template->get();
1211 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1234 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1236 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
1237 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
1238 foreach ($this->object->getMatchingPairs() as $index => $answer)
1240 $this->
object->saveFeedbackSingleAnswer($index,
$_POST[
"feedback_answer_$index"]);
1242 $this->
object->cleanupMediaObjectUsage();
1255 global $rbacsystem, $ilTabs;
1257 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
1258 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1259 $q_type = $this->
object->getQuestionType();
1261 if (strlen($q_type))
1263 $classname = $q_type .
"GUI";
1264 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1265 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1270 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1273 $ilTabs->addTarget(
"edit_page",
1274 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1275 array(
"edit",
"insert",
"exec_pg"),
1276 "",
"", $force_active);
1280 $ilTabs->addTarget(
"preview",
1281 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1283 "ilPageObjectGUI",
"", $force_active);
1286 $force_active =
false;
1287 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1290 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1292 $ilTabs->addTarget(
"edit_question",
1294 array(
"editQuestion",
"save",
"saveEdit",
"removeimageterms",
"uploadterms",
"removeimagedefinitions",
"uploaddefinitions",
1295 "addpairs",
"removepairs",
"addterms",
"removeterms",
"adddefinitions",
"removedefinitions",
"originalSyncForm"),
1296 $classname,
"", $force_active);
1301 $ilTabs->addTarget(
"feedback",
1302 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1303 array(
"feedback",
"saveFeedback"),
1312 $ilTabs->addTarget(
"solution_hint",
1313 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
1314 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
1315 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
1325 $ilTabs->addTarget(
"statistics",
1326 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1327 array(
"assessment"),
1331 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1336 global $___test_express_mode;
1338 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
1339 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1343 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
1348 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
1360 $save = (strcmp($this->ctrl->getCmd(),
"saveFeedback") == 0) ? TRUE : FALSE;
1361 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1363 $form->setFormAction($this->ctrl->getFormAction($this));
1364 $form->setTitle($this->lng->txt(
'feedback_answers'));
1365 $form->setTableWidth(
"98%");
1366 $form->setId(
"feedback");
1368 $complete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_complete_solution"),
"feedback_complete");
1369 $complete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
1370 $complete->setRequired(
false);
1371 $complete->setRows(10);
1372 $complete->setCols(80);
1375 $complete->setUseRte(
true);
1377 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1379 $complete->addPlugin(
"latex");
1380 $complete->addButton(
"latex");
1381 $complete->addButton(
"pastelatex");
1382 $complete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
1383 $form->addItem($complete);
1385 $incomplete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_incomplete_solution"),
"feedback_incomplete");
1386 $incomplete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
1387 $incomplete->setRequired(
false);
1388 $incomplete->setRows(10);
1389 $incomplete->setCols(80);
1392 $incomplete->setUseRte(
true);
1394 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1396 $incomplete->addPlugin(
"latex");
1397 $incomplete->addButton(
"latex");
1398 $incomplete->addButton(
"pastelatex");
1399 $incomplete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
1400 $form->addItem($incomplete);
1404 foreach ($this->object->getMatchingPairs() as $index => $answer)
1406 $caption = $ordinal = $index+1;
1407 $caption .=
'. <br />"' . $answer->term->text .
'" => ';
1408 $caption .=
'"' . $answer->definition->text .
'"';
1411 $answerobj =
new ilTextAreaInputGUI($this->object->prepareTextareaOutput($caption,
true),
"feedback_answer_$index");
1412 $answerobj->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)));
1413 $answerobj->setRequired(
false);
1414 $answerobj->setRows(10);
1415 $answerobj->setCols(80);
1416 $answerobj->setUseRte(
true);
1417 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1419 $answerobj->addPlugin(
"latex");
1420 $answerobj->addButton(
"latex");
1421 $answerobj->addButton(
"pastelatex");
1422 $answerobj->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
1423 $form->addItem($answerobj);
1430 $form->addCommandButton(
"saveFeedback", $this->lng->txt(
"save"));
1434 $form->setValuesByPost();
1435 $errors = !$form->checkInput();
1436 $form->setValuesByPost();
1438 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
1444 $feedback =
'<table><tbody>';
1446 foreach ($this->object->getMatchingPairs() as $idx => $ans)
1448 $feedback .=
'<tr><td><b><i>' . $ans->definition->text .
'</i></b></td><td>'. $this->lng->txt(
"matches") .
' ';
1449 $feedback .=
'</td><td><b><i>' . $ans->term->text .
'</i></b></td><td> </td><td>';
1450 $feedback .= $this->
object->getFeedbackSingleAnswer($idx) .
'</td> </tr>';
1453 $feedback .=
'</tbody></table>';
1454 return $this->
object->prepareTextareaOutput($feedback, TRUE);
1459 if( !($pair->points > 0) )
1464 if( !is_object($term) )
1469 if( $pair->definition->identifier != $definition->identifier )
1474 if( $pair->term->identifier != $term->identifier )