ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $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 ()
 
 geCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 cancel ()
 
 originalSyncForm (string $return_to="", string $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 
 save ()
 
 saveReturn ()
 
 apply ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 outAdditionalOutput ()
 Why are you here? Some magic for plugins? More...
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addNewIdListener ($a_object, string $a_method, string $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners (int $a_new_id)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 suggestedsolution ()
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 
- 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 ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 getSuggestedSolutionsRepo ()
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI (string $question_type='', int $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput (?string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
- Protected Attributes inherited from assQuestionGUI
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ilLogger $logger
 
ILIAS TestQuestionPool QuestionInfoService $questioninfo
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
Refinery $refinery
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 
bool $parent_type_is_lm = false
 
assQuestionSuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Detailed Description

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

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

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

References $id, and ILIAS\MetaData\Repository\Validation\Data\__construct().

47  {
49  $this->object = new assNumeric();
50  if ($id >= 0) {
51  $this->object->loadFromDb($id);
52  }
53  }
__construct(VocabulariesInterface $vocabularies)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Member Function Documentation

◆ aggregateAnswers()

assNumericGUI::aggregateAnswers (   $relevant_answers_chosen)

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

Referenced by getAggregatedAnswersView().

459  : array
460  {
461  $aggregate = [];
462 
463  foreach ($relevant_answers_chosen as $relevant_answer) {
464  if (array_key_exists($relevant_answer['value1'], $aggregate)) {
465  $aggregate[$relevant_answer['value1']]++;
466  } else {
467  $aggregate[$relevant_answer['value1']] = 1;
468  }
469  }
470  return $aggregate;
471  }
+ Here is the caller graph for this function:

◆ checkRange()

assNumericGUI::checkRange (   $lower,
  $upper 
)

Checks the range limits.

Checks the Range limits Upper and Lower for their correctness

Returns
boolean

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

Referenced by editQuestion().

142  : bool
143  {
144  $eval = new EvalMath();
145  $eval->suppress_errors = true;
146  if (($eval->e($lower) !== false) and ($eval->e($upper) !== false)) {
147  if ($eval->e($lower) <= $eval->e($upper)) {
148  return true;
149  } else {
150  return false;
151  }
152  }
153  return false;
154  }
+ 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 86 of file class.assNumericGUI.php.

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

Referenced by writePostData().

86  : bool
87  {
88  $save = $this->isSaveCommand();
89  $this->getQuestionTemplate();
90 
91  $form = new ilPropertyFormGUI();
92  $this->editForm = $form;
93 
94  $form->setFormAction($this->ctrl->getFormAction($this));
95  $form->setTitle($this->outQuestionType());
96  $form->setMultipart(true);
97  $form->setTableWidth("100%");
98  $form->setId("assnumeric");
99 
100  $this->addBasicQuestionFormProperties($form);
101  $this->populateQuestionSpecificFormPart($form);
102  $this->populateAnswerSpecificFormPart($form);
103  $this->populateTaxonomyFormSection($form);
104  $this->addQuestionFormCommandButtons($form);
105 
106  $errors = false;
107 
108  if ($save) {
109  $form->setValuesByPost();
110  $errors = !$form->checkInput();
111  $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
112 
113  $lower = $form->getItemByPostVar('lowerlimit');
114  $upper = $form->getItemByPostVar('upperlimit');
115 
116  if (!$this->checkRange($lower->getValue(), $upper->getValue())) {
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->tpl->setVariable("QUESTION_DATA", $form->getHTML());
131  }
132  return $errors;
133  }
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
global $DIC
Definition: feed.php:28
checkRange($lower, $upper)
Checks the range limits.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\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 427 of file class.assNumericGUI.php.

427  : array
428  {
429  return [];
430  }

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

441  : array
442  {
443  return [];
444  }

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

References aggregateAnswers(), and renderAggregateView().

452  : string
453  {
454  return $this->renderAggregateView(
455  $this->aggregateAnswers($relevant_answers)
456  )->get();
457  }
aggregateAnswers($relevant_answers_chosen)
renderAggregateView($aggregate)
+ Here is the call graph for this function:

◆ getAnswersFrequency()

assNumericGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

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

499  : array
500  {
501  $answers = [];
502 
503  foreach ($relevantAnswers as $ans) {
504  if (!isset($answers[$ans['value1']])) {
505  $answers[$ans['value1']] = array(
506  'answer' => $ans['value1'], 'frequency' => 0
507  );
508  }
509 
510  $answers[$ans['value1']]['frequency']++;
511  }
512 
513  return $answers;
514  }

◆ 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

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

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

283  : string
284  {
285  // generate the question output
286  $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "Modules/TestQuestionPool");
287  if (is_object($this->getPreviewSession())) {
288  $template->setVariable("NUMERIC_VALUE", " value=\"" . $this->getPreviewSession()->getParticipantsSolution() . "\"");
289  }
290  $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
291  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
292  $questionoutput = $template->get();
293  if (!$show_question_only) {
294  // get page object output
295  $questionoutput = $this->getILIASPage($questionoutput);
296  }
297  return $questionoutput;
298  }
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
+ 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

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

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

179  : string {
180  // get the solution of the user for the active pass or from the last pass if allowed
181  $solutions = [];
182  if (($active_id > 0) && (!$show_correct_solution)) {
183  $solutions = $this->object->getSolutionValues($active_id, $pass);
184  } else {
185  array_push($solutions, [
186  'value1' => sprintf(
187  $this->lng->txt("value_between_x_and_y"),
188  $this->object->getLowerLimit(),
189  $this->object->getUpperLimit()
190  )
191  ]);
192  }
193 
194  return $this->renderSolutionOutput(
195  $solutions,
196  $active_id,
197  $pass,
198  $graphicalOutput,
199  $result_output,
200  $show_question_only,
201  $show_feedback,
202  $show_correct_solution,
203  $show_manual_scoring,
204  $show_question_text,
205  false,
206  false,
207  );
208  }
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 342 of file class.assNumericGUI.php.

References ilLegacyFormElementsUtil\prepareTextareaOutput().

342  : string
343  {
344  $output = "";
346  }
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 (   $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

PhpArrayAccessOnIllegalTypeInspection

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

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

309  : string
310  // hey.
311  {
312  $solutions = null;
313  // get the solution of the user for the active pass or from the last pass if allowed
314  if ($use_post_solutions !== false) {
316  $solutions = array(
317  array('value1' => $use_post_solutions['numeric_result'])
318  );
319  } elseif ($active_id) {
320  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
321  }
322 
323  // generate the question output
324  $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "Modules/TestQuestionPool");
325  if (is_array($solutions)) {
326  foreach ($solutions as $solution) {
327  $template->setVariable("NUMERIC_VALUE", " value=\"" . $solution['value1'] . "\"");
328  }
329  }
330  $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
331  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
332  $questionoutput = $template->get();
333  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
334  return $pageoutput;
335  }
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 376 of file class.assNumericGUI.php.

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

Referenced by editQuestion().

377  {
378  // points
379  $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
380  $points->allowDecimals(true);
381  $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
382  $points->setRequired(true);
383  $points->setSize(3);
384  $points->setMinValue(0.0);
385  $points->setMinvalueShouldBeGreater(true);
386  $form->addItem($points);
387 
388  $header = new ilFormSectionHeaderGUI();
389  $header->setTitle($this->lng->txt("range"));
390  $form->addItem($header);
391 
392  // lower bound
393  $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
394  $lower_limit->setSize(25);
395  $lower_limit->setMaxLength(20);
396  $lower_limit->setRequired(true);
397  $lower_limit->setValue((string) $this->object->getLowerLimit());
398  $form->addItem($lower_limit);
399 
400  // upper bound
401  $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
402  $upper_limit->setSize(25);
403  $upper_limit->setMaxLength(20);
404  $upper_limit->setRequired(true);
405  $upper_limit->setValue((string) $this->object->getUpperLimit());
406  $form->addItem($upper_limit);
407 
408  // reset input length, if max chars are set
409  if ($this->object->getMaxChars() > 0) {
410  $lower_limit->setSize($this->object->getMaxChars());
411  $lower_limit->setMaxLength($this->object->getMaxChars());
412  $upper_limit->setSize($this->object->getMaxChars());
413  $upper_limit->setMaxLength($this->object->getMaxChars());
414  }
415  return $form;
416  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateCorrectionsFormProperties()

assNumericGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

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

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

516  : void
517  {
518  // points
519  $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
520  $points->allowDecimals(true);
521  $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
522  $points->setRequired(true);
523  $points->setSize(3);
524  $points->setMinValue(0.0);
525  $points->setMinvalueShouldBeGreater(true);
526  $form->addItem($points);
527 
528  $header = new ilFormSectionHeaderGUI();
529  $header->setTitle($this->lng->txt("range"));
530  $form->addItem($header);
531 
532  // lower bound
533  $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
534  $lower_limit->setSize(25);
535  $lower_limit->setMaxLength(20);
536  $lower_limit->setRequired(true);
537  $lower_limit->setValue($this->object->getLowerLimit());
538  $form->addItem($lower_limit);
539 
540  // upper bound
541  $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
542  $upper_limit->setSize(25);
543  $upper_limit->setMaxLength(20);
544  $upper_limit->setRequired(true);
545  $upper_limit->setValue($this->object->getUpperLimit());
546  $form->addItem($upper_limit);
547 
548  // reset input length, if max chars are set
549  if ($this->object->getMaxChars() > 0) {
550  $lower_limit->setSize($this->object->getMaxChars());
551  $lower_limit->setMaxLength($this->object->getMaxChars());
552  $upper_limit->setSize($this->object->getMaxChars());
553  $upper_limit->setMaxLength($this->object->getMaxChars());
554  }
555  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assNumericGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

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

Referenced by editQuestion().

361  {
362  // maxchars
363  $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
364  $maxchars->setInfo($this->lng->txt('qpl_maxchars_info_numeric_question'));
365  $maxchars->setSize(10);
366  $maxchars->setDecimals(0);
367  $maxchars->setMinValue(1);
368  $maxchars->setRequired(true);
369  if ($this->object->getMaxChars() > 0) {
370  $maxchars->setValue($this->object->getMaxChars());
371  }
372  $form->addItem($maxchars);
373  return $form;
374  }
+ 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 478 of file class.assNumericGUI.php.

References ILIAS\LTI\ToolProvider\$key, assQuestionGUI\$tpl, ILIAS\Repository\lng(), ilGlobalPageTemplate\parseCurrentBlock(), ilGlobalPageTemplate\setCurrentBlock(), and ilGlobalPageTemplate\setVariable().

Referenced by getAggregatedAnswersView().

478  : ilTemplate
479  {
480  $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
481 
482  $tpl->setCurrentBlock('headercell');
483  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
485 
486  $tpl->setCurrentBlock('headercell');
487  $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
489 
490  foreach ($aggregate as $key => $value) {
491  $tpl->setCurrentBlock('aggregaterow');
492  $tpl->setVariable('OPTION', $key);
493  $tpl->setVariable('COUNT', $value);
495  }
496  return $tpl;
497  }
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
ilGlobalPageTemplate $tpl
string $key
Consumer key/client ID value.
Definition: System.php:193
setVariable(string $variable, $value='')
Sets the given variable to the given value.
+ 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 210 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(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

Referenced by getSolutionOutput().

223  : ?string {
224  $template = new ilTemplate("tpl.il_as_qpl_numeric_output_solution.html", true, true, "Modules/TestQuestionPool");
225  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
226  if (is_array($user_solutions)) {
227  if (($active_id > 0) && (!$show_correct_solution)) {
228  if ($graphical_output) {
229  if ($this->object->getStep() === null) {
230  $reached_points = $this->object->getReachedPoints($active_id, $pass);
231  } else {
232  $reached_points = $this->object->calculateReachedPoints($active_id, $pass);
233  }
234 
235  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
236  if ($reached_points == $this->object->getMaximumPoints()) {
237  $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
238  }
239  $template->setCurrentBlock("icon_ok");
240  $template->setVariable("ICON_OK", $correctness_icon);
241  $template->parseCurrentBlock();
242  }
243  }
244  foreach ($user_solutions as $solution) {
245  $template->setVariable("NUMERIC_VALUE", $solution['value1']);
246  }
247  if (count($user_solutions) == 0) {
248  $template->setVariable("NUMERIC_VALUE", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
249  }
250  }
251  $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
252  if ($show_question_text == true) {
253  $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
254  }
255  $questionoutput = $template->get();
256  //$feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : ""; // Moving new method
257  // due to deprecation.
258  $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
259  if (strlen($feedback)) {
260  $cssClass = (
261  $this->hasCorrectSolution($active_id, $pass) ?
263  );
264 
265  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
266  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
267  }
268  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
269 
270  $solutionoutput = $solutiontemplate->get();
271  if (!$show_question_only) {
272  // get page object output
273  $solutionoutput = $this->getILIASPage($solutionoutput);
274  }
275  return $solutionoutput;
276  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
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 560 of file class.assNumericGUI.php.

References ilPropertyFormGUI\getInput().

560  : void
561  {
562  $this->object->setPoints((float) str_replace(',', '.', $form->getInput('points')));
563  $this->object->setLowerLimit((float) str_replace(',', '.', $form->getInput('lowerlimit')));
564  $this->object->setUpperLimit((float) str_replace(',', '.', $form->getInput('upperlimit')));
565  }
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 $_POST and applies them to the data object.

Implements ilGuiAnswerScoringAdjustable.

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

Referenced by writePostData().

353  : void
354  {
355  $this->object->setLowerLimit($_POST['lowerlimit']);
356  $this->object->setUpperLimit($_POST['upperlimit']);
357  $this->object->setPoints((float) str_replace(',', '.', $_POST['points']));
358  }
+ Here is the caller graph for this function:

◆ writePostData()

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

{}

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

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

66  : int
67  {
68  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
69  if (!$hasErrors) {
73  $this->saveTaxonomyAssignments();
74  return 0;
75  }
76  return 1;
77  }
editQuestion($checkonly=false)
Creates an output of the edit form for the question.
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.
+ 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 348 of file class.assNumericGUI.php.

Referenced by writePostData().

348  : void
349  {
350  $this->object->setMaxChars($_POST["maxchars"]);
351  }
+ Here is the caller graph for this function:

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