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);
167 $form->setValuesByPost();
168 $points->setValue($this->object->getMaximumPoints());
169 $errors = !$form->checkInput();
170 $form->setValuesByPost();
171 if (
$errors) $checkonly =
false;
174 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
184 $position = key(
$_POST[
'cmd'][
'addanswers']);
185 $this->
object->addAnswer(
"", 0, $position+1);
195 $position = key(
$_POST[
'cmd'][
'removeanswers']);
196 $this->
object->deleteAnswer($position);
202 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
203 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
204 $this->tpl->setVariable(
"FORMACTION", $formaction);
223 $graphicalOutput = FALSE,
224 $result_output = FALSE,
225 $show_question_only = TRUE,
226 $show_feedback = FALSE,
227 $show_correct_solution = FALSE,
228 $show_manual_scoring = FALSE
232 $solutions = array();
233 if (($active_id > 0) && (!$show_correct_solution))
235 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
240 foreach ($this->object->answers as $answer)
242 if ($answer->getPoints() > 0)
244 if (!is_array($rank[$answer->getPoints()]))
246 $rank[$answer->getPoints()] = array();
248 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
251 krsort($rank, SORT_NUMERIC);
252 foreach ($rank as $index => $bestsolutions)
254 array_push($solutions, array(
"value1" => join(
",", $bestsolutions),
"points" => $index));
259 include_once
"./classes/class.ilTemplate.php";
260 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
261 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
262 $available_answers =& $this->
object->getAvailableAnswers();
263 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
265 if ((!$test_id) && (strcmp($solutions[$i][
"value1"],
"") == 0))
270 if (($active_id > 0) && (!$show_correct_solution))
272 if ($graphicalOutput)
275 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
277 if ($index !== FALSE)
279 unset($available_answers[$index]);
284 $template->setCurrentBlock(
"icon_ok");
286 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
287 $template->parseCurrentBlock();
291 $template->setCurrentBlock(
"icon_ok");
293 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
294 $template->parseCurrentBlock();
298 $template->setCurrentBlock(
"textsubset_row");
299 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
300 $template->setVariable(
"COUNTER", $i+1);
303 $points = $solutions[$i][
"points"];
304 $resulttext = (
$points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
305 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext,
$points));
307 $template->parseCurrentBlock();
310 $questiontext = $this->
object->getQuestion();
311 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
312 $questionoutput = $template->get();
314 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
315 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
317 $solutionoutput = $solutiontemplate->get();
318 if (!$show_question_only)
323 return $solutionoutput;
329 include_once
"./classes/class.ilTemplate.php";
330 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
331 $width = $this->
object->getMaxTextboxWidth();
332 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
334 $template->setCurrentBlock(
"textsubset_row");
335 $template->setVariable(
"COUNTER", $i+1);
336 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
337 $template->setVariable(
"TEXTFIELD_SIZE", $width);
338 $template->parseCurrentBlock();
340 $questiontext = $this->
object->getQuestion();
341 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
342 $questionoutput = $template->get();
343 if (!$show_question_only)
348 return $questionoutput;
358 include_once
"./Modules/Test/classes/class.ilObjTest.php";
363 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
367 include_once
"./classes/class.ilTemplate.php";
368 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
369 $width = $this->
object->getMaxTextboxWidth();
370 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
372 $template->setCurrentBlock(
"textsubset_row");
373 foreach ($solutions as $idx => $solution_value)
377 $template->setVariable(
"TEXTFIELD_VALUE",
" value=\"" . $solution_value[
"value1"].
"\"");
380 $template->setVariable(
"COUNTER", $i+1);
381 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
382 $template->setVariable(
"TEXTFIELD_SIZE", $width);
383 $template->parseCurrentBlock();
385 $questiontext = $this->
object->getQuestion();
386 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
387 $questionoutput = $template->get();
388 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
399 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
401 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
402 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
403 $this->
object->cleanupMediaObjectUsage();
414 global $rbacsystem, $ilTabs;
416 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
417 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
418 $q_type = $this->
object->getQuestionType();
422 $classname = $q_type .
"GUI";
423 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
424 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
429 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
432 $ilTabs->addTarget(
"edit_content",
433 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
434 array(
"edit",
"insert",
"exec_pg"),
435 "",
"", $force_active);
439 $ilTabs->addTarget(
"preview",
440 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
442 "ilPageObjectGUI",
"", $force_active);
445 $force_active =
false;
446 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
449 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
451 $ilTabs->addTarget(
"edit_properties",
453 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
454 $classname,
"", $force_active);
459 $ilTabs->addTarget(
"feedback",
460 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
461 array(
"feedback",
"saveFeedback"),
467 $ilTabs->addTarget(
"solution_hint",
468 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
469 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
470 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
480 $ilTabs->addTarget(
"statistics",
481 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
486 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
490 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
494 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));