24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
50 include_once
"./Modules/TestQuestionPool/classes/class.assTextSubset.php";
54 $this->
object->loadFromDb($id);
71 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
74 $this->
object->setTitle(
$_POST[
"title"]);
75 $this->
object->setAuthor(
$_POST[
"author"]);
76 $this->
object->setComment(
$_POST[
"comment"]);
77 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
78 $questiontext =
$_POST[
"question"];
79 $this->
object->setQuestion($questiontext);
80 $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"]);
81 $this->
object->setTextRating(
$_POST[
"text_rating"]);
83 $this->
object->flushAnswers();
84 foreach (
$_POST[
'answers'][
'answer'] as $index => $answer)
86 $answertext = $answer;
87 $this->
object->addAnswer($answertext,
$_POST[
'answers'][
'points'][$index], $index);
104 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
107 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
109 $form->setFormAction($this->ctrl->getFormAction($this));
111 $form->setMultipart(FALSE);
112 $form->setTableWidth(
"100%");
113 $form->setId(
"asstextsubset");
118 $correctanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers"),
"correctanswers");
120 $correctanswers->setDecimals(0);
121 $correctanswers->setSize(3);
122 $correctanswers->setValue($this->object->getCorrectAnswers());
123 $correctanswers->setRequired(
true);
124 $form->addItem($correctanswers);
131 $points->setValue($this->object->getMaximumPoints());
136 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
137 $text_options = array(
138 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
139 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
140 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
141 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
142 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
143 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
144 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
146 $textrating->setOptions($text_options);
147 $textrating->setValue($this->object->getTextRating());
148 $form->addItem($textrating);
151 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
154 $choices->setQuestionObject($this->
object);
155 $choices->setSingleline(
true);
156 $choices->setAllowMove(
false);
157 if ($this->object->getAnswerCount() == 0) $this->object->addAnswer(
"", 0, 0);
158 $choices->setValues($this->object->getAnswers());
159 $form->addItem($choices);
165 include_once(
"./Services/Form/classes/class.ilAdditionalCharactersGUI.php");
169 $form->setValuesByPost();
170 $points->setValue($this->object->getMaximumPoints());
171 $errors = !$form->checkInput();
172 $form->setValuesByPost();
173 if (
$errors) $checkonly =
false;
176 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
186 $position = key(
$_POST[
'cmd'][
'addanswers']);
187 $this->
object->addAnswer(
"", 0, $position+1);
197 $position = key(
$_POST[
'cmd'][
'removeanswers']);
198 $this->
object->deleteAnswer($position);
204 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
205 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
206 $this->tpl->setVariable(
"FORMACTION", $formaction);
225 $graphicalOutput = FALSE,
226 $result_output = FALSE,
227 $show_question_only = TRUE,
228 $show_feedback = FALSE,
229 $show_correct_solution = FALSE,
230 $show_manual_scoring = FALSE
234 $solutions = array();
235 if (($active_id > 0) && (!$show_correct_solution))
237 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
242 foreach ($this->object->answers as $answer)
244 if ($answer->getPoints() > 0)
246 if (!is_array($rank[$answer->getPoints()]))
248 $rank[$answer->getPoints()] = array();
250 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
253 krsort($rank, SORT_NUMERIC);
254 foreach ($rank as $index => $bestsolutions)
256 array_push($solutions, array(
"value1" => join(
",", $bestsolutions),
"points" => $index));
261 include_once
"./classes/class.ilTemplate.php";
262 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
263 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
264 $available_answers =& $this->
object->getAvailableAnswers();
265 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
267 if ((!$test_id) && (strcmp($solutions[$i][
"value1"],
"") == 0))
272 if (($active_id > 0) && (!$show_correct_solution))
274 if ($graphicalOutput)
277 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
279 if ($index !== FALSE)
281 unset($available_answers[$index]);
286 $template->setCurrentBlock(
"icon_ok");
288 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
289 $template->parseCurrentBlock();
293 $template->setCurrentBlock(
"icon_ok");
295 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
296 $template->parseCurrentBlock();
300 $template->setCurrentBlock(
"textsubset_row");
301 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
302 $template->setVariable(
"COUNTER", $i+1);
305 $points = $solutions[$i][
"points"];
306 $resulttext = (
$points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
307 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext,
$points));
309 $template->parseCurrentBlock();
312 $questiontext = $this->
object->getQuestion();
313 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
314 $questionoutput = $template->get();
316 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
317 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
319 $solutionoutput = $solutiontemplate->get();
320 if (!$show_question_only)
325 return $solutionoutput;
331 include_once
"./classes/class.ilTemplate.php";
332 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
333 $width = $this->
object->getMaxTextboxWidth();
334 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
336 $template->setCurrentBlock(
"textsubset_row");
337 $template->setVariable(
"COUNTER", $i+1);
338 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
339 $template->setVariable(
"TEXTFIELD_SIZE", $width);
340 $template->parseCurrentBlock();
342 $questiontext = $this->
object->getQuestion();
343 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
344 $questionoutput = $template->get();
345 if (!$show_question_only)
350 return $questionoutput;
360 include_once
"./Modules/Test/classes/class.ilObjTest.php";
365 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
369 include_once
"./classes/class.ilTemplate.php";
370 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
371 $width = $this->
object->getMaxTextboxWidth();
372 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
374 $template->setCurrentBlock(
"textsubset_row");
375 foreach ($solutions as $idx => $solution_value)
379 $template->setVariable(
"TEXTFIELD_VALUE",
" value=\"" . $solution_value[
"value1"].
"\"");
382 $template->setVariable(
"COUNTER", $i+1);
383 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
384 $template->setVariable(
"TEXTFIELD_SIZE", $width);
385 $template->parseCurrentBlock();
387 $questiontext = $this->
object->getQuestion();
388 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
389 $questionoutput = $template->get();
390 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
401 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
403 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
404 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
405 $this->
object->cleanupMediaObjectUsage();
416 global $rbacsystem, $ilTabs;
418 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
419 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
420 $q_type = $this->
object->getQuestionType();
424 $classname = $q_type .
"GUI";
425 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
426 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
431 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
434 $ilTabs->addTarget(
"edit_content",
435 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
436 array(
"edit",
"insert",
"exec_pg"),
437 "",
"", $force_active);
441 $ilTabs->addTarget(
"preview",
442 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
444 "ilPageObjectGUI",
"", $force_active);
447 $force_active =
false;
448 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
451 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
453 $ilTabs->addTarget(
"edit_properties",
455 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
456 $classname,
"", $force_active);
461 $ilTabs->addTarget(
"feedback",
462 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
463 array(
"feedback",
"saveFeedback"),
469 $ilTabs->addTarget(
"solution_hint",
470 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
471 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
472 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
482 $ilTabs->addTarget(
"statistics",
483 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
488 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
492 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
496 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));