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.assErrorText.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);
81 $this->
object->setEstimatedWorkingTime(
86 $this->
object->setTextSize(
$_POST[
"textsize"]);
87 $this->
object->setErrorText(
$_POST[
"errortext"]);
88 $points_wrong = str_replace(
",",
".",
$_POST[
"points_wrong"]);
89 if (strlen($points_wrong) == 0) $points_wrong = -1.0;
90 $this->
object->setPointsWrong($points_wrong);
92 $this->
object->flushErrorData();
93 if (is_array(
$_POST[
'errordata'][
'key']))
95 foreach (
$_POST[
'errordata'][
'key'] as $idx => $val)
97 $this->
object->addErrorData($val,
$_POST[
'errordata'][
'value'][$idx],
$_POST[
'errordata'][
'points'][$idx]);
115 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
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(
"orderinghorizontal");
131 $errortext->setRequired(TRUE);
132 $errortext->setInfo($this->lng->txt(
"errortext_info"));
133 $errortext->setRows(10);
134 $errortext->setCols(80);
135 $form->addItem($errortext);
137 include_once(
"./Services/Form/classes/class.ilAdditionalCharactersGUI.php");
141 $textsize->
setValue(strlen($this->object->getTextSize()) ? $this->object->getTextSize() : 100.0);
142 $textsize->setInfo($this->lng->txt(
"textsize_errortext_info"));
143 $textsize->setSize(6);
144 $textsize->setSuffix(
"%");
145 $textsize->setMinValue(10);
146 $textsize->setRequired(
true);
147 $form->addItem($textsize);
149 if (count($this->object->getErrorData()) || $checkonly)
152 $header->setTitle($this->lng->txt(
"errors_section"));
153 $form->addItem($header);
155 include_once
"./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
158 $errordata->setKeyName($this->lng->txt(
'text_wrong'));
159 $errordata->setValueName($this->lng->txt(
'text_correct'));
160 $errordata->setValues($this->object->getErrorData());
161 $form->addItem($errordata);
164 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong"),
"points_wrong");
165 $points_wrong->
setValue($this->object->getPointsWrong());
166 $points_wrong->setInfo($this->lng->txt(
"points_wrong_info"));
167 $points_wrong->setSize(6);
168 $points_wrong->setRequired(
true);
169 $form->addItem($points_wrong);
172 $form->addCommandButton(
"analyze", $this->lng->txt(
'analyze_errortext'));
179 $form->setValuesByPost();
180 $errors = !$form->checkInput();
181 $form->setValuesByPost();
182 if (
$errors) $checkonly =
false;
185 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
195 $this->
object->setErrorData($this->object->getErrorsFromText(
$_POST[
'errortext']));
199 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
201 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
202 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
203 $this->tpl->setVariable(
"FORMACTION", $formaction);
222 $graphicalOutput = FALSE,
223 $result_output = FALSE,
224 $show_question_only = TRUE,
225 $show_feedback = FALSE,
226 $show_correct_solution = FALSE,
227 $show_manual_scoring = FALSE
231 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
233 $selections = array();
234 if (($active_id > 0) && (!$show_correct_solution))
236 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
237 if (is_array($solutions))
239 foreach ($solutions as $solution)
241 array_push($selections, $solution[
'value1']);
243 $errortext_value = join(
",", $selections);
248 $selections = $this->
object->getBestSelection();
251 if (($active_id > 0) && (!$show_correct_solution))
253 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
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 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
266 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
267 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution);
268 $errortext = preg_replace(
"/#HREF\d+/is",
"javascript:void(0);", $errortext);
269 $template->setVariable(
"ERRORTEXT", $errortext);
270 $questionoutput = $template->get();
272 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
273 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
274 $solutionoutput = $solutiontemplate->get();
275 if (!$show_question_only)
280 return $solutionoutput;
285 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
286 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
287 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
288 $errortext = $this->
object->createErrorTextOutput($selections);
289 $errortext = preg_replace(
"/#HREF\d+/is",
"javascript:void(0);", $errortext);
290 $template->setVariable(
"ERRORTEXT", $errortext);
291 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
292 $questionoutput = $template->get();
293 if (!$show_question_only)
298 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
300 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
301 return $questionoutput;
304 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
307 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
311 include_once
"./Modules/Test/classes/class.ilObjTest.php";
316 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
318 $errortext_value =
"";
321 $this->
object->toggleSelection(
$_SESSION[
'qst_selection'], $active_id,
$pass);
323 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
325 $selections = array();
326 if (is_array($solutions))
328 foreach ($solutions as $solution)
330 array_push($selections, $solution[
'value1']);
332 $errortext_value = join(
",", $selections);
334 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
335 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
336 $errortext = $this->
object->createErrorTextOutput($selections);
337 $errortext = preg_replace_callback(
"/#HREF(\d+)/is", array(&$this,
'exchangeURL'), $errortext);
338 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'errorvalue',
'');
339 $template->setVariable(
"ERRORTEXT", $errortext);
340 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
341 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
342 $questionoutput = $template->get();
343 if (!$show_question_only)
348 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
350 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
351 $questionoutput = $template->get();
352 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
358 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'qst_selection', $matches[1]);
359 return $this->ctrl->getLinkTargetByClass(
'iltestoutputgui',
'gotoQuestion');
369 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
371 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
372 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
373 $this->
object->cleanupMediaObjectUsage();
384 global $rbacsystem, $ilTabs;
386 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
387 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
388 $q_type = $this->
object->getQuestionType();
392 $classname = $q_type .
"GUI";
393 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
394 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
399 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
402 $ilTabs->addTarget(
"edit_content",
403 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
404 array(
"edit",
"insert",
"exec_pg"),
405 "",
"", $force_active);
409 $ilTabs->addTarget(
"preview",
410 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
412 "ilPageObjectGUI",
"", $force_active);
415 $force_active =
false;
416 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
419 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
421 $ilTabs->addTarget(
"edit_properties",
423 array(
"editQuestion",
"save",
"saveEdit",
"analyze",
"originalSyncForm"),
424 $classname,
"", $force_active);
429 $ilTabs->addTarget(
"feedback",
430 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
431 array(
"feedback",
"saveFeedback"),
437 $ilTabs->addTarget(
"solution_hint",
438 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
439 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
440 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
450 $ilTabs->addTarget(
"statistics",
451 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
456 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
460 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
464 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));