ILIAS  release_7 Revision v7.30-3-g800a261c036
assNumericGUI Class Reference

Numeric question GUI representation. 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...
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() 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)
 
 getSpecificFeedbackOutput ($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 ($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
 __construct ()
 assQuestionGUI constructor More...
 
 hasInlineFeedback ()
 this method can be overwritten per question type More...
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 execute command More...
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput ($userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $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)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 hasIntermediateSolution ($activeId, $passIndex)
 Check if the question has an intermediate solution. More...
 
 setUseIntermediateSolution ($use)
 
 getUseIntermediateSolution ()
 Get if intermediate solution should be used for solution output. More...
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=false, $user_post_solutions=false, $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFreuqencyStatisticSupported ()
 
 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 ($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 ($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 ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 addSaveOnEnterOnLoadCode ()
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants 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 SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $request
 
 $sequence_no
 sequence number in test More...
 
 $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 HAS_SPECIAL_QUESTION_COMMANDS = false
 
 $ctrl
 
 $editForm
 
 $use_intermediate_solution = false
 

Detailed Description

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 25 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
Returns
assNumericGUI

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

37 {
39 require_once './Modules/TestQuestionPool/classes/class.assNumeric.php';
40 $this->object = new assNumeric();
41 if ($id >= 0) {
42 $this->object->loadFromDb($id);
43 }
44 }
Class for numeric questions.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ aggregateAnswers()

assNumericGUI::aggregateAnswers (   $relevant_answers_chosen)

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

446 {
447 $aggregate = array();
448
449 foreach ($relevant_answers_chosen as $relevant_answer) {
450 if (array_key_exists($relevant_answer['value1'], $aggregate)) {
451 $aggregate[$relevant_answer['value1']]++;
452 } else {
453 $aggregate[$relevant_answer['value1']] = 1;
454 }
455 }
456 return $aggregate;
457 }

Referenced by getAggregatedAnswersView().

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

136 {
137 include_once "./Services/Math/classes/class.EvalMath.php";
138 $eval = new EvalMath();
139 $eval->suppress_errors = true;
140 if (($eval->e($lower) !== false) and ($eval->e($upper) !== false)) {
141 if ($eval->e($lower) <= $eval->e($upper)) {
142 return true;
143 } else {
144 return false;
145 }
146 }
147 return false;
148 }

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

79 {
80 $save = $this->isSaveCommand();
81 $this->getQuestionTemplate();
82
83 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
84 $form = new ilPropertyFormGUI();
85 $this->editForm = $form;
86
87 $form->setFormAction($this->ctrl->getFormAction($this));
88 $form->setTitle($this->outQuestionType());
89 $form->setMultipart(true);
90 $form->setTableWidth("100%");
91 $form->setId("assnumeric");
92
96 $this->populateTaxonomyFormSection($form);
98
99 $errors = false;
100
101 if ($save) {
102 $form->setValuesByPost();
103 $errors = !$form->checkInput();
104 $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
105
106 $lower = $form->getItemByPostVar('lowerlimit');
107 $upper = $form->getItemByPostVar('upperlimit');
108
109 if (!$this->checkRange($lower->getValue(), $upper->getValue())) {
110 global $DIC;
111 $lower->setAlert($DIC->language()->txt('qpl_numeric_lower_needs_valid_lower_alert'));
112 $upper->setAlert($DIC->language()->txt('qpl_numeric_upper_needs_valid_upper_alert'));
113 ilUtil::sendFailure($DIC->language()->txt("form_input_not_valid"));
114 $errors = true;
115 }
116
117 if ($errors) {
118 $checkonly = false;
119 }
120 }
121
122 if (!$checkonly) {
123 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
124 }
125 return $errors;
126 }
checkRange($lower, $upper)
Checks the range limits.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateAnswerSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getQuestionTemplate()
get question template
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
This class represents a property form user interface.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24
$errors
Definition: imgupload.php:49

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

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

412 {
413 return array();
414 }

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

426 {
427 return array();
428 }

◆ getAggregatedAnswersView()

assNumericGUI::getAggregatedAnswersView (   $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 438 of file class.assNumericGUI.php.

439 {
440 return $this->renderAggregateView(
441 $this->aggregateAnswers($relevant_answers)
442 )->get();
443 }
aggregateAnswers($relevant_answers_chosen)
renderAggregateView($aggregate)

References aggregateAnswers(), and renderAggregateView().

+ Here is the call graph for this function:

◆ getAnswersFrequency()

assNumericGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

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

486 {
487 $answers = array();
488
489 foreach ($relevantAnswers as $ans) {
490 if (!isset($answers[$ans['value1']])) {
491 $answers[$ans['value1']] = array(
492 'answer' => $ans['value1'], 'frequency' => 0
493 );
494 }
495
496 $answers[$ans['value1']]['frequency']++;
497 }
498
499 return $answers;
500 }

◆ getCommand()

assNumericGUI::getCommand (   $cmd)

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

47 {
48 if (substr($cmd, 0, 6) == "delete") {
49 $cmd = "delete";
50 }
51 return $cmd;
52 }

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

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

References assQuestionGUI\getILIASPage(), and assQuestionGUI\getPreviewSession().

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

185 {
186 // get the solution of the user for the active pass or from the last pass if allowed
187 $solutions = array();
188 if (($active_id > 0) && (!$show_correct_solution)) {
189 $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
190 } else {
191 array_push($solutions, array("value1" => sprintf($this->lng->txt("value_between_x_and_y"), $this->object->getLowerLimit(), $this->object->getUpperLimit())));
192 }
193
194 // generate the question output
195 require_once './Services/UICore/classes/class.ilTemplate.php';
196 $template = new ilTemplate("tpl.il_as_qpl_numeric_output_solution.html", true, true, "Modules/TestQuestionPool");
197 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
198 if (is_array($solutions)) {
199 if (($active_id > 0) && (!$show_correct_solution)) {
200 if ($graphicalOutput) {
201 if ($this->object->getStep() === null) {
202 $reached_points = $this->object->getReachedPoints($active_id, $pass);
203 } else {
204 $reached_points = $this->object->calculateReachedPoints($active_id, $pass);
205 }
206 // output of ok/not ok icons for user entered solutions
207 if ($reached_points == $this->object->getMaximumPoints()) {
208 $template->setCurrentBlock("icon_ok");
209 $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
210 $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
211 $template->parseCurrentBlock();
212 } else {
213 $template->setCurrentBlock("icon_ok");
214 $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg"));
215 $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
216 $template->parseCurrentBlock();
217 }
218 }
219 }
220 foreach ($solutions as $solution) {
221 $template->setVariable("NUMERIC_VALUE", $solution["value1"]);
222 }
223 if (count($solutions) == 0) {
224 $template->setVariable("NUMERIC_VALUE", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
225 }
226 }
227 $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
228 if ($show_question_text == true) {
229 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
230 }
231 $questionoutput = $template->get();
232 //$feedback = ($show_feedback) ? $this->getAnswerFeedbackOutput($active_id, $pass) : ""; // Moving new method
233 // due to deprecation.
234 $feedback = ($show_feedback && !$this->isTestPresentationContext()) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
235 if (strlen($feedback)) {
236 $cssClass = (
237 $this->hasCorrectSolution($active_id, $pass) ?
239 );
240
241 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
242 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
243 }
244 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
245
246 $solutionoutput = $solutiontemplate->get();
247 if (!$show_question_only) {
248 // get page object output
249 $solutionoutput = $this->getILIASPage($solutionoutput);
250 }
251 return $solutionoutput;
252 }
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
hasCorrectSolution($activeId, $passIndex)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)

References $pass, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), ilUtil\getImagePath(), assQuestionGUI\getUseIntermediateSolution(), assQuestionGUI\hasCorrectSolution(), and assQuestionGUI\isTestPresentationContext().

+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

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

Reimplemented from assQuestionGUI.

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

329 {
330 $output = "";
331 return $this->object->prepareTextareaOutput($output, true);
332 }

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

288 {
289 $solutions = null;
290 // get the solution of the user for the active pass or from the last pass if allowed
291 if ($use_post_solutions !== false) {
292 $solutions = array(
293 array('value1' => $use_post_solutions['numeric_result'])
294 );
295 } elseif ($active_id) {
296
297 // hey: prevPassSolutions - obsolete due to central check
298 #include_once "./Modules/Test/classes/class.ilObjTest.php";
299 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
300 #{
301 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
302 #}
303 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
304 // hey.
305 }
306
307 // generate the question output
308 require_once './Services/UICore/classes/class.ilTemplate.php';
309 $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "Modules/TestQuestionPool");
310 if (is_array($solutions)) {
311 foreach ($solutions as $solution) {
312 $template->setVariable("NUMERIC_VALUE", " value=\"" . $solution["value1"] . "\"");
313 }
314 }
315 $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars());
316 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
317 $questionoutput = $template->get();
318 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
319 return $pageoutput;
320 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page

References $pass, and assQuestionGUI\outQuestionPage().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assNumericGUI::populateAnswerSpecificFormPart ( \ilPropertyFormGUI  $form)

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

362 {
363 // points
364 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
365 $points->allowDecimals(true);
366 $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
367 $points->setRequired(true);
368 $points->setSize(3);
369 $points->setMinValue(0.0);
370 $points->setMinvalueShouldBeGreater(true);
371 $form->addItem($points);
372
373 $header = new ilFormSectionHeaderGUI();
374 $header->setTitle($this->lng->txt("range"));
375 $form->addItem($header);
376
377 // lower bound
378 $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
379 $lower_limit->setSize(25);
380 $lower_limit->setMaxLength(20);
381 $lower_limit->setRequired(true);
382 $lower_limit->setValue($this->object->getLowerLimit());
383 $form->addItem($lower_limit);
384
385 // upper bound
386 $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
387 $upper_limit->setSize(25);
388 $upper_limit->setMaxLength(20);
389 $upper_limit->setRequired(true);
390 $upper_limit->setValue($this->object->getUpperLimit());
391 $form->addItem($upper_limit);
392
393 // reset input length, if max chars are set
394 if ($this->object->getMaxChars() > 0) {
395 $lower_limit->setSize($this->object->getMaxChars());
396 $lower_limit->setMaxLength($this->object->getMaxChars());
397 $upper_limit->setSize($this->object->getMaxChars());
398 $upper_limit->setMaxLength($this->object->getMaxChars());
399 }
400 }
This class represents a section header in a property form.
This class represents a formula text property in a property form.
This class represents a number property in a property form.

References ilPropertyFormGUI\addItem().

Referenced by editQuestion().

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

◆ populateCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

503 {
504 // points
505 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
506 $points->allowDecimals(true);
507 $points->setValue($this->object->getPoints() > 0 ? $this->object->getPoints() : '');
508 $points->setRequired(true);
509 $points->setSize(3);
510 $points->setMinValue(0.0);
511 $points->setMinvalueShouldBeGreater(true);
512 $form->addItem($points);
513
514 $header = new ilFormSectionHeaderGUI();
515 $header->setTitle($this->lng->txt("range"));
516 $form->addItem($header);
517
518 // lower bound
519 $lower_limit = new ilFormulaInputGUI($this->lng->txt("range_lower_limit"), "lowerlimit");
520 $lower_limit->setSize(25);
521 $lower_limit->setMaxLength(20);
522 $lower_limit->setRequired(true);
523 $lower_limit->setValue($this->object->getLowerLimit());
524 $form->addItem($lower_limit);
525
526 // upper bound
527 $upper_limit = new ilFormulaInputGUI($this->lng->txt("range_upper_limit"), "upperlimit");
528 $upper_limit->setSize(25);
529 $upper_limit->setMaxLength(20);
530 $upper_limit->setRequired(true);
531 $upper_limit->setValue($this->object->getUpperLimit());
532 $form->addItem($upper_limit);
533
534 // reset input length, if max chars are set
535 if ($this->object->getMaxChars() > 0) {
536 $lower_limit->setSize($this->object->getMaxChars());
537 $lower_limit->setMaxLength($this->object->getMaxChars());
538 $upper_limit->setSize($this->object->getMaxChars());
539 $upper_limit->setMaxLength($this->object->getMaxChars());
540 }
541 }
addItem($a_item)
Add Item (Property, SectionHeader).

References ilPropertyFormGUI\addItem().

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assNumericGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

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

347 {
348 // maxchars
349 $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
350 $maxchars->setInfo($this->lng->txt('qpl_maxchars_info_numeric_question'));
351 $maxchars->setSize(10);
352 $maxchars->setDecimals(0);
353 $maxchars->setMinValue(1);
354 $maxchars->setRequired(true);
355 if ($this->object->getMaxChars() > 0) {
356 $maxchars->setValue($this->object->getMaxChars());
357 }
358 $form->addItem($maxchars);
359 }

References ilPropertyFormGUI\addItem().

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

465 {
466 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
467
468 $tpl->setCurrentBlock('headercell');
469 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_answer_header'));
470 $tpl->parseCurrentBlock();
471
472 $tpl->setCurrentBlock('headercell');
473 $tpl->setVariable('HEADER', $this->lng->txt('tst_answer_aggr_frequency_header'));
474 $tpl->parseCurrentBlock();
475
476 foreach ($aggregate as $key => $value) {
477 $tpl->setCurrentBlock('aggregaterow');
478 $tpl->setVariable('OPTION', $key);
479 $tpl->setVariable('COUNT', $value);
480 $tpl->parseCurrentBlock();
481 }
482 return $tpl;
483 }

References assQuestionGUI\$tpl.

Referenced by getAggregatedAnswersView().

+ Here is the caller graph for this function:

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

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

547 {
548 $this->object->setPoints((float) $form->getInput('points'));
549 $this->object->setLowerLimit((float) $form->getInput('lowerlimit'));
550 $this->object->setUpperLimit((float) $form->getInput('upperlimit'));
551 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ supportsIntermediateSolutionOutput()

assNumericGUI::supportsIntermediateSolutionOutput ( )

Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution()

Returns
bool

Reimplemented from assQuestionGUI.

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

156 {
157 return true;
158 }

◆ writeAnswerSpecificPostData()

assNumericGUI::writeAnswerSpecificPostData ( ilPropertyFormGUI  $form)

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

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiAnswerScoringAdjustable.

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

340 {
341 $this->object->setLowerLimit($_POST['lowerlimit']);
342 $this->object->setUpperLimit($_POST['upperlimit']);
343 $this->object->setPoints($_POST['points']);
344 }
$_POST["username"]

References $_POST.

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ writePostData()

assNumericGUI::writePostData (   $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 57 of file class.assNumericGUI.php.

58 {
59 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
60 if (!$hasErrors) {
61 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
66 return 0;
67 }
68 return 1;
69 }
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.

Parameters
bool$alwaysIf true, a check for form validity is omitted.
Returns
void

Implements ilGuiQuestionScoringAdjustable.

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

335 {
336 $this->object->setMaxChars($_POST["maxchars"]);
337 }

References $_POST.

Referenced by writePostData().

+ Here is the caller graph for this function:

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