ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
assErrorTextGUI Class Reference

The assErrorTextGUI class encapsulates the GUI representation for error text questions. More...

+ Inheritance diagram for assErrorTextGUI:
+ Collaboration diagram for assErrorTextGUI:

Public Member Functions

 __construct ($id=-1)
 assErrorTextGUI constructor More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 
 analyze ()
 Parse the error text. More...
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 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. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type. More...
 
 getSpecificFeedbackOutput ($userSolution)
 Returns the answer specific feedback for the question. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 hasInlineFeedback ()
 this method can be overwritten per question type More...
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput ($userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $classname)
 
 getEditQuestionTabCommands ()
 
 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)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 hasIntermediateSolution ($activeId, $passIndex)
 Check if the question has an intermediate solution. More...
 
 setUseIntermediateSolution ($use)
 
 getUseIntermediateSolution ()
 Get if intermediate solution should be used for solution output. More...
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=false, $user_post_solutions=false, $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFreuqencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView ($relevant_answers)
 Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface. More...
 
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 

Protected Member Functions

 writePostData ($always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} More...
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 buildEditForm ()
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
- Protected Attributes inherited from assQuestionGUI
 $editForm
 
 $use_intermediate_solution = false
 

Detailed Description

The assErrorTextGUI class encapsulates the GUI representation for error text questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

@ilctrl_iscalledby assErrorTextGUI: ilObjQuestionPoolGUI @ilCtrl_Calls assErrorTextGUI: ilFormPropertyDispatchGUI

Definition at line 24 of file class.assErrorTextGUI.php.

Constructor & Destructor Documentation

◆ __construct()

assErrorTextGUI::__construct (   $id = -1)

assErrorTextGUI constructor

The constructor takes possible arguments an creates an instance of the assOrderingHorizontalGUI object.

Parameters
integer$idThe database id of a single choice question object @access public

Definition at line 34 of file class.assErrorTextGUI.php.

35 {
37 include_once "./Modules/TestQuestionPool/classes/class.assErrorText.php";
38 $this->object = new assErrorText();
39 $this->setErrorMessage($this->lng->txt("msg_form_save_error"));
40 if ($id >= 0) {
41 $this->object->loadFromDb($id);
42 }
43 }
Class for error text questions.
setErrorMessage($errormessage)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and assQuestionGUI\setErrorMessage().

+ Here is the call graph for this function:

Member Function Documentation

◆ analyze()

assErrorTextGUI::analyze ( )

Parse the error text.

Definition at line 205 of file class.assErrorTextGUI.php.

206 {
207 $this->writePostData(true);
208 $this->object->setErrorData($this->object->getErrorsFromText($_POST['errortext']));
209 $this->editQuestion();
210 }
$_POST["username"]
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData($always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...

References $_POST, editQuestion(), and writePostData().

+ Here is the call graph for this function:

◆ editQuestion()

assErrorTextGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

Parameters
bool$checkonly
Returns
bool

Definition at line 99 of file class.assErrorTextGUI.php.

100 {
101 $save = $this->isSaveCommand();
102 $this->getQuestionTemplate();
103
104 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
105 $form = new ilPropertyFormGUI();
106 $this->editForm = $form;
107
108 $form->setFormAction($this->ctrl->getFormAction($this));
109 $form->setTitle($this->outQuestionType());
110 $form->setMultipart(false);
111 $form->setTableWidth("100%");
112 $form->setId("orderinghorizontal");
113
114 $this->addBasicQuestionFormProperties($form);
115
117
118 if (count($this->object->getErrorData()) || $checkonly) {
119 $this->populateAnswerSpecificFormPart($form);
120 }
121
122 $this->populateTaxonomyFormSection($form);
123
124 $form->addCommandButton("analyze", $this->lng->txt('analyze_errortext'));
125 $this->addQuestionFormCommandButtons($form);
126
127 $errors = false;
128
129 if ($save) {
130 $form->setValuesByPost();
131 $errors = !$form->checkInput();
132 $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
133 if ($errors) {
134 $checkonly = false;
135 }
136 }
137
138 if (!$checkonly) {
139 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
140 }
141 return $errors;
142 }
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getQuestionTemplate()
get question template
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
This class represents a property form user interface.
$errors

References $errors, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\isSaveCommand(), assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), and assQuestionGUI\populateTaxonomyFormSection().

Referenced by analyze(), and writePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assErrorTextGUI::getAfterParticipationSuppressionAnswerPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiAnswerScoringAdjustable.

Definition at line 544 of file class.assErrorTextGUI.php.

545 {
546 return array();
547 }

◆ getAfterParticipationSuppressionQuestionPostVars()

assErrorTextGUI::getAfterParticipationSuppressionQuestionPostVars ( )

Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment.

The form elements will be shown disabled, so the users see the usual form but can only edit the settings, which make sense in the given context.

E.g. array('cloze_type', 'image_filename')

Returns
string[]

Implements ilGuiQuestionScoringAdjustable.

Definition at line 558 of file class.assErrorTextGUI.php.

559 {
560 return array();
561 }

◆ getAggregatedAnswersView()

assErrorTextGUI::getAggregatedAnswersView (   $relevant_answers)

Returns an html string containing a question specific representation of the answers so far given in the test for use in the right column in the scoring adjustment user interface.

Parameters
array$relevant_answers
Returns
string

Implements ilGuiQuestionScoringAdjustable.

Definition at line 571 of file class.assErrorTextGUI.php.

572 {
573 $errortext = $this->object->getErrorText();
574
575 $passdata = array(); // Regroup answers into units of passes.
576 foreach ($relevant_answers as $answer_chosen) {
577 $passdata[$answer_chosen['active_fi'] . '-' . $answer_chosen['pass']][$answer_chosen['value2']][] = $answer_chosen['value1'];
578 }
579
580 $html = '';
581 foreach ($passdata as $key => $pass) {
582 $passdata[$key] = $this->object->createErrorTextOutput($pass);
583 $html .= $passdata[$key] . '<hr /><br />';
584 }
585
586 return $html;
587 }

References $pass.

◆ getAnswersFrequency()

assErrorTextGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

Definition at line 589 of file class.assErrorTextGUI.php.

590 {
591 $answersByActiveAndPass = array();
592
593 foreach ($relevantAnswers as $row) {
594 $key = $row['active_fi'] . ':' . $row['pass'];
595
596 if (!isset($answersByActiveAndPass[$key])) {
597 $answersByActiveAndPass[$key] = array();
598 }
599
600 if (!isset($answersByActiveAndPass[$key][$row['value2']])) {
601 $answersByActiveAndPass[$key][$row['value2']] = array();
602 }
603
604 $answersByActiveAndPass[$key][$row['value2']][] = $row['value1'];
605 }
606
607 $answers = array();
608
609 foreach ($answersByActiveAndPass as $ans) {
610 $errorText = $this->object->createErrorTextOutput($ans);
611 $errorMd5 = md5($errorText);
612
613 if (!isset($answers[$errorMd5])) {
614 $answers[$errorMd5] = array(
615 'answer' => $errorText, 'frequency' => 0
616 );
617 }
618
619 $answers[$errorMd5]['frequency']++;
620 }
621
622 return array_values($answers);
623 }

◆ getPreview()

assErrorTextGUI::getPreview (   $show_question_only = false,
  $showInlineFeedback = false 
)

Reimplemented from assQuestionGUI.

Definition at line 321 of file class.assErrorTextGUI.php.

322 {
323 $selections = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
324
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() . "%;\"");
328 }
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());
333 $questionoutput = $template->get();
334 if (!$show_question_only) {
335 // get page object output
336 $questionoutput = $this->getILIASPage($questionoutput);
337 }
338 $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/errortext.js");
339 return $questionoutput;
340 }
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR

References assQuestionGUI\getILIASPage(), and assQuestionGUI\getPreviewSession().

+ Here is the call graph for this function:

◆ getSolutionOutput()

assErrorTextGUI::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.

The getSolutionOutput() method is used to print either the user's pass' solution or the best possible solution for the current errorText question object.

Parameters
integer$active_idThe active test id
integer$passThe test pass counter
boolean$graphicalOutputShow visual feedback for right/wrong answers
boolean$result_outputShow the reached points for parts of the question
boolean$show_question_onlyShow the question without the ILIAS content around
boolean$show_feedbackShow the question feedback
boolean$show_correct_solutionShow the correct solution instead of the user solution
boolean$show_manual_scoringShow specific information for the manual scoring output
Returns
string HTML solution output

Reimplemented from assQuestionGUI.

Definition at line 240 of file class.assErrorTextGUI.php.

250 {
251 // get the solution of the user for the active pass or from the last pass if allowed
252 $template = new ilTemplate("tpl.il_as_qpl_errortext_output_solution.html", true, true, "Modules/TestQuestionPool");
253
254 $selections = array();
255 if (($active_id > 0) && (!$show_correct_solution)) {
256
257 /* Retrieve tst_solutions entries. */
258 $reached_points = $this->object->getReachedPoints($active_id, $pass);
259 $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
260 if (is_array($solutions)) {
261 foreach ($solutions as $solution) {
262 array_push($selections, (int) $solution['value1']);
263 }
264 $errortext_value = join(",", $selections);
265 }
266 } else {
267 $selections = $this->object->getBestSelection();
268 $reached_points = $this->object->getPoints();
269 }
270
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));
274 }
275
276 if ($this->object->getTextSize() >= 10) {
277 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
278 }
279
280 if ($show_question_text == true) {
281 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), true));
282 }
283
284 $errortext = $this->object->createErrorTextOutput($selections, $graphicalOutput, $show_correct_solution, false);
285
286 $template->setVariable("ERRORTEXT", $errortext);
287 $questionoutput = $template->get();
288
289 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
290
291 $feedback = '';
292 if ($show_feedback) {
293 if (!$this->isTestPresentationContext()) {
294 $fb = $this->getGenericFeedbackOutput($active_id, $pass);
295 $feedback .= strlen($fb) ? $fb : '';
296 }
297
298 $fb = $this->getSpecificFeedbackOutput(array());
299 $feedback .= strlen($fb) ? $fb : '';
300 }
301 if (strlen($feedback)) {
302 $cssClass = (
303 $this->hasCorrectSolution($active_id, $pass) ?
305 );
306
307 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
308 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
309 }
310
311 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
312
313 $solutionoutput = $solutiontemplate->get();
314 if (!$show_question_only) {
315 // get page object output
316 $solutionoutput = $this->getILIASPage($solutionoutput);
317 }
318 return $solutionoutput;
319 }
getSpecificFeedbackOutput($userSolution)
Returns the answer specific feedback for the question.
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
hasCorrectSolution($activeId, $passIndex)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.

References $pass, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), getSpecificFeedbackOutput(), assQuestionGUI\getUseIntermediateSolution(), assQuestionGUI\hasCorrectSolution(), and assQuestionGUI\isTestPresentationContext().

+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assErrorTextGUI::getSpecificFeedbackOutput (   $userSolution)

Returns the answer specific feedback for the question.

This method should be overwritten by the actual question.

Todo:
Mark this method abstract!
Parameters
array$userSolution($userSolution[<value1>] = <value2>)
Returns
string HTML Code with the answer specific feedback @access public

Reimplemented from assQuestionGUI.

Definition at line 474 of file class.assErrorTextGUI.php.

475 {
476 $selection = $this->object->getBestSelection(false);
477
478 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
479 return '';
480 }
481
482 $feedback = '<table class="test_specific_feedback"><tbody>';
483
484 $elements = array();
485 foreach (preg_split("/[\n\r]+/", $this->object->errortext) as $line) {
486 $elements = array_merge($elements, preg_split("/\s+/", $line));
487 }
488
489 $matchedIndexes = array();
490
491 $i = 0;
492 foreach ($selection as $index => $answer) {
493 $element = array();
494 foreach ($answer as $answerPartIndex) {
495 $element[] = $elements[$answerPartIndex];
496 }
497
498 $element = implode(' ', $element);
499 $element = str_replace(array('((', '))', '#'), array('', '', ''), $element);
500
501 $ordinal = $index + 1;
502
503 $feedback .= '<tr>';
504
505 $feedback .= '<td class="text-nowrap">' . $ordinal . '. ' . $element . ':</td>';
506
507 foreach ($this->object->getErrorData() as $idx => $ans) {
508 if (isset($matchedIndexes[$idx])) {
509 continue;
510 }
511
512 if (preg_match('/' . preg_quote($ans->text_wrong, '/') . '/', $element)) {
513 $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
514 $this->object->getId(),
515 0,
516 $idx
517 );
518
519 $feedback .= '<td>' . $fb . '</td>';
520
521 $matchedIndexes[$idx] = $idx;
522
523 break;
524 }
525 }
526
527 $feedback .= '</tr>';
528 }
529
530 $feedback .= '</tbody></table>';
531
532 return $this->object->prepareTextareaOutput($feedback, true);
533 }
$index
Definition: metadata.php:128
$i
Definition: metadata.php:24

References $i, and $index.

Referenced by getSolutionOutput().

+ Here is the caller graph for this function:

◆ getTestOutput()

assErrorTextGUI::getTestOutput (   $active_id,
  $pass,
  $is_postponed = false,
  $use_post_solutions = false,
  $show_feedback = false 
)

Reimplemented from assQuestionGUI.

Definition at line 342 of file class.assErrorTextGUI.php.

350 {
351 // generate the question output
352 $template = new ilTemplate("tpl.il_as_qpl_errortext_output.html", true, true, "Modules/TestQuestionPool");
353 if ($active_id) {
354 // hey: prevPassSolutions - obsolete due to central check
355 #$solutions = NULL;
356 #include_once "./Modules/Test/classes/class.ilObjTest.php";
357 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
358 #{
359 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
360 #}
361 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
362 // hey.
363 }
364 $errortext_value = "";
365 $selections = array();
366 if (is_array($solutions)) {
367 foreach ($solutions as $solution) {
368 array_push($selections, $solution['value1']);
369 }
370 $errortext_value = join(",", $selections);
371 }
372 if ($this->object->getTextSize() >= 10) {
373 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
374 }
375 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), true));
376 $errortext = $this->object->createErrorTextOutput($selections);
377 $this->ctrl->setParameterByClass($this->getTargetGuiClass(), 'errorvalue', '');
378 $template->setVariable("ERRORTEXT", $errortext);
379 $template->setVariable("ERRORTEXT_ID", "qst_" . $this->object->getId());
380 $template->setVariable("ERRORTEXT_VALUE", $errortext_value);
381
382 $questionoutput = $template->get();
383 if (!$show_question_only) {
384 // get page object output
385 $questionoutput = $this->getILIASPage($questionoutput);
386 }
387 $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/errortext.js");
388 $questionoutput = $template->get();
389 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
390 return $pageoutput;
391 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page

References $pass, assQuestionGUI\getILIASPage(), assQuestionGUI\getTargetGuiClass(), and assQuestionGUI\outQuestionPage().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assErrorTextGUI::populateAnswerSpecificFormPart ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form
Returns
\ilPropertyFormGUI|void

Implements ilGuiAnswerScoringAdjustable.

Definition at line 148 of file class.assErrorTextGUI.php.

149 {
150 $header = new ilFormSectionHeaderGUI();
151 $header->setTitle($this->lng->txt("errors_section"));
152 $form->addItem($header);
153
154 include_once "./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
155 $errordata = new ilErrorTextWizardInputGUI($this->lng->txt("errors"), "errordata");
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);
160
161 // points for wrong selection
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);
171 return $form;
172 }
This class represents a key value pair wizard property in a property form.
This class represents a section header in a property form.
This class represents a number property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).

References ilPropertyFormGUI\addItem().

Referenced by editQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assErrorTextGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Reimplemented from assQuestionGUI.

Definition at line 625 of file class.assErrorTextGUI.php.

626 {
627 // error terms
628 include_once "./Modules/TestQuestionPool/classes/forms/class.ilAssErrorTextCorrectionsInputGUI.php";
629 $errordata = new ilAssErrorTextCorrectionsInputGUI($this->lng->txt("errors"), "errordata");
630 $errordata->setKeyName($this->lng->txt('text_wrong'));
631 $errordata->setValueName($this->lng->txt('text_correct'));
632 $errordata->setValues($this->object->getErrorData());
633 $form->addItem($errordata);
634
635 // points for wrong selection
636 $points_wrong = new ilNumberInputGUI($this->lng->txt("points_wrong"), "points_wrong");
637 $points_wrong->allowDecimals(true);
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);
644 $form->addItem($points_wrong);
645
646 return $form;
647 }

References ilPropertyFormGUI\addItem().

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assErrorTextGUI::populateQuestionSpecificFormPart ( ilPropertyFormGUI  $form)
Parameters
$formilPropertyFormGUI
Returns
\ilPropertyFormGUI|void

Implements ilGuiQuestionScoringAdjustable.

Definition at line 178 of file class.assErrorTextGUI.php.

179 {
180 // errortext
181 $errortext = new ilTextAreaInputGUI($this->lng->txt("errortext"), "errortext");
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);
188
189 if (!$this->object->getSelfAssessmentEditingMode()) {
190 // textsize
191 $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
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);
199 }
200 }
This class represents a text area property in a property form.

References ilPropertyFormGUI\addItem().

Referenced by editQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

assErrorTextGUI::saveCorrectionsFormProperties ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Reimplemented from assQuestionGUI.

Definition at line 652 of file class.assErrorTextGUI.php.

653 {
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,
659 $errAnswer->points
660 );
661 }
662
663 $this->object->setPointsWrong((float) $form->getInput('points_wrong'));
664 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
getItemByPostVar($a_post_var)
Get Item by POST variable.

References ilPropertyFormGUI\getInput(), and ilPropertyFormGUI\getItemByPostVar().

+ Here is the call graph for this function:

◆ setQuestionTabs()

assErrorTextGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type.

@access public

Todo:
: MOVE THIS STEPS TO COMMON QUESTION CLASS assQuestionGUI

Reimplemented from assQuestionGUI.

Definition at line 400 of file class.assErrorTextGUI.php.

401 {
402 global $DIC;
403 $rbacsystem = $DIC['rbacsystem'];
404 $ilTabs = $DIC['ilTabs'];
405
406 $ilTabs->clearTargets();
407
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();
411
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"]);
416 }
417
418 if ($_GET["q_id"]) {
419 if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
420 // edit page
421 $ilTabs->addTarget(
422 "edit_page",
423 $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
424 array("edit", "insert", "exec_pg"),
425 "",
426 "",
427 $force_active
428 );
429 }
430
431 $this->addTab_QuestionPreview($ilTabs);
432 }
433
434 $force_active = false;
435 if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
436 $url = "";
437 if ($classname) {
438 $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
439 }
440 // edit question properties
441 $ilTabs->addTarget(
442 "edit_question",
443 $url,
444 array("editQuestion", "save", "saveEdit", "analyze", "originalSyncForm"),
445 $classname,
446 "",
447 $force_active
448 );
449 }
450
451 // add tab for question feedback within common class assQuestionGUI
452 $this->addTab_QuestionFeedback($ilTabs);
453
454 // add tab for question hint within common class assQuestionGUI
455 $this->addTab_QuestionHints($ilTabs);
456
457 // add tab for question's suggested solution within common class assQuestionGUI
458 $this->addTab_SuggestedSolution($ilTabs, $classname);
459
460 // Assessment of questions sub menu entry
461 if ($_GET["q_id"]) {
462 $ilTabs->addTarget(
463 "statistics",
464 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
465 array("assessment"),
466 $classname,
467 ""
468 );
469 }
470
471 $this->addBackTab($ilTabs);
472 }
$_GET["client_id"]
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addBackTab(ilTabsGUI $ilTabs)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
$url
$DIC
Definition: xapitoken.php:46

References $_GET, $DIC, $url, assQuestionGUI\addBackTab(), assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), assQuestionGUI\addTab_QuestionPreview(), and assQuestionGUI\addTab_SuggestedSolution().

+ Here is the call graph for this function:

◆ supportsIntermediateSolutionOutput()

assErrorTextGUI::supportsIntermediateSolutionOutput ( )

Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution()

Returns
bool

Reimplemented from assQuestionGUI.

Definition at line 217 of file class.assErrorTextGUI.php.

218 {
219 return true;
220 }

◆ writeAnswerSpecificPostData()

assErrorTextGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

Extracts the answer specific values from $_POST and applies them to the data object.

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiAnswerScoringAdjustable.

Definition at line 62 of file class.assErrorTextGUI.php.

63 {
64 if (is_array($_POST['errordata']['key'])) {
65 $this->object->flushErrorData();
66 foreach ($_POST['errordata']['key'] as $idx => $val) {
67 $this->object->addErrorData(
68 $val,
69 $_POST['errordata']['value'][$idx],
70 $_POST['errordata']['points'][$idx]
71 );
72 }
73 }
74 }

References $_POST.

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ writePostData()

assErrorTextGUI::writePostData (   $always = false)
protected

{Evaluates a posted edit form and writes the form data in the question object.

Returns
integer A positive value, if one of the required fields wasn't set, else 0
}

Reimplemented from assQuestionGUI.

Definition at line 48 of file class.assErrorTextGUI.php.

49 {
50 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
51 if (!$hasErrors) {
52 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
57 return 0;
58 }
59 return 1;
60 }
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.

References editQuestion(), assQuestionGUI\saveTaxonomyAssignments(), writeAnswerSpecificPostData(), assQuestionGUI\writeQuestionGenericPostData(), and writeQuestionSpecificPostData().

Referenced by analyze().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeQuestionSpecificPostData()

assErrorTextGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

Extracts the question specific values from $_POST and applies them to the data object.

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiQuestionScoringAdjustable.

Definition at line 76 of file class.assErrorTextGUI.php.

77 {
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) {
83 $points_wrong = -1.0;
84 }
85 $this->object->setPointsWrong($points_wrong);
86
87 if (!$this->object->getSelfAssessmentEditingMode()) {
88 $this->object->setTextSize($_POST["textsize"]);
89 }
90 }

References $_POST.

Referenced by writePostData().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: