24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
51 include_once
"./Modules/TestQuestionPool/classes/class.assClozeTest.php";
55 $this->
object->loadFromDb($id);
61 if (preg_match(
"/^(removegap|addgap)_(\d+)$/",
$cmd, $matches))
64 $this->gapIndex = $matches[2];
77 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
80 $this->
object->flushGaps();
81 $this->
object->setTitle(
$_POST[
"title"]);
82 $this->
object->setAuthor(
$_POST[
"author"]);
83 $this->
object->setComment(
$_POST[
"comment"]);
84 $this->
object->setTextgapRating(
$_POST[
"textgap_rating"]);
85 $this->
object->setIdenticalScoring(
$_POST[
"identical_scoring"]);
88 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
90 $this->
object->setFixedTextLength(
$_POST[
"fixedTextLength"]);
91 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
92 $cloze_text =
$_POST[
"question"];
93 $this->
object->setClozeText($cloze_text);
94 $this->
object->setEstimatedWorkingTime(
100 if (is_array(
$_POST[
'gap']))
102 if (strcmp($this->ctrl->getCmd(),
'createGaps') != 0) $this->
object->clearGapAnswers();
103 foreach (
$_POST[
'gap'] as $idx => $hidden)
105 $clozetype =
$_POST[
'clozetype_' . $idx];
106 $this->
object->setGapType($idx, $clozetype);
107 if (array_key_exists(
'shuffle_' . $idx,
$_POST))
109 $this->
object->setGapShuffle($idx,
$_POST[
'shuffle_' . $idx]);
112 if (strcmp($this->ctrl->getCmd(),
'createGaps') != 0)
114 if (is_array(
$_POST[
'gap_' . $idx][
'answer']))
116 foreach (
$_POST[
'gap_' . $idx][
'answer'] as $order => $value)
118 $this->
object->addGapAnswer($idx, $order, $value);
122 if (array_key_exists(
'gap_' . $idx .
'_numeric',
$_POST))
124 if (strcmp($this->ctrl->getCmd(),
'createGaps') != 0) $this->
object->addGapAnswer($idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric']));
125 $this->
object->setGapAnswerLowerBound($idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_lower']));
126 $this->
object->setGapAnswerUpperBound($idx, 0, str_replace(
",",
".",
$_POST[
'gap_' . $idx .
'_numeric_upper']));
127 $this->
object->setGapAnswerPoints($idx, 0,
$_POST[
'gap_' . $idx .
'_numeric_points']);
129 if (is_array(
$_POST[
'gap_' . $idx][
'points']))
131 foreach (
$_POST[
'gap_' . $idx][
'points'] as $order => $value)
133 $this->
object->setGapAnswerPoints($idx, $order, $value);
137 if (strcmp($this->ctrl->getCmd(),
'createGaps') != 0) $this->
object->updateClozeTextFromGaps();
157 # if ($_REQUEST['prev_qid']) {
158 # $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
161 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
163 $form->setFormAction($this->ctrl->getFormAction($this));
165 $form->setMultipart(FALSE);
166 $form->setTableWidth(
"100%");
167 $form->setId(
"assclozetest");
171 $q_item = $form->getItemByPostVar(
"question");
172 $q_item->setInfo($this->lng->txt(
"close_text_hint"));
173 $q_item->setTitle($this->lng->txt(
"cloze_text"));
178 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"textgap_rating");
179 $text_options = array(
180 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
181 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
182 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
183 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
184 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
185 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
186 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
188 $textrating->setOptions($text_options);
189 $textrating->setValue($this->object->getTextgapRating());
190 $form->addItem($textrating);
193 $fixedTextLength =
new ilNumberInputGUI($this->lng->txt(
"cloze_fixed_textlength"),
"fixedTextLength");
195 $fixedTextLength->setMinValue(0);
196 $fixedTextLength->setSize(3);
197 $fixedTextLength->setMaxLength(6);
198 $fixedTextLength->setInfo($this->lng->txt(
'cloze_fixed_textlength_description'));
199 $fixedTextLength->setRequired(
false);
200 $form->addItem($fixedTextLength);
203 $identical_scoring =
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring"),
"identical_scoring");
205 $identical_scoring->setChecked($this->object->getIdenticalScoring());
206 $identical_scoring->setInfo($this->lng->txt(
'identical_scoring_desc'));
207 $identical_scoring->setRequired(FALSE);
208 $form->addItem($identical_scoring);
211 for ($i = 0; $i < $this->
object->getGapCount(); $i++)
213 $gap = $this->
object->getGap($i);
215 $header->setTitle($this->lng->txt(
"gap") .
" " . ($i+1));
216 $form->addItem($header);
219 $gapcounter->setValue($i);
220 $form->addItem($gapcounter);
224 0 => $this->lng->txt(
"text_gap"),
225 1 => $this->lng->txt(
"select_gap"),
226 2 => $this->lng->txt(
"numeric_gap")
229 $gaptype->setValue($gap->getType());
230 $form->addItem($gaptype);
235 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
236 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
239 $values->setQuestionObject($this->
object);
240 $values->setSingleline(
true);
241 $values->setAllowMove(
false);
242 if (count($gap->getItemsRaw()) == 0) $gap->addItem(
new assAnswerCloze(
"", 0, 0));
243 $values->setValues($gap->getItemsRaw());
244 $form->addItem($values);
248 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
249 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
252 $values->setQuestionObject($this->
object);
253 $values->setSingleline(
true);
254 $values->setAllowMove(
false);
255 if (count($gap->getItemsRaw()) == 0) $gap->addItem(
new assAnswerCloze(
"", 0, 0));
256 $values->setValues($gap->getItemsRaw());
257 $form->addItem($values);
260 $shuffle =
new ilCheckboxInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle_" . $i .
"");
262 $shuffle->setChecked($gap->getShuffle());
263 $shuffle->setRequired(FALSE);
264 $form->addItem($shuffle);
268 if (count($gap->getItemsRaw()) == 0) $gap->addItem(
new assAnswerCloze(
"", 0, 0));
269 foreach ($gap->getItemsRaw() as $item)
271 $value =
new ilFormulaInputGUI($this->lng->txt(
'value'),
"gap_" . $i .
"_numeric");
274 $value->setRequired(
true);
275 $value->setInlineStyle(
'text-align: right;');
276 $form->addItem($value);
278 $lowerbound =
new ilFormulaInputGUI($this->lng->txt(
'range_lower_limit'),
"gap_" . $i .
"_numeric_lower");
280 $lowerbound->setRequired(
true);
282 $lowerbound->setInlineStyle(
'text-align: right;');
283 $form->addItem($lowerbound);
285 $upperbound =
new ilFormulaInputGUI($this->lng->txt(
'range_upper_limit'),
"gap_" . $i .
"_numeric_upper");
287 $upperbound->setRequired(
true);
289 $upperbound->setInlineStyle(
'text-align: right;');
290 $form->addItem($upperbound);
292 $points =
new ilNumberInputGUI($this->lng->txt(
'points'),
"gap_" . $i .
"_numeric_points");
294 $points->setRequired(
true);
296 $form->addItem($points);
301 $form->addCommandButton(
'createGaps', $this->lng->txt(
'create_gaps'));
308 $form->setValuesByPost();
309 $errors = !$form->checkInput();
310 $form->setValuesByPost();
311 if (
$errors) $checkonly =
false;
314 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
324 $this->
object->saveToDb();
334 $this->
object->deleteAnswerText($this->gapIndex, key(
$_POST[
'cmd'][
'removegap_' . $this->gapIndex]));
344 $this->
object->addGapAnswer($this->gapIndex, key(
$_POST[
'cmd'][
'addgap_' . $this->gapIndex])+1,
"");
362 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
363 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
364 $this->tpl->setVariable(
"FORMACTION", $formaction);
378 include_once
"./classes/class.ilTemplate.php";
379 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
380 $output = $this->
object->getClozeText();
381 foreach ($this->object->getGaps() as $gap_index => $gap)
383 switch ($gap->getType())
386 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
387 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
388 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
389 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
392 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
393 foreach ($gap->getItems() as $item)
395 $gaptemplate->setCurrentBlock(
"select_gap_option");
396 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
398 $gaptemplate->parseCurrentBlock();
400 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
401 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
402 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
405 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
406 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
407 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
408 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
412 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
413 $questionoutput = $template->get();
414 if (!$show_question_only)
419 return $questionoutput;
438 $graphicalOutput = FALSE,
439 $result_output = FALSE,
440 $show_question_only = TRUE,
441 $show_feedback = FALSE,
442 $show_correct_solution = FALSE,
443 $show_manual_scoring = FALSE
447 $user_solution = array();
451 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
452 if (!is_array($user_solution))
454 $user_solution = array();
458 include_once
"./classes/class.ilTemplate.php";
459 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
460 $output = $this->
object->getClozeText();
461 foreach ($this->object->getGaps() as $gap_index => $gap)
463 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output_solution_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
465 foreach ($user_solution as $solutionarray)
467 if ($solutionarray[
"value1"] == $gap_index) $found = $solutionarray;
472 if ($graphicalOutput)
475 $details = $this->
object->calculateReachedPoints($active_id,
$pass, TRUE);
476 $check = $details[$gap_index];
479 $gaptemplate->setCurrentBlock(
"icon_ok");
481 $gaptemplate->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
482 $gaptemplate->parseCurrentBlock();
486 $gaptemplate->setCurrentBlock(
"icon_not_ok");
487 if ($check[
"positive"])
490 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
495 $gaptemplate->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
497 $gaptemplate->parseCurrentBlock();
503 $points = $this->
object->getMaximumGapPoints($gap_index);
504 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
505 $gaptemplate->setCurrentBlock(
"result_output");
506 $gaptemplate->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
507 $gaptemplate->parseCurrentBlock();
509 switch ($gap->getType())
513 if (($active_id > 0) && (!$show_correct_solution))
515 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
517 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
519 $solutiontext .=
" ";
531 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
532 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
536 if (($active_id > 0) && (!$show_correct_solution))
538 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
540 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
542 $solutiontext .=
" ";
547 $item = $gap->getItem($found[
"value2"]);
548 if (is_object($item))
554 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
556 $solutiontext .=
" ";
565 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
566 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
570 if (($active_id > 0) && (!$show_correct_solution))
572 if ((count($found) == 0) || (strlen(trim($found[
"value2"])) == 0))
574 for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++)
576 $solutiontext .=
" ";
588 $gaptemplate->setVariable(
"SOLUTION", $solutiontext);
589 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
593 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
596 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
597 $questionoutput = $template->get();
599 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
600 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
602 $solutionoutput = $solutiontemplate->get();
603 if (!$show_question_only)
608 return $solutionoutput;
614 $user_solution = array();
617 include_once
"./Modules/Test/classes/class.ilObjTest.php";
622 $user_solution =& $this->
object->getSolutionValues($active_id,
$pass);
623 if (!is_array($user_solution))
625 $user_solution = array();
630 include_once
"./classes/class.ilTemplate.php";
631 $template =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
632 $output = $this->
object->getClozeText();
633 foreach ($this->object->getGaps() as $gap_index => $gap)
635 switch ($gap->getType())
638 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_text.html", TRUE, TRUE,
"Modules/TestQuestionPool");
639 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
640 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
641 foreach ($user_solution as $solution)
643 if (strcmp($solution[
"value1"], $gap_index) == 0)
648 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
651 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_select.html", TRUE, TRUE,
"Modules/TestQuestionPool");
652 foreach ($gap->getItems() as $item)
654 $gaptemplate->setCurrentBlock(
"select_gap_option");
655 $gaptemplate->setVariable(
"SELECT_GAP_VALUE", $item->getOrder());
657 foreach ($user_solution as $solution)
659 if (strcmp($solution[
"value1"], $gap_index) == 0)
661 if (strcmp($solution[
"value2"], $item->getOrder()) == 0)
663 $gaptemplate->setVariable(
"SELECT_GAP_SELECTED",
" selected=\"selected\"");
667 $gaptemplate->parseCurrentBlock();
669 $gaptemplate->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
670 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
671 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
674 $gaptemplate =
new ilTemplate(
"tpl.il_as_qpl_cloze_question_gap_numeric.html", TRUE, TRUE,
"Modules/TestQuestionPool");
675 $gaptemplate->setVariable(
"TEXT_GAP_SIZE", $this->object->getFixedTextLength() ? $this->
object->getFixedTextLength() : $gap->getMaxWidth());
676 $gaptemplate->setVariable(
"GAP_COUNTER", $gap_index);
677 foreach ($user_solution as $solution)
679 if (strcmp($solution[
"value1"], $gap_index) == 0)
684 $output = preg_replace(
"/\[gap\].*?\[\/gap\]/", $gaptemplate->get(), $output, 1);
688 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($output, TRUE));
689 $questionoutput = $template->get();
690 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
701 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
703 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
704 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
705 $this->
object->cleanupMediaObjectUsage();
716 global $rbacsystem, $ilTabs;
718 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
719 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
720 $q_type = $this->
object->getQuestionType();
724 $classname = $q_type .
"GUI";
725 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
726 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
727 # $this->ctrl->setParameterByClass(strtolower($classname), 'prev_qid', $_REQUEST['prev_qid']);
732 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
735 $ilTabs->addTarget(
"edit_content",
736 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
737 array(
"edit",
"insert",
"exec_pg"),
738 "",
"", $force_active);
742 $ilTabs->addTarget(
"preview",
743 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
745 "ilPageObjectGUI",
"", $force_active);
748 $force_active =
false;
749 $commands =
$_POST[
"cmd"];
750 if (is_array($commands))
752 foreach ($commands as $key => $value)
754 if (preg_match(
"/^removegap_.*/", $key, $matches) ||
755 preg_match(
"/^addgap_.*/", $key, $matches)
758 $force_active =
true;
762 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
765 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
767 $ilTabs->addTarget(
"edit_properties",
769 array(
"editQuestion",
"originalSyncForm",
"save",
"createGaps",
"saveEdit"),
770 $classname,
"", $force_active);
775 $ilTabs->addTarget(
"feedback",
776 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
777 array(
"feedback",
"saveFeedback"),
783 $ilTabs->addTarget(
"solution_hint",
784 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
785 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
786 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
796 $ilTabs->addTarget(
"statistics",
797 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
802 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
807 global $___test_express_mode;
809 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
810 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
814 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
819 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));