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"]);
79 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
83 $this->
object->setEstimatedWorkingTime(
88 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
89 $questiontext =
$_POST[
"question"];
90 $this->
object->setQuestion($questiontext);
91 $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"]);
92 $this->
object->setTextRating(
$_POST[
"text_rating"]);
94 $this->
object->flushAnswers();
95 foreach (
$_POST[
'answers'][
'answer'] as $index => $answer)
97 $answertext = $answer;
98 $this->
object->addAnswer($answertext,
$_POST[
'answers'][
'points'][$index], $index);
118 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
120 $form->setFormAction($this->ctrl->getFormAction($this));
122 $form->setMultipart(FALSE);
123 $form->setTableWidth(
"100%");
124 $form->setId(
"asstextsubset");
129 $correctanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers"),
"correctanswers");
131 $correctanswers->setDecimals(0);
132 $correctanswers->setSize(3);
133 $correctanswers->setValue($this->object->getCorrectAnswers());
134 $correctanswers->setRequired(
true);
135 $form->addItem($correctanswers);
138 $points =
new ilNumberInputGUI($this->lng->txt(
"maximum_points"),
"points");
141 $points->setDisabled(
true);
142 $points->setValue($this->object->getMaximumPoints());
143 $points->setRequired(
false);
144 $form->addItem($points);
147 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
148 $text_options = array(
149 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
150 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive")
154 $text_options[
"l1"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1");
155 $text_options[
"l2"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2");
156 $text_options[
"l3"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3");
157 $text_options[
"l4"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4");
158 $text_options[
"l5"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5");
161 $textrating->setValue($this->object->getTextRating());
162 $form->addItem($textrating);
165 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
168 $choices->setQuestionObject($this->
object);
169 $choices->setSingleline(
true);
170 $choices->setAllowMove(
false);
171 if ($this->object->getAnswerCount() == 0) $this->object->addAnswer(
"", 0, 0);
172 $choices->setValues($this->object->getAnswers());
173 $form->addItem($choices);
181 $form->setValuesByPost();
182 $points->setValue($this->object->getMaximumPoints());
183 $errors = !$form->checkInput();
184 $form->setValuesByPost();
185 if (
$errors) $checkonly =
false;
188 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
198 $position = key(
$_POST[
'cmd'][
'addanswers']);
199 $this->
object->addAnswer(
"", 0, $position+1);
209 $position = key(
$_POST[
'cmd'][
'removeanswers']);
210 $this->
object->deleteAnswer($position);
216 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
217 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
218 $this->tpl->setVariable(
"FORMACTION", $formaction);
237 $graphicalOutput = FALSE,
238 $result_output = FALSE,
239 $show_question_only = TRUE,
240 $show_feedback = FALSE,
241 $show_correct_solution = FALSE,
242 $show_manual_scoring = FALSE
246 $solutions = array();
247 if (($active_id > 0) && (!$show_correct_solution))
249 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
254 foreach ($this->object->answers as $answer)
256 if ($answer->getPoints() > 0)
258 if (!is_array($rank[$answer->getPoints()]))
260 $rank[$answer->getPoints()] = array();
262 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
265 krsort($rank, SORT_NUMERIC);
266 foreach ($rank as $index => $bestsolutions)
268 array_push($solutions, array(
"value1" => join(
",", $bestsolutions),
"points" => $index));
273 include_once
"./classes/class.ilTemplate.php";
274 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
275 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
276 $available_answers =& $this->
object->getAvailableAnswers();
277 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
279 if ((!$test_id) && (strcmp($solutions[$i][
"value1"],
"") == 0))
284 if (($active_id > 0) && (!$show_correct_solution))
286 if ($graphicalOutput)
289 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
291 if ($index !== FALSE)
293 unset($available_answers[$index]);
298 $template->setCurrentBlock(
"icon_ok");
300 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
301 $template->parseCurrentBlock();
305 $template->setCurrentBlock(
"icon_ok");
307 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
308 $template->parseCurrentBlock();
312 $template->setCurrentBlock(
"textsubset_row");
313 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
314 $template->setVariable(
"COUNTER", $i+1);
317 $points = $solutions[$i][
"points"];
318 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
319 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
321 $template->parseCurrentBlock();
324 $questiontext = $this->
object->getQuestion();
325 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
326 $questionoutput = $template->get();
328 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
329 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
331 $solutionoutput = $solutiontemplate->get();
332 if (!$show_question_only)
337 return $solutionoutput;
343 include_once
"./classes/class.ilTemplate.php";
344 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
345 $width = $this->
object->getMaxTextboxWidth();
346 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
348 $template->setCurrentBlock(
"textsubset_row");
349 $template->setVariable(
"COUNTER", $i+1);
350 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
351 $template->setVariable(
"TEXTFIELD_SIZE", $width);
352 $template->parseCurrentBlock();
354 $questiontext = $this->
object->getQuestion();
355 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
356 $questionoutput = $template->get();
357 if (!$show_question_only)
362 return $questionoutput;
372 include_once
"./Modules/Test/classes/class.ilObjTest.php";
377 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
381 include_once
"./classes/class.ilTemplate.php";
382 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
383 $width = $this->
object->getMaxTextboxWidth();
384 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
386 $template->setCurrentBlock(
"textsubset_row");
387 foreach ($solutions as $idx => $solution_value)
391 $template->setVariable(
"TEXTFIELD_VALUE",
" value=\"" . $solution_value[
"value1"].
"\"");
394 $template->setVariable(
"COUNTER", $i+1);
395 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
396 $template->setVariable(
"TEXTFIELD_SIZE", $width);
397 $template->parseCurrentBlock();
399 $questiontext = $this->
object->getQuestion();
400 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
401 $questionoutput = $template->get();
402 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
413 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
415 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
416 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
417 $this->
object->cleanupMediaObjectUsage();
428 global $rbacsystem, $ilTabs;
430 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
431 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
432 $q_type = $this->
object->getQuestionType();
436 $classname = $q_type .
"GUI";
437 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
438 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
443 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
446 $ilTabs->addTarget(
"edit_content",
447 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
448 array(
"edit",
"insert",
"exec_pg"),
449 "",
"", $force_active);
453 $ilTabs->addTarget(
"preview",
454 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
456 "ilPageObjectGUI",
"", $force_active);
459 $force_active =
false;
460 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
463 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
465 $ilTabs->addTarget(
"edit_properties",
467 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
468 $classname,
"", $force_active);
473 $ilTabs->addTarget(
"feedback",
474 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
475 array(
"feedback",
"saveFeedback"),
481 $ilTabs->addTarget(
"solution_hint",
482 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
483 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
484 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
494 $ilTabs->addTarget(
"statistics",
495 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
500 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
505 global $___test_express_mode;
507 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
508 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
512 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
517 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));