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;
70 if (is_array(
$_POST[
'errordata'][
'key'] ))
72 $this->
object->flushErrorData();
73 foreach (
$_POST[
'errordata'][
'key'] as $idx => $val)
75 $this->
object->addErrorData( $val,
76 $_POST[
'errordata'][
'value'][$idx],
77 $_POST[
'errordata'][
'points'][$idx]
85 $questiontext =
$_POST[
"question"];
86 $this->
object->setQuestion( $questiontext );
87 $this->
object->setErrorText(
$_POST[
"errortext"] );
88 $points_wrong = str_replace(
",",
".",
$_POST[
"points_wrong"] );
89 if (strlen( $points_wrong ) == 0)
91 $this->
object->setPointsWrong( $points_wrong );
93 if (!$this->object->getSelfAssessmentEditingMode())
95 $this->
object->setTextSize(
$_POST[
"textsize"] );
111 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
113 $form->setFormAction($this->ctrl->getFormAction($this));
115 $form->setMultipart(FALSE);
116 $form->setTableWidth(
"100%");
117 $form->setId(
"orderinghorizontal");
123 if (count($this->object->getErrorData()) || $checkonly)
130 $form->addCommandButton(
"analyze", $this->lng->txt(
'analyze_errortext'));
137 $form->setValuesByPost();
138 $errors = !$form->checkInput();
139 $form->setValuesByPost();
140 if (
$errors) $checkonly =
false;
143 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
154 $header->setTitle( $this->lng->txt(
"errors_section" ) );
157 include_once
"./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
159 $errordata->
setKeyName( $this->lng->txt(
'text_wrong' ) );
160 $errordata->setValueName( $this->lng->txt(
'text_correct' ) );
161 $errordata->setValues( $this->object->getErrorData() );
165 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong" ),
"points_wrong");
167 $points_wrong->setValue( $this->object->getPointsWrong() );
168 $points_wrong->setInfo( $this->lng->txt(
"points_wrong_info" ) );
169 $points_wrong->setSize( 6 );
170 $points_wrong->setRequired(
true );
171 $form->
addItem( $points_wrong );
183 $errortext->
setValue( $this->object->getErrorText() );
184 $errortext->setRequired( TRUE );
185 $errortext->setInfo( $this->lng->txt(
"errortext_info" ) );
186 $errortext->setRows( 10 );
187 $errortext->setCols( 80 );
190 if (!$this->object->getSelfAssessmentEditingMode())
193 $textsize =
new ilNumberInputGUI($this->lng->txt(
"textsize" ),
"textsize");
194 $textsize->
setValue( strlen( $this->object->getTextSize() ) ? $this->object->getTextSize() : 100.0 );
195 $textsize->setInfo( $this->lng->txt(
"textsize_errortext_info" ) );
196 $textsize->setSize( 6 );
197 $textsize->setSuffix(
"%" );
198 $textsize->setMinValue( 10 );
199 $textsize->setRequired(
true );
210 $this->
object->setErrorData($this->object->getErrorsFromText(
$_POST[
'errortext']));
218 $is_postponed = FALSE,
219 $use_post_solutions = FALSE,
220 $show_feedback = FALSE
223 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
224 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
225 $this->tpl->setVariable(
"FORMACTION", $formaction);
247 $active_id,
$pass = NULL,
248 $graphicalOutput = FALSE,
249 $result_output = FALSE,
250 $show_question_only = TRUE,
251 $show_feedback = FALSE,
252 $show_correct_solution = FALSE,
253 $show_manual_scoring = FALSE,
254 $show_question_text = TRUE
258 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
260 $selections = array();
261 if (($active_id > 0) && (!$show_correct_solution)) {
264 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
265 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
266 if (is_array($solutions)) {
267 foreach ($solutions as $solution) {
268 array_push($selections, (
int) $solution[
'value1']);
270 $errortext_value = join(
",", $selections);
274 $selections = $this->
object->getBestSelection();
275 $reached_points = $this->
object->getPoints();
278 if ($result_output) {
279 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
280 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
283 if ($this->object->getTextSize() >= 10)
284 echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
286 if ($show_question_text==
true)
287 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
289 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution);
290 $errortext = preg_replace(
"/#HREF\d+/is",
"javascript:void(0);", $errortext);
292 $template->setVariable(
"ERRORTEXT", $errortext);
293 $questionoutput = $template->get();
295 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
301 $feedback .= strlen($fb) ? $fb :
'';
304 $feedback .= strlen($fb) ? $fb :
'';
306 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
308 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
310 $solutionoutput = $solutiontemplate->get();
311 if (!$show_question_only)
313 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
315 return $solutionoutput;
320 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
321 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
322 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
323 $errortext = $this->
object->createErrorTextOutput($selections);
324 $errortext = preg_replace(
"/#HREF\d+/is",
"javascript:void(0);", $errortext);
325 $template->setVariable(
"ERRORTEXT", $errortext);
326 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
327 $questionoutput = $template->get();
328 if (!$show_question_only)
333 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
335 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
336 return $questionoutput;
342 $is_postponed = FALSE,
343 $use_post_solutions = FALSE,
344 $show_feedback = FALSE
348 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
352 include_once
"./Modules/Test/classes/class.ilObjTest.php";
357 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
359 $errortext_value =
"";
362 $this->
object->toggleSelection(
$_SESSION[
'qst_selection'], $active_id,
$pass);
364 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
366 $selections = array();
367 if (is_array($solutions))
369 foreach ($solutions as $solution)
371 array_push($selections, $solution[
'value1']);
373 $errortext_value = join(
",", $selections);
375 if ($this->object->getTextSize() >= 10) echo $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
376 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
377 $errortext = $this->
object->createErrorTextOutput($selections);
378 $errortext = preg_replace_callback(
"/#HREF(\d+)/is", array(&$this,
'exchangeURL'), $errortext);
379 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'errorvalue',
'');
380 $template->setVariable(
"ERRORTEXT", $errortext);
381 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
382 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
384 $questionoutput = $template->get();
385 if (!$show_question_only)
390 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
392 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
393 $questionoutput = $template->get();
394 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
400 $this->ctrl->setParameterByClass(
'iltestoutputgui',
'qst_selection', $matches[1]);
401 return $this->ctrl->getLinkTargetByClass(
'iltestoutputgui',
'gotoQuestion');
413 global $rbacsystem, $ilTabs;
415 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
416 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
417 $q_type = $this->
object->getQuestionType();
421 $classname = $q_type .
"GUI";
422 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
423 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
428 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
431 $ilTabs->addTarget(
"edit_page",
432 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
433 array(
"edit",
"insert",
"exec_pg"),
434 "",
"", $force_active);
438 $ilTabs->addTarget(
"preview",
439 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
441 "ilAssQuestionPageGUI",
"", $force_active);
444 $force_active =
false;
445 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
448 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
450 $ilTabs->addTarget(
"edit_question",
452 array(
"editQuestion",
"save",
"saveEdit",
"analyze",
"originalSyncForm"),
453 $classname,
"", $force_active);
464 $ilTabs->addTarget(
"solution_hint",
465 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
466 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
467 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution" 477 $ilTabs->addTarget(
"statistics",
478 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
483 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
488 global $___test_express_mode;
490 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
491 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
495 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
500 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
506 $feedback =
'<table><tbody>';
508 $selection = $this->
object->getBestSelection(
false);
510 foreach(preg_split(
"/[\n\r]+/", $this->object->errortext) as $line)
512 $elements = array_merge( $elements, preg_split(
"/\s+/", $line));
515 $matchedIndexes = array();
518 foreach ($selection as $index => $answer)
521 foreach($answer as $answerPartIndex)
523 $element[] = $elements[$answerPartIndex];
526 $element = implode(
' ', $element);
527 $element = str_replace(array(
'((',
'))',
'#'), array(
'',
'',
''), $element);
529 $ordinal = $index + 1;
533 $feedback .=
'<td>' . $ordinal .
'. <i>' . $element .
'</i>:</td>';
535 foreach ($this->object->getErrorData() as $idx => $ans)
537 if( isset($matchedIndexes[$idx]) )
542 if ( preg_match(
'/'.preg_quote($ans->text_wrong,
'/').
'/', $element) )
544 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
545 $this->object->getId(), $idx
548 $feedback .=
'<td>'. $fb .
'</td>';
550 $matchedIndexes[$idx] = $idx;
556 $feedback .=
'</tr>';
559 $feedback .=
'</tbody></table>';
561 return $this->
object->prepareTextareaOutput($feedback, TRUE);
602 $errortext = $this->
object->getErrorText();
605 foreach($relevant_answers as $answer_chosen)
607 $passdata[$answer_chosen[
'active_fi'].
'-'. $answer_chosen[
'pass']][$answer_chosen[
'value2']][] = $answer_chosen[
'value1'];
611 foreach($passdata as $key =>
$pass)
613 $passdata[$key] = $this->
object->createErrorTextOutput(
$pass);
614 $html .= $passdata[$key] .
'<hr /><br />';
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
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
static initElementSelection()
init element selection
_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)
writeQuestionSpecificPostData($always=false)
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)
writeAnswerSpecificPostData($always=false)
outQuestionForTest( $formaction, $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
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...
setKeyName($a_name)
Set key name.
writeQuestionGenericPostData()
static getReturnToPageLink($q_id=null)
getILIASPage($html="")
Returns the ILIAS Page around a question.
getPreview($show_question_only=FALSE)
special template class to simplify handling of ITX/PEAR
Class for error text questions.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
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.
This class represents a key value pair wizard property in a property form.
getSpecificFeedbackOutput($active_id, $pass)
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.
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.