ILIAS  release_8 Revision v8.24
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 ($checkonly=false)
 Creates an output of the edit form for the question. More...
 
 checkRange ($lower, $upper)
 Checks the range limits. More...
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 Get the question solution output. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $inlineFeedback=false)
 
 getSpecificFeedbackOutput (array $userSolution)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from $_POST and applies them to the data object. More...
 
 writeAnswerSpecificPostData (ilPropertyFormGUI $form)
 Extracts the answer specific values from $_POST 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...
 
 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...
 
 aggregateAnswers ($relevant_answers_chosen)
 
 renderAggregateView ($aggregate)
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 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)
 
- Public Member Functions inherited from ilGuiQuestionScoringAdjustable
 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...
 
- Public Member Functions inherited from ilGuiAnswerScoringAdjustable
 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 ()
 

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 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$

@ilCtrl_Calls assNumericGUI: ilFormPropertyDispatchGUI

Definition at line 36 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 45 of file class.assNumericGUI.php.

46 {
48 require_once './Modules/TestQuestionPool/classes/class.assNumeric.php';
49 $this->object = new assNumeric();
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...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ aggregateAnswers()

assNumericGUI::aggregateAnswers (   $relevant_answers_chosen)

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

430 : array
431 {
432 $aggregate = array();
433
434 foreach ($relevant_answers_chosen as $relevant_answer) {
435 if (array_key_exists($relevant_answer['value1'], $aggregate)) {
436 $aggregate[$relevant_answer['value1']]++;
437 } else {
438 $aggregate[$relevant_answer['value1']] = 1;
439 }
440 }
441 return $aggregate;
442 }

◆ checkRange()

assNumericGUI::checkRange (   $lower,
  $upper 
)

Checks the range limits.

Checks the Range limits Upper and Lower for their correctness

Returns
boolean

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

144 : bool
145 {
146 include_once "./Services/Math/classes/class.EvalMath.php";
147 $eval = new EvalMath();
148 $eval->suppress_errors = true;
149 if (($eval->e($lower) !== false) and ($eval->e($upper) !== false)) {
150 if ($eval->e($lower) <= $eval->e($upper)) {
151 return true;
152 } else {
153 return false;
154 }
155 }
156 return false;
157 }

Referenced by editQuestion().

+ Here is the caller graph for this function:

◆ editQuestion()

assNumericGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

Parameters
bool$checkonly
Returns
bool

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

87 : bool
88 {
89 $save = $this->isSaveCommand();
90 $this->getQuestionTemplate();
91
92 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
93 $form = new ilPropertyFormGUI();
94 $this->editForm = $form;
95
96 $form->setFormAction($this->ctrl->getFormAction($this));
97 $form->setTitle($this->outQuestionType());
98 $form->setMultipart(true);
99 $form->setTableWidth("100%");
100 $form->setId("assnumeric");
101
102 $this->addBasicQuestionFormProperties($form);
104 $this->populateAnswerSpecificFormPart($form);
105 $this->populateTaxonomyFormSection($form);
106 $this->addQuestionFormCommandButtons($form);
107
108 $errors = false;
109
110 if ($save) {
111 $form->setValuesByPost();
112 $errors = !$form->checkInput();
113 $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
114
115 $lower = $form->getItemByPostVar('lowerlimit');
116 $upper = $form->getItemByPostVar('upperlimit');
117
118 if (!$this->checkRange($lower->getValue(), $upper->getValue())) {
119 global $DIC;
120 $lower->setAlert($DIC->language()->txt('qpl_numeric_lower_needs_valid_lower_alert'));
121 $upper->setAlert($DIC->language()->txt('qpl_numeric_upper_needs_valid_upper_alert'));
122 $this->tpl->setOnScreenMessage('failure', $DIC->language()->txt("form_input_not_valid"));
123 $errors = true;
124 }
125
126 if ($errors) {
127 $checkonly = false;
128 }
129 }
130
131 if (!$checkonly) {
132 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
133 }
134 return $errors;
135 }
checkRange($lower, $upper)
Checks the range limits.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
This class represents a property form user interface.
global $DIC
Definition: feed.php:28
$errors
Definition: imgupload.php:65

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

Referenced by writePostData().

+ 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 398 of file class.assNumericGUI.php.

398 : array
399 {
400 return array();
401 }

◆ 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 412 of file class.assNumericGUI.php.

412 : array
413 {
414 return array();
415 }

◆ getAggregatedAnswersView()

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

423 : string
424 {
425 return $this->renderAggregateView(
426 $this->aggregateAnswers($relevant_answers)
427 )->get();
428 }
aggregateAnswers($relevant_answers_chosen)
renderAggregateView($aggregate)

◆ getAnswersFrequency()

assNumericGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

470 : array
471 {
472 $answers = array();
473
474 foreach ($relevantAnswers as $ans) {
475 if (!isset($answers[$ans['value1']])) {
476 $answers[$ans['value1']] = array(
477 'answer' => $ans['value1'], 'frequency' => 0
478 );
479 }
480
481 $answers[$ans['value1']]['frequency']++;
482 }
483
484 return $answers;
485 }

◆ getCommand()

assNumericGUI::getCommand (   $cmd)

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

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

◆ getPreview()

assNumericGUI::getPreview (   $show_question_only = false,
  $showInlineFeedback = false 
)
Parameters
bool$show_question_only
Returns
string

Reimplemented from assQuestionGUI.

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

252 : string
253 {
254 // generate the question output
255 require_once './Services/UICore/classes/class.ilTemplate.php';
256 $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "Modules/TestQuestionPool");
257 if (is_object($this->getPreviewSession())) {
258 $template->setVariable("NUMERIC_VALUE", " value=\"" . $this->getPreviewSession()->getParticipantsSolution() . "\"");
259 }
260 $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
261 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
262 $questionoutput = $template->get();
263 if (!$show_question_only) {
264 // get page object output
265 $questionoutput = $this->getILIASPage($questionoutput);
266 }
267 return $questionoutput;
268 }
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getSolutionOutput()

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

Get the question solution output.

Parameters
integer$active_idThe active user id
integer$passThe test pass
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
bool$show_question_text
Returns
string The solution output of the question as HTML code

Reimplemented from assQuestionGUI.

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

182 : string {
183 // get the solution of the user for the active pass or from the last pass if allowed
184 $solutions = array();
185 if (($active_id > 0) && (!$show_correct_solution)) {
186 $solutions = $this->object->getSolutionValues($active_id, $pass);
187 } else {
188 array_push($solutions, array("value1" => sprintf($this->lng->txt("value_between_x_and_y"), $this->object->getLowerLimit(), $this->object->getUpperLimit())));
189 }
190
191 // generate the question output
192 require_once './Services/UICore/classes/class.ilTemplate.php';
193 $template = new ilTemplate("tpl.il_as_qpl_numeric_output_solution.html", true, true, "Modules/TestQuestionPool");
194 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
195 if (is_array($solutions)) {
196 if (($active_id > 0) && (!$show_correct_solution)) {
197 if ($graphicalOutput) {
198 if ($this->object->getStep() === null) {
199 $reached_points = $this->object->getReachedPoints($active_id, $pass);
200 } else {
201 $reached_points = $this->object->calculateReachedPoints($active_id, $pass);
202 }
203
204 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
205 if ($reached_points == $this->object->getMaximumPoints()) {
206 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
207 }
208 $template->setCurrentBlock("icon_ok");
209 $template->setVariable("ICON_OK", $correctness_icon);
210 $template->parseCurrentBlock();
211 }
212 }
213 foreach ($solutions as $solution) {
214 $template->setVariable("NUMERIC_VALUE", $solution["value1"]);
215 }
216 if (count($solutions) == 0) {
217 $template->setVariable("NUMERIC_VALUE", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
218 }
219 }
220 $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
221 if ($show_question_text == true) {
222 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
223 }
224 $questionoutput = $template->get();
225 //$feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : ""; // Moving new method
226 // due to deprecation.
227 $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
228 if (strlen($feedback)) {
229 $cssClass = (
230 $this->hasCorrectSolution($active_id, $pass) ?
232 );
233
234 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
235 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
236 }
237 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
238
239 $solutionoutput = $solutiontemplate->get();
240 if (!$show_question_only) {
241 // get page object output
242 $solutionoutput = $this->getILIASPage($solutionoutput);
243 }
244 return $solutionoutput;
245 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)

◆ getSpecificFeedbackOutput()

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

Reimplemented from assQuestionGUI.

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

313 : string
314 {
315 $output = "";
316 return $this->object->prepareTextareaOutput($output, true);
317 }

◆ getTestOutput()

assNumericGUI::getTestOutput (   $active_id,
  $pass,
  $is_postponed = false,
  $use_post_solutions = false,
  $inlineFeedback = false 
)
Parameters
integer$active_id
integer | null$pass
bool$is_postponed
bool$use_post_solutions
Returns
string

@noinspection PhpArrayAccessOnIllegalTypeInspection

Reimplemented from assQuestionGUI.

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

279 : string
280 // hey.
281 {
282 $solutions = null;
283 // get the solution of the user for the active pass or from the last pass if allowed
284 if ($use_post_solutions !== false) {
286 $solutions = array(
287 array('value1' => $use_post_solutions['numeric_result'])
288 );
289 } elseif ($active_id) {
290 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
291 }
292
293 // generate the question output
294 require_once './Services/UICore/classes/class.ilTemplate.php';
295 $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "Modules/TestQuestionPool");
296 if (is_array($solutions)) {
297 foreach ($solutions as $solution) {
298 $template->setVariable("NUMERIC_VALUE", " value=\"" . $solution["value1"] . "\"");
299 }
300 }
301 $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
302 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
303 $questionoutput = $template->get();
304 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
305 return $pageoutput;
306 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assNumericGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

348 {
349 // points
350 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
351 $points->allowDecimals(true);
352 $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
353 $points->setRequired(true);
354 $points->setSize(3);
355 $points->setMinValue(0.0);
356 $points->setMinvalueShouldBeGreater(true);
357 $form->addItem($points);
358
359 $header = new ilFormSectionHeaderGUI();
360 $header->setTitle($this->lng->txt("range"));
361 $form->addItem($header);
362
363 // lower bound
364 $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
365 $lower_limit->setSize(25);
366 $lower_limit->setMaxLength(20);
367 $lower_limit->setRequired(true);
368 $lower_limit->setValue((string) $this->object->getLowerLimit());
369 $form->addItem($lower_limit);
370
371 // upper bound
372 $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
373 $upper_limit->setSize(25);
374 $upper_limit->setMaxLength(20);
375 $upper_limit->setRequired(true);
376 $upper_limit->setValue((string) $this->object->getUpperLimit());
377 $form->addItem($upper_limit);
378
379 // reset input length, if max chars are set
380 if ($this->object->getMaxChars() > 0) {
381 $lower_limit->setSize($this->object->getMaxChars());
382 $lower_limit->setMaxLength($this->object->getMaxChars());
383 $upper_limit->setSize($this->object->getMaxChars());
384 $upper_limit->setMaxLength($this->object->getMaxChars());
385 }
386 return $form;
387 }
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()

assNumericGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

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

487 : void
488 {
489 // points
490 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
491 $points->allowDecimals(true);
492 $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
493 $points->setRequired(true);
494 $points->setSize(3);
495 $points->setMinValue(0.0);
496 $points->setMinvalueShouldBeGreater(true);
497 $form->addItem($points);
498
499 $header = new ilFormSectionHeaderGUI();
500 $header->setTitle($this->lng->txt("range"));
501 $form->addItem($header);
502
503 // lower bound
504 $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
505 $lower_limit->setSize(25);
506 $lower_limit->setMaxLength(20);
507 $lower_limit->setRequired(true);
508 $lower_limit->setValue($this->object->getLowerLimit());
509 $form->addItem($lower_limit);
510
511 // upper bound
512 $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
513 $upper_limit->setSize(25);
514 $upper_limit->setMaxLength(20);
515 $upper_limit->setRequired(true);
516 $upper_limit->setValue($this->object->getUpperLimit());
517 $form->addItem($upper_limit);
518
519 // reset input length, if max chars are set
520 if ($this->object->getMaxChars() > 0) {
521 $lower_limit->setSize($this->object->getMaxChars());
522 $lower_limit->setMaxLength($this->object->getMaxChars());
523 $upper_limit->setSize($this->object->getMaxChars());
524 $upper_limit->setMaxLength($this->object->getMaxChars());
525 }
526 }

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

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assNumericGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

332 {
333 // maxchars
334 $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
335 $maxchars->setInfo($this->lng->txt('qpl_maxchars_info_numeric_question'));
336 $maxchars->setSize(10);
337 $maxchars->setDecimals(0);
338 $maxchars->setMinValue(1);
339 $maxchars->setRequired(true);
340 if ($this->object->getMaxChars() > 0) {
341 $maxchars->setValue($this->object->getMaxChars());
342 }
343 $form->addItem($maxchars);
344 return $form;
345 }

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:

◆ renderAggregateView()

assNumericGUI::renderAggregateView (   $aggregate)
Parameters
$aggregate
Returns
ilTemplate

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

449 : ilTemplate
450 {
451 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
452
453 $tpl->setCurrentBlock('headercell');
454 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
456
457 $tpl->setCurrentBlock('headercell');
458 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
460
461 foreach ($aggregate as $key => $value) {
462 $tpl->setCurrentBlock('aggregaterow');
463 $tpl->setVariable('OPTION', $key);
464 $tpl->setVariable('COUNT', $value);
466 }
467 return $tpl;
468 }
ilGlobalPageTemplate $tpl
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, $tpl, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

531 : void
532 {
533 $this->object->setPoints((float) str_replace(',', '.', $form->getInput('points')));
534 $this->object->setLowerLimit((float) str_replace(',', '.', $form->getInput('lowerlimit')));
535 $this->object->setUpperLimit((float) str_replace(',', '.', $form->getInput('upperlimit')));
536 }
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()

assNumericGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiAnswerScoringAdjustable.

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

324 : void
325 {
326 $this->object->setLowerLimit($_POST['lowerlimit']);
327 $this->object->setUpperLimit($_POST['upperlimit']);
328 $this->object->setPoints((float) str_replace(',', '.', $_POST['points']));
329 }

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ writePostData()

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

66 : int
67 {
68 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
69 if (!$hasErrors) {
70 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
75 return 0;
76 }
77 return 1;
78 }
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
editQuestion($checkonly=false)
Creates an output of the edit form for the question.

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

+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assNumericGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

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

319 : void
320 {
321 $this->object->setMaxChars($_POST["maxchars"]);
322 }

Referenced by writePostData().

+ Here is the caller graph for this function:

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