ILIAS  release_8 Revision v8.24
assOrderingHorizontalGUI 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 assOrderingHorizontalGUI:
+ Collaboration diagram for assOrderingHorizontalGUI:

Public Member Functions

 __construct ($id=-1)
 assOrderingHorizontalGUI constructor More...
 
 getCommand ($cmd)
 
 editQuestion ($checkonly=false)
 Creates an output of the edit form for the question. 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, $show_feedback=false)
 
 getPresentationJavascripts ()
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. 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...
 
 populateQuestionSpecificFormPart (\ilPropertyFormGUI $form)
 
 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, $answer_defined_on_question)
 
 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...
 

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 The assOrderingHorizontalGUI class encapsulates the GUI representation for horizontal ordering questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

@ilctrl_iscalledby assOrderingHorizontalGUI: ilObjQuestionPoolGUI @ilCtrl_Calls assOrderingHorizontalGUI: ilPropertyFormGUI, ilFormPropertyDispatchGUI

Definition at line 34 of file class.assOrderingHorizontalGUI.php.

Constructor & Destructor Documentation

◆ __construct()

assOrderingHorizontalGUI::__construct (   $id = -1)

assOrderingHorizontalGUI constructor

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

Parameters
integer$idThe database id of a single choice question object @access public

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

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

References $id, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), and assQuestionGUI\setErrorMessage().

+ Here is the call graph for this function:

Member Function Documentation

◆ aggregateAnswers()

assOrderingHorizontalGUI::aggregateAnswers (   $relevant_answers_chosen,
  $answer_defined_on_question 
)

Definition at line 442 of file class.assOrderingHorizontalGUI.php.

442 : array
443 {
444 $aggregate = array();
445 foreach ($relevant_answers_chosen as $answer) {
446 $answer = str_replace($this->object->getAnswerSeparator(), '&nbsp;&nbsp;-&nbsp;&nbsp;', $answer);
447 if (in_array($answer['value1'], $aggregate)) {
448 $aggregate[$answer['value1']] = $aggregate[$answer['value1']] + 1;
449 } else {
450 $aggregate[$answer['value1']] = 1;
451 }
452 }
453
454 return $aggregate;
455 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ editQuestion()

assOrderingHorizontalGUI::editQuestion (   $checkonly = false)

Creates an output of the edit form for the question.

@access public

Definition at line 81 of file class.assOrderingHorizontalGUI.php.

81 : bool
82 {
83 $save = $this->isSaveCommand();
84 $this->getQuestionTemplate();
85
86 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
87 $form = new ilPropertyFormGUI();
88 $this->editForm = $form;
89
90 $form->setFormAction($this->ctrl->getFormAction($this));
91 $form->setTitle($this->outQuestionType());
92 $form->setMultipart(false);
93 $form->setTableWidth("100%");
94 $form->setId("orderinghorizontal");
95
98
99
100 $this->populateTaxonomyFormSection($form);
101
102 $this->addQuestionFormCommandButtons($form);
103
104 $errors = false;
105
106 if ($save) {
107 $form->setValuesByPost();
108 $errors = !$form->checkInput();
109 $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
110 if ($errors) {
111 $checkonly = false;
112 }
113 }
114
115 if (!$checkonly) {
116 $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
117 }
118 return $errors;
119 }
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
This class represents a property form user interface.
$errors
Definition: imgupload.php:65

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

Referenced by writePostData().

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

◆ getAfterParticipationSuppressionQuestionPostVars()

assOrderingHorizontalGUI::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 387 of file class.assOrderingHorizontalGUI.php.

387 : array
388 {
389 return array();
390 }

◆ getAggregatedAnswersView()

assOrderingHorizontalGUI::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 435 of file class.assOrderingHorizontalGUI.php.

435 : string
436 {
437 return $this->renderAggregateView(
438 $this->aggregateAnswers($relevant_answers, $this->object->getOrderText())
439 )->get();
440 }
aggregateAnswers($relevant_answers_chosen, $answer_defined_on_question)

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getAnswersFrequency()

assOrderingHorizontalGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

Definition at line 475 of file class.assOrderingHorizontalGUI.php.

475 : array
476 {
477 $answers = array();
478
479 foreach ($relevantAnswers as $ans) {
480 $md5 = md5($ans['value1']);
481
482 if (!isset($answers[$md5])) {
483 $answer = str_replace(
484 $this->object->getAnswerSeparator(),
485 '&nbsp;&nbsp;-&nbsp;&nbsp;',
486 $ans['value1']
487 );
488
489 $answers[$md5] = array(
490 'answer' => $answer, 'frequency' => 0
491 );
492 }
493
494 $answers[$md5]['frequency']++;
495 }
496
497 return $answers;
498 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getCommand()

assOrderingHorizontalGUI::getCommand (   $cmd)

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

56 {
57 return $cmd;
58 }

◆ getPresentationJavascripts()

assOrderingHorizontalGUI::getPresentationJavascripts ( )

Reimplemented from assQuestionGUI.

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

353 : array
354 {
355 global $DIC; /* @var ILIAS\DI\Container $DIC */
356
357 $files = array();
358
359 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
360 $files[] = './node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js';
361 }
362
363 return $files;
364 }
global $DIC
Definition: feed.php:28

References $DIC.

◆ getPreview()

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

Reimplemented from assQuestionGUI.

Definition at line 238 of file class.assOrderingHorizontalGUI.php.

238 : string
239 {
240 if (is_object($this->getPreviewSession()) && strlen((string) $this->getPreviewSession()->getParticipantsSolution())) {
241 $elements = (string) $this->getPreviewSession()->getParticipantsSolution();
242 $elements = $this->object->splitAndTrimOrderElementText($elements, $this->object->getAnswerSeparator());
243 } else {
244 $elements = $this->object->getRandomOrderingElements();
245 }
246
247 $template = new ilTemplate("tpl.il_as_qpl_orderinghorizontal_preview.html", true, true, "Modules/TestQuestionPool");
248 $js = <<<JS
249
250 $('#horizontal_{QUESTION_ID}').ilHorizontalOrderingQuestion({
251 result_value_selector : '.ilOrderingValue',
252 result_separator : '{::}'
253 });
254
255JS;
256 $js = str_replace('{QUESTION_ID}', $this->object->getId(), $js);
257 $this->tpl->addOnLoadCode($js);
258
259 foreach ($elements as $id => $element) {
260 $template->setCurrentBlock("element");
261 $template->setVariable("ELEMENT_ID", "e_" . $this->object->getId() . "_$id");
262 $template->setVariable("ORDERING_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($element));
263 $template->setVariable("ELEMENT_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($element));
264 $template->parseCurrentBlock();
265 }
266 $template->setVariable("QUESTION_ID", $this->object->getId());
267 $template->setVariable("VALUE_ORDERRESULT", ' value="' . join('{::}', $elements) . '"');
268 if ($this->object->getTextSize() >= 10) {
269 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
270 }
271 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
272 $questionoutput = $template->get();
273 if (!$show_question_only) {
274 // get page object output
275 $questionoutput = $this->getILIASPage($questionoutput);
276 }
277 global $DIC; /* @var ILIAS\DI\Container $DIC */
278 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
279 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
282 $this->tpl->addJavaScript('./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
283 }
284 $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
285 return $questionoutput;
286 }
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
static initjQueryUI(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template

References $DIC, $id, iljQueryUtil\initjQuery(), iljQueryUtil\initjQueryUI(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ getSolutionOutput()

assOrderingHorizontalGUI::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
Returns
string solution output of the question as HTML code

Reimplemented from assQuestionGUI.

Definition at line 133 of file class.assOrderingHorizontalGUI.php.

143 : string {
144 // get the solution of the user for the active pass or from the last pass if allowed
145 $template = new ilTemplate("tpl.il_as_qpl_orderinghorizontal_output_solution.html", true, true, "Modules/TestQuestionPool");
146
147 if (($active_id > 0) && (!$show_correct_solution)) {
148 $elements = [];
149 $solutions = $this->object->getSolutionValues($active_id, $pass);
150
151 if (count($solutions) && strlen($solutions[0]["value1"])) {
152 $elements = explode("{::}", $solutions[0]["value1"]);
153 }
154
155 if (!count($elements)) {
156 $elements = $this->object->getRandomOrderingElements();
157 }
158
159 foreach ($elements as $id => $element) {
160 $template->setCurrentBlock("element");
161 $template->setVariable("ELEMENT_ID", "sol_e_" . $this->object->getId() . "_$id");
162 $template->setVariable("ELEMENT_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($element));
163 $template->parseCurrentBlock();
164 }
165 } else {
166 $elements = $this->object->getOrderingElements();
167 foreach ($elements as $id => $element) {
168 $template->setCurrentBlock("element");
169 $template->setVariable("ELEMENT_ID", "sol_e_" . $this->object->getId() . "_$id");
170 $template->setVariable("ELEMENT_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($element));
171 $template->parseCurrentBlock();
172 }
173 }
174
175 if (($active_id > 0) && (!$show_correct_solution)) {
176 if ($this->object->getStep() === null) {
177 $reached_points = $this->object->getReachedPoints($active_id, $pass);
178 } else {
179 $reached_points = $this->object->calculateReachedPoints($active_id, $pass);
180 }
181 if ($graphicalOutput) {
182 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
183 if ($reached_points == $this->object->getMaximumPoints()) {
184 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
185 } elseif ($reached_points > 0) {
186 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_MOSTLY_OK);
187 }
188 $template->setCurrentBlock("icon_ok");
189 $template->setVariable("ICON_OK", $correctness_icon);
190 $template->parseCurrentBlock();
191 }
192 } else {
193 $reached_points = $this->object->getPoints();
194 }
195
196 if ($result_output) {
197 $resulttext = ($reached_points == 1) ? "(%s " . $this->lng->txt("point") . ")" : "(%s " . $this->lng->txt("points") . ")";
198 $template->setVariable("RESULT_OUTPUT", sprintf($resulttext, $reached_points));
199 }
200 if ($show_question_text == true) {
201 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
202 }
203 // $template->setVariable("SOLUTION_TEXT", ilUtil::prepareFormOutput($solutionvalue));
204 if ($this->object->getTextSize() >= 10) {
205 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
206 }
207
208 $questionoutput = $template->get();
209 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
210 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
211
212
213 $feedback = '';
214 if ($show_feedback) {
215 if (!$this->isTestPresentationContext()) {
216 $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
217 $feedback .= strlen($fb) ? $fb : '';
218 }
219 }
220 if (strlen($feedback)) {
221 $cssClass = (
222 $this->hasCorrectSolution($active_id, $pass) ?
224 );
225
226 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
227 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
228 }
229 $solutionoutput = $solutiontemplate->get();
230 if (!$show_question_only) {
231 // get page object output
232 $solutionoutput = $this->getILIASPage($solutionoutput);
233 }
234 return $solutionoutput;
235 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)

References $id, ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assOrderingHorizontalGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

Parameters
array$userSolution($userSolution[<value1>] = <value2>)

Reimplemented from assQuestionGUI.

Definition at line 366 of file class.assOrderingHorizontalGUI.php.

366 : string
367 {
368 return '';
369 }

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

Definition at line 289 of file class.assOrderingHorizontalGUI.php.

289 : string
290 // hey.
291 {
292 // generate the question output
293 $template = new ilTemplate("tpl.il_as_qpl_orderinghorizontal_output.html", true, true, "Modules/TestQuestionPool");
294 $js = <<<JS
295 $().ready(function() {
296 if (typeof $.fn.ilHorizontalOrderingQuestion != 'undefined') {
297 $('#horizontal_{QUESTION_ID}').ilHorizontalOrderingQuestion({
298 result_value_selector: '.ilOrderingValue',
299 result_separator: '{::}'
300 });
301 }
302 });
303JS;
304 $js = str_replace('{QUESTION_ID}', $this->object->getId(), $js);
305 $this->tpl->addOnLoadCode($js);
306
307
308 $elements = $this->object->getRandomOrderingElements();
309
310 if ($active_id) {
311 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
312 // hey.
313 if (is_array($solutions) && count($solutions) == 1) {
314 $elements = explode("{::}", $solutions[0]["value1"]);
315 }
316 }
317 if (!is_array($solutions) || count($solutions) == 0) {
318 ilSession::set('qst_ordering_horizontal_elements', $elements);
319 } else {
320 ilSession::clear('qst_ordering_horizontal_elements');
321 }
322 foreach ($elements as $id => $element) {
323 $template->setCurrentBlock("element");
324 $template->setVariable("ELEMENT_ID", "e_" . $this->object->getId() . "_$id");
325 $template->setVariable("ORDERING_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($element));
326 $template->setVariable("ELEMENT_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($element));
327 $template->parseCurrentBlock();
328 }
329 $template->setVariable("QUESTION_ID", $this->object->getId());
330 if ($this->object->getTextSize() >= 10) {
331 $template->setVariable("STYLE", " style=\"font-size: " . $this->object->getTextSize() . "%;\"");
332 }
333 $template->setVariable("VALUE_ORDERRESULT", ' value="' . join('{::}', $elements) . '"');
334 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
335 $questionoutput = $template->get();
336 //if (!$show_question_only) {
337 // get page object output
338 $questionoutput = $this->getILIASPage($questionoutput);
339 //}
340 global $DIC; /* @var ILIAS\DI\Container $DIC */
341 if ($DIC->http()->agent()->isMobile() || $DIC->http()->agent()->isIpad()) {
342 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
345 $this->tpl->addJavaScript('./node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js');
346 }
347 $this->tpl->addJavascript("./Modules/TestQuestionPool/templates/default/orderinghorizontal.js");
348 $questionoutput = $template->get();
349 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
350 return $pageoutput;
351 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.

◆ populateCorrectionsFormProperties()

assOrderingHorizontalGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

Definition at line 500 of file class.assOrderingHorizontalGUI.php.

500 : void
501 {
502 // points
503 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
504
505 $points->allowDecimals(true);
506 $points->setValue($this->object->getPoints());
507 $points->setRequired(true);
508 $points->setSize(3);
509 $points->setMinValue(0.0);
510 $points->setMinvalueShouldBeGreater(true);
511 $form->addItem($points);
512 }
This class represents a number property in a property form.

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

+ Here is the call graph for this function:

◆ populateQuestionSpecificFormPart()

assOrderingHorizontalGUI::populateQuestionSpecificFormPart ( \ilPropertyFormGUI  $form)

Definition at line 392 of file class.assOrderingHorizontalGUI.php.

393 {
394 // ordertext
395 $ordertext = new ilTextAreaInputGUI($this->lng->txt("ordertext"), "ordertext");
396 $ordertext->setValue((string) self::prepareTextareaOutput($this->object->getOrderText(), false, true));
397 $ordertext->setRequired(true);
398 $ordertext->setInfo(sprintf($this->lng->txt("ordertext_info"), $this->object->getSeparator()));
399 $ordertext->setRows(10);
400 $ordertext->setCols(80);
401 $form->addItem($ordertext);
402 // textsize
403 $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
404 $textsize->setValue($this->object->getTextSize());
405 $textsize->setInfo($this->lng->txt("textsize_info"));
406 $textsize->setSize(6);
407 $textsize->setMinValue(10);
408 $textsize->setRequired(false);
409 $form->addItem($textsize);
410 // points
411 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
412
413 $points->allowDecimals(true);
414 // mbecker: Fix for mantis bug 7866: Predefined values schould make sense.
415 // This implements a default value of "1" for this question type.
416 if ($this->object->getPoints() == null) {
417 $points->setValue("1");
418 } else {
419 $points->setValue($this->object->getPoints());
420 }
421 $points->setRequired(true);
422 $points->setSize(3);
423 $points->setMinValue(0.0);
424 $points->setMinvalueShouldBeGreater(true);
425 $form->addItem($points);
426 return $form;
427 }
This class represents a text area property in a property form.

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

Referenced by editQuestion().

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

◆ renderAggregateView()

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

Definition at line 462 of file class.assOrderingHorizontalGUI.php.

462 : ilTemplate
463 {
464 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
465
466 foreach ($aggregate as $key => $line_data) {
467 $tpl->setCurrentBlock('aggregaterow');
468 $tpl->setVariable('COUNT', $line_data);
469 $tpl->setVariable('OPTION', $key);
471 }
472 return $tpl;
473 }
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, and $tpl.

◆ saveCorrectionsFormProperties()

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

Reimplemented from assQuestionGUI.

Definition at line 517 of file class.assOrderingHorizontalGUI.php.

517 : void
518 {
519 $this->object->setPoints((float) str_replace(',', '.', $form->getInput('points')));
520 }
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:

◆ writePostData()

assOrderingHorizontalGUI::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 63 of file class.assOrderingHorizontalGUI.php.

63 : int
64 {
65 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
66 if (!$hasErrors) {
67 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
71 return 0;
72 }
73 return 1;
74 }
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.

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

+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assOrderingHorizontalGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

Definition at line 371 of file class.assOrderingHorizontalGUI.php.

371 : void
372 {
373 $this->object->setTextSize($_POST["textsize"]);
374 $this->object->setOrderText($_POST["ordertext"]);
375 $this->object->setPoints((float) str_replace(',', '.', $_POST["points"]));
376 }

Referenced by writePostData().

+ Here is the caller graph for this function:

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