ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 the request and applies them to the data object. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 
 analyze ()
 Parse the error text. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, 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_inline_feedback=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,)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 getSpecificFeedbackOutput (array $user_solution)
 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 (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
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, 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_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 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,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 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 (string $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)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 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)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 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)
 
 buildFileDownloadLink ()
 
 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 the request 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...
 
 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 the request 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 (bool $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
 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 ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 renderLatex ($content)
 Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in the browser. More...
 
 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 ()
 
 resetSavedPreviewSession ()
 

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 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 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'
 
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 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'
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const CMD_SYNC_QUESTION_AND_RETURN = 'syncQuestionReturn'
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const QUESTION_SAVE_CMDS
 
const ADDITIONAL_CMDS_NEEDING_EXISTING_QST
 There are functions that need an existing question. More...
 
ilLogger $logger
 
GeneralQuestionPropertiesRepository $questionrepository
 
GUIService $notes_gui
 
ilCtrl $ctrl
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
Refinery $refinery
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
ilPropertyFormGUI $editForm = null
 
readonly ilTestLegacyFormsHelper $forms_helper
 
readonly RequestDataCollector $request_data_collector
 
bool $parent_type_is_lm = false
 
SuggestedSolutionsDatabaseRepository $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$

@ilctrl_iscalledby assErrorTextGUI: ilObjQuestionPoolGUI @ilCtrl_Calls assErrorTextGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assErrorTextGUI::__construct (   $id = -1)

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

40 {
41 global $DIC;
42 $this->tabs = $DIC->tabs();
43
45 $this->object = new assErrorText();
46 $this->setErrorMessage($this->lng->txt("msg_form_save_error"));
47 if ($id >= 0) {
48 $this->object->loadFromDb($id);
49 }
50 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class for error text questions.
setErrorMessage(string $errormessage)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, $id, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), assQuestionGUI\setErrorMessage(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

Member Function Documentation

◆ analyze()

assErrorTextGUI::analyze ( )

Parse the error text.

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

218 : void
219 {
221 $this->writePostData(true);
223 $this->object->setErrorsFromParsedErrorText();
224 $this->tabs->activateTab('edit_question');
225 $this->editQuestion();
226 }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...

References ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ editQuestion()

assErrorTextGUI::editQuestion ( bool  $checkonly = false,
?bool  $is_save_cmd = null 
)

Reimplemented from assQuestionGUI.

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

115 : bool {
116 $save = $is_save_cmd ?? $this->isSaveCommand();
117
118 $form = new ilPropertyFormGUI();
119 $this->editForm = $form;
120
121 $form->setFormAction($this->ctrl->getFormAction($this));
122 $form->setTitle($this->outQuestionType());
123 $form->setMultipart(false);
124 $form->setTableWidth("100%");
125 $form->setId("orderinghorizontal");
126
127 $this->addBasicQuestionFormProperties($form);
128
130
131 if (count($this->object->getErrorData()) || $checkonly) {
132 $this->populateAnswerSpecificFormPart($form);
133 }
134
135 $this->populateTaxonomyFormSection($form);
136
137 $form->addCommandButton("analyze", $this->lng->txt('analyze_errortext'));
138 $this->addQuestionFormCommandButtons($form);
139
140 $errors = false;
141
142 if ($save) {
143 $form->setValuesByPost();
144 $errors = !$form->checkInput();
145 $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
146 if ($errors) {
147 $checkonly = false;
148 }
149 }
150
151 if (!$checkonly) {
152 $this->renderEditForm($form);
153 }
154 return $errors;
155 }
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
renderEditForm(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
This class represents a property form user interface.

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ generateQuestionOutput()

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

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

369 : string
370 {
371 $template = new ilTemplate("tpl.il_as_qpl_errortext_output.html", true, true, "components/ILIAS/TestQuestionPool");
372
373 if ($this->object->getTextSize() >= 10) {
374 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
375 }
376 $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
377 $errortext = $this->object->assembleErrorTextOutput($selections);
378 if ($this->getTargetGuiClass() !== null) {
379 $this->ctrl->setParameterByClass($this->getTargetGuiClass(), 'errorvalue', '');
380 }
381 $template->setVariable("ERRORTEXT", $errortext);
382 $template->setVariable("ERRORTEXT_ID", "qst_" . $this->object->getId());
383 $template->setVariable("ERRORTEXT_VALUE", join(',', $selections['user']));
384
385 $this->tpl->addOnLoadCode('il.test.player.errortext.init()');
386 $this->tpl->addJavascript('assets/js/errortext.js');
387 $questionoutput = $template->get();
388
389 if ($show_question_only) {
390 return $questionoutput;
391 }
392
393 return $this->getILIASPage($questionoutput);
394 }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR

References ILIAS\Repository\ctrl(), and ILIAS\Repository\object().

+ Here is the call 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 447 of file class.assErrorTextGUI.php.

447 : array
448 {
449 return [];
450 }

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

461 : array
462 {
463 return [];
464 }

◆ 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

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

472 : string
473 {
474 $errortext = $this->object->getErrorText();
475
476 $passdata = []; // Regroup answers into units of passes.
477 foreach ($relevant_answers as $answer_chosen) {
478 $passdata[$answer_chosen['active_fi'] . '-' . $answer_chosen['pass']][$answer_chosen['value2']][] = $answer_chosen['value1'];
479 }
480
481 $html = '';
482 foreach ($passdata as $key => $pass) {
483 $passdata[$key] = $this->object->createErrorTextOutput($pass);
484 $html .= $passdata[$key] . '<hr /><br />';
485 }
486
487 return $html;
488 }

◆ getAnswersFrequency()

assErrorTextGUI::getAnswersFrequency (   $relevant_answers,
  $question_index 
)

Reimplemented from assQuestionGUI.

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

490 : array
491 {
492 $answers_by_active_and_pass = [];
493
494 foreach ($relevant_answers as $row) {
495 $key = $row['active_fi'] . ':' . $row['pass'];
496
497 if (!isset($answers_by_active_and_pass[$key])) {
498 $answers_by_active_and_pass[$key] = ['user' => []];
499 }
500
501 $answers_by_active_and_pass[$key]['user'][] = $row['value1'];
502 }
503
504 $answers = [];
505
506 foreach ($answers_by_active_and_pass as $answer) {
507 $error_text = '<div class="errortext">' . $this->object->assembleErrorTextOutput($answer) . '</div>';
508 $error_text_hashed = md5($error_text);
509
510 if (!isset($answers[$error_text_hashed])) {
511 $answers[$error_text_hashed] = [
512 'answer' => $error_text, 'frequency' => 0
513 ];
514 }
515
516 $answers[$error_text_hashed]['frequency']++;
517 }
518
519 return array_values($answers);
520 }

◆ getPreview()

assErrorTextGUI::getPreview ( bool  $show_question_only = false,
bool  $show_inline_feedback = false 
)

Reimplemented from assQuestionGUI.

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

342 : string {
343 $selections = [
345 ];
346
347 return $this->generateQuestionOutput($selections, $show_question_only);
348 }
getUsersSolutionFromPreviewOrDatabase(int $active_id=0, ?int $pass=null)
generateQuestionOutput($selections, $show_question_only)

◆ getSolutionOutput()

assErrorTextGUI::getSolutionOutput ( int  $active_id,
?int  $pass = null,
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_inline_feedback = true 
)

Reimplemented from assQuestionGUI.

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

239 : string {
240 $user_solutions = $this->getUsersSolutionFromPreviewOrDatabase($active_id, $pass);
241 return $this->renderSolutionOutput(
242 $user_solutions,
243 $active_id,
244 $pass,
245 $graphical_output,
246 $result_output,
247 $show_question_only,
248 $show_feedback,
249 $show_correct_solution,
250 $show_manual_scoring,
251 $show_question_text,
252 false,
253 $show_inline_feedback,
254 );
255 }
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,)

◆ getSpecificFeedbackOutput()

assErrorTextGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

Parameters
array$userSolution($userSolution[<value1>] = <value2>)

Reimplemented from assQuestionGUI.

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

414 : string
415 {
416 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
417 return '';
418 }
419
420 $feedback = '<table class="test_specific_feedback"><tbody>';
421 $elements = $this->object->getErrorData();
422 foreach ($elements as $index => $element) {
423 $feedback .= '<tr>';
424 $feedback .= '<td class="text-nowrap">' . $index . '. ' . $element->getTextWrong() . ':</td>';
425 $feedback .= '<td>' . $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
426 $this->object->getId(),
427 0,
428 $index
429 ) . '</td>';
430
431 $feedback .= '</tr>';
432 }
433 $feedback .= '</tbody></table>';
434
435 return $this->renderLatex(ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
436 }
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,...

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

+ Here is the call graph for this function:

◆ getTestOutput()

assErrorTextGUI::getTestOutput ( int  $active_id,
int  $pass,
bool  $is_question_postponed = false,
array|bool  $user_post_solutions = false,
bool  $show_specific_inline_feedback = false 
)

Reimplemented from assQuestionGUI.

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

356 : string {
357 $selections = [
358 'user' => $this->getUsersSolutionFromPreviewOrDatabase($active_id, $pass)
359 ];
360
361 return $this->outQuestionPage(
362 '',
363 $is_question_postponed,
364 $active_id,
365 $this->generateQuestionOutput($selections, true)
366 );
367 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

◆ getUsersSolutionFromPreviewOrDatabase()

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

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

396 : array
397 {
398 if (is_object($this->getPreviewSession())) {
399 return (array) $this->getPreviewSession()->getParticipantsSolution();
400 }
401
402 if ($active_id > 0) {
403 $selections = [];
404 $solutions = $this->object->getSolutionValues($active_id, $pass ?? 0, true);
405 foreach ($solutions as $solution) {
406 $selections[] = $solution['value1'];
407 }
408 return $selections;
409 }
410
411 return [];
412 }

◆ populateAnswerSpecificFormPart()

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

Implements ilGuiAnswerScoringAdjustable.

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

162 {
163 $header = new ilFormSectionHeaderGUI();
164 $header->setTitle($this->lng->txt("errors_section"));
165 $form->addItem($header);
166
167 $errordata = new ilErrorTextWizardInputGUI($this->lng->txt("errors"), "errordata");
168 $errordata->setKeyName($this->lng->txt('text_wrong'));
169 $errordata->setValueName($this->lng->txt('text_correct'));
170 $errordata->setValues($this->object->getErrorData());
171 $form->addItem($errordata);
172
173 // points for wrong selection
174 $points_wrong = new ilNumberInputGUI($this->lng->txt("points_wrong"), "points_wrong");
175 $points_wrong->allowDecimals(true);
176 $points_wrong->setMaxValue(0);
177 $points_wrong->setMaxvalueShouldBeLess(true);
178 $points_wrong->setValue($this->object->getPointsWrong());
179 $points_wrong->setInfo($this->lng->txt("points_wrong_info"));
180 $points_wrong->setSize(6);
181 $points_wrong->setRequired(true);
182 $form->addItem($points_wrong);
183 return $form;
184 }
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.

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

+ Here is the call graph for this function:

◆ populateCorrectionsFormProperties()

assErrorTextGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

522 : void
523 {
524 $errordata = new ilAssErrorTextCorrectionsInputGUI($this->lng->txt('errors'), 'errordata');
525 $errordata->setKeyName($this->lng->txt('text_wrong'));
526 $errordata->setValueName($this->lng->txt('text_correct'));
527 $errordata->setValues($this->object->getErrorData());
528 $form->addItem($errordata);
529
530 // points for wrong selection
531 $points_wrong = new ilNumberInputGUI($this->lng->txt('points_wrong'), 'points_wrong');
532 $points_wrong->allowDecimals(true);
533 $points_wrong->setMaxValue(0);
534 $points_wrong->setMaxvalueShouldBeLess(true);
535 $points_wrong->setValue($this->object->getPointsWrong());
536 $points_wrong->setInfo($this->lng->txt('points_wrong_info'));
537 $points_wrong->setSize(6);
538 $points_wrong->setRequired(true);
539 $form->addItem($points_wrong);
540 }

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

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

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

Implements ilGuiQuestionScoringAdjustable.

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

191 {
192 // errortext
193 $errortext = new ilTextAreaInputGUI($this->lng->txt("errortext"), "errortext");
194 $errortext->setValue($this->object->getErrorText());
195 $errortext->setRequired(true);
196 $errortext->setInfo($this->lng->txt("errortext_info"));
197 $errortext->setRows(10);
198 $errortext->setCols(80);
199 $form->addItem($errortext);
200
201 if (!$this->object->getSelfAssessmentEditingMode()) {
202 // textsize
203 $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
204 $textsize->setValue($this->object->getTextSize() ?? 100.0);
205 $textsize->setInfo($this->lng->txt("textsize_errortext_info"));
206 $textsize->setSize(6);
207 $textsize->setSuffix("%");
208 $textsize->setMinValue(10);
209 $textsize->setRequired(true);
210 $form->addItem($textsize);
211 }
212 return $form;
213 }
This class represents a text area property in a property form.

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

+ Here is the call 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 
)

Reimplemented from assQuestionGUI.

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

270 : ?string {
271 $template = new ilTemplate("tpl.il_as_qpl_errortext_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
272
273 $selections = [
274 'user' => $user_solutions ?
275 $user_solutions :
276 $this->getUsersSolutionFromPreviewOrDatabase($active_id, $pass)
277 ];
278 $selections['best'] = $this->object->getBestSelection();
279
280 $reached_points = $this->object->getPoints();
281 if ($active_id > 0 && !$show_correct_solution) {
282 $reached_points = $this->object->getReachedPoints($active_id, $pass);
283 }
284
285 if ($result_output === true) {
286 $resulttext = ($reached_points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
287 $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $reached_points));
288 }
289
290 if ($this->object->getTextSize() >= 10) {
291 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
292 }
293
294 if ($show_question_text === true) {
295 $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
296 }
297
298 $correctness_icons = [
299 'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
300 'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
301 ];
302 $errortext = $this->object->assembleErrorTextOutput($selections, $graphical_output, $show_correct_solution, false, $correctness_icons);
303
304 $template->setVariable("ERRORTEXT", $errortext);
305 $questionoutput = $template->get();
306
307 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
308
309 $feedback = '';
310 if ($show_feedback) {
311 if (!$this->isTestPresentationContext()) {
312 $fb = $this->getGenericFeedbackOutput($active_id, $pass);
313 $feedback .= mb_strlen($fb) ? $fb : '';
314 }
315
316 $fb = $this->getSpecificFeedbackOutput([]);
317 $feedback .= mb_strlen($fb) ? $fb : '';
318 }
319 if (mb_strlen($feedback)) {
320 $cssClass = (
321 $this->hasCorrectSolution($active_id, $pass) ?
323 );
324
325 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
326 $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
327 }
328
329 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
330
331 $solutionoutput = $solutiontemplate->get();
332 if (!$show_question_only) {
333 // get page object output
334 $solutionoutput = $this->getILIASPage($solutionoutput);
335 }
336 return $solutionoutput;
337 }
getSpecificFeedbackOutput(array $user_solution)
Returns the answer specific feedback for the question.
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)

◆ restructurePostDataForSaving()

assErrorTextGUI::restructurePostDataForSaving ( array  $post)
private

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

75 : array
76 {
77 $keys = $post['key'] ?? [];
78 $restructured_array = [];
79 foreach ($keys as $key => $text_wrong) {
80 $restructured_array[] = new assAnswerErrorText(
81 $text_wrong,
82 $post['value'][$key],
83 (float) str_replace(',', '.', $post['points'][$key])
84 );
85 }
86 return $restructured_array;
87 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$post
Definition: ltitoken.php:46

References $post.

Referenced by writeAnswerSpecificPostData().

+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

545 : void
546 {
547 $existing_errordata = $this->object->getErrorData();
548 $this->object->flushErrorData();
549 $new_errordata = $this->request_data_collector->raw('errordata');
550 $errordata = [];
551 foreach ($new_errordata['points'] as $index => $points) {
552 $errordata[$index] = $existing_errordata[$index]->withPoints(
553 (float) str_replace(',', '.', $points)
554 );
555 }
556 $this->object->setErrorData($errordata);
557 $this->object->setPointsWrong((float) str_replace(',', '.', $form->getInput('points_wrong')));
558 }
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-...

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ writeAnswerSpecificPostData()

assErrorTextGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

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

68 : void
69 {
70 $data = $this->restructurePostDataForSaving($this->request_data_collector->raw('errordata') ?? []);
71 $this->object->setErrorData($data);
72 $this->object->removeErrorDataWithoutPosition();
73 }
restructurePostDataForSaving(array $post)

References $data, and restructurePostDataForSaving().

Referenced by writePostData().

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

◆ writePostData()

assErrorTextGUI::writePostData ( bool  $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 55 of file class.assErrorTextGUI.php.

55 : int
56 {
57 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
58 if (!$hasErrors) {
63 return 0;
64 }
65 return 1;
66 }
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from the request and applies them to the data object.

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

+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assErrorTextGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

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

89 : void
90 {
91 $this->object->setQuestion(
92 $this->request_data_collector->string('question')
93 );
94
95 $this->object->setErrorText(
96 $this->request_data_collector->raw('errortext')
97 );
98
99 $this->object->parseErrorText();
100
101 $this->object->setPointsWrong(
102 $this->request_data_collector->float('points_wrong') ?? self::DEFAULT_POINTS_WRONG
103 );
104
105 if (!$this->object->getSelfAssessmentEditingMode()) {
106 $this->object->setTextSize(
107 $this->request_data_collector->float('textsize')
108 );
109 }
110 }

References ILIAS\Repository\object().

Referenced by writePostData().

+ 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 37 of file class.assErrorTextGUI.php.

◆ DEFAULT_POINTS_WRONG

const assErrorTextGUI::DEFAULT_POINTS_WRONG = -1
private

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


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