ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
assErrorTextGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct ($id=-1)
 
 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...
 
 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. More...
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 getSpecificFeedbackOutput (array $user_solution)
 
 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 (array $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 ($relevant_answers, $question_index)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 geCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 cancel ()
 
 originalSyncForm (string $return_to="", string $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 
 save ()
 
 saveReturn ()
 
 apply ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 outAdditionalOutput ()
 Why are you here? Some magic for plugins? More...
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addNewIdListener ($a_object, string $a_method, string $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners (int $a_new_id)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 suggestedsolution ()
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $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)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 

Protected Member Functions

 writePostData (bool $always=false)
 {} More...
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 getSuggestedSolutionsRepo ()
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Private Member Functions

 restructurePostDataForSaving (array $post)
 
 generateQuestionOutput ($selections, $show_question_only)
 
 getUsersSolutionFromPreviewOrDatabase (int $active_id=0, ?int $pass=null)
 

Private Attributes

const DEFAULT_POINTS_WRONG = -1
 
ilTabsGUI $tabs
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI (string $question_type='', int $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput (?string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. 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 CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $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 SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ilLogger $logger
 
ILIAS TestQuestionPool QuestionInfoService $questioninfo
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
Refinery $refinery
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 
bool $parent_type_is_lm = false
 
assQuestionSuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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$

assErrorTextGUI: ilObjQuestionPoolGUI assErrorTextGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assErrorTextGUI::__construct (   $id = -1)

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

References $DIC, $id, ILIAS\MetaData\Repository\Validation\Data\__construct(), ILIAS\Repository\lng(), assQuestionGUI\setErrorMessage(), and ILIAS\Repository\tabs().

42  {
43  global $DIC;
44  $this->tabs = $DIC->tabs();
45 
47  $this->object = new assErrorText();
48  $this->setErrorMessage($this->lng->txt("msg_form_save_error"));
49  if ($id >= 0) {
50  $this->object->loadFromDb($id);
51  }
52  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
setErrorMessage(string $errormessage)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Member Function Documentation

◆ analyze()

assErrorTextGUI::analyze ( )

Parse the error text.

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

References editQuestion(), assQuestionGUI\saveTaxonomyAssignments(), and writePostData().

229  : void
230  {
231  $this->writePostData(true);
232  $this->saveTaxonomyAssignments();
233  $this->object->setErrorsFromParsedErrorText();
234  $this->editQuestion();
235  }
writePostData(bool $always=false)
{}
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
+ 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 123 of file class.assErrorTextGUI.php.

References assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), ILIAS\Repository\ctrl(), assQuestionGUI\getQuestionTemplate(), assQuestionGUI\isSaveCommand(), ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), assQuestionGUI\populateTaxonomyFormSection(), and ILIAS\Repository\tabs().

Referenced by analyze(), and writePostData().

123  : bool
124  {
125  $this->tabs->setTabActive('edit_question');
126  $save = $this->isSaveCommand();
127  $this->getQuestionTemplate();
128 
129  $form = new ilPropertyFormGUI();
130  $this->editForm = $form;
131 
132  $form->setFormAction($this->ctrl->getFormAction($this));
133  $form->setTitle($this->outQuestionType());
134  $form->setMultipart(false);
135  $form->setTableWidth("100%");
136  $form->setId("orderinghorizontal");
137 
138  $this->addBasicQuestionFormProperties($form);
139 
140  $this->populateQuestionSpecificFormPart($form);
141 
142  if (count($this->object->getErrorData()) || $checkonly) {
143  $this->populateAnswerSpecificFormPart($form);
144  }
145 
146  $this->populateTaxonomyFormSection($form);
147 
148  $form->addCommandButton("analyze", $this->lng->txt('analyze_errortext'));
149  $this->addQuestionFormCommandButtons($form);
150 
151  $errors = false;
152 
153  if ($save) {
154  $form->setValuesByPost();
155  $errors = !$form->checkInput();
156  $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
157  if ($errors) {
158  $checkonly = false;
159  }
160  }
161 
162  if (!$checkonly) {
163  $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
164  }
165  return $errors;
166  }
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateQuestionOutput()

assErrorTextGUI::generateQuestionOutput (   $selections,
  $show_question_only 
)
private

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

References ILIAS\Repository\ctrl(), assQuestionGUI\getILIASPage(), assQuestionGUI\getTargetGuiClass(), and ILIAS\Repository\object().

Referenced by getPreview(), and getTestOutput().

394  : string
395  {
396  $template = new ilTemplate("tpl.il_as_qpl_errortext_output.html", true, true, "Modules/TestQuestionPool");
397 
398  if ($this->object->getTextSize() >= 10) {
399  $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
400  }
401  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
402  $errortext = $this->object->assembleErrorTextOutput($selections);
403  if ($this->getTargetGuiClass() !== null) {
404  $this->ctrl->setParameterByClass($this->getTargetGuiClass(), 'errorvalue', '');
405  }
406  $template->setVariable("ERRORTEXT", $errortext);
407  $template->setVariable("ERRORTEXT_ID", "qst_" . $this->object->getId());
408  $template->setVariable("ERRORTEXT_VALUE", join(',', $selections['user']));
409 
410  $this->tpl->addOnLoadCode('il.test.player.errortext.init()');
411  $this->tpl->addJavascript('./Modules/TestQuestionPool/templates/default/errortext.js');
412  $questionoutput = $template->get();
413 
414  if ($show_question_only) {
415  return $questionoutput;
416  }
417 
418  return $this->getILIASPage($questionoutput);
419  }
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
+ 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 472 of file class.assErrorTextGUI.php.

472  : array
473  {
474  return [];
475  }

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

486  : array
487  {
488  return [];
489  }

◆ getAggregatedAnswersView()

assErrorTextGUI::getAggregatedAnswersView ( array  $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 497 of file class.assErrorTextGUI.php.

References ILIAS\LTI\ToolProvider\$key.

497  : string
498  {
499  $errortext = $this->object->getErrorText();
500 
501  $passdata = []; // Regroup answers into units of passes.
502  foreach ($relevant_answers as $answer_chosen) {
503  $passdata[$answer_chosen['active_fi'] . '-' . $answer_chosen['pass']][$answer_chosen['value2']][] = $answer_chosen['value1'];
504  }
505 
506  $html = '';
507  foreach ($passdata as $key => $pass) {
508  $passdata[$key] = $this->object->createErrorTextOutput($pass);
509  $html .= $passdata[$key] . '<hr /><br />';
510  }
511 
512  return $html;
513  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ getAnswersFrequency()

assErrorTextGUI::getAnswersFrequency (   $relevant_answers,
  $question_index 
)

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

References ILIAS\LTI\ToolProvider\$key.

515  : array
516  {
517  $answers_by_active_and_pass = [];
518 
519  foreach ($relevant_answers as $row) {
520  $key = $row['active_fi'] . ':' . $row['pass'];
521 
522  if (!isset($answers_by_active_and_pass[$key])) {
523  $answers_by_active_and_pass[$key] = ['user' => []];
524  }
525 
526  $answers_by_active_and_pass[$key]['user'][] = $row['value1'];
527  }
528 
529  $answers = [];
530 
531  foreach ($answers_by_active_and_pass as $answer) {
532  $error_text = '<div class="errortext">' . $this->object->assembleErrorTextOutput($answer) . '</div>';
533  $error_text_hashed = md5($error_text);
534 
535  if (!isset($answers[$error_text_hashed])) {
536  $answers[$error_text_hashed] = [
537  'answer' => $error_text, 'frequency' => 0
538  ];
539  }
540 
541  $answers[$error_text_hashed]['frequency']++;
542  }
543 
544  return array_values($answers);
545  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ getPreview()

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

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

References generateQuestionOutput(), and getUsersSolutionFromPreviewOrDatabase().

366  : string
367  {
368  $selections = [
369  'user' => $this->getUsersSolutionFromPreviewOrDatabase()
370  ];
371 
372  return $this->generateQuestionOutput($selections, $show_question_only);
373  }
generateQuestionOutput($selections, $show_question_only)
getUsersSolutionFromPreviewOrDatabase(int $active_id=0, ?int $pass=null)
+ 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 252 of file class.assErrorTextGUI.php.

References getUsersSolutionFromPreviewOrDatabase(), and renderSolutionOutput().

262  : string {
263  $user_solutions = $this->getUsersSolutionFromPreviewOrDatabase((int) $active_id, $pass);
264  $show_inline_feedback = false;
265  return $this->renderSolutionOutput(
266  $user_solutions,
267  $active_id,
268  $pass,
269  $graphicalOutput,
270  $result_output,
271  $show_question_only,
272  $show_feedback,
273  $show_correct_solution,
274  $show_manual_scoring,
275  $show_question_text,
276  false,
277  $show_inline_feedback,
278  );
279  }
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
getUsersSolutionFromPreviewOrDatabase(int $active_id=0, ?int $pass=null)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assErrorTextGUI::getSpecificFeedbackOutput ( array  $user_solution)

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

References ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

Referenced by renderSolutionOutput().

439  : string
440  {
441  if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
442  return '';
443  }
444 
445  $feedback = '<table class="test_specific_feedback"><tbody>';
446  $elements = $this->object->getErrorData();
447  foreach ($elements as $index => $element) {
448  $feedback .= '<tr>';
449  $feedback .= '<td class="text-nowrap">' . $index . '. ' . $element->getTextWrong() . ':</td>';
450  $feedback .= '<td>' . $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
451  $this->object->getId(),
452  0,
453  $index
454  ) . '</td>';
455 
456  $feedback .= '</tr>';
457  }
458  $feedback .= '</tbody></table>';
459 
460  return ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true);
461  }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:
+ 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 375 of file class.assErrorTextGUI.php.

References generateQuestionOutput(), getUsersSolutionFromPreviewOrDatabase(), and assQuestionGUI\outQuestionPage().

381  : string {
382  $selections = [
383  'user' => $this->getUsersSolutionFromPreviewOrDatabase($active_id, $pass)
384  ];
385 
386  return $this->outQuestionPage(
387  '',
388  $is_postponed,
389  $active_id,
390  $this->generateQuestionOutput($selections, false)
391  );
392  }
generateQuestionOutput($selections, $show_question_only)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
getUsersSolutionFromPreviewOrDatabase(int $active_id=0, ?int $pass=null)
+ Here is the call graph for this function:

◆ getUsersSolutionFromPreviewOrDatabase()

assErrorTextGUI::getUsersSolutionFromPreviewOrDatabase ( int  $active_id = 0,
?int  $pass = null 
)
private

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

References assQuestionGUI\getPreviewSession().

Referenced by getPreview(), getSolutionOutput(), getTestOutput(), and renderSolutionOutput().

421  : array
422  {
423  if (is_object($this->getPreviewSession())) {
424  return (array) $this->getPreviewSession()->getParticipantsSolution();
425  }
426 
427  if ($active_id > 0) {
428  $selections = [];
429  $solutions = $this->object->getSolutionValues($active_id, $pass ?? 0, true);
430  foreach ($solutions as $solution) {
431  $selections[] = $solution['value1'];
432  }
433  return $selections;
434  }
435 
436  return [];
437  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateAnswerSpecificFormPart()

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

Implements ilGuiAnswerScoringAdjustable.

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

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilErrorTextWizardInputGUI\setKeyName().

Referenced by editQuestion().

173  {
174  $header = new ilFormSectionHeaderGUI();
175  $header->setTitle($this->lng->txt("errors_section"));
176  $form->addItem($header);
177 
178  $errordata = new ilErrorTextWizardInputGUI($this->lng->txt("errors"), "errordata");
179  $errordata->setKeyName($this->lng->txt('text_wrong'));
180  $errordata->setValueName($this->lng->txt('text_correct'));
181  $errordata->setValues($this->object->getErrorData());
182  $form->addItem($errordata);
183 
184  // points for wrong selection
185  $points_wrong = new ilNumberInputGUI($this->lng->txt("points_wrong"), "points_wrong");
186  $points_wrong->allowDecimals(true);
187  $points_wrong->setMaxValue(0);
188  $points_wrong->setMaxvalueShouldBeLess(true);
189  $points_wrong->setValue($this->object->getPointsWrong());
190  $points_wrong->setInfo($this->lng->txt("points_wrong_info"));
191  $points_wrong->setSize(6);
192  $points_wrong->setRequired(true);
193  $form->addItem($points_wrong);
194  return $form;
195  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilErrorTextWizardInputGUI\setKeyName().

547  : void
548  {
549  $errordata = new ilAssErrorTextCorrectionsInputGUI($this->lng->txt('errors'), 'errordata');
550  $errordata->setKeyName($this->lng->txt('text_wrong'));
551  $errordata->setValueName($this->lng->txt('text_correct'));
552  $errordata->setValues($this->object->getErrorData());
553  $form->addItem($errordata);
554 
555  // points for wrong selection
556  $points_wrong = new ilNumberInputGUI($this->lng->txt('points_wrong'), 'points_wrong');
557  $points_wrong->allowDecimals(true);
558  $points_wrong->setMaxValue(0);
559  $points_wrong->setMaxvalueShouldBeLess(true);
560  $points_wrong->setValue($this->object->getPointsWrong());
561  $points_wrong->setInfo($this->lng->txt('points_wrong_info'));
562  $points_wrong->setSize(6);
563  $points_wrong->setRequired(true);
564  $form->addItem($points_wrong);
565  }
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

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

Implements ilGuiQuestionScoringAdjustable.

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

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilTextAreaInputGUI\setValue().

Referenced by editQuestion().

202  {
203  // errortext
204  $errortext = new ilTextAreaInputGUI($this->lng->txt("errortext"), "errortext");
205  $errortext->setValue($this->object->getErrorText());
206  $errortext->setRequired(true);
207  $errortext->setInfo($this->lng->txt("errortext_info"));
208  $errortext->setRows(10);
209  $errortext->setCols(80);
210  $form->addItem($errortext);
211 
212  if (!$this->object->getSelfAssessmentEditingMode()) {
213  // textsize
214  $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
215  $textsize->setValue($this->object->getTextSize() ?? 100.0);
216  $textsize->setInfo($this->lng->txt("textsize_errortext_info"));
217  $textsize->setSize(6);
218  $textsize->setSuffix("%");
219  $textsize->setMinValue(10);
220  $textsize->setRequired(true);
221  $form->addItem($textsize);
222  }
223  return $form;
224  }
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:

◆ renderSolutionOutput()

assErrorTextGUI::renderSolutionOutput ( mixed  $user_solutions,
int  $active_id,
?int  $pass,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_autosave_title = false,
bool  $show_inline_feedback = false 
)

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

References ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\generateCorrectnessIconsForCorrectness(), assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), getSpecificFeedbackOutput(), getUsersSolutionFromPreviewOrDatabase(), assQuestionGUI\hasCorrectSolution(), assQuestionGUI\isTestPresentationContext(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

Referenced by getSolutionOutput().

294  : ?string {
295  // get the solution of the user for the active pass or from the last pass if allowed
296  $template = new ilTemplate("tpl.il_as_qpl_errortext_output_solution.html", true, true, "Modules/TestQuestionPool");
297 
298  $selections = [
299  'user' => $user_solutions ?
300  $user_solutions :
301  $this->getUsersSolutionFromPreviewOrDatabase((int) $active_id, $pass)
302  ];
303 
304 
305  $selections['best'] = $this->object->getBestSelection();
306 
307  $reached_points = $this->object->getPoints();
308  if ($active_id > 0 && !$show_correct_solution) {
309  $reached_points = $this->object->getReachedPoints($active_id, $pass);
310  }
311 
312  if ($result_output === true) {
313  $resulttext = ($reached_points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
314  $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $reached_points));
315  }
316 
317  if ($this->object->getTextSize() >= 10) {
318  $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
319  }
320 
321  if ($show_question_text === true) {
322  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
323  }
324 
325  $correctness_icons = [
326  'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
327  'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
328  ];
329  $errortext = $this->object->assembleErrorTextOutput($selections, $graphical_output, $show_correct_solution, false, $correctness_icons);
330 
331  $template->setVariable("ERRORTEXT", $errortext);
332  $questionoutput = $template->get();
333 
334  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
335 
336  $feedback = '';
337  if ($show_feedback) {
338  if (!$this->isTestPresentationContext()) {
339  $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
340  $feedback .= mb_strlen($fb) ? $fb : '';
341  }
342 
343  $fb = $this->getSpecificFeedbackOutput(array());
344  $feedback .= mb_strlen($fb) ? $fb : '';
345  }
346  if (mb_strlen($feedback)) {
347  $cssClass = (
348  $this->hasCorrectSolution($active_id, $pass) ?
350  );
351 
352  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
353  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
354  }
355 
356  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
357 
358  $solutionoutput = $solutiontemplate->get();
359  if (!$show_question_only) {
360  // get page object output
361  $solutionoutput = $this->getILIASPage($solutionoutput);
362  }
363  return $solutionoutput;
364  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
getSpecificFeedbackOutput(array $user_solution)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
getUsersSolutionFromPreviewOrDatabase(int $active_id=0, ?int $pass=null)
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
getGenericFeedbackOutput(int $active_id, ?int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restructurePostDataForSaving()

assErrorTextGUI::restructurePostDataForSaving ( array  $post)
private

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

References ILIAS\LTI\ToolProvider\$key.

Referenced by writeAnswerSpecificPostData().

77  : array
78  {
79  $keys = $post['key'] ?? [];
80  $restructured_array = [];
81  foreach ($keys as $key => $text_wrong) {
82  $restructured_array[] = new assAnswerErrorText(
83  $text_wrong,
84  $post['value'][$key],
85  (float) str_replace(',', '.', $post['points'][$key])
86  );
87  }
88  return $restructured_array;
89  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
$post
Definition: ltitoken.php:49
+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

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

References ilPropertyFormGUI\getInput().

570  : void
571  {
572  $existing_errordata = $this->object->getErrorData();
573  $this->object->flushErrorData();
574  $new_errordata = $this->request->raw('errordata');
575  $errordata = [];
576  foreach ($new_errordata['points'] as $index => $points) {
577  $errordata[$index] = $existing_errordata[$index]->withPoints(
578  (float) str_replace(',', '.', $points)
579  );
580  }
581  $this->object->setErrorData($errordata);
582  $this->object->setPointsWrong((float) str_replace(',', '.', $form->getInput('points_wrong')));
583  }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assErrorTextGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

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

References restructurePostDataForSaving().

Referenced by writePostData().

70  : void
71  {
72  $errordata = $this->restructurePostDataForSaving($this->request->raw('errordata') ?? []);
73  $this->object->setErrorData($errordata);
74  $this->object->removeErrorDataWithoutPosition();
75  }
restructurePostDataForSaving(array $post)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assErrorTextGUI::writePostData ( bool  $always = false)
protected

{}

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

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

Referenced by analyze().

57  : int
58  {
59  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
60  if (!$hasErrors) {
64  $this->saveTaxonomyAssignments();
65  return 0;
66  }
67  return 1;
68  }
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.

Implements ilGuiQuestionScoringAdjustable.

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

References ILIAS\Repository\object().

Referenced by writePostData().

91  : void
92  {
93  $this->object->setQuestion(
94  $this->request->raw('question')
95  );
96 
97  $this->object->setErrorText(
98  $this->request->raw('errortext')
99  );
100 
101  $this->object->parseErrorText();
102 
103  $points_wrong = str_replace(",", ".", $this->request->raw('points_wrong') ?? '');
104  if (mb_strlen($points_wrong) == 0) {
105  $points_wrong = self::DEFAULT_POINTS_WRONG;
106  }
107  $this->object->setPointsWrong((float) $points_wrong);
108 
109  if (!$this->object->getSelfAssessmentEditingMode()) {
110  $this->object->setTextSize(
111  (float) str_replace(',', '.', $this->request->raw('textsize'))
112  );
113  }
114  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $tabs

ilTabsGUI assErrorTextGUI::$tabs
private

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

◆ DEFAULT_POINTS_WRONG

const assErrorTextGUI::DEFAULT_POINTS_WRONG = -1
private

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


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