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.assOrderingHorizontal.php";
55 $this->
object->loadFromDb($id);
72 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
75 $this->
object->setTitle(
$_POST[
"title"]);
76 $this->
object->setAuthor(
$_POST[
"author"]);
77 $this->
object->setComment(
$_POST[
"comment"]);
80 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
83 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
84 $questiontext =
$_POST[
"question"];
85 $this->
object->setQuestion($questiontext);
86 $this->
object->setPoints(
$_POST[
"points"]);
88 $this->
object->setEstimatedWorkingTime(
93 $this->
object->setTextSize(
$_POST[
"textsize"]);
94 $this->
object->setOrderText(
$_POST[
"ordertext"]);
113 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
115 $form->setFormAction($this->ctrl->getFormAction($this));
117 $form->setMultipart(FALSE);
118 $form->setTableWidth(
"100%");
119 $form->setId(
"orderinghorizontal");
125 $ordertext->
setValue($this->object->prepareTextareaOutput($this->object->getOrderText()));
126 $ordertext->setRequired(TRUE);
127 $ordertext->setInfo(sprintf($this->lng->txt(
"ordertext_info"), $this->
object->separator));
128 $ordertext->setRows(10);
129 $ordertext->setCols(80);
130 $form->addItem($ordertext);
133 $textsize->
setValue($this->object->getTextSize());
134 $textsize->setInfo($this->lng->txt(
"textsize_info"));
135 $textsize->setSize(6);
136 $textsize->setMinValue(10);
137 $textsize->setRequired(FALSE);
138 $form->addItem($textsize);
145 if($this->object->getPoints() == null)
147 $points->setValue(
"1");
151 $points->setValue($this->object->getPoints());
153 $points->setRequired(TRUE);
155 $points->setMinValue(0.0);
156 $points->setMinvalueShouldBeGreater(
true);
157 $form->addItem($points);
165 $form->setValuesByPost();
166 $errors = !$form->checkInput();
167 $form->setValuesByPost();
168 if (
$errors) $checkonly =
false;
171 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
175 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
177 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
178 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
179 $this->tpl->setVariable(
"FORMACTION", $formaction);
198 $graphicalOutput = FALSE,
199 $result_output = FALSE,
200 $show_question_only = TRUE,
201 $show_feedback = FALSE,
202 $show_correct_solution = FALSE,
203 $show_manual_scoring = FALSE,
204 $show_question_text = TRUE
208 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
211 if (($active_id > 0) && (!$show_correct_solution))
213 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
214 if (strlen($solutions[0][
"value1"]))
216 $elements = split(
"{::}", $solutions[0][
"value1"]);
217 foreach ($elements as $id => $element)
219 $template->setCurrentBlock(
"element");
220 $template->setVariable(
"ELEMENT_ID",
"e$id");
222 $template->parseCurrentBlock();
225 $solutionvalue = str_replace(
"{::}",
" ", $solutions[0][
"value1"]);
229 $elements = $this->
object->getOrderingElements();
230 foreach ($elements as $id => $element)
232 $template->setCurrentBlock(
"element");
233 $template->setVariable(
"ELEMENT_ID",
"e$id");
235 $template->parseCurrentBlock();
237 $solutionvalue = join($this->object->getOrderingElements(),
" ");
240 if (($active_id > 0) && (!$show_correct_solution))
242 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
243 if ($graphicalOutput)
246 if ($reached_points == $this->object->getMaximumPoints())
248 $template->setCurrentBlock(
"icon_ok");
250 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
251 $template->parseCurrentBlock();
255 $template->setCurrentBlock(
"icon_ok");
256 if ($reached_points > 0)
259 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
264 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
266 $template->parseCurrentBlock();
272 $reached_points = $this->
object->getPoints();
277 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
278 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
280 if($show_question_text==
true)
282 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
285 if ($this->object->textsize >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
287 $questionoutput = $template->get();
288 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
289 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
290 $solutionoutput = $solutiontemplate->get();
291 if (!$show_question_only)
294 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
296 return $solutionoutput;
301 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
302 $elements = $this->
object->getRandomOrderingElements();
303 foreach ($elements as $id => $element)
305 $template->setCurrentBlock(
"element");
306 $template->setVariable(
"ELEMENT_ID",
"e$id");
308 $template->parseCurrentBlock();
310 if ($this->object->textsize >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
311 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
312 $questionoutput = $template->get();
313 if (!$show_question_only)
318 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
320 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
321 return $questionoutput;
324 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
327 $template =
new ilTemplate(
"tpl.il_as_qpl_orderinghorizontal_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
328 $elements = $this->
object->getRandomOrderingElements();
333 include_once
"./Modules/Test/classes/class.ilObjTest.php";
338 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
339 if (count($solutions) == 1)
341 $elements = split(
"{::}", $solutions[0][
"value1"]);
346 $this->
object->moveRight(
$_SESSION[
'qst_selection'], $active_id,
$pass);
348 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
349 if (count($solutions) == 1)
351 $elements = split(
"{::}", $solutions[0][
"value1"]);
354 if (count($solutions) == 0)
356 $_SESSION[
'qst_ordering_horizontal_elements'] = $elements;
360 unset(
$_SESSION[
'qst_ordering_horizontal_elements']);
363 foreach ($elements as $id => $element)
365 $template->setCurrentBlock(
"element");
366 $template->setVariable(
"ELEMENT_ID",
"e_" . $this->object->getId() .
"_$id");
368 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'qst_selection', $idx);
370 $url = $this->ctrl->getLinkTargetByClass(
'iltestoutputgui',
'gotoQuestion');
371 $template->setVariable(
"MOVE_RIGHT", $url);
372 $template->setVariable(
"TEXT_MOVE_RIGHT", $this->lng->txt(
'move_right'));
374 $template->parseCurrentBlock();
376 if ($this->object->textsize >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->textsize .
"%;\"");
377 $template->setVariable(
"VALUE_ORDERRESULT",
' value="' . join($elements,
'{::}') .
'"');
378 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
379 $questionoutput = $template->get();
380 if (!$show_question_only)
385 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
387 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
388 $questionoutput = $template->get();
389 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
400 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
402 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
403 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
404 $this->
object->cleanupMediaObjectUsage();
417 global $rbacsystem, $ilTabs;
419 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
420 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
421 $q_type = $this->
object->getQuestionType();
425 $classname = $q_type .
"GUI";
426 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
427 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
432 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
435 $ilTabs->addTarget(
"edit_page",
436 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
437 array(
"edit",
"insert",
"exec_pg"),
438 "",
"", $force_active);
442 $ilTabs->addTarget(
"preview",
443 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
445 "ilPageObjectGUI",
"", $force_active);
448 $force_active =
false;
449 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
452 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
453 $commands =
$_POST[
"cmd"];
454 if (is_array($commands))
456 foreach ($commands as $key => $value)
458 if (preg_match(
"/^suggestrange_.*/", $key, $matches))
460 $force_active =
true;
465 $ilTabs->addTarget(
"edit_question",
467 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
468 $classname,
"", $force_active);
473 $ilTabs->addTarget(
"feedback",
474 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
475 array(
"feedback",
"saveFeedback"),
484 $ilTabs->addTarget(
"solution_hint",
485 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
486 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
487 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
497 $ilTabs->addTarget(
"statistics",
498 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
503 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
508 global $___test_express_mode;
510 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
511 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
515 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
520 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
527 return $this->
object->prepareTextareaOutput($output, TRUE);