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.assErrorText.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);
87 $this->
object->setEstimatedWorkingTime(
92 $this->
object->setErrorText(
$_POST[
"errortext"]);
93 $points_wrong = str_replace(
",",
".",
$_POST[
"points_wrong"]);
94 if (strlen($points_wrong) == 0) $points_wrong = -1.0;
95 $this->
object->setPointsWrong($points_wrong);
99 $this->
object->setTextSize(
$_POST[
"textsize"]);
102 $this->
object->flushErrorData();
103 if (is_array(
$_POST[
'errordata'][
'key']))
105 foreach (
$_POST[
'errordata'][
'key'] as $idx => $val)
107 $this->
object->addErrorData($val,
$_POST[
'errordata'][
'value'][$idx],
$_POST[
'errordata'][
'points'][$idx]);
128 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
130 $form->setFormAction($this->ctrl->getFormAction($this));
132 $form->setMultipart(FALSE);
133 $form->setTableWidth(
"100%");
134 $form->setId(
"orderinghorizontal");
141 $errortext->setRequired(TRUE);
142 $errortext->setInfo($this->lng->txt(
"errortext_info"));
143 $errortext->setRows(10);
144 $errortext->setCols(80);
145 $form->addItem($errortext);
151 $textsize->
setValue(strlen($this->object->getTextSize()) ? $this->object->getTextSize() : 100.0);
152 $textsize->setInfo($this->lng->txt(
"textsize_errortext_info"));
153 $textsize->setSize(6);
154 $textsize->setSuffix(
"%");
155 $textsize->setMinValue(10);
156 $textsize->setRequired(
true);
157 $form->addItem($textsize);
160 if (count($this->object->getErrorData()) || $checkonly)
163 $header->setTitle($this->lng->txt(
"errors_section"));
164 $form->addItem($header);
166 include_once
"./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
169 $errordata->setKeyName($this->lng->txt(
'text_wrong'));
170 $errordata->setValueName($this->lng->txt(
'text_correct'));
171 $errordata->setValues($this->object->getErrorData());
172 $form->addItem($errordata);
175 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong"),
"points_wrong");
177 $points_wrong->setValue($this->object->getPointsWrong());
178 $points_wrong->setInfo($this->lng->txt(
"points_wrong_info"));
179 $points_wrong->setSize(6);
180 $points_wrong->setRequired(
true);
181 $form->addItem($points_wrong);
184 $form->addCommandButton(
"analyze", $this->lng->txt(
'analyze_errortext'));
191 $form->setValuesByPost();
192 $errors = !$form->checkInput();
193 $form->setValuesByPost();
194 if (
$errors) $checkonly =
false;
197 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
207 $this->
object->setErrorData($this->object->getErrorsFromText(
$_POST[
'errortext']));
211 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
213 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
214 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
215 $this->tpl->setVariable(
"FORMACTION", $formaction);
234 $graphicalOutput = FALSE,
235 $result_output = FALSE,
236 $show_question_only = TRUE,
237 $show_feedback = FALSE,
238 $show_correct_solution = FALSE,
239 $show_manual_scoring = FALSE,
240 $show_question_text = TRUE
244 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
246 $selections = array();
247 if (($active_id > 0) && (!$show_correct_solution))
249 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
250 if (is_array($solutions))
252 foreach ($solutions as $solution)
254 array_push($selections, $solution[
'value1']);
256 $errortext_value = join(
",", $selections);
261 $selections = $this->
object->getBestSelection();
264 if (($active_id > 0) && (!$show_correct_solution))
266 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
270 $reached_points = $this->
object->getPoints();
275 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
276 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
278 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
279 if ($show_question_text==
true)
281 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
283 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution);
284 $errortext = preg_replace(
"/#HREF\d+/is",
"javascript:void(0);", $errortext);
285 $template->setVariable(
"ERRORTEXT", $errortext);
286 $questionoutput = $template->get();
288 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
294 $feedback .= strlen($fb) ? $fb :
'';
297 $feedback .= strlen($fb) ? $fb :
'';
299 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
301 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
303 $solutionoutput = $solutiontemplate->get();
304 if (!$show_question_only)
307 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
309 return $solutionoutput;
314 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
315 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
316 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
317 $errortext = $this->
object->createErrorTextOutput($selections);
318 $errortext = preg_replace(
"/#HREF\d+/is",
"javascript:void(0);", $errortext);
319 $template->setVariable(
"ERRORTEXT", $errortext);
320 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
321 $questionoutput = $template->get();
322 if (!$show_question_only)
327 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
329 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
330 return $questionoutput;
333 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
336 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
340 include_once
"./Modules/Test/classes/class.ilObjTest.php";
345 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
347 $errortext_value =
"";
350 $this->
object->toggleSelection(
$_SESSION[
'qst_selection'], $active_id,
$pass);
352 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
354 $selections = array();
355 if (is_array($solutions))
357 foreach ($solutions as $solution)
359 array_push($selections, $solution[
'value1']);
361 $errortext_value = join(
",", $selections);
363 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
364 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
365 $errortext = $this->
object->createErrorTextOutput($selections);
366 $errortext = preg_replace_callback(
"/#HREF(\d+)/is", array(&$this,
'exchangeURL'), $errortext);
367 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'errorvalue',
'');
368 $template->setVariable(
"ERRORTEXT", $errortext);
369 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
370 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
372 $questionoutput = $template->get();
373 if (!$show_question_only)
378 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
380 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
381 $questionoutput = $template->get();
382 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
388 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'qst_selection', $matches[1]);
389 return $this->ctrl->getLinkTargetByClass(
'iltestoutputgui',
'gotoQuestion');
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 foreach ($this->object->getErrorData() as $index => $answer)
405 $this->
object->saveFeedbackSingleAnswer($index,
$_POST[
"feedback_answer_$index"]);
408 $this->
object->cleanupMediaObjectUsage();
421 global $rbacsystem, $ilTabs;
423 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
424 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
425 $q_type = $this->
object->getQuestionType();
429 $classname = $q_type .
"GUI";
430 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
431 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
436 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
439 $ilTabs->addTarget(
"edit_page",
440 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
441 array(
"edit",
"insert",
"exec_pg"),
442 "",
"", $force_active);
446 $ilTabs->addTarget(
"preview",
447 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
449 "ilPageObjectGUI",
"", $force_active);
452 $force_active =
false;
453 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
456 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
458 $ilTabs->addTarget(
"edit_question",
460 array(
"editQuestion",
"save",
"saveEdit",
"analyze",
"originalSyncForm"),
461 $classname,
"", $force_active);
466 $ilTabs->addTarget(
"feedback",
467 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
468 array(
"feedback",
"saveFeedback"),
477 $ilTabs->addTarget(
"solution_hint",
478 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
479 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
480 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
490 $ilTabs->addTarget(
"statistics",
491 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
496 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
501 global $___test_express_mode;
503 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
504 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
508 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
513 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
524 $save = (strcmp($this->ctrl->getCmd(),
"saveFeedback") == 0) ? TRUE : FALSE;
525 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
527 $form->setFormAction($this->ctrl->getFormAction($this));
528 $form->setTitle($this->lng->txt(
'feedback_answers'));
529 $form->setTableWidth(
"98%");
530 $form->setId(
"feedback");
532 $complete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_complete_solution"),
"feedback_complete");
533 $complete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
534 $complete->setRequired(
false);
535 $complete->setRows(10);
536 $complete->setCols(80);
539 $complete->setUseRte(
true);
541 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
543 $complete->addPlugin(
"latex");
544 $complete->addButton(
"latex");
545 $complete->addButton(
"pastelatex");
546 $complete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
547 $form->addItem($complete);
549 $incomplete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_incomplete_solution"),
"feedback_incomplete");
550 $incomplete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
551 $incomplete->setRequired(
false);
552 $incomplete->setRows(10);
553 $incomplete->setCols(80);
556 $incomplete->setUseRte(
true);
558 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
560 $incomplete->addPlugin(
"latex");
561 $incomplete->addButton(
"latex");
562 $incomplete->addButton(
"pastelatex");
563 $incomplete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
564 $form->addItem($incomplete);
568 foreach ($this->object->getErrorData() as $index => $answer)
570 $caption = $ordinal = $index+1;
571 $caption .=
'. <br />"' . $answer->text_wrong .
'" => ';
572 $caption .=
'"' . $answer->text_correct .
'"';
575 $answerobj =
new ilTextAreaInputGUI($this->object->prepareTextareaOutput($caption,
true),
"feedback_answer_$index");
576 $answerobj->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)));
577 $answerobj->setRequired(
false);
578 $answerobj->setRows(10);
579 $answerobj->setCols(80);
580 $answerobj->setUseRte(
true);
581 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
583 $answerobj->addPlugin(
"latex");
584 $answerobj->addButton(
"latex");
585 $answerobj->addButton(
"pastelatex");
586 $answerobj->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
587 $form->addItem($answerobj);
594 $form->addCommandButton(
"saveFeedback", $this->lng->txt(
"save"));
598 $form->setValuesByPost();
599 $errors = !$form->checkInput();
600 $form->setValuesByPost();
602 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
608 $feedback =
'<table><tbody>';
609 $selection = $this->
object->getBestSelection(
false);
611 foreach(preg_split(
"/[\n\r]+/", $this->object->errortext) as $line)
613 $elements = array_merge( $elements, preg_split(
"/\s+/", $line));
616 $matchedIndexes = array();
619 foreach ($selection as $index => $answer)
621 $caption = $ordinal = $index+1 .
'.<i> ';
622 $caption .= $elements[$answer];
623 $caption = str_replace(
'#',
'', $caption);
626 $feedback .=
'<tr><td>';
628 $feedback .= $caption .
'</td><td>';
629 foreach ($this->object->getErrorData() as $idx => $ans)
631 if( isset($matchedIndexes[$idx]) )
636 $cand =
'#'.$ans->text_wrong;
637 if ($elements[$answer] == $cand)
639 $feedback .= $this->
object->getFeedbackSingleAnswer($idx) .
'</td> </tr>';
641 $matchedIndexes[$idx] = $idx;
646 #$feedback .= $this->object->getFeedbackSingleAnswer($answer) . '</td> </tr>';
648 $feedback .=
'</tbody></table>';
649 return $this->
object->prepareTextareaOutput($feedback, TRUE);