24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
52 include_once
"./Modules/TestQuestionPool/classes/class.assMatchingQuestion.php";
56 $this->
object->loadFromDb($id);
62 if (substr(
$cmd, 0, 6) ==
"upload")
79 $multiline_answers = $this->
object->getMultilineAnswerSetting();
81 $this->tpl->addBlockFile(
"QUESTION_DATA",
"question_data",
"tpl.il_as_qpl_matching.html",
"Modules/TestQuestionPool");
83 $tblrow = array(
"tblrow1top",
"tblrow2top");
85 for ($termcount = 1; $termcount <= 10; $termcount++)
87 $this->tpl->setCurrentBlock(
"termcountvalues");
88 $this->tpl->setVariable(
"TERMCOUNTVALUE", $termcount);
89 $this->tpl->parseCurrentBlock();
92 if (($this->ctrl->getCmd() ==
"addTerm") && (!$has_error))
94 for ($i = 0; $i < $_POST[
"termcount"]; $i++)
96 $this->
object->addTerm(
"");
100 if ($this->object->getTermCount())
102 $this->tpl->setCurrentBlock(
"termfooter");
103 $this->tpl->setVariable(
"ARROW",
"<img src=\"" .
ilUtil::getImagePath(
"arrow_downright.gif") .
"\" alt=\"".$this->lng->txt(
"arrow_downright").
"\"/>");
104 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
105 $this->tpl->setVariable(
"SELECT_ALL", $this->lng->txt(
"select_all"));
106 $this->tpl->parseCurrentBlock();
108 $this->tpl->setCurrentBlock(
"termhead");
109 $this->tpl->setVariable(
"TEXT_TERMS", $this->lng->txt(
"terms"));
110 $this->tpl->parseCurrentBlock();
111 foreach ($this->object->getTerms() as $key => $value)
113 $this->tpl->setCurrentBlock(
"terms");
115 $this->tpl->setVariable(
"TERM_ID", $key);
116 $this->tpl->parseCurrentBlock();
122 if ($this->object->getTermCount() == 0) $allow_add_pair = 0;
125 foreach ($_POST as $key => $value)
127 if (preg_match(
"/(termoption|picture|definition)_(\d+)_(\d+)/", $key, $matches))
129 if (strlen($value) == 0)
135 if (!$allow_add_pair)
137 $this->error .= $this->lng->txt(
"fill_out_all_matching_pairs") .
"<br />";
140 if (($this->ctrl->getCmd() ==
"addPair") && ($this->object->getTermCount() == 0))
142 $this->error .= $this->lng->txt(
"no_terms_message") .
"<br />";
144 if (($this->ctrl->getCmd() ==
"addPair") and $allow_add_pair and (!$has_error))
146 $this->
object-> addMatchingPair();
149 if ($this->object->getMatchingPairCount() && $this->
object->getTermCount())
152 for ($i = 0; $i < $this->
object->getMatchingPairCount(); $i++)
154 $thispair = $this->
object->get_matchingpair($i);
157 $this->tpl->setCurrentBlock(
"pictures");
158 $this->tpl->setVariable(
"ANSWER_ORDER", $i);
159 $this->tpl->setVariable(
"PICTURE_ID", $thispair->getPictureId());
160 $this->tpl->setVariable(
"COLOR_CLASS", $tblrow[$i % 2]);
164 $imagepath = $this->
object->getImagePathWeb() . $thispair->getPicture();
165 $this->tpl->setVariable(
"UPLOADED_IMAGE",
"<img src=\"$imagepath.thumb.jpg\" alt=\"" . $this->lng->txt(
"qpl_display_fullsize_image") .
"\" title=\"" . $this->lng->txt(
"qpl_display_fullsize_image") .
"\" border=\"\" />");
166 $this->tpl->setVariable(
"IMAGE_FILENAME", $thispair->getPicture());
167 $this->tpl->setVariable(
"VALUE_PICTURE", $thispair->getPicture());
169 $this->tpl->setVariable(
"UPLOAD", $this->lng->txt(
"upload"));
173 $this->tpl->setCurrentBlock(
"definitions");
174 $this->tpl->setVariable(
"ANSWER_ORDER", $i);
175 $this->tpl->setVariable(
"DEFINITION_ID", $thispair->getDefinitionId());
177 $this->tpl->setVariable(
"COLOR_CLASS", $tblrow[$i % 2]);
179 $this->tpl->parseCurrentBlock();
180 foreach ($this->object->getTerms() as $termkey => $termvalue)
182 $this->tpl->setCurrentBlock(
"termoptions");
183 $this->tpl->setVariable(
"TERMOPTION_VALUE", $termkey);
185 if (strcmp($termkey, $thispair->getTerm()) == 0)
187 $this->tpl->setVariable(
"TERMOPTION_SELECTED",
' selected="selected"');
189 $this->tpl->parseCurrentBlock();
191 $this->tpl->setCurrentBlock(
"answers");
192 $this->tpl->setVariable(
"VALUE_ANSWER_COUNTER", $i + 1);
193 $this->tpl->setVariable(
"ANSWER_ORDER", $i);
194 $this->tpl->setVariable(
"TERM_ID", $thispair->getTermId());
196 $this->tpl->setVariable(
"TEXT_MATCHES", $this->lng->txt(
"matches"));
197 $this->tpl->setVariable(
"VALUE_MATCHINGPAIR_POINTS", $thispair->getPoints());
198 $this->tpl->setVariable(
"COLOR_CLASS", $tblrow[$i % 2]);
199 $this->tpl->parseCurrentBlock();
216 $this->tpl->setCurrentBlock(
"answerhead");
217 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
218 $this->tpl->setVariable(
"TERM", $this->lng->txt(
"term"));
221 $this->tpl->setVariable(
"PICTURE_OR_DEFINITION", $this->lng->txt(
"picture"));
225 $this->tpl->setVariable(
"PICTURE_OR_DEFINITION", $this->lng->txt(
"definition"));
227 $this->tpl->parseCurrentBlock();
228 $this->tpl->setCurrentBlock(
"selectall");
229 $this->tpl->setVariable(
"SELECT_ALL", $this->lng->txt(
"select_all"));
231 $this->tpl->setVariable(
"COLOR_CLASS", $tblrow[$i % 2]);
232 $this->tpl->parseCurrentBlock();
233 $this->tpl->setCurrentBlock(
"QFooter");
234 $this->tpl->setVariable(
"ARROW",
"<img src=\"" .
ilUtil::getImagePath(
"arrow_downright.gif") .
"\" alt=\"".$this->lng->txt(
"arrow_downright").
"\"/>");
235 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
236 $this->tpl->parseCurrentBlock();
241 $internallinks = array(
242 "lm" => $this->lng->txt(
"obj_lm"),
243 "st" => $this->lng->txt(
"obj_st"),
244 "pg" => $this->lng->txt(
"obj_pg"),
245 "glo" => $this->lng->txt(
"glossary_term")
247 foreach ($internallinks as $key => $value)
249 $this->tpl->setCurrentBlock(
"internallink");
250 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
251 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
252 $this->tpl->parseCurrentBlock();
255 $this->tpl->setCurrentBlock(
"HeadContent");
256 $this->tpl->addJavascript(
"./Services/JavaScript/js/Basic.js");
257 $javascript =
"<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
258 "function initialSelect() {\n%s\n}</script>";
261 if ($this->object->getMatchingPairCount() > 0)
263 $thispair = $this->
object->get_matchingpair($this->object->getMatchingPairCount()-1);
264 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_matching.term_".($this->object->getMatchingPairCount()-1).
"_" . $thispair->getTerm().
".focus(); document.frm_matching.term_".($this->
object->getMatchingPairCount()-1).
"_" . $thispair->getTerm().
".scrollIntoView(\"true\");"));
268 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_matching.title.focus();"));
273 switch ($this->ctrl->getCmd())
276 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_matching.term_".($this->object->getMatchingPairCount()).
"_" . $add_random_id.
".focus(); document.frm_matching.term_".($this->object->getMatchingPairCount()).
"_" . $add_random_id.
".scrollIntoView(\"true\");"));
279 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_matching.title.focus();"));
283 $this->tpl->parseCurrentBlock();
284 $this->tpl->setCurrentBlock(
"question_data");
285 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
286 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
287 $this->tpl->setVariable(
"TEXT_COMMENT", $this->lng->txt(
"description"));
288 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
289 $this->tpl->setVariable(
"TEXT_SHUFFLE_ANSWERS", $this->lng->txt(
"shuffle_answers"));
290 $this->tpl->setVariable(
"TXT_SHUFFLE_TERMS", $this->lng->txt(
"matching_shuffle_terms"));
293 $this->tpl->setVariable(
"TXT_YES", $this->lng->txt(
"matching_shuffle_terms_definitions"));
294 $this->tpl->setVariable(
"TXT_SHUFFLE_PICTURES", $this->lng->txt(
"matching_shuffle_definitions"));
298 $this->tpl->setVariable(
"TXT_YES", $this->lng->txt(
"matching_shuffle_terms_pictures"));
299 $this->tpl->setVariable(
"TXT_SHUFFLE_PICTURES", $this->lng->txt(
"matching_shuffle_pictures"));
301 $this->tpl->setVariable(
"TXT_NO", $this->lng->txt(
"no"));
302 switch ($this->object->getShuffle())
305 $this->tpl->setVariable(
"SELECTED_YES",
" selected=\"selected\"");
308 $this->tpl->setVariable(
"SELECTED_SHUFFLE_TERMS",
" selected=\"selected\"");
311 $this->tpl->setVariable(
"SELECTED_SHUFFLE_PICTURES",
" selected=\"selected\"");
314 $this->tpl->setVariable(
"SELECTED_NO",
" selected=\"selected\"");
317 $this->tpl->setVariable(
"MATCHING_ID", $this->object->getId());
321 $questiontext = $this->
object->getQuestion();
322 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
323 $this->tpl->setVariable(
"VALUE_ADD_ANSWER", $this->lng->txt(
"add_matching_pair"));
324 $this->tpl->setVariable(
"VALUE_ADD_TERM", $this->lng->txt(
"add"));
325 $this->tpl->setVariable(
"TEXT_TERMS", $this->lng->txt(
"terms"));
326 $this->tpl->setVariable(
"TEXT_TYPE", $this->lng->txt(
"type"));
327 $this->tpl->setVariable(
"TEXT_TYPE_TERMS_PICTURES", $this->lng->txt(
"match_terms_and_pictures"));
328 $this->tpl->setVariable(
"TEXT_TYPE_TERMS_DEFINITIONS", $this->lng->txt(
"match_terms_and_definitions"));
331 $this->tpl->setVariable(
"SELECTED_DEFINITIONS",
" selected=\"selected\"");
335 $this->tpl->setVariable(
"SELECTED_PICTURES",
" selected=\"selected\"");
337 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
338 if (count($this->object->suggested_solutions))
340 $solution_array = $this->
object->getSuggestedSolution(0);
341 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
343 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
344 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
345 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
346 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
350 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
352 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
353 $this->tpl->setVariable(
"SET_EDIT_MODE", $this->lng->txt(
"set_edit_mode"));
354 $this->tpl->setVariable(
"SAVE_EDIT", $this->lng->txt(
"save_edit"));
355 $this->tpl->setVariable(
"CANCEL", $this->lng->txt(
"cancel"));
356 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
357 $this->ctrl->setParameter($this,
"sel_question_types",
"assMatchingQuestion");
358 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->
outQuestionType());
359 $this->tpl->setVariable(
"ACTION_MATCHING_QUESTION", $this->ctrl->getFormAction($this));
361 $this->tpl->parseCurrentBlock();
366 include_once
"./Services/RTE/classes/class.ilRTE.php";
368 include_once
"./Services/RTE/classes/class.$rtestring.php";
369 $rte =
new $rtestring();
370 $rte->addPlugin(
"latex");
371 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
372 include_once
"./classes/class.ilObject.php";
373 $obj_id =
$_GET[
"q_id"];
375 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
376 $this->tpl->setCurrentBlock(
"adm_content");
378 $this->tpl->parseCurrentBlock();
414 if (is_array($_POST[
"delete_terms"]))
416 $terms = $_POST[
"delete_terms"];
417 foreach ($terms as $key => $value)
419 $this->
object->deleteTerm($value);
431 if (is_array($_POST[
"chb_answer"]))
433 $deleteanswers = $_POST[
"chb_answer"];
434 rsort($deleteanswers);
435 foreach ($deleteanswers as $value)
437 $this->
object->delete_matchingpair($value);
461 if ((
$result) and ($_POST[
"cmd"][
"addPair"]))
464 $this->error .= $this->lng->txt(
"fill_out_all_required_fields_add_matching") .
"<br />";
467 if ((
$result) and ($_POST[
"cmd"][
"addTerm"]))
470 $this->error .= $this->lng->txt(
"empty_terms_exist") .
"<br />";
476 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
478 $this->
object->setQuestion($questiontext);
479 $this->
object->setSuggestedSolution($_POST[
"solution_hint"], 0);
480 $this->
object->setShuffle($_POST[
"shuffle"]);
483 $this->
object->setMatchingType($_POST[
"matching_type"]);
487 $this->
object->flush_matchingpairs();
488 $this->
object->flushTerms();
492 $postvalues = $_POST;
493 foreach ($postvalues as $key => $value)
496 if (preg_match(
"/terms_(.*)/", $key, $matches))
498 if (in_array($value, $this->object->getTerms()))
504 if (strlen($value) == 0)
510 if (preg_match(
"/termoption_(\d+)_(\d+)/", $key, $matches))
513 foreach ($_POST as $key2 => $value2)
515 if (preg_match(
"/(definition|picture)_$matches[1]_(\d+)/", $key2, $matches2))
517 $matchingtext_id = $matches2[2];
518 if (strcmp($matches2[1],
"definition") == 0)
520 $matching_text = $_POST[
"definition_$matches[1]_$matches2[2]"];
524 $matching_text = $_POST[
"picture_$matches[1]_$matches2[2]"];
532 foreach ($_FILES as $key2 => $value2)
534 if (preg_match(
"/picture_$matches[1]_(\d+)/", $key2, $matches2))
536 if ($value2[
"tmp_name"])
539 if ($this->object->getId() <= 0)
541 $this->
object->saveToDb();
543 $this->error .= $this->lng->txt(
"question_saved_for_upload") .
"<br />";
545 $value2[
'name'] = $this->
object->createNewImageFileName($value2[
'name']);
546 $upload_result = $this->
object->setImageFile($value2[
'name'], $value2[
'tmp_name']);
547 switch ($upload_result)
550 $_POST[
"picture_$matches[1]_".$matches2[1]] = $value2[
'name'];
551 $matching_text = $value2[
'name'];
554 $this->error .= $this->lng->txt(
"error_image_upload_wrong_format") .
"<br />";
557 $this->error .= $this->lng->txt(
"error_image_upload_copy_file") .
"<br />";
564 $points = $_POST[
"points_$matches[1]"];
568 $this->
setErrorMessage($this->lng->txt(
"negative_points_not_allowed"));
570 $this->
object->addMatchingPair(
586 $this->
object->saveToDb();
587 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
594 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $user_post_solution);
595 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
596 $this->tpl->setVariable(
"FORMACTION", $formaction);
599 function getSolutionOutput($active_id,
$pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
602 include_once
"./classes/class.ilTemplate.php";
603 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
604 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
606 $keys = array_keys($this->object->matchingpairs);
608 $solutions = array();
609 if (($active_id > 0) && (!$show_correct_solution))
611 include_once
"./Modules/Test/classes/class.ilObjTest.php";
612 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
613 $solution_script .=
"";
617 foreach ($this->object->matchingpairs as $pair)
619 array_push($solutions, array(
"value1" => $pair->getTerm(),
"value2" => $pair->getDefinitionId()));
622 foreach ($keys as $idx)
624 $answer = $this->
object->matchingpairs[$idx];
625 if (($active_id > 0) && (!$show_correct_solution))
627 if ($graphicalOutput)
631 foreach ($solutions as $solution)
633 if ($answer->getDefinitionId() == $solution[
"value2"])
635 if ($answer->getTerm() == $solution[
"value1"])
643 $template->setCurrentBlock(
"icon_ok");
645 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
646 $template->parseCurrentBlock();
650 $template->setCurrentBlock(
"icon_ok");
652 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
653 $template->parseCurrentBlock();
660 $template->setCurrentBlock(
"standard_matching_pictures");
661 $template->setVariable(
"DEFINITION_ID", $answer->getPictureId());
662 $size = getimagesize($this->object->getImagePath() . $answer->getPicture() .
".thumb.jpg");
663 $template->setVariable(
"THUMBNAIL_WIDTH",
$size[0]);
664 $template->setVariable(
"THUMBNAIL_HEIGHT",
$size[1]);
665 $template->setVariable(
"THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() .
".thumb.jpg");
666 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
667 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
668 $template->parseCurrentBlock();
672 $template->setCurrentBlock(
"standard_matching_terms");
673 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
674 $template->parseCurrentBlock();
677 $template->setCurrentBlock(
"standard_matching_row");
678 $template->setVariable(
"MATCHES", $this->lng->txt(
"matches"));
681 $points = $answer->getPoints();
682 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
683 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
686 foreach ($solutions as $solution)
688 if ($answer->getDefinitionId() == $solution[
"value2"])
690 foreach ($this->object->getTerms() as $termindex => $termvalue)
692 if ($termindex == $solution[
"value1"])
702 $template->setVariable(
"SOLUTION",
" ");
704 $template->parseCurrentBlock();
707 $questiontext = $this->
object->getQuestion();
708 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
709 $questionoutput = $template->get();
711 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
712 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
714 $solutionoutput = $solutiontemplate->get();
715 if (!$show_question_only)
720 return $solutionoutput;
726 include_once
"./classes/class.ilTemplate.php";
727 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
730 $keys = array_keys($this->object->matchingpairs);
731 $keys2 = array_keys($this->object->getTerms());
732 if ($this->object->getShuffle())
734 if (($this->object->getShuffle() == 3) || ($this->object->getShuffle() == 1))
735 $keys = $this->
object->pcArrayShuffle(array_keys($this->object->matchingpairs));
736 if (($this->object->getShuffle() == 2) || ($this->object->getShuffle() == 1))
737 $keys2 = $this->
object->pcArrayShuffle($keys2);
740 $terms = $this->
object->getTerms();
741 foreach ($keys as $idx)
743 $answer = $this->
object->matchingpairs[$idx];
744 foreach ($keys2 as $termkey)
746 $comboanswer = $this->
object->matchingpairs[$comboidx];
747 $template->setCurrentBlock(
"matching_selection");
748 $template->setVariable(
"VALUE_SELECTION", $termkey);
750 $template->parseCurrentBlock();
754 $template->setCurrentBlock(
"standard_matching_pictures");
755 $template->setVariable(
"DEFINITION_ID", $answer->getPictureId());
756 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $answer->getPicture());
757 $template->setVariable(
"THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() .
".thumb.jpg");
758 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
759 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
760 $template->parseCurrentBlock();
764 $template->setCurrentBlock(
"standard_matching_terms");
765 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
766 $template->parseCurrentBlock();
769 $template->setCurrentBlock(
"standard_matching_row");
770 $template->setVariable(
"MATCHES", $this->lng->txt(
"matches"));
771 $template->setVariable(
"DEFINITION_ID", $answer->getDefinitionId());
772 $template->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
773 $template->parseCurrentBlock();
776 $questiontext = $this->
object->getQuestion();
777 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
778 $questionoutput = $template->get();
779 if (!$show_question_only)
784 return $questionoutput;
789 $allterms = $this->
object->getTerms();
791 include_once
"./classes/class.ilTemplate.php";
792 $template =
new ilTemplate(
"tpl.il_as_qpl_matching_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
795 $keys = array_keys($this->object->matchingpairs);
796 $keys2 = array_keys($this->object->getTerms());
797 if (is_array($user_post_solution))
804 if ($this->object->getShuffle())
806 if (($this->object->getShuffle() == 3) || ($this->object->getShuffle() == 1))
807 $keys = $this->
object->pcArrayShuffle(array_keys($this->object->matchingpairs));
808 if (($this->object->getShuffle() == 2) || ($this->object->getShuffle() == 1))
809 $keys2 = $this->
object->pcArrayShuffle($keys2);
818 include_once
"./Modules/Test/classes/class.ilObjTest.php";
823 if (is_array($user_post_solution))
825 $solutions = array();
826 foreach ($user_post_solution as $key => $value)
828 if (preg_match(
"/sel_matching_(\d+)/", $key, $matches))
830 array_push($solutions, array(
"value1" => $value,
"value2" => $matches[1]));
836 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
838 foreach ($solutions as $idx => $solution_value)
842 if (($solution_value[
"value2"] > 1) && ($solution_value[
"value1"] > 1))
844 $template->setCurrentBlock(
"restoreposition");
845 $template->setVariable(
"TERM_ID", $solution_value[
"value1"]);
846 $template->setVariable(
"PICTURE_DEFINITION_ID", $solution_value[
"value2"]);
847 $template->parseCurrentBlock();
854 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
859 foreach ($keys as $idx)
861 $answer = $this->
object->matchingpairs[$idx];
864 $template->setCurrentBlock(
"js_match_picture");
865 $template->setVariable(
"DEFINITION_ID", $answer->getPictureId());
866 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $answer->getPicture());
867 $template->setVariable(
"THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() .
".thumb.jpg");
868 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
869 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
870 $template->parseCurrentBlock();
874 $template->setCurrentBlock(
"js_match_definition");
875 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
876 $template->parseCurrentBlock();
878 $template->setCurrentBlock(
"droparea");
879 $template->setVariable(
"ID_DROPAREA", $answer->getDefinitionId());
880 $template->setVariable(
"ID_DROPAREA", $answer->getDefinitionId());
881 $template->parseCurrentBlock();
882 $template->setCurrentBlock(
"init_dropareas");
883 $template->setVariable(
"COUNTER", $arrayindex++);
884 $template->setVariable(
"ID_DROPAREA", $answer->getDefinitionId());
885 $template->parseCurrentBlock();
890 foreach ($keys2 as $termid)
892 $template->setCurrentBlock(
"draggable");
893 $template->setVariable(
"ID_DRAGGABLE", $termid);
894 $template->setVariable(
"VALUE_DRAGGABLE", $this->object->prepareTextareaOutput($this->object->getTermWithId($termid)));
895 $template->parseCurrentBlock();
896 $template->setCurrentBlock(
"init_draggables");
897 $template->setVariable(
"COUNTER", $arrayindex++);
898 $template->setVariable(
"ID_DRAGGABLE", $termid);
899 $template->parseCurrentBlock();
902 $template->setVariable(
"RESET_BUTTON", $this->lng->txt(
"reset_terms"));
904 $this->tpl->setVariable(
"LOCATION_ADDITIONAL_STYLESHEET",
ilUtil::getStyleSheetLocation(
"output",
"test_javascript.css",
"Modules/TestQuestionPool"));
908 foreach ($keys as $idx)
910 $answer = $this->
object->matchingpairs[$idx];
911 foreach ($keys2 as $comboidx)
913 $template->setCurrentBlock(
"matching_selection");
914 $template->setVariable(
"VALUE_SELECTION", $comboidx);
916 foreach ($solutions as $solution)
918 if ((strcmp($solution[
"value1"], $comboidx) == 0) && ($answer->getDefinitionId() == $solution[
"value2"]))
920 $template->setVariable(
"SELECTED_SELECTION",
" selected=\"selected\"");
923 $template->parseCurrentBlock();
927 $template->setCurrentBlock(
"standard_matching_pictures");
928 $template->setVariable(
"DEFINITION_ID", $answer->getPictureId());
929 $template->setVariable(
"IMAGE_HREF", $this->object->getImagePathWeb() . $answer->getPicture());
930 $template->setVariable(
"THUMBNAIL_HREF", $this->object->getImagePathWeb() . $answer->getPicture() .
".thumb.jpg");
931 $template->setVariable(
"THUMB_ALT", $this->lng->txt(
"image"));
932 $template->setVariable(
"THUMB_TITLE", $this->lng->txt(
"image"));
933 $template->parseCurrentBlock();
937 $template->setCurrentBlock(
"standard_matching_terms");
938 $template->setVariable(
"DEFINITION", $this->object->prepareTextareaOutput($answer->getDefinition(), TRUE));
939 $template->parseCurrentBlock();
942 $template->setCurrentBlock(
"standard_matching_row");
943 $template->setVariable(
"MATCHES", $this->lng->txt(
"matches"));
944 $template->setVariable(
"DEFINITION_ID", $answer->getDefinitionId());
945 $template->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
946 $template->parseCurrentBlock();
950 $questiontext = $this->
object->getQuestion();
951 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
952 $questionoutput = $template->get();
953 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
962 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
973 if ($_POST[
"cmd"][
"addSuggestedSolution"])
983 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
988 $this->
object->saveToDb();
989 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
990 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
1000 $this->
object->setMatchingType($_POST[
"matching_type"]);
1014 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1017 $this->
object->cleanupMediaObjectUsage();
1030 $this->tpl->addBlockFile(
"ADM_CONTENT",
"feedback",
"tpl.il_as_qpl_matching_feedback.html",
"Modules/TestQuestionPool");
1031 $this->tpl->setVariable(
"FEEDBACK_TEXT", $this->lng->txt(
"feedback"));
1032 $this->tpl->setVariable(
"FEEDBACK_COMPLETE", $this->lng->txt(
"feedback_complete_solution"));
1033 $this->tpl->setVariable(
"VALUE_FEEDBACK_COMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
1034 $this->tpl->setVariable(
"FEEDBACK_INCOMPLETE", $this->lng->txt(
"feedback_incomplete_solution"));
1035 $this->tpl->setVariable(
"VALUE_FEEDBACK_INCOMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
1037 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1039 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
1041 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
1043 include_once
"./Services/RTE/classes/class.ilRTE.php";
1045 include_once
"./Services/RTE/classes/class.$rtestring.php";
1046 $rte =
new $rtestring();
1047 $rte->addPlugin(
"latex");
1048 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
1049 include_once
"./classes/class.ilObject.php";
1050 $obj_id =
$_GET[
"q_id"];
1052 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
1064 global $rbacsystem, $ilTabs;
1066 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
1067 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1068 $q_type = $this->
object->getQuestionType();
1070 if (strlen($q_type))
1072 $classname = $q_type .
"GUI";
1073 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1074 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1079 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1082 $ilTabs->addTarget(
"edit_content",
1083 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1084 array(
"edit",
"insert",
"exec_pg"),
1085 "",
"", $force_active);
1089 $ilTabs->addTarget(
"preview",
1090 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1092 "ilPageObjectGUI",
"", $force_active);
1095 $force_active =
false;
1096 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1099 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1101 $ilTabs->addTarget(
"edit_properties",
1103 array(
"editQuestion",
"save",
"cancel",
"addSuggestedSolution",
1104 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
1105 "addPair",
"addTerm",
"delete",
"deleteTerms",
"editMode",
"upload",
1107 $classname,
"", $force_active);
1112 $ilTabs->addTarget(
"feedback",
1113 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1114 array(
"feedback",
"saveFeedback"),
1121 $ilTabs->addTarget(
"statistics",
1122 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1123 array(
"assessment"),
1127 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1131 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1135 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));