4require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
8require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
36 parent::__construct();
37 include_once
"./Modules/TestQuestionPool/classes/class.assErrorText.php";
41 $this->
object->loadFromDb(
$id);
50 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
52 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
64 if (is_array(
$_POST[
'errordata'][
'key'])) {
65 $this->
object->flushErrorData();
66 foreach (
$_POST[
'errordata'][
'key'] as $idx => $val) {
67 $this->
object->addErrorData(
69 $_POST[
'errordata'][
'value'][$idx],
70 $_POST[
'errordata'][
'points'][$idx]
78 $questiontext =
$_POST[
"question"];
79 $this->
object->setQuestion($questiontext);
80 $this->
object->setErrorText(
$_POST[
"errortext"]);
81 $points_wrong = str_replace(
",",
".",
$_POST[
"points_wrong"]);
82 if (strlen($points_wrong) == 0) {
85 $this->
object->setPointsWrong($points_wrong);
87 if (!$this->object->getSelfAssessmentEditingMode()) {
88 $this->
object->setTextSize(
$_POST[
"textsize"]);
104 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
106 $this->editForm =
$form;
108 $form->setFormAction($this->ctrl->getFormAction($this));
110 $form->setMultipart(
false);
111 $form->setTableWidth(
"100%");
112 $form->setId(
"orderinghorizontal");
118 if (count($this->object->getErrorData()) || $checkonly) {
124 $form->addCommandButton(
"analyze", $this->lng->txt(
'analyze_errortext'));
130 $form->setValuesByPost();
132 $form->setValuesByPost();
139 $this->tpl->setVariable(
"QUESTION_DATA",
$form->getHTML());
151 $header->setTitle($this->lng->txt(
"errors_section"));
154 include_once
"./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
156 $errordata->setKeyName($this->lng->txt(
'text_wrong'));
157 $errordata->setValueName($this->lng->txt(
'text_correct'));
158 $errordata->setValues($this->object->getErrorData());
159 $form->addItem($errordata);
162 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong"),
"points_wrong");
163 $points_wrong->allowDecimals(
true);
164 $points_wrong->setMaxValue(0);
165 $points_wrong->setMaxvalueShouldBeLess(
true);
166 $points_wrong->setValue($this->object->getPointsWrong());
167 $points_wrong->setInfo($this->lng->txt(
"points_wrong_info"));
168 $points_wrong->setSize(6);
169 $points_wrong->setRequired(
true);
170 $form->addItem($points_wrong);
182 $errortext->setValue($this->object->getErrorText());
183 $errortext->setRequired(
true);
184 $errortext->setInfo($this->lng->txt(
"errortext_info"));
185 $errortext->setRows(10);
186 $errortext->setCols(80);
187 $form->addItem($errortext);
189 if (!$this->object->getSelfAssessmentEditingMode()) {
192 $textsize->setValue(strlen($this->object->getTextSize()) ? $this->object->getTextSize() : 100.0);
193 $textsize->setInfo($this->lng->txt(
"textsize_errortext_info"));
194 $textsize->setSize(6);
195 $textsize->setSuffix(
"%");
196 $textsize->setMinValue(10);
197 $textsize->setRequired(
true);
198 $form->addItem($textsize);
208 $this->
object->setErrorData($this->object->getErrorsFromText(
$_POST[
'errortext']));
233 $graphicalOutput =
false,
234 $result_output =
false,
235 $show_question_only =
true,
236 $show_feedback =
false,
237 $show_correct_solution =
false,
238 $show_manual_scoring =
false,
239 $show_question_text =
true
242 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
244 $selections = array();
245 if (($active_id > 0) && (!$show_correct_solution)) {
248 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
249 $solutions =&$this->
object->getSolutionValues($active_id,
$pass);
250 if (is_array($solutions)) {
251 foreach ($solutions as $solution) {
252 array_push($selections, (
int) $solution[
'value1']);
254 $errortext_value = join(
",", $selections);
257 $selections = $this->
object->getBestSelection();
258 $reached_points = $this->
object->getPoints();
261 if ($result_output) {
262 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
263 $template->setVariable(
"RESULT_OUTPUT",
sprintf($resulttext, $reached_points));
266 if ($this->object->getTextSize() >= 10) {
267 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
270 if ($show_question_text==
true) {
271 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
274 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution,
false);
276 $template->setVariable(
"ERRORTEXT", $errortext);
279 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
282 if ($show_feedback) {
285 $feedback .= strlen($fb) ? $fb :
'';
289 $feedback .= strlen($fb) ? $fb :
'';
291 if (strlen($feedback)) {
297 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
298 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
301 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
303 $solutionoutput = $solutiontemplate->get();
304 if (!$show_question_only) {
308 return $solutionoutput;
311 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
315 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",
true,
true,
"Modules/TestQuestionPool");
316 if ($this->object->getTextSize() >= 10) {
317 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
319 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
320 $errortext = $this->
object->createErrorTextOutput($selections);
321 $template->setVariable(
"ERRORTEXT", $errortext);
322 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
324 if (!$show_question_only) {
328 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
329 return $questionoutput;
337 $is_postponed =
false,
338 $use_post_solutions =
false,
339 $show_feedback =
false
342 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",
true,
true,
"Modules/TestQuestionPool");
346 #include_once "./Modules/Test/classes/class.ilObjTest.php";
347 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
349 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
351 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
354 $errortext_value =
"";
355 $selections = array();
356 if (is_array($solutions)) {
357 foreach ($solutions as $solution) {
358 array_push($selections, $solution[
'value1']);
360 $errortext_value = join(
",", $selections);
362 if ($this->object->getTextSize() >= 10) {
363 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
365 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
366 $errortext = $this->
object->createErrorTextOutput($selections);
368 $template->setVariable(
"ERRORTEXT", $errortext);
369 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
370 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
373 if (!$show_question_only) {
377 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
379 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
392 global $rbacsystem, $ilTabs;
394 $ilTabs->clearTargets();
396 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
397 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
398 $q_type = $this->
object->getQuestionType();
400 if (strlen($q_type)) {
401 $classname = $q_type .
"GUI";
402 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
403 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
407 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
411 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
412 array(
"edit",
"insert",
"exec_pg"),
422 $force_active =
false;
423 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
426 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
432 array(
"editQuestion",
"save",
"saveEdit",
"analyze",
"originalSyncForm"),
452 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
464 $selection = $this->
object->getBestSelection(
false);
466 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists(array_keys($selection))) {
470 $feedback =
'<table class="test_specific_feedback"><tbody>';
473 foreach (preg_split(
"/[\n\r]+/", $this->object->errortext) as $line) {
474 $elements = array_merge($elements, preg_split(
"/\s+/", $line));
477 $matchedIndexes = array();
480 foreach ($selection as
$index => $answer) {
482 foreach ($answer as $answerPartIndex) {
483 $element[] = $elements[$answerPartIndex];
486 $element = implode(
' ', $element);
487 $element = str_replace(array(
'((',
'))',
'#'), array(
'',
'',
''), $element);
493 $feedback .=
'<td class="text-nowrap">' . $ordinal .
'. ' . $element .
':</td>';
495 foreach ($this->object->getErrorData() as $idx => $ans) {
496 if (isset($matchedIndexes[$idx])) {
500 if (preg_match(
'/' . preg_quote($ans->text_wrong,
'/') .
'/', $element)) {
501 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
502 $this->object->getId(),
506 $feedback .=
'<td>' . $fb .
'</td>';
508 $matchedIndexes[$idx] = $idx;
514 $feedback .=
'</tr>';
517 $feedback .=
'</tbody></table>';
519 return $this->
object->prepareTextareaOutput($feedback,
true);
560 $errortext = $this->
object->getErrorText();
563 foreach ($relevant_answers as $answer_chosen) {
564 $passdata[$answer_chosen[
'active_fi'] .
'-' . $answer_chosen[
'pass']][$answer_chosen[
'value2']][] = $answer_chosen[
'value1'];
569 $passdata[
$key] = $this->
object->createErrorTextOutput(
$pass);
570 $html .= $passdata[
$key] .
'<hr /><br />';
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
The assErrorTextGUI class encapsulates the GUI representation for error text questions.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
getPreview($show_question_only=false, $showInlineFeedback=false)
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
Get the question solution output.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
writePostData($always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
__construct($id=-1)
assErrorTextGUI constructor
getTestOutput( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
getSpecificFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
analyze()
Parse the error text.
Class for error text questions.
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
setErrorMessage($errormessage)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
writeQuestionGenericPostData()
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
saveTaxonomyAssignments()
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
addBackTab(ilTabsGUI $ilTabs)
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
const CSS_CLASS_FEEDBACK_WRONG
const CSS_CLASS_FEEDBACK_CORRECT
This class represents a key value pair wizard property in a property form.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
if(!array_key_exists('StateId', $_REQUEST)) $id
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.
if(isset($_POST['submit'])) $form