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";
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());
162 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong"),
"points_wrong");
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);
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);
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);
208 $this->
object->setErrorData($this->object->getErrorsFromText(
$_POST[
'errortext']));
243 $graphicalOutput =
false,
244 $result_output =
false,
245 $show_question_only =
true,
246 $show_feedback =
false,
247 $show_correct_solution =
false,
248 $show_manual_scoring =
false,
249 $show_question_text =
true 252 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
254 $selections = array();
255 if (($active_id > 0) && (!$show_correct_solution)) {
258 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
260 if (is_array($solutions)) {
261 foreach ($solutions as $solution) {
262 array_push($selections, (
int) $solution[
'value1']);
264 $errortext_value = join(
",", $selections);
267 $selections = $this->
object->getBestSelection();
268 $reached_points = $this->
object->getPoints();
271 if ($result_output) {
272 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
273 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
276 if ($this->object->getTextSize() >= 10) {
277 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
280 if ($show_question_text ==
true) {
281 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
284 $errortext = $this->
object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution,
false);
286 $template->setVariable(
"ERRORTEXT", $errortext);
289 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
292 if ($show_feedback) {
295 $feedback .= strlen($fb) ? $fb :
'';
299 $feedback .= strlen($fb) ? $fb :
'';
301 if (strlen($feedback)) {
307 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
308 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
311 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
313 $solutionoutput = $solutiontemplate->get();
314 if (!$show_question_only) {
318 return $solutionoutput;
321 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
325 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",
true,
true,
"Modules/TestQuestionPool");
326 if ($this->object->getTextSize() >= 10) {
327 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
329 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
330 $errortext = $this->
object->createErrorTextOutput($selections);
331 $template->setVariable(
"ERRORTEXT", $errortext);
332 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
334 if (!$show_question_only) {
338 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
339 return $questionoutput;
347 $is_postponed =
false,
348 $use_post_solutions =
false,
349 $show_feedback =
false 352 $template =
new ilTemplate(
"tpl.il_as_qpl_errortext_output.html",
true,
true,
"Modules/TestQuestionPool");
356 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 357 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 359 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 361 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
364 $errortext_value =
"";
365 $selections = array();
366 if (is_array($solutions)) {
367 foreach ($solutions as $solution) {
368 array_push($selections, $solution[
'value1']);
370 $errortext_value = join(
",", $selections);
372 if ($this->object->getTextSize() >= 10) {
373 $template->setVariable(
"STYLE",
" style=\"font-size: " . $this->object->getTextSize() .
"%;\"");
375 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(),
true));
376 $errortext = $this->
object->createErrorTextOutput($selections);
378 $template->setVariable(
"ERRORTEXT", $errortext);
379 $template->setVariable(
"ERRORTEXT_ID",
"qst_" . $this->object->getId());
380 $template->setVariable(
"ERRORTEXT_VALUE", $errortext_value);
383 if (!$show_question_only) {
387 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/errortext.js");
389 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
403 $rbacsystem = $DIC[
'rbacsystem'];
404 $ilTabs = $DIC[
'ilTabs'];
406 $ilTabs->clearTargets();
408 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
409 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
410 $q_type = $this->
object->getQuestionType();
412 if (strlen($q_type)) {
413 $classname = $q_type .
"GUI";
414 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
415 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
419 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
423 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
424 array(
"edit",
"insert",
"exec_pg"),
434 $force_active =
false;
435 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
438 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
444 array(
"editQuestion",
"save",
"saveEdit",
"analyze",
"originalSyncForm"),
464 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
476 $selection = $this->
object->getBestSelection(
false);
478 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
482 $feedback =
'<table class="test_specific_feedback"><tbody>';
485 foreach (preg_split(
"/[\n\r]+/", $this->object->errortext) as $line) {
486 $elements = array_merge($elements, preg_split(
"/\s+/", $line));
489 $matchedIndexes = array();
492 foreach ($selection as
$index => $answer) {
494 foreach ($answer as $answerPartIndex) {
495 $element[] = $elements[$answerPartIndex];
498 $element = implode(
' ', $element);
499 $element = str_replace(array(
'((',
'))',
'#'), array(
'',
'',
''), $element);
505 $feedback .=
'<td class="text-nowrap">' . $ordinal .
'. ' . $element .
':</td>';
507 foreach ($this->object->getErrorData() as $idx => $ans) {
508 if (isset($matchedIndexes[$idx])) {
512 if (preg_match(
'/' . preg_quote($ans->text_wrong,
'/') .
'/', $element)) {
513 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
514 $this->object->getId(),
519 $feedback .=
'<td>' . $fb .
'</td>';
521 $matchedIndexes[$idx] = $idx;
527 $feedback .=
'</tr>';
530 $feedback .=
'</tbody></table>';
532 return $this->
object->prepareTextareaOutput($feedback,
true);
573 $errortext = $this->
object->getErrorText();
576 foreach ($relevant_answers as $answer_chosen) {
577 $passdata[$answer_chosen[
'active_fi'] .
'-' . $answer_chosen[
'pass']][$answer_chosen[
'value2']][] = $answer_chosen[
'value1'];
582 $passdata[
$key] = $this->
object->createErrorTextOutput(
$pass);
583 $html .= $passdata[
$key] .
'<hr /><br />';
591 $answersByActiveAndPass = array();
593 foreach ($relevantAnswers as
$row) {
594 $key = $row[
'active_fi'] .
':' . $row[
'pass'];
596 if (!isset($answersByActiveAndPass[
$key])) {
597 $answersByActiveAndPass[
$key] = array();
600 if (!isset($answersByActiveAndPass[$key][$row[
'value2']])) {
601 $answersByActiveAndPass[
$key][$row[
'value2']] = array();
604 $answersByActiveAndPass[
$key][$row[
'value2']][] = $row[
'value1'];
609 foreach ($answersByActiveAndPass as $ans) {
610 $errorText = $this->
object->createErrorTextOutput($ans);
611 $errorMd5 = md5($errorText);
613 if (!isset($answers[$errorMd5])) {
614 $answers[$errorMd5] = array(
615 'answer' => $errorText,
'frequency' => 0
619 $answers[$errorMd5][
'frequency']++;
622 return array_values($answers);
628 include_once
"./Modules/TestQuestionPool/classes/forms/class.ilAssErrorTextCorrectionsInputGUI.php";
630 $errordata->
setKeyName($this->lng->txt(
'text_wrong'));
631 $errordata->setValueName($this->lng->txt(
'text_correct'));
632 $errordata->setValues($this->object->getErrorData());
636 $points_wrong =
new ilNumberInputGUI($this->lng->txt(
"points_wrong"),
"points_wrong");
638 $points_wrong->setMaxValue(0);
639 $points_wrong->setMaxvalueShouldBeLess(
true);
640 $points_wrong->setValue($this->object->getPointsWrong());
641 $points_wrong->setInfo($this->lng->txt(
"points_wrong_info"));
642 $points_wrong->setSize(6);
643 $points_wrong->setRequired(
true);
654 $this->
object->flushErrorData();
655 foreach ($form->
getItemByPostVar(
'errordata')->getValues() as $idx => $errAnswer) {
656 $this->
object->addErrorData(
657 $errAnswer->text_wrong,
658 $errAnswer->text_correct,
663 $this->
object->setPointsWrong((
float) $form->
getInput(
'points_wrong'));
isTestPresentationContext()
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
getAnswersFrequency($relevantAnswers, $questionIndex)
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
if(!array_key_exists('StateId', $_REQUEST)) $id
setValue($a_value)
Set Value.
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
writePostData($always=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.
getSpecificFeedbackOutput($userSolution)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getTestOutput( $active_id, $pass, $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()
if(isset($_POST['submit'])) $form
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
Class for error text questions.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
getPreview($show_question_only=false, $showInlineFeedback=false)
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)
setQuestionTabs()
Sets the ILIAS tabs for this question type.
analyze()
Parse the error text.
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.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
saveTaxonomyAssignments()
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
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.
Interface ilGuiAnswerScoringAdjustable.
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.