4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
8 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
36 parent::__construct();
37 include_once
"./Modules/TestQuestionPool/classes/class.assErrorText.php";
42 $this->
object->loadFromDb($id);
56 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
59 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
71 if (is_array(
$_POST[
'errordata'][
'key'] ))
73 $this->
object->flushErrorData();
74 foreach (
$_POST[
'errordata'][
'key'] as $idx => $val)
76 $this->
object->addErrorData( $val,
77 $_POST[
'errordata'][
'value'][$idx],
78 $_POST[
'errordata'][
'points'][$idx]
86 $questiontext =
$_POST[
"question"];
87 $this->
object->setQuestion( $questiontext );
88 $this->
object->setErrorText(
$_POST[
"errortext"] );
89 $points_wrong = str_replace(
",",
".",
$_POST[
"points_wrong"] );
90 if (strlen( $points_wrong ) == 0)
92 $this->
object->setPointsWrong( $points_wrong );
94 if (!$this->object->getSelfAssessmentEditingMode())
96 $this->
object->setTextSize(
$_POST[
"textsize"] );
112 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
114 $form->setFormAction($this->ctrl->getFormAction($this));
116 $form->setMultipart(FALSE);
117 $form->setTableWidth(
"100%");
118 $form->setId(
"orderinghorizontal");
124 if (count($this->object->getErrorData()) || $checkonly)
131 $form->addCommandButton(
"analyze", $this->lng->txt(
'analyze_errortext'));
138 $form->setValuesByPost();
139 $errors = !$form->checkInput();
140 $form->setValuesByPost();
141 if (
$errors) $checkonly =
false;
144 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
155 $header->setTitle( $this->lng->txt(
"errors_section" ) );
158 include_once
"./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
160 $errordata->
setKeyName( $this->lng->txt(
'text_wrong' ) );
161 $errordata->setValueName( $this->lng->txt(
'text_correct' ) );
162 $errordata->setValues( $this->object->getErrorData() );
166 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong" ),
"points_wrong");
168 $points_wrong->setValue( $this->object->getPointsWrong() );
169 $points_wrong->setInfo( $this->lng->txt(
"points_wrong_info" ) );
170 $points_wrong->setSize( 6 );
171 $points_wrong->setRequired(
true );
172 $form->
addItem( $points_wrong );
184 $errortext->
setValue( $this->object->getErrorText() );
185 $errortext->setRequired( TRUE );
186 $errortext->setInfo( $this->lng->txt(
"errortext_info" ) );
187 $errortext->setRows( 10 );
188 $errortext->setCols( 80 );
191 if (!$this->object->getSelfAssessmentEditingMode())
194 $textsize =
new ilNumberInputGUI($this->lng->txt(
"textsize" ),
"textsize");
195 $textsize->
setValue( strlen( $this->object->getTextSize() ) ? $this->object->getTextSize() : 100.0 );
196 $textsize->setInfo( $this->lng->txt(
"textsize_errortext_info" ) );
197 $textsize->setSize( 6 );
198 $textsize->setSuffix(
"%" );
199 $textsize->setMinValue( 10 );
200 $textsize->setRequired(
true );
211 $this->
object->setErrorData($this->object->getErrorsFromText(
$_POST[
'errortext']));
234 $active_id,
$pass = NULL,
235 $graphicalOutput = FALSE,
236 $result_output = FALSE,
237 $show_question_only = TRUE,
238 $show_feedback = FALSE,
239 $show_correct_solution = FALSE,
240 $show_manual_scoring = FALSE,
241 $show_question_text = TRUE
245 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
247 $selections = array();
248 if (($active_id > 0) && (!$show_correct_solution)) {
251 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
252 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
253 if (is_array($solutions)) {
254 foreach ($solutions as $solution) {
255 array_push($selections, (
int) $solution[
'value1']);
257 $errortext_value = join(
",", $selections);
261 $selections = $this->
object->getBestSelection();
262 $reached_points = $this->
object->getPoints();
265 if ($result_output) {
266 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
267 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
270 if ($this->object->getTextSize() >= 10)
271 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
273 if ($show_question_text==
true)
274 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
276 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution);
278 $template->setVariable(
"ERRORTEXT", $errortext);
279 $questionoutput = $template->get();
281 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
287 $feedback .= strlen($fb) ? $fb :
'';
290 $feedback .= strlen($fb) ? $fb :
'';
292 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
294 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
296 $solutionoutput = $solutiontemplate->get();
297 if (!$show_question_only)
302 return $solutionoutput;
305 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
309 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
310 if ($this->object->getTextSize() >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
311 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
312 $errortext = $this->
object->createErrorTextOutput($selections);
313 $template->setVariable(
"ERRORTEXT", $errortext);
314 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
315 $questionoutput = $template->get();
316 if (!$show_question_only)
321 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
322 return $questionoutput;
328 $is_postponed = FALSE,
329 $use_post_solutions = FALSE,
330 $show_feedback = FALSE
334 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
338 include_once
"./Modules/Test/classes/class.ilObjTest.php";
343 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
345 $errortext_value =
"";
346 $selections = array();
347 if (is_array($solutions))
349 foreach ($solutions as $solution)
351 array_push($selections, $solution[
'value1']);
353 $errortext_value = join(
",", $selections);
355 if ($this->object->getTextSize() >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
356 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
357 $errortext = $this->
object->createErrorTextOutput($selections);
359 $template->setVariable(
"ERRORTEXT", $errortext);
360 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
361 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
363 $questionoutput = $template->get();
364 if (!$show_question_only)
369 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
370 $questionoutput = $template->get();
371 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
384 global $rbacsystem, $ilTabs;
386 $ilTabs->clearTargets();
388 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
389 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
390 $q_type = $this->
object->getQuestionType();
394 $classname = $q_type .
"GUI";
395 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
396 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
401 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
404 $ilTabs->addTarget(
"edit_page",
405 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
406 array(
"edit",
"insert",
"exec_pg"),
407 "",
"", $force_active);
413 $force_active =
false;
414 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
417 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
419 $ilTabs->addTarget(
"edit_question",
421 array(
"editQuestion",
"save",
"saveEdit",
"analyze",
"originalSyncForm"),
422 $classname,
"", $force_active);
437 $ilTabs->addTarget(
"statistics",
438 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
448 $selection = $this->
object->getBestSelection(
false);
450 if( !$this->object->feedbackOBJ->specificAnswerFeedbackExists(array_keys($selection)) )
455 $feedback =
'<table class="test_specific_feedback"><tbody>';
458 foreach(preg_split(
"/[\n\r]+/", $this->object->errortext) as $line)
460 $elements = array_merge( $elements, preg_split(
"/\s+/", $line));
463 $matchedIndexes = array();
466 foreach ($selection as $index => $answer)
469 foreach($answer as $answerPartIndex)
471 $element[] = $elements[$answerPartIndex];
474 $element = implode(
' ', $element);
475 $element = str_replace(array(
'((',
'))',
'#'), array(
'',
'',
''), $element);
477 $ordinal = $index + 1;
481 $feedback .=
'<td class="text-nowrap">' . $ordinal .
'. ' . $element .
':</td>';
483 foreach ($this->object->getErrorData() as $idx => $ans)
485 if( isset($matchedIndexes[$idx]) )
490 if ( preg_match(
'/'.preg_quote($ans->text_wrong,
'/').
'/', $element) )
492 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
493 $this->object->getId(), $idx
496 $feedback .=
'<td>'. $fb .
'</td>';
498 $matchedIndexes[$idx] = $idx;
504 $feedback .=
'</tr>';
507 $feedback .=
'</tbody></table>';
509 return $this->
object->prepareTextareaOutput($feedback, TRUE);
550 $errortext = $this->
object->getErrorText();
553 foreach($relevant_answers as $answer_chosen)
555 $passdata[$answer_chosen[
'active_fi'].
'-'. $answer_chosen[
'pass']][$answer_chosen[
'value2']][] = $answer_chosen[
'value1'];
559 foreach($passdata as $key =>
$pass)
561 $passdata[$key] = $this->
object->createErrorTextOutput(
$pass);
562 $html .= $passdata[$key] .
'<hr /><br />';
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
setValue($a_value)
Set Value.
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
writePostData($always=false)
Evaluates a posted edit form and writes the form data in the question object.
getQuestionTemplate()
get question template
__construct($id=-1)
assErrorTextGUI constructor
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
populateTaxonomyFormSection(ilPropertyFormGUI $form)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
getTestOutput( $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
setKeyName($a_name)
Set key name.
writeQuestionGenericPostData()
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
Class for error text questions.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
The assErrorTextGUI class encapsulates the GUI representation for error text questions.
Basic GUI class for assessment questions.
setErrorMessage($errormessage)
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
analyze()
Parse the error text.
saveTaxonomyAssignments()
This class represents a text area property in a property form.
addBackTab(ilTabsGUI $ilTabs)
This class represents a key value pair wizard property in a property form.
getSpecificFeedbackOutput($active_id, $pass)
Interface ilGuiAnswerScoringAdjustable.
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.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.