24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
49 include_once
"./Modules/TestQuestionPool/classes/class.assOrderingHorizontal.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->setPoints(
$_POST[
"points"]);
82 $this->
object->setEstimatedWorkingTime(
87 $this->
object->setTextSize(
$_POST[
"textsize"]);
88 $this->
object->setOrderText(
$_POST[
"ordertext"]);
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(
"orderinghorizontal");
119 $ordertext->
setValue($this->object->prepareTextareaOutput($this->object->getOrderText()));
120 $ordertext->setRequired(TRUE);
121 $ordertext->setInfo(sprintf($this->lng->txt(
"ordertext_info"), $this->
object->separator));
122 $ordertext->setRows(10);
123 $ordertext->setCols(80);
124 $form->addItem($ordertext);
126 include_once(
"./Services/Form/classes/class.ilAdditionalCharactersGUI.php");
130 $textsize->
setValue($this->object->getTextSize());
131 $textsize->setInfo($this->lng->txt(
"textsize_info"));
132 $textsize->setSize(6);
133 $textsize->setMinValue(10);
134 $textsize->setRequired(FALSE);
135 $form->addItem($textsize);
138 $points->setValue($this->object->getPoints());
142 $points->setMinvalueShouldBeGreater(
true);
151 $form->setValuesByPost();
152 $errors = !$form->checkInput();
153 $form->setValuesByPost();
154 if (
$errors) $checkonly =
false;
157 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
161 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
163 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
164 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
165 $this->tpl->setVariable(
"FORMACTION", $formaction);
184 $graphicalOutput = FALSE,
185 $result_output = FALSE,
186 $show_question_only = TRUE,
187 $show_feedback = FALSE,
188 $show_correct_solution = FALSE,
189 $show_manual_scoring = FALSE
193 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
196 if (($active_id > 0) && (!$show_correct_solution))
198 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
199 if (strlen($solutions[0][
"value1"]))
201 $elements = split(
"{::}", $solutions[0][
"value1"]);
202 foreach ($elements as $id => $element)
204 $template->setCurrentBlock(
"element");
205 $template->setVariable(
"ELEMENT_ID",
"e$id");
207 $template->parseCurrentBlock();
210 $solutionvalue = str_replace(
"{::}",
" ", $solutions[0][
"value1"]);
214 $elements = $this->
object->getOrderingElements();
215 foreach ($elements as $id => $element)
217 $template->setCurrentBlock(
"element");
218 $template->setVariable(
"ELEMENT_ID",
"e$id");
220 $template->parseCurrentBlock();
222 $solutionvalue = join($this->object->getOrderingElements(),
" ");
225 if (($active_id > 0) && (!$show_correct_solution))
227 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
228 if ($graphicalOutput)
231 if ($reached_points == $this->object->getMaximumPoints())
233 $template->setCurrentBlock(
"icon_ok");
235 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
236 $template->parseCurrentBlock();
240 $template->setCurrentBlock(
"icon_ok");
241 if ($reached_points > 0)
244 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
249 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
251 $template->parseCurrentBlock();
257 $reached_points = $this->
object->getPoints();
262 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
263 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
265 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
267 if ($this->object->textsize >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
269 $questionoutput = $template->get();
270 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
271 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
272 $solutionoutput = $solutiontemplate->get();
273 if (!$show_question_only)
278 return $solutionoutput;
283 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
284 $elements = $this->
object->getRandomOrderingElements();
285 foreach ($elements as $id => $element)
287 $template->setCurrentBlock(
"element");
288 $template->setVariable(
"ELEMENT_ID",
"e$id");
290 $template->parseCurrentBlock();
292 if ($this->object->textsize >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
293 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
294 $questionoutput = $template->get();
295 if (!$show_question_only)
300 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
302 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
303 return $questionoutput;
306 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
309 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
310 $elements = $this->
object->getRandomOrderingElements();
315 include_once
"./Modules/Test/classes/class.ilObjTest.php";
320 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
321 if (count($solutions) == 1)
323 $elements = split(
"{::}", $solutions[0][
"value1"]);
328 $this->
object->moveRight(
$_SESSION[
'qst_selection'], $active_id,
$pass);
330 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
331 if (count($solutions) == 1)
333 $elements = split(
"{::}", $solutions[0][
"value1"]);
336 if (count($solutions) == 0)
338 $_SESSION[
'qst_ordering_horizontal_elements'] = $elements;
342 unset(
$_SESSION[
'qst_ordering_horizontal_elements']);
345 foreach ($elements as $id => $element)
347 $template->setCurrentBlock(
"element");
348 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->object->getId() .
"_$id");
350 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'qst_selection', $idx);
352 $url = $this->ctrl->getLinkTargetByClass(
'iltestoutputgui',
'gotoQuestion');
353 $template->setVariable(
"MOVE_RIGHT", $url);
354 $template->setVariable(
"TEXT_MOVE_RIGHT", $this->lng->txt(
'move_right'));
356 $template->parseCurrentBlock();
358 if ($this->object->textsize >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
359 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
360 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
361 $questionoutput = $template->get();
362 if (!$show_question_only)
367 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
369 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
370 $questionoutput = $template->get();
371 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
382 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
384 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
385 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
386 $this->
object->cleanupMediaObjectUsage();
397 global $rbacsystem, $ilTabs;
399 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
400 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
401 $q_type = $this->
object->getQuestionType();
405 $classname = $q_type .
"GUI";
406 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
407 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
412 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
415 $ilTabs->addTarget(
"edit_content",
416 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
417 array(
"edit",
"insert",
"exec_pg"),
418 "",
"", $force_active);
422 $ilTabs->addTarget(
"preview",
423 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
425 "ilPageObjectGUI",
"", $force_active);
428 $force_active =
false;
429 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
432 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
433 $commands =
$_POST[
"cmd"];
434 if (is_array($commands))
436 foreach ($commands as $key => $value)
438 if (preg_match(
"/^suggestrange_.*/", $key, $matches))
440 $force_active =
true;
445 $ilTabs->addTarget(
"edit_properties",
447 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
448 $classname,
"", $force_active);
453 $ilTabs->addTarget(
"feedback",
454 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
455 array(
"feedback",
"saveFeedback"),
461 $ilTabs->addTarget(
"solution_hint",
462 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
463 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
464 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
474 $ilTabs->addTarget(
"statistics",
475 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
480 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
484 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
488 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));