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);
51 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
54 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
66 if (is_array(
$_POST[
'errordata'][
'key'] ))
68 $this->
object->flushErrorData();
69 foreach (
$_POST[
'errordata'][
'key'] as $idx => $val)
71 $this->
object->addErrorData( $val,
72 $_POST[
'errordata'][
'value'][$idx],
73 $_POST[
'errordata'][
'points'][$idx]
81 $questiontext =
$_POST[
"question"];
82 $this->
object->setQuestion( $questiontext );
83 $this->
object->setErrorText(
$_POST[
"errortext"] );
84 $points_wrong = str_replace(
",",
".",
$_POST[
"points_wrong"] );
85 if (strlen( $points_wrong ) == 0)
87 $this->
object->setPointsWrong( $points_wrong );
89 if (!$this->
object->getSelfAssessmentEditingMode())
91 $this->
object->setTextSize(
$_POST[
"textsize"] );
107 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
109 $this->editForm = $form;
111 $form->setFormAction($this->ctrl->getFormAction($this));
113 $form->setMultipart(FALSE);
114 $form->setTableWidth(
"100%");
115 $form->setId(
"orderinghorizontal");
121 if (count($this->
object->getErrorData()) || $checkonly)
128 $form->addCommandButton(
"analyze", $this->lng->txt(
'analyze_errortext'));
135 $form->setValuesByPost();
136 $errors = !$form->checkInput();
137 $form->setValuesByPost();
138 if (
$errors) $checkonly =
false;
141 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
152 $header->setTitle( $this->lng->txt(
"errors_section" ) );
155 include_once
"./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
157 $errordata->
setKeyName( $this->lng->txt(
'text_wrong' ) );
158 $errordata->setValueName( $this->lng->txt(
'text_correct' ) );
159 $errordata->setValues( $this->
object->getErrorData() );
163 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong" ),
"points_wrong");
165 $points_wrong->setMaxValue(0);
166 $points_wrong->setMaxvalueShouldBeLess(
true);
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 );
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']));
233 $active_id,
$pass = NULL,
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)) {
250 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
251 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
252 if (is_array($solutions)) {
253 foreach ($solutions as $solution) {
254 array_push($selections, (
int) $solution[
'value1']);
256 $errortext_value = join(
",", $selections);
260 $selections = $this->
object->getBestSelection();
261 $reached_points = $this->
object->getPoints();
264 if ($result_output) {
265 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
266 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
269 if ($this->
object->getTextSize() >= 10)
270 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
272 if ($show_question_text==
true)
273 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
275 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution,
false);
277 $template->setVariable(
"ERRORTEXT", $errortext);
278 $questionoutput = $template->get();
280 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
288 $feedback .= strlen($fb) ? $fb :
'';
292 $feedback .= strlen($fb) ? $fb :
'';
294 if (strlen($feedback))
300 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
301 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput( $feedback,
true ));
304 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
306 $solutionoutput = $solutiontemplate->get();
307 if (!$show_question_only)
312 return $solutionoutput;
315 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
319 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
320 if ($this->
object->getTextSize() >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
321 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
322 $errortext = $this->
object->createErrorTextOutput($selections);
323 $template->setVariable(
"ERRORTEXT", $errortext);
324 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->
object->getId());
325 $questionoutput = $template->get();
326 if (!$show_question_only)
331 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
332 return $questionoutput;
340 $is_postponed = FALSE,
341 $use_post_solutions = FALSE,
342 $show_feedback = FALSE
346 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
351 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 352 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 354 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 356 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
359 $errortext_value =
"";
360 $selections =
array();
361 if (is_array($solutions))
363 foreach ($solutions as $solution)
365 array_push($selections, $solution[
'value1']);
367 $errortext_value = join(
",", $selections);
369 if ($this->
object->getTextSize() >= 10) $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
370 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
371 $errortext = $this->
object->createErrorTextOutput($selections);
373 $template->setVariable(
"ERRORTEXT", $errortext);
374 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->
object->getId());
375 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
377 $questionoutput = $template->get();
378 if (!$show_question_only)
383 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
384 $questionoutput = $template->get();
385 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
398 global $rbacsystem, $ilTabs;
400 $ilTabs->clearTargets();
402 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
403 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
404 $q_type = $this->
object->getQuestionType();
408 $classname = $q_type .
"GUI";
409 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
410 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
415 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
418 $ilTabs->addTarget(
"edit_page",
419 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
420 array(
"edit",
"insert",
"exec_pg"),
421 "",
"", $force_active);
427 $force_active =
false;
428 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
431 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
433 $ilTabs->addTarget(
"edit_question",
435 array(
"editQuestion",
"save",
"saveEdit",
"analyze",
"originalSyncForm"),
436 $classname,
"", $force_active);
451 $ilTabs->addTarget(
"statistics",
452 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
462 $selection = $this->
object->getBestSelection(
false);
464 if( !$this->
object->feedbackOBJ->specificAnswerFeedbackExists(array_keys($selection)) )
469 $feedback =
'<table class="test_specific_feedback"><tbody>';
472 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)
483 foreach($answer as $answerPartIndex)
485 $element[] = $elements[$answerPartIndex];
488 $element = implode(
' ', $element);
489 $element = str_replace(
array(
'((',
'))',
'#'),
array(
'',
'',
''), $element);
491 $ordinal = $index + 1;
495 $feedback .=
'<td class="text-nowrap">' . $ordinal .
'. ' . $element .
':</td>';
497 foreach ($this->
object->getErrorData() as $idx => $ans)
499 if( isset($matchedIndexes[$idx]) )
504 if ( preg_match(
'/'.preg_quote($ans->text_wrong,
'/').
'/', $element) )
506 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
507 $this->
object->getId(), $idx
510 $feedback .=
'<td>'. $fb .
'</td>';
512 $matchedIndexes[$idx] = $idx;
518 $feedback .=
'</tr>';
521 $feedback .=
'</tbody></table>';
523 return $this->
object->prepareTextareaOutput($feedback, TRUE);
564 $errortext = $this->
object->getErrorText();
567 foreach($relevant_answers as $answer_chosen)
569 $passdata[$answer_chosen[
'active_fi'].
'-'. $answer_chosen[
'pass']][$answer_chosen[
'value2']][] = $answer_chosen[
'value1'];
573 foreach($passdata as $key =>
$pass)
575 $passdata[$key] = $this->
object->createErrorTextOutput(
$pass);
576 $html .= $passdata[$key] .
'<hr /><br />';
isTestPresentationContext()
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
setValue($a_value)
Set Value.
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
writePostData($always=false)
{}
getTestOutput( $active_id, $pass, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
__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.
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
const CSS_CLASS_FEEDBACK_WRONG
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)
Create styles array
The data for the language used.
setQuestionTabs()
Sets the ILIAS tabs for this question type.
analyze()
Parse the error text.
saveTaxonomyAssignments()
Create new PHPExcel object
obj_idprivate
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.