ILIAS  release_8 Revision v8.24
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, $graphical_output=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...
 
 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)
 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
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 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)
 
 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)
 
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getAggregatedAnswersView (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...
 
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST and applies them to the data object. More...
 
 getAfterParticipationSuppressionAnswerPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 

Protected Member Functions

 writePostData (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 ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 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)
 
 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 ($txt_output, $prepare_for_latex_output=false, $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
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 

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

Constructor & Destructor Documentation

◆ __construct()

assErrorTextGUI::__construct (   $id = -1)

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

42 {
43 global $DIC;
44 $this->tabs = $DIC->tabs();
45
47 include_once "./Modules/TestQuestionPool/classes/class.assErrorText.php";
48 $this->object = new assErrorText();
49 $this->setErrorMessage($this->lng->txt("msg_form_save_error"));
50 if ($id >= 0) {
51 $this->object->loadFromDb($id);
52 }
53 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setErrorMessage(string $errormessage)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

231 : void
232 {
233 $this->writePostData(true);
235 $this->object->setErrorsFromParsedErrorText();
236 $this->editQuestion();
237 }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...

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

+ Here is the call graph for this function:

◆ editQuestion()

assErrorTextGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

Parameters
bool$checkonly
Returns
bool

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

123 : bool
124 {
125 $this->tabs->setTabActive('edit_question');
126 $save = $this->isSaveCommand();
127 $this->getQuestionTemplate();
128
129 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
130 $form = new ilPropertyFormGUI();
131 $this->editForm = $form;
132
133 $form->setFormAction($this->ctrl->getFormAction($this));
134 $form->setTitle($this->outQuestionType());
135 $form->setMultipart(false);
136 $form->setTableWidth("100%");
137 $form->setId("orderinghorizontal");
138
139 $this->addBasicQuestionFormProperties($form);
140
142
143 if (count($this->object->getErrorData()) || $checkonly) {
144 $this->populateAnswerSpecificFormPart($form);
145 }
146
147 $this->populateTaxonomyFormSection($form);
148
149 $form->addCommandButton("analyze", $this->lng->txt('analyze_errortext'));
150 $this->addQuestionFormCommandButtons($form);
151
152 $errors = false;
153
154 if ($save) {
155 $form->setValuesByPost();
156 $errors = !$form->checkInput();
157 $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
158 if ($errors) {
159 $checkonly = false;
160 }
161 }
162
163 if (!$checkonly) {
164 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
165 }
166 return $errors;
167 }
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
This class represents a property form user interface.
$errors
Definition: imgupload.php:65

References $errors, 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().

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

361 : string
362 {
363 $template = new ilTemplate("tpl.il_as_qpl_errortext_output.html", true, true, "Modules/TestQuestionPool");
364
365 if ($this->object->getTextSize() >= 10) {
366 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
367 }
368 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
369 $errortext = $this->object->assembleErrorTextOutput($selections);
370 if ($this->getTargetGuiClass() !== null) {
371 $this->ctrl->setParameterByClass($this->getTargetGuiClass(), 'errorvalue', '');
372 }
373 $template->setVariable("ERRORTEXT", $errortext);
374 $template->setVariable("ERRORTEXT_ID", "qst_" . $this->object->getId());
375 $template->setVariable("ERRORTEXT_VALUE", join(',', $selections['user']));
376
377 $this->tpl->addOnLoadCode('il.test.player.errortext.init()');
378 $this->tpl->addJavascript('./Modules/TestQuestionPool/templates/default/errortext.js');
379 $questionoutput = $template->get();
380
381 if ($show_question_only) {
382 return $questionoutput;
383 }
384
385 return $this->getILIASPage($questionoutput);
386 }
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 439 of file class.assErrorTextGUI.php.

439 : array
440 {
441 return [];
442 }

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

453 : array
454 {
455 return [];
456 }

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

464 : string
465 {
466 $errortext = $this->object->getErrorText();
467
468 $passdata = []; // Regroup answers into units of passes.
469 foreach ($relevant_answers as $answer_chosen) {
470 $passdata[$answer_chosen['active_fi'] . '-' . $answer_chosen['pass']][$answer_chosen['value2']][] = $answer_chosen['value1'];
471 }
472
473 $html = '';
474 foreach ($passdata as $key => $pass) {
475 $passdata[$key] = $this->object->createErrorTextOutput($pass);
476 $html .= $passdata[$key] . '<hr /><br />';
477 }
478
479 return $html;
480 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key.

◆ getAnswersFrequency()

assErrorTextGUI::getAnswersFrequency (   $relevant_answers,
  $question_index 
)

Reimplemented from assQuestionGUI.

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

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

References ILIAS\LTI\ToolProvider\$key.

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

333 : string
334 {
335 $selections = [
337 ];
338
339 return $this->generateQuestionOutput($selections, $show_question_only);
340 }
getUsersSolutionFromPreviewOrDatabase(int $active_id=0, ?int $pass=null)
generateQuestionOutput($selections, $show_question_only)

◆ getSolutionOutput()

assErrorTextGUI::getSolutionOutput (   $active_id,
  $pass = null,
  $graphical_output = false,
  $result_output = false,
  $show_question_only = true,
  $show_feedback = false,
  $show_correct_solution = false,
  $show_manual_scoring = false,
  $show_question_text = true 
)

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

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

Reimplemented from assQuestionGUI.

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

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

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

406 : string
407 {
408 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
409 return '';
410 }
411
412 $feedback = '<table class="test_specific_feedback"><tbody>';
413 $elements = $this->object->getErrorData();
414 foreach ($elements as $index => $element) {
415 $feedback .= '<tr>';
416 $feedback .= '<td class="text-nowrap">' . $index . '. ' . $element->getTextWrong() . ':</td>';
417 $feedback .= '<td>' . $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
418 $this->object->getId(),
419 0,
420 $index
421 ) . '</td>';
422
423 $feedback .= '</tr>';
424 }
425 $feedback .= '</tbody></table>';
426
427 return $this->object->prepareTextareaOutput($feedback, true);
428 }
$index
Definition: metadata.php:145

References $index, and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

348 : string {
349 $selections = [
350 'user' => $this->getUsersSolutionFromPreviewOrDatabase($active_id, $pass)
351 ];
352
353 return $this->outQuestionPage(
354 '',
355 $is_postponed,
356 $active_id,
357 $this->generateQuestionOutput($selections, false)
358 );
359 }
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 388 of file class.assErrorTextGUI.php.

388 : array
389 {
390 if (is_object($this->getPreviewSession())) {
391 return (array) $this->getPreviewSession()->getParticipantsSolution();
392 }
393
394 if ($active_id > 0) {
395 $selections = [];
396 $solutions = $this->object->getSolutionValues($active_id, $pass ?? 0, true);
397 foreach ($solutions as $solution) {
398 $selections[] = $solution['value1'];
399 }
400 return $selections;
401 }
402
403 return [];
404 }

◆ populateAnswerSpecificFormPart()

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

Implements ilGuiAnswerScoringAdjustable.

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

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

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

Referenced by editQuestion().

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

◆ populateCorrectionsFormProperties()

assErrorTextGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

514 : void
515 {
516 // error terms
517 include_once "./Modules/TestQuestionPool/classes/forms/class.ilAssErrorTextCorrectionsInputGUI.php";
518 $errordata = new ilAssErrorTextCorrectionsInputGUI($this->lng->txt('errors'), 'errordata');
519 $errordata->setKeyName($this->lng->txt('text_wrong'));
520 $errordata->setValueName($this->lng->txt('text_correct'));
521 $errordata->setValues($this->object->getErrorData());
522 $form->addItem($errordata);
523
524 // points for wrong selection
525 $points_wrong = new ilNumberInputGUI($this->lng->txt('points_wrong'), 'points_wrong');
526 $points_wrong->allowDecimals(true);
527 $points_wrong->setMaxValue(0);
528 $points_wrong->setMaxvalueShouldBeLess(true);
529 $points_wrong->setValue($this->object->getPointsWrong());
530 $points_wrong->setInfo($this->lng->txt('points_wrong_info'));
531 $points_wrong->setSize(6);
532 $points_wrong->setRequired(true);
533 $form->addItem($points_wrong);
534 }

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

204 {
205 // errortext
206 $errortext = new ilTextAreaInputGUI($this->lng->txt("errortext"), "errortext");
207 $errortext->setValue($this->object->getErrorText());
208 $errortext->setRequired(true);
209 $errortext->setInfo($this->lng->txt("errortext_info"));
210 $errortext->setRows(10);
211 $errortext->setCols(80);
212 $form->addItem($errortext);
213
214 if (!$this->object->getSelfAssessmentEditingMode()) {
215 // textsize
216 $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
217 $textsize->setValue(mb_strlen($this->object->getTextSize()) ? $this->object->getTextSize() : 100.0);
218 $textsize->setInfo($this->lng->txt("textsize_errortext_info"));
219 $textsize->setSize(6);
220 $textsize->setSuffix("%");
221 $textsize->setMinValue(10);
222 $textsize->setRequired(true);
223 $form->addItem($textsize);
224 }
225 return $form;
226 }
This class represents a text area property in a property form.

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

Referenced by editQuestion().

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

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

References ILIAS\LTI\ToolProvider\$key, $keys, and $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 539 of file class.assErrorTextGUI.php.

539 : void
540 {
541 $existing_errordata = $this->object->getErrorData();
542 $this->object->flushErrorData();
543 $new_errordata = $this->request->raw('errordata');
544 $errordata = [];
545 foreach ($new_errordata['points'] as $index => $points) {
546 $errordata[$index] = $existing_errordata[$index]->withPoints(
547 (float) str_replace(',', '.', $points)
548 );
549 }
550 $this->object->setErrorData($errordata);
551 $this->object->setPointsWrong((float) str_replace(',', '.', $form->getInput('points_wrong')));
552 }
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 $index, and ilPropertyFormGUI\getInput().

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

72 : void
73 {
74 $errordata = $this->restructurePostDataForSaving($this->request->raw('errordata') ?? []);
75 $this->object->setErrorData($errordata);
76 $this->object->removeErrorDataWithoutPosition();
77 }
restructurePostDataForSaving(array $post)

References 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 58 of file class.assErrorTextGUI.php.

58 : int
59 {
60 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
61 if (!$hasErrors) {
62 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
67 return 0;
68 }
69 return 1;
70 }
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.

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

Referenced by analyze().

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

◆ writeQuestionSpecificPostData()

assErrorTextGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

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

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

References DEFAULT_POINTS_WRONG, and 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 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.

Referenced by writeQuestionSpecificPostData().


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