ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
assNumericGUI 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 assNumericGUI:
+ Collaboration diagram for assNumericGUI:

Public Member Functions

 __construct ($id=-1)
 assNumericGUI constructor More...
 
 getCommand ($cmd)
 
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 checkRange (float $lower, float $upper)
 
 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 $userSolution)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from the request and applies them to the data object. More...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 populateAnswerSpecificFormPart (\ilPropertyFormGUI $form)
 
 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...
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 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 ()
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 Adds the answer specific form parts to a question property form gui. More...
 

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 ()
 
 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 ()
 

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 Numeric question GUI representation

The assNumericGUI class encapsulates the GUI representation for numeric 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
Nina Gharib nina@.nosp@m.wgse.nosp@m.rve.d.nosp@m.e
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$

\ assNumericGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assNumericGUI::__construct (   $id = -1)

assNumericGUI constructor

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

Parameters
integer$idThe database id of a Numeric question object

Definition at line 44 of file class.assNumericGUI.php.

References $id, and ILIAS\GlobalScreen\Provider\__construct().

45  {
47  $this->object = new assNumeric();
48  if ($id >= 0) {
49  $this->object->loadFromDb($id);
50  }
51  }
Class for numeric questions.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkRange()

assNumericGUI::checkRange ( float  $lower,
float  $upper 
)

Definition at line 135 of file class.assNumericGUI.php.

Referenced by editQuestion().

135  : bool
136  {
137  $eval = new EvalMath();
138  $eval->suppress_errors = true;
139  if (($eval->e($lower) !== false) and ($eval->e($upper) !== false)) {
140  if ($eval->e($lower) <= $eval->e($upper)) {
141  return true;
142  } else {
143  return false;
144  }
145  }
146  return false;
147  }
+ Here is the caller graph for this function:

◆ editQuestion()

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

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

References $DIC, assQuestionGUI\addBasicQuestionFormProperties(), assQuestionGUI\addQuestionFormCommandButtons(), checkRange(), ILIAS\Repository\ctrl(), assQuestionGUI\isSaveCommand(), assQuestionGUI\outQuestionType(), populateAnswerSpecificFormPart(), populateQuestionSpecificFormPart(), assQuestionGUI\populateTaxonomyFormSection(), ILIAS\Repository\refinery(), and assQuestionGUI\renderEditForm().

Referenced by writePostData().

80  : bool {
81  $save = $is_save_cmd ?? $this->isSaveCommand();
82 
83  $form = new ilPropertyFormGUI();
84  $this->editForm = $form;
85 
86  $form->setFormAction($this->ctrl->getFormAction($this));
87  $form->setTitle($this->outQuestionType());
88  $form->setMultipart(true);
89  $form->setTableWidth("100%");
90  $form->setId("assnumeric");
91 
92  $this->addBasicQuestionFormProperties($form);
94  $this->populateAnswerSpecificFormPart($form);
95  $this->populateTaxonomyFormSection($form);
96  $this->addQuestionFormCommandButtons($form);
97 
98  $errors = false;
99 
100  if ($save) {
101  $form->setValuesByPost();
102  $errors = !$form->checkInput();
103  $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
104 
105  $lower = $form->getItemByPostVar('lowerlimit');
106  $upper = $form->getItemByPostVar('upperlimit');
107 
108  $to_float_trafo = $this->refinery->byTrying([
109  $this->refinery->kindlyTo()->float(),
110  $this->refinery->always(0.0)
111  ]);
112 
113  if (!$this->checkRange(
114  $to_float_trafo->transform($lower->getValue()),
115  $to_float_trafo->transform($upper->getValue())
116  )) {
117  global $DIC;
118  $lower->setAlert($DIC->language()->txt('qpl_numeric_lower_needs_valid_lower_alert'));
119  $upper->setAlert($DIC->language()->txt('qpl_numeric_upper_needs_valid_upper_alert'));
120  $this->tpl->setOnScreenMessage('failure', $DIC->language()->txt("form_input_not_valid"));
121  $errors = true;
122  }
123 
124  if ($errors) {
125  $checkonly = false;
126  }
127  }
128 
129  if (!$checkonly) {
130  $this->renderEditForm($form);
131  }
132  return $errors;
133  }
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
global $DIC
Definition: shib_login.php:26
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
checkRange(float $lower, float $upper)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
renderEditForm(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionAnswerPostVars()

assNumericGUI::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 400 of file class.assNumericGUI.php.

400  : array
401  {
402  return [];
403  }

◆ getAfterParticipationSuppressionQuestionPostVars()

assNumericGUI::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 414 of file class.assNumericGUI.php.

414  : array
415  {
416  return [];
417  }

◆ getAnswersFrequency()

assNumericGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Definition at line 419 of file class.assNumericGUI.php.

419  : array
420  {
421  $answers = [];
422 
423  foreach ($relevantAnswers as $ans) {
424  if (!isset($answers[$ans['value1']])) {
425  $answers[$ans['value1']] = [
426  'answer' => $ans['value1'], 'frequency' => 0
427  ];
428  }
429 
430  $answers[$ans['value1']]['frequency']++;
431  }
432 
433  return $answers;
434  }

◆ getCommand()

assNumericGUI::getCommand (   $cmd)

Definition at line 53 of file class.assNumericGUI.php.

54  {
55  if (substr($cmd, 0, 6) == "delete") {
56  $cmd = "delete";
57  }
58  return $cmd;
59  }

◆ getPreview()

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

Definition at line 259 of file class.assNumericGUI.php.

References assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), ILIAS\Repository\object(), and assQuestionGUI\renderLatex().

262  : string {
263  // generate the question output
264  $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "components/ILIAS/TestQuestionPool");
265  if (is_object($this->getPreviewSession())) {
266  $template->setVariable("NUMERIC_VALUE", " value=\"" . $this->getPreviewSession()->getParticipantsSolution() . "\"");
267  }
268  $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
269  $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
270  $questionoutput = $template->get();
271  if (!$show_question_only) {
272  // get page object output
273  $questionoutput = $this->getILIASPage($questionoutput);
274  }
275  return $questionoutput;
276  }
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.
+ Here is the call graph for this function:

◆ getSolutionOutput()

assNumericGUI::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 
)

Definition at line 149 of file class.assNumericGUI.php.

References ILIAS\Repository\lng(), and renderSolutionOutput().

160  : string {
161  // get the solution of the user for the active pass or from the last pass if allowed
162  $solutions = [];
163  if (($active_id > 0) && (!$show_correct_solution)) {
164  $solutions = $this->object->getSolutionValues($active_id, $pass);
165  } else {
166  array_push($solutions, [
167  'value1' => sprintf(
168  $this->lng->txt("value_between_x_and_y"),
169  $this->object->getLowerLimit(),
170  $this->object->getUpperLimit()
171  )
172  ]);
173  }
174 
175  return $this->renderSolutionOutput(
176  $solutions,
177  $active_id,
178  $pass,
179  $graphical_output,
180  $result_output,
181  $show_question_only,
182  $show_feedback,
183  $show_correct_solution,
184  $show_manual_scoring,
185  $show_question_text,
186  false,
187  $show_inline_feedback
188  );
189  }
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,)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assNumericGUI::getSpecificFeedbackOutput ( array  $userSolution)
Parameters
int$active_id
int$pass
Returns
string

Definition at line 315 of file class.assNumericGUI.php.

References ilLegacyFormElementsUtil\prepareTextareaOutput().

315  : string
316  {
317  $output = "";
319  }
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:

◆ getTestOutput()

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

PhpArrayAccessOnIllegalTypeInspection

Definition at line 278 of file class.assNumericGUI.php.

References null, ILIAS\Repository\object(), assQuestionGUI\outQuestionPage(), and assQuestionGUI\renderLatex().

284  : string {
285  $solutions = null;
286  // get the solution of the user for the active pass or from the last pass if allowed
287  if ($user_post_solutions !== false) {
289  $solutions = [
290  ['value1' => $user_post_solutions['numeric_result']]
291  ];
292  } elseif ($active_id) {
293  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
294  }
295 
296  // generate the question output
297  $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "components/ILIAS/TestQuestionPool");
298  if (is_array($solutions)) {
299  foreach ($solutions as $solution) {
300  $template->setVariable("NUMERIC_VALUE", " value=\"" . $solution['value1'] . "\"");
301  }
302  }
303  $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
304  $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
305  $questionoutput = $template->get();
306  $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
307  return $pageoutput;
308  }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assNumericGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 349 of file class.assNumericGUI.php.

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\allowDecimals(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilTextInputGUI\setSize().

Referenced by editQuestion().

350  {
351  // points
352  $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
353  $points->allowDecimals(true);
354  $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
355  $points->setRequired(true);
356  $points->setSize(3);
357  $points->setMinValue(0.0);
358  $points->setMinvalueShouldBeGreater(true);
359  $form->addItem($points);
360 
361  $header = new ilFormSectionHeaderGUI();
362  $header->setTitle($this->lng->txt("range"));
363  $form->addItem($header);
364 
365  // lower bound
366  $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
367  $lower_limit->setSize(25);
368  $lower_limit->setMaxLength(20);
369  $lower_limit->setRequired(true);
370  $lower_limit->setValue((string) $this->object->getLowerLimit());
371  $form->addItem($lower_limit);
372 
373  // upper bound
374  $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
375  $upper_limit->setSize(25);
376  $upper_limit->setMaxLength(20);
377  $upper_limit->setRequired(true);
378  $upper_limit->setValue((string) $this->object->getUpperLimit());
379  $form->addItem($upper_limit);
380 
381  // reset input length, if max chars are set
382  if ($this->object->getMaxChars() > 0) {
383  $lower_limit->setSize($this->object->getMaxChars());
384  $lower_limit->setMaxLength($this->object->getMaxChars());
385  $upper_limit->setSize($this->object->getMaxChars());
386  $upper_limit->setMaxLength($this->object->getMaxChars());
387  }
388  return $form;
389  }
This class represents a formula text property in a property form.
allowDecimals(bool $a_value)
This class represents a number property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assNumericGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Definition at line 436 of file class.assNumericGUI.php.

References ilPropertyFormGUI\addItem(), ilNumberInputGUI\allowDecimals(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilTextInputGUI\setSize().

436  : void
437  {
438  // points
439  $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
440  $points->allowDecimals(true);
441  $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
442  $points->setRequired(true);
443  $points->setSize(3);
444  $points->setMinValue(0.0);
445  $points->setMinvalueShouldBeGreater(true);
446  $form->addItem($points);
447 
448  $header = new ilFormSectionHeaderGUI();
449  $header->setTitle($this->lng->txt("range"));
450  $form->addItem($header);
451 
452  // lower bound
453  $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
454  $lower_limit->setSize(25);
455  $lower_limit->setMaxLength(20);
456  $lower_limit->setRequired(true);
457  $lower_limit->setValue($this->object->getLowerLimit());
458  $form->addItem($lower_limit);
459 
460  // upper bound
461  $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
462  $upper_limit->setSize(25);
463  $upper_limit->setMaxLength(20);
464  $upper_limit->setRequired(true);
465  $upper_limit->setValue($this->object->getUpperLimit());
466  $form->addItem($upper_limit);
467 
468  // reset input length, if max chars are set
469  if ($this->object->getMaxChars() > 0) {
470  $lower_limit->setSize($this->object->getMaxChars());
471  $lower_limit->setMaxLength($this->object->getMaxChars());
472  $upper_limit->setSize($this->object->getMaxChars());
473  $upper_limit->setMaxLength($this->object->getMaxChars());
474  }
475  }
This class represents a formula text property in a property form.
allowDecimals(bool $a_value)
This class represents a number property in a property form.
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assNumericGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

334  {
335  // maxchars
336  $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
337  $maxchars->setInfo($this->lng->txt('qpl_maxchars_info_numeric_question'));
338  $maxchars->setSize(10);
339  $maxchars->setDecimals(0);
340  $maxchars->setMinValue(1);
341  $maxchars->setRequired(true);
342  if ($this->object->getMaxChars() > 0) {
343  $maxchars->setValue($this->object->getMaxChars());
344  }
345  $form->addItem($maxchars);
346  return $form;
347  }
This class represents a number property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSolutionOutput()

assNumericGUI::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 191 of file class.assNumericGUI.php.

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

Referenced by getSolutionOutput().

204  : ?string {
205  $template = new ilTemplate("tpl.il_as_qpl_numeric_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
206  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
207  if (is_array($user_solutions)) {
208  if (($active_id > 0) && (!$show_correct_solution)) {
209  if ($graphical_output) {
210  if ($this->object->getStep() === null) {
211  $reached_points = $this->object->getReachedPoints($active_id, $pass);
212  } else {
213  $reached_points = $this->object->calculateReachedPoints($active_id, $pass);
214  }
215 
216  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
217  if ($reached_points == $this->object->getMaximumPoints()) {
218  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
219  }
220  $template->setCurrentBlock("icon_ok");
221  $template->setVariable("ICON_OK", $correctness_icon);
222  $template->parseCurrentBlock();
223  }
224  }
225  foreach ($user_solutions as $solution) {
226  $template->setVariable("NUMERIC_VALUE", $solution['value1']);
227  }
228  if (count($user_solutions) == 0) {
229  $template->setVariable("NUMERIC_VALUE", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
230  }
231  }
232  $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
233  if ($show_question_text == true) {
234  $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
235  }
236  $questionoutput = $template->get();
237  //$feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : ""; // Moving new method
238  // due to deprecation.
239  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
240  if (strlen($feedback)) {
241  $cssClass = (
242  $this->hasCorrectSolution($active_id, $pass) ?
244  );
245 
246  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
247  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
248  }
249  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
250 
251  $solutionoutput = $solutiontemplate->get();
252  if (!$show_question_only) {
253  // get page object output
254  $solutionoutput = $this->getILIASPage($solutionoutput);
255  }
256  return $solutionoutput;
257  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
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:

◆ saveCorrectionsFormProperties()

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

Definition at line 480 of file class.assNumericGUI.php.

References ilPropertyFormGUI\getInput().

480  : void
481  {
482  $this->object->setPoints((float) str_replace(',', '.', $form->getInput('points')));
483  $this->object->setLowerLimit((float) str_replace(',', '.', $form->getInput('lowerlimit')));
484  $this->object->setUpperLimit((float) str_replace(',', '.', $form->getInput('upperlimit')));
485  }
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()

assNumericGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

Definition at line 326 of file class.assNumericGUI.php.

Referenced by writePostData().

326  : void
327  {
328  $this->object->setLowerLimit($this->request_data_collector->float('lowerlimit'));
329  $this->object->setUpperLimit($this->request_data_collector->float('upperlimit'));
330  $this->object->setPoints($this->request_data_collector->float('points'));
331  }
+ Here is the caller graph for this function:

◆ writePostData()

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

{}

Definition at line 64 of file class.assNumericGUI.php.

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

64  : int
65  {
66  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
67  if (!$hasErrors) {
71  $this->saveTaxonomyAssignments();
72  return 0;
73  }
74  return 1;
75  }
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...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assNumericGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

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

Referenced by writePostData().

321  : void
322  {
323  $this->object->setMaxChars($this->request_data_collector->int('maxchars') ?? 6);
324  }
+ Here is the caller graph for this function:

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