24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
63 include_once
"./Modules/TestQuestionPool/classes/class.assClozeTest.php";
67 $this->
object->loadFromDb($id);
73 if (preg_match(
"/^(addGapText|addSelectGapText|addSuggestedSolution|removeSuggestedSolution)_(\d+)$/",
$cmd, $matches))
76 $this->gapIndex = $matches[2];
78 else if (preg_match(
"/^(delete)_(\d+)_(\d+)$/",
$cmd, $matches))
81 $this->gapIndex = $matches[2];
82 $this->answerIndex = $matches[3];
110 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"clozetext"]))
126 foreach ($_POST as $key => $value)
129 if (preg_match(
"/clozetype_(\d+)/", $key, $matches))
131 $this->
object->setGapType($matches[1], $value);
145 foreach ($_POST as $key => $value)
148 if (preg_match(
"/^shuffle_(\d+)$/", $key, $matches))
150 $this->
object->setGapShuffle($matches[1], $value);
165 $this->
object->clearGapAnswers();
166 foreach ($_POST as $key => $value)
168 if (preg_match(
"/^(textgap|selectgap|numericgap)_(\d+)_(\d+)$/", $key, $matches))
172 $order = $matches[3];
174 $gapObj = $this->
object->getGap($gap);
175 if (is_object($gapObj))
179 include_once
"./Services/Math/classes/class.EvalMath.php";
181 $eval->suppress_errors = TRUE;
203 foreach ($_POST as $key => $value)
205 if (preg_match(
"/points_(\d+)_(\d+)/", $key, $matches))
208 $order = $matches[2];
224 foreach ($_POST as $key => $value)
226 if (preg_match(
"/numericgap_(\d+)_(\d+)_lower/", $key, $matches))
229 $order = $matches[2];
230 $gapObj = $this->
object->getGap($gap);
231 if (is_object($gapObj))
235 include_once
"./Services/Math/classes/class.EvalMath.php";
237 $eval->suppress_errors = TRUE;
240 if (is_object($gapObj->getItem($order)))
242 if ($eval->e($gapObj->getItem($order)->getAnswertext()) !== FALSE)
244 $value = $gapObj->getItem($order)->getAnswertext();
259 $this->
object->setGapAnswerLowerBound($gap, $order, $value);
261 if (preg_match(
"/numericgap_(\d+)_(\d+)_upper/", $key, $matches))
264 $order = $matches[2];
265 $gapObj = $this->
object->getGap($gap);
266 if (is_object($gapObj))
270 include_once
"./Services/Math/classes/class.EvalMath.php";
272 $eval->suppress_errors = TRUE;
275 if (is_object($gapObj->getItem($order)))
277 if ($eval->e($gapObj->getItem($order)->getAnswertext()) !== FALSE)
279 $value = $gapObj->getItem($order)->getAnswertext();
294 $this->
object->setGapAnswerUpperBound($gap, $order, $value);
310 $this->
object->addGapText($this->gapIndex);
324 $this->
object->addGapText($this->gapIndex);
338 $this->
object->deleteAnswerText($this->gapIndex, $this->answerIndex);
355 $this->
object->flushGaps();
360 $this->
setErrorMessage($this->lng->txt(
"fill_out_all_required_fields"));
374 $this->
object->setTextgapRating($_POST[
"textgap_rating"]);
375 $this->
object->setIdenticalScoring($_POST[
"identical_scoring"]);
376 $this->
object->setFixedTextLength($_POST[
"fixedTextLength"]);
377 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
379 $this->
object->setClozeText($cloze_text);
382 $this->
object->suggested_solutions = array();
383 foreach ($_POST as $key => $value)
385 if (preg_match(
"/^solution_hint_(\d+)/", $key, $matches))
389 $this->
object->setSuggestedSolution($value, $matches[1]);
394 if (strcmp($this->ctrl->getCmd(),
"createGaps") == 0)
413 $this->
object->updateClozeTextFromGaps();
421 $this->
object->saveToDb();
422 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
436 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
437 $internallinks = array(
438 "lm" => $this->lng->txt(
"obj_lm"),
439 "st" => $this->lng->txt(
"obj_st"),
440 "pg" => $this->lng->txt(
"obj_pg"),
441 "glo" => $this->lng->txt(
"glossary_term")
445 $this->tpl->addBlockFile(
"QUESTION_DATA",
"question_data",
"tpl.il_as_qpl_cloze_question.html",
"Modules/TestQuestionPool");
446 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
448 $gap = $this->
object->getGap($i);
451 $this->tpl->setCurrentBlock(
"textgap_value");
452 foreach ($gap->getItemsRaw() as $item)
454 $this->tpl->setVariable(
"TEXT_VALUE", $this->lng->txt(
"value"));
455 $this->tpl->setVariable(
"VALUE_TEXT_GAP", $item->getAnswertext());
456 $this->tpl->setVariable(
"VALUE_GAP_COUNTER",
"$i" .
"_" . $item->getOrder());
457 $this->tpl->setVariable(
"VALUE_GAP", $i);
458 $this->tpl->setVariable(
"VALUE_INDEX", $item->getOrder());
459 $this->tpl->setVariable(
"VALUE_STATUS_COUNTER", $item->getOrder());
460 $this->tpl->setVariable(
"VALUE_GAP", $i);
461 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
462 $this->tpl->setVariable(
"VALUE_TEXT_GAP_POINTS", $item->getPoints());
463 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
464 $this->tpl->parseCurrentBlock();
467 foreach ($internallinks as $key => $value)
469 $this->tpl->setCurrentBlock(
"textgap_internallink");
470 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
471 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
472 $this->tpl->parseCurrentBlock();
475 $this->tpl->setCurrentBlock(
"textgap_suggested_solution");
476 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
477 if (array_key_exists($i, $this->object->suggested_solutions))
479 $solution_array = $this->
object->getSuggestedSolution($i);
481 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
482 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
483 $this->tpl->setVariable(
"VALUE_GAP_COUNTER_REMOVE", $i);
484 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
485 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
489 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
491 $this->tpl->setVariable(
"VALUE_GAP_COUNTER", $i);
492 $this->tpl->parseCurrentBlock();
493 $this->tpl->setCurrentBlock(
"textgap");
494 $this->tpl->setVariable(
"ADD_TEXT_GAP", $this->lng->txt(
"add_gap"));
495 $this->tpl->setVariable(
"VALUE_GAP_COUNTER",
"$i");
496 $this->tpl->parseCurrentBlock();
501 $this->tpl->setCurrentBlock(
"numericgap_value");
502 foreach ($gap->getItemsRaw() as $item)
504 $this->tpl->setVariable(
"TEXT_VALUE", $this->lng->txt(
"value"));
505 $this->tpl->setVariable(
"TEXT_LOWER_LIMIT", $this->lng->txt(
"range_lower_limit"));
506 $this->tpl->setVariable(
"TEXT_UPPER_LIMIT", $this->lng->txt(
"range_upper_limit"));
507 $this->tpl->setVariable(
"VALUE_NUMERIC_GAP", $item->getAnswertext());
508 $this->tpl->setVariable(
"VALUE_GAP_COUNTER",
"$i" .
"_" . $item->getOrder());
509 $this->tpl->setVariable(
"VALUE_GAP", $i);
510 $this->tpl->setVariable(
"VALUE_INDEX", $item->getOrder());
511 $this->tpl->setVariable(
"VALUE_STATUS_COUNTER", $item->getOrder());
512 $this->tpl->setVariable(
"VALUE_GAP", $i);
513 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
514 $this->tpl->setVariable(
"VALUE_NUMERIC_GAP_POINTS", $item->getPoints());
515 $this->tpl->setVariable(
"VALUE_LOWER_LIMIT", $item->getLowerBound());
516 $this->tpl->setVariable(
"VALUE_UPPER_LIMIT", $item->getUpperBound());
517 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
518 $this->tpl->parseCurrentBlock();
521 foreach ($internallinks as $key => $value)
523 $this->tpl->setCurrentBlock(
"numericgap_internallink");
524 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
525 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
526 $this->tpl->parseCurrentBlock();
529 $this->tpl->setCurrentBlock(
"numericgap_suggested_solution");
530 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
531 if (array_key_exists($i, $this->object->suggested_solutions))
533 $solution_array = $this->
object->getSuggestedSolution($i);
535 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
536 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
537 $this->tpl->setVariable(
"VALUE_GAP_COUNTER_REMOVE", $i);
538 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
539 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
543 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
545 $this->tpl->setVariable(
"VALUE_GAP_COUNTER", $i);
546 $this->tpl->parseCurrentBlock();
547 $this->tpl->setCurrentBlock(
"numericgap");
548 $this->tpl->parseCurrentBlock();
553 $this->tpl->setCurrentBlock(
"selectgap_value");
554 foreach ($gap->getItemsRaw() as $item)
556 $this->tpl->setVariable(
"TEXT_VALUE", $this->lng->txt(
"value"));
557 $this->tpl->setVariable(
"VALUE_SELECT_GAP", $item->getAnswertext());
558 $this->tpl->setVariable(
"VALUE_GAP_COUNTER",
"$i" .
"_" . $item->getOrder());
559 $this->tpl->setVariable(
"VALUE_GAP", $i);
560 $this->tpl->setVariable(
"VALUE_INDEX", $item->getOrder());
561 $this->tpl->setVariable(
"VALUE_STATUS_COUNTER", $item->getOrder());
562 $this->tpl->setVariable(
"VALUE_GAP", $i);
563 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
564 $this->tpl->setVariable(
"VALUE_SELECT_GAP_POINTS", $item->getPoints());
565 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
566 $this->tpl->parseCurrentBlock();
569 foreach ($internallinks as $key => $value)
571 $this->tpl->setCurrentBlock(
"selectgap_internallink");
572 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
573 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
574 $this->tpl->parseCurrentBlock();
577 $this->tpl->setCurrentBlock(
"selectgap_suggested_solution");
578 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
579 if (array_key_exists($i, $this->object->suggested_solutions))
581 $solution_array = $this->
object->getSuggestedSolution($i);
583 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
584 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
585 $this->tpl->setVariable(
"VALUE_GAP_COUNTER_REMOVE", $i);
586 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
587 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
591 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
593 $this->tpl->setVariable(
"VALUE_GAP_COUNTER", $i);
594 $this->tpl->parseCurrentBlock();
595 $this->tpl->setCurrentBlock(
"selectgap");
596 $this->tpl->setVariable(
"ADD_SELECT_GAP", $this->lng->txt(
"add_gap"));
597 $this->tpl->setVariable(
"TEXT_SHUFFLE_ANSWERS", $this->lng->txt(
"shuffle_answers"));
598 $this->tpl->setVariable(
"VALUE_GAP_COUNTER",
"$i");
599 if ($gap->getShuffle())
601 $this->tpl->setVariable(
"SELECTED_YES",
" selected=\"selected\"");
605 $this->tpl->setVariable(
"SELECTED_NO",
" selected=\"selected\"");
607 $this->tpl->setVariable(
"TXT_YES", $this->lng->txt(
"yes"));
608 $this->tpl->setVariable(
"TXT_NO", $this->lng->txt(
"no"));
609 $this->tpl->parseCurrentBlock();
612 $this->tpl->setCurrentBlock(
"answer_row");
613 $name = $this->lng->txt(
"gap") .
" " . ($i+1);
614 $this->tpl->setVariable(
"TEXT_GAP_NAME", $name);
615 $this->tpl->setVariable(
"TEXT_TYPE", $this->lng->txt(
"type"));
616 $this->tpl->setVariable(
"TEXT_CHANGE", $this->lng->txt(
"change"));
617 switch ($gap->getType())
620 $this->tpl->setVariable(
"SELECTED_TEXT_GAP",
" selected=\"selected\"");
623 $this->tpl->setVariable(
"SELECTED_SELECT_GAP",
" selected=\"selected\"");
626 $this->tpl->setVariable(
"SELECTED_NUMERIC_GAP",
" selected=\"selected\"");
629 $this->tpl->setVariable(
"TEXT_TEXT_GAP", $this->lng->txt(
"text_gap"));
630 $this->tpl->setVariable(
"TEXT_SELECT_GAP", $this->lng->txt(
"select_gap"));
631 $this->tpl->setVariable(
"TEXT_NUMERIC_GAP", $this->lng->txt(
"numeric_gap"));
632 $this->tpl->setVariable(
"VALUE_GAP_COUNTER", $i);
633 $this->tpl->parseCurrentBlock();
640 $this->tpl->setCurrentBlock(
"HeadContent");
641 $this->tpl->addJavascript(
"./Services/JavaScript/js/Basic.js");
642 $javascript =
"<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
643 "function initialSelect() {\n%s\n}</script>";
644 if (preg_match(
"/addGapText_(\d+)/", $this->ctrl->getCmd(), $matches))
646 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_cloze_test.textgap_" . $matches[1] .
"_" .(is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .
".focus(); document.frm_cloze_test.textgap_" . $matches[1] .
"_" . (is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .
".scrollIntoView(\"true\");"));
648 else if (preg_match(
"/addSelectGapText_(\d+)/", $this->ctrl->getCmd(), $matches))
650 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_cloze_test.selectgap_" . $matches[1] .
"_" .(is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .
".focus(); document.frm_cloze_test.selectgap_" . $matches[1] .
"_" . (is_object($this->object->getGap($matches[1])) ? $this->object->getGap($matches[1])->getItemCount() - 1 : 0) .
".scrollIntoView(\"true\");"));
654 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_cloze_test.title.focus();"));
656 $this->tpl->parseCurrentBlock();
659 $textgap_options = array(
660 array(
"ci", $this->lng->txt(
"cloze_textgap_case_insensitive")),
661 array(
"cs", $this->lng->txt(
"cloze_textgap_case_sensitive")),
662 array(
"l1", sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1")),
663 array(
"l2", sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2")),
664 array(
"l3", sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3")),
665 array(
"l4", sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4")),
666 array(
"l5", sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5"))
668 $textgap_rating = $this->
object->getTextgapRating();
669 foreach ($textgap_options as $textgap_option)
671 $this->tpl->setCurrentBlock(
"textgap_rating");
672 $this->tpl->setVariable(
"TEXTGAP_VALUE", $textgap_option[0]);
673 $this->tpl->setVariable(
"TEXTGAP_TEXT", $textgap_option[1]);
674 if (strcmp($textgap_rating, $textgap_option[0]) == 0)
676 $this->tpl->setVariable(
"SELECTED_TEXTGAP_VALUE",
" selected=\"selected\"");
678 $this->tpl->parseCurrentBlock();
681 $this->tpl->setCurrentBlock(
"question_data");
682 $this->tpl->setVariable(
"FIXED_TEXTLENGTH", $this->lng->txt(
"cloze_fixed_textlength"));
683 $this->tpl->setVariable(
"FIXED_TEXTLENGTH_DESCRIPTION", $this->lng->txt(
"cloze_fixed_textlength_description"));
684 if ($this->object->getFixedTextLength())
686 $this->tpl->setVariable(
"VALUE_FIXED_TEXTLENGTH",
" value=\"" .
ilUtil::prepareFormOutput($this->object->getFixedTextLength()) .
"\"");
691 $cloze_text = $this->
object->getClozeText();
692 $this->tpl->setVariable(
"VALUE_CLOZE_TEXT",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($cloze_text)));
693 $this->tpl->setVariable(
"TEXT_CREATE_GAPS", $this->lng->txt(
"create_gaps"));
694 $identical_scoring = $this->
object->getIdenticalScoring();
695 if ($identical_scoring) $this->tpl->setVariable(
"CHECKED_IDENTICAL_SCORING",
" checked=\"checked\"");
696 $this->tpl->setVariable(
"TEXT_IDENTICAL_SCORING", $this->lng->txt(
"identical_scoring"));
697 $this->tpl->setVariable(
"TEXT_IDENTICAL_SCORING_DESCRIPTION", $this->lng->txt(
"identical_scoring_desc"));
698 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
699 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
700 $this->tpl->setVariable(
"TEXT_COMMENT", $this->lng->txt(
"description"));
701 $this->tpl->setVariable(
"TEXT_CLOZE_TEXT", $this->lng->txt(
"cloze_text"));
703 $this->tpl->setVariable(
"TEXTGAP_RATING", $this->lng->txt(
"cloze_textgap_rating"));
704 $this->tpl->setVariable(
"TEXT_GAP_DEFINITION", $this->lng->txt(
"gap_definition"));
705 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
706 $this->tpl->setVariable(
"SAVE_EDIT", $this->lng->txt(
"save_edit"));
707 $this->tpl->setVariable(
"CANCEL",$this->lng->txt(
"cancel"));
708 $this->ctrl->setParameter($this,
"sel_question_types", $this->object->getQuestionType());
709 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->
outQuestionType());
710 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
711 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
712 $this->tpl->parseCurrentBlock();
714 include_once
"./Services/RTE/classes/class.ilRTE.php";
716 include_once
"./Services/RTE/classes/class.$rtestring.php";
717 $rte =
new $rtestring();
718 $rte->addPlugin(
"latex");
719 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
720 include_once
"./classes/class.ilObject.php";
721 $obj_id =
$_GET[
"q_id"];
723 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
725 $this->tpl->setCurrentBlock(
"adm_content");
727 $this->tpl->parseCurrentBlock();
744 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
745 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
746 $this->tpl->setVariable(
"FORMACTION", $formaction);
760 include_once
"./classes/class.ilTemplate.php";
761 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
762 $output = $this->
object->getClozeText();
763 foreach ($this->object->getGaps() as $gap_index => $gap)
765 switch ($gap->getType())
768 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
769 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
770 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
771 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
774 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
775 foreach ($gap->getItems() as $item)
777 $gaptemplate->setCurrentBlock(
"select_gap_option");
778 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
780 $gaptemplate->parseCurrentBlock();
782 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
783 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
784 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
787 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
788 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
789 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
790 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
794 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
795 $questionoutput = $template->get();
796 if (!$show_question_only)
801 return $questionoutput;
816 function getSolutionOutput($active_id,
$pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
819 $user_solution = array();
823 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
824 if (!is_array($user_solution))
826 $user_solution = array();
830 include_once
"./classes/class.ilTemplate.php";
831 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
832 $output = $this->
object->getClozeText();
833 $ssc = $this->
object->_getSuggestedSolutionCount($this->object->getId());
834 foreach ($this->object->getGaps() as $gap_index => $gap)
836 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
838 foreach ($user_solution as $solutionarray)
840 if ($solutionarray[
"value1"] == $gap_index) $found = $solutionarray;
845 if ($graphicalOutput)
848 $details = $this->
object->calculateReachedPoints($active_id,
$pass, TRUE);
849 $check = $details[$gap_index];
852 $gaptemplate->setCurrentBlock(
"icon_ok");
854 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
855 $gaptemplate->parseCurrentBlock();
859 $gaptemplate->setCurrentBlock(
"icon_not_ok");
860 if ($check[
"positive"])
863 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
868 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
870 $gaptemplate->parseCurrentBlock();
875 $ss = $this->
object->_getSuggestedSolution($this->object->getId(), $gap_index);
878 $gaptemplate->setCurrentBlock(
"solution_hint");
879 $gaptemplate->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
880 $gaptemplate->setVariable(
"URL_SOLUTION_HINT", $this->object->_getInternalLinkHref($ss[
"internal_link"]));
881 $gaptemplate->parseCurrentBlock();
887 $points = $this->
object->getMaximumGapPoints($gap_index);
888 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
889 $gaptemplate->setCurrentBlock(
"result_output");
890 $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
891 $gaptemplate->parseCurrentBlock();
893 switch ($gap->getType())
897 if (($active_id > 0) && (!$show_correct_solution))
899 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
901 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
903 $solutiontext .=
" ";
915 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
916 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
920 if (($active_id > 0) && (!$show_correct_solution))
922 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
924 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
926 $solutiontext .=
" ";
931 $item = $gap->getItem($found[
"value2"]);
932 if (is_object($item))
938 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
940 $solutiontext .=
" ";
949 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
950 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
954 if (($active_id > 0) && (!$show_correct_solution))
956 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
958 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
960 $solutiontext .=
" ";
972 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
973 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
977 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
980 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
981 $questionoutput = $template->get();
983 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
984 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
986 $solutionoutput = $solutiontemplate->get();
987 if (!$show_question_only)
992 return $solutionoutput;
998 $user_solution = array();
1001 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1006 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
1007 if (!is_array($user_solution))
1009 $user_solution = array();
1014 include_once
"./classes/class.ilTemplate.php";
1015 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1016 $output = $this->
object->getClozeText();
1017 foreach ($this->object->getGaps() as $gap_index => $gap)
1019 switch ($gap->getType())
1022 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1023 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
1024 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1025 foreach ($user_solution as $solution)
1027 if (strcmp($solution[
"value1"], $gap_index) == 0)
1032 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1035 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1036 foreach ($gap->getItems() as $item)
1038 $gaptemplate->setCurrentBlock(
"select_gap_option");
1039 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
1041 foreach ($user_solution as $solution)
1043 if (strcmp($solution[
"value1"], $gap_index) == 0)
1045 if (strcmp($solution[
"value2"], $item->getOrder()) == 0)
1047 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
1051 $gaptemplate->parseCurrentBlock();
1053 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
1054 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1055 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1058 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1059 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
1060 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
1061 foreach ($user_solution as $solution)
1063 if (strcmp($solution[
"value1"], $gap_index) == 0)
1068 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
1072 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
1073 $questionoutput = $template->get();
1074 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
1081 if (array_key_exists(
"cmd", $_POST))
1083 foreach ($_POST[
"cmd"] as $key => $value)
1085 if (preg_match(
"/addSuggestedSolution_(\d+)/", $key, $matches))
1087 $addForGap = $matches[1];
1091 if ($addForGap > -1)
1101 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
1105 $_POST[
"internalLinkType"] = $_POST[
"internalLinkType_$addForGap"];
1106 $this->ctrl->setParameter($this,
"subquestion_index", $addForGap);
1109 $this->
object->saveToDb();
1110 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
1111 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
1118 $removeFromGap = -1;
1119 foreach ($_POST[
"cmd"] as $key => $value)
1121 if (preg_match(
"/removeSuggestedSolution_(\d+)/", $key, $matches))
1123 $removeFromGap = $matches[1];
1126 if ($removeFromGap > -1)
1128 unset($this->object->suggested_solutions[$removeFromGap]);
1130 $this->
object->saveToDb();
1143 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1146 $this->
object->cleanupMediaObjectUsage();
1159 $this->tpl->addBlockFile(
"ADM_CONTENT",
"feedback",
"tpl.il_as_qpl_cloze_question_feedback.html",
"Modules/TestQuestionPool");
1160 $this->tpl->setVariable(
"FEEDBACK_TEXT", $this->lng->txt(
"feedback"));
1161 $this->tpl->setVariable(
"FEEDBACK_COMPLETE", $this->lng->txt(
"feedback_complete_solution"));
1162 $this->tpl->setVariable(
"VALUE_FEEDBACK_COMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
1163 $this->tpl->setVariable(
"FEEDBACK_INCOMPLETE", $this->lng->txt(
"feedback_incomplete_solution"));
1164 $this->tpl->setVariable(
"VALUE_FEEDBACK_INCOMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
1166 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1168 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
1170 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
1172 include_once
"./Services/RTE/classes/class.ilRTE.php";
1174 include_once
"./Services/RTE/classes/class.$rtestring.php";
1175 $rte =
new $rtestring();
1176 $rte->addPlugin(
"latex");
1177 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
1178 include_once
"./classes/class.ilObject.php";
1179 $obj_id =
$_GET[
"q_id"];
1181 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
1193 global $rbacsystem, $ilTabs;
1195 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
1196 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1197 $q_type = $this->
object->getQuestionType();
1199 if (strlen($q_type))
1201 $classname = $q_type .
"GUI";
1202 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1203 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1208 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1211 $ilTabs->addTarget(
"edit_content",
1212 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1213 array(
"edit",
"insert",
"exec_pg"),
1214 "",
"", $force_active);
1218 $ilTabs->addTarget(
"preview",
1219 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1221 "ilPageObjectGUI",
"", $force_active);
1224 $force_active =
false;
1225 $commands = $_POST[
"cmd"];
1226 if (is_array($commands))
1228 foreach ($commands as $key => $value)
1230 if (preg_match(
"/^delete_.*/", $key, $matches) ||
1231 preg_match(
"/^addSelectGapText_.*/", $key, $matches) ||
1232 preg_match(
"/^addGapText_.*/", $key, $matches) ||
1233 preg_match(
"/^upload_.*/", $key, $matches) ||
1234 preg_match(
"/^addSuggestedSolution_.*/", $key, $matches) ||
1235 preg_match(
"/^removeSuggestedSolution_.*/", $key, $matches)
1238 $force_active =
true;
1242 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1245 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1247 $ilTabs->addTarget(
"edit_properties",
1249 array(
"editQuestion",
"save",
"cancel",
"addSuggestedSolution",
1250 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
1251 "createGaps",
"saveEdit",
"changeGapType"),
1252 $classname,
"", $force_active);
1257 $ilTabs->addTarget(
"feedback",
1258 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1259 array(
"feedback",
"saveFeedback"),
1266 $ilTabs->addTarget(
"statistics",
1267 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1268 array(
"assessment"),
1272 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1276 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1280 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));