ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 getSpecificFeedbackOutput ($userSolution)
 
 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...
 
 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)
 

Protected Member Functions

 writePostData ($always=false)
 {} More...
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 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)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 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_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 addSaveOnEnterOnLoadCode ()
 

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
 
 $request
 
 $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
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
 $ctrl
 
 $editForm
 
 $use_intermediate_solution = false
 

Detailed Description

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 public

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

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

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)
+ Here is the call graph for this function:

Member Function Documentation

◆ analyze()

assErrorTextGUI::analyze ( )

Parse the error text.

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

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

209  {
210  $this->writePostData(true);
211  $this->object->setErrorData($this->object->getErrorsFromText($_POST['errortext']));
212  $this->editQuestion();
213  }
writePostData($always=false)
{}
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
$_POST["username"]
+ 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.

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

Referenced by analyze(), and writePostData().

100  {
101  global $DIC;
102  $tabs = $DIC['ilTabs'];
103  $tabs->setTabActive('edit_question');
104  $save = $this->isSaveCommand();
105  $this->getQuestionTemplate();
106 
107  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
108  $form = new ilPropertyFormGUI();
109  $this->editForm = $form;
110 
111  $form->setFormAction($this->ctrl->getFormAction($this));
112  $form->setTitle($this->outQuestionType());
113  $form->setMultipart(false);
114  $form->setTableWidth("100%");
115  $form->setId("orderinghorizontal");
116 
117  $this->addBasicQuestionFormProperties($form);
118 
119  $this->populateQuestionSpecificFormPart($form);
120 
121  if (count($this->object->getErrorData()) || $checkonly) {
122  $this->populateAnswerSpecificFormPart($form);
123  }
124 
125  $this->populateTaxonomyFormSection($form);
126 
127  $form->addCommandButton("analyze", $this->lng->txt('analyze_errortext'));
128  $this->addQuestionFormCommandButtons($form);
129 
130  $errors = false;
131 
132  if ($save) {
133  $form->setValuesByPost();
134  $errors = !$form->checkInput();
135  $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
136  if ($errors) {
137  $checkonly = false;
138  }
139  }
140 
141  if (!$checkonly) {
142  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
143  }
144  return $errors;
145  }
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
$errors
Definition: imgupload.php:49
This class represents a property form user interface.
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
getQuestionTemplate()
get question template
populateTaxonomyFormSection(ilPropertyFormGUI $form)
global $DIC
Definition: goto.php:24
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
+ 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 466 of file class.assErrorTextGUI.php.

467  {
468  return array();
469  }

◆ 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 480 of file class.assErrorTextGUI.php.

481  {
482  return array();
483  }

◆ 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 493 of file class.assErrorTextGUI.php.

References $pass.

494  {
495  $errortext = $this->object->getErrorText();
496 
497  $passdata = array(); // Regroup answers into units of passes.
498  foreach ($relevant_answers as $answer_chosen) {
499  $passdata[$answer_chosen['active_fi'] . '-' . $answer_chosen['pass']][$answer_chosen['value2']][] = $answer_chosen['value1'];
500  }
501 
502  $html = '';
503  foreach ($passdata as $key => $pass) {
504  $passdata[$key] = $this->object->createErrorTextOutput($pass);
505  $html .= $passdata[$key] . '<hr /><br />';
506  }
507 
508  return $html;
509  }

◆ getAnswersFrequency()

assErrorTextGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

512  {
513  $answersByActiveAndPass = array();
514 
515  foreach ($relevantAnswers as $row) {
516  $key = $row['active_fi'] . ':' . $row['pass'];
517 
518  if (!isset($answersByActiveAndPass[$key])) {
519  $answersByActiveAndPass[$key] = array();
520  }
521 
522  if (!isset($answersByActiveAndPass[$key][$row['value2']])) {
523  $answersByActiveAndPass[$key][$row['value2']] = array();
524  }
525 
526  $answersByActiveAndPass[$key][$row['value2']][] = $row['value1'];
527  }
528 
529  $answers = array();
530 
531  foreach ($answersByActiveAndPass as $ans) {
532  $errorText = $this->object->createErrorTextOutput($ans);
533  $errorMd5 = md5($errorText);
534 
535  if (!isset($answers[$errorMd5])) {
536  $answers[$errorMd5] = array(
537  'answer' => $errorText, 'frequency' => 0
538  );
539  }
540 
541  $answers[$errorMd5]['frequency']++;
542  }
543 
544  return array_values($answers);
545  }

◆ getPreview()

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

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

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

325  {
326  $selections = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
327 
328  $template = new ilTemplate("tpl.il_as_qpl_errortext_output.html", true, true, "Modules/TestQuestionPool");
329  if ($this->object->getTextSize() >= 10) {
330  $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
331  }
332  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
333  $errortext = $this->object->createErrorTextOutput($selections);
334  $template->setVariable("ERRORTEXT", $errortext);
335  $template->setVariable("ERRORTEXT_ID", "qst_" . $this->object->getId());
336  $questionoutput = $template->get();
337  if (!$show_question_only) {
338  // get page object output
339  $questionoutput = $this->getILIASPage($questionoutput);
340  }
341  $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/errortext.js");
342  return $questionoutput;
343  }
getILIASPage($html="")
Returns the ILIAS Page around a question.
+ 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

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

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

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

◆ getSpecificFeedbackOutput()

assErrorTextGUI::getSpecificFeedbackOutput (   $userSolution)

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

References $i, and $index.

Referenced by getSolutionOutput().

397  {
398  $selection = $this->object->getBestSelection(false);
399 
400  if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
401  return '';
402  }
403 
404  $feedback = '<table class="test_specific_feedback"><tbody>';
405 
406  $elements = array();
407  foreach (preg_split("/[\n\r]+/", $this->object->errortext) as $line) {
408  $elements = array_merge($elements, preg_split("/\s+/", $line));
409  }
410 
411  $matchedIndexes = array();
412 
413  $i = 0;
414  foreach ($selection as $index => $answer) {
415  $element = array();
416  foreach ($answer as $answerPartIndex) {
417  $element[] = $elements[$answerPartIndex];
418  }
419 
420  $element = implode(' ', $element);
421  $element = str_replace(array('((', '))', '#'), array('', '', ''), $element);
422 
423  $ordinal = $index + 1;
424 
425  $feedback .= '<tr>';
426 
427  $feedback .= '<td class="text-nowrap">' . $ordinal . '. ' . $element . ':</td>';
428 
429  foreach ($this->object->getErrorData() as $idx => $ans) {
430  if (isset($matchedIndexes[$idx])) {
431  continue;
432  }
433 
434  if (preg_match('/' . preg_quote($ans->text_wrong, '/') . '/', $element)) {
435  $fb = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
436  $this->object->getId(),
437  0,
438  $idx
439  );
440 
441  $feedback .= '<td>' . $fb . '</td>';
442 
443  $matchedIndexes[$idx] = $idx;
444 
445  break;
446  }
447  }
448 
449  $feedback .= '</tr>';
450  }
451 
452  $feedback .= '</tbody></table>';
453 
454  return $this->object->prepareTextareaOutput($feedback, true);
455  }
$index
Definition: metadata.php:128
$i
Definition: metadata.php:24
+ Here is the caller graph for this function:

◆ getTestOutput()

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

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

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

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

◆ populateAnswerSpecificFormPart()

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

Implements ilGuiAnswerScoringAdjustable.

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

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\allowDecimals(), and ilErrorTextWizardInputGUI\setKeyName().

Referenced by editQuestion().

152  {
153  $header = new ilFormSectionHeaderGUI();
154  $header->setTitle($this->lng->txt("errors_section"));
155  $form->addItem($header);
156 
157  include_once "./Modules/TestQuestionPool/classes/class.ilErrorTextWizardInputGUI.php";
158  $errordata = new ilErrorTextWizardInputGUI($this->lng->txt("errors"), "errordata");
159  $errordata->setKeyName($this->lng->txt('text_wrong'));
160  $errordata->setValueName($this->lng->txt('text_correct'));
161  $errordata->setValues($this->object->getErrorData());
162  $form->addItem($errordata);
163 
164  // points for wrong selection
165  $points_wrong = new ilNumberInputGUI($this->lng->txt("points_wrong"), "points_wrong");
166  $points_wrong->allowDecimals(true);
167  $points_wrong->setMaxValue(0);
168  $points_wrong->setMaxvalueShouldBeLess(true);
169  $points_wrong->setValue($this->object->getPointsWrong());
170  $points_wrong->setInfo($this->lng->txt("points_wrong_info"));
171  $points_wrong->setSize(6);
172  $points_wrong->setRequired(true);
173  $form->addItem($points_wrong);
174  return $form;
175  }
This class represents a section header in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
allowDecimals($a_value)
Toggle Decimals.
This class represents a number property in a property form.
This class represents a key value pair wizard property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assErrorTextGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

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

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\allowDecimals(), and ilErrorTextWizardInputGUI\setKeyName().

548  {
549  // error terms
550  include_once "./Modules/TestQuestionPool/classes/forms/class.ilAssErrorTextCorrectionsInputGUI.php";
551  $errordata = new ilAssErrorTextCorrectionsInputGUI($this->lng->txt("errors"), "errordata");
552  $errordata->setKeyName($this->lng->txt('text_wrong'));
553  $errordata->setValueName($this->lng->txt('text_correct'));
554  $errordata->setValues($this->object->getErrorData());
555  $form->addItem($errordata);
556 
557  // points for wrong selection
558  $points_wrong = new ilNumberInputGUI($this->lng->txt("points_wrong"), "points_wrong");
559  $points_wrong->allowDecimals(true);
560  $points_wrong->setMaxValue(0);
561  $points_wrong->setMaxvalueShouldBeLess(true);
562  $points_wrong->setValue($this->object->getPointsWrong());
563  $points_wrong->setInfo($this->lng->txt("points_wrong_info"));
564  $points_wrong->setSize(6);
565  $points_wrong->setRequired(true);
566  $form->addItem($points_wrong);
567 
568  return $form;
569  }
addItem($a_item)
Add Item (Property, SectionHeader).
allowDecimals($a_value)
Toggle Decimals.
This class represents a number property in a property form.
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

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

Implements ilGuiQuestionScoringAdjustable.

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

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\setValue(), and ilTextAreaInputGUI\setValue().

Referenced by editQuestion().

182  {
183  // errortext
184  $errortext = new ilTextAreaInputGUI($this->lng->txt("errortext"), "errortext");
185  $errortext->setValue($this->object->getErrorText());
186  $errortext->setRequired(true);
187  $errortext->setInfo($this->lng->txt("errortext_info"));
188  $errortext->setRows(10);
189  $errortext->setCols(80);
190  $form->addItem($errortext);
191 
192  if (!$this->object->getSelfAssessmentEditingMode()) {
193  // textsize
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);
201  $form->addItem($textsize);
202  }
203  }
setValue($a_value)
Set Value.
setValue($a_value)
Set Value.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a number property in a property form.
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

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

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

575  {
576  $this->object->flushErrorData();
577  foreach ($form->getItemByPostVar('errordata')->getValues() as $idx => $errAnswer) {
578  $this->object->addErrorData(
579  $errAnswer->text_wrong,
580  $errAnswer->text_correct,
581  $errAnswer->points
582  );
583  }
584 
585  $this->object->setPointsWrong((float) $form->getInput('points_wrong'));
586  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ 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

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

221  {
222  return true;
223  }

◆ 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.

References $_POST.

Referenced by writePostData().

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  }
$_POST["username"]
+ Here is the caller graph for this function:

◆ writePostData()

assErrorTextGUI::writePostData (   $always = false)
protected

{}

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

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

Referenced by analyze().

49  {
50  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
51  if (!$hasErrors) {
52  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
56  $this->saveTaxonomyAssignments();
57  return 0;
58  }
59  return 1;
60  }
This class represents a property form user interface.
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.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
+ 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.

References $_POST.

Referenced by writePostData().

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  }
$_POST["username"]
+ Here is the caller graph for this function:

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