ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
assLongMenuGUI Class Reference
+ Inheritance diagram for assLongMenuGUI:
+ Collaboration diagram for assLongMenuGUI:

Public Member Functions

 getCommand ($cmd)
 
 writeQuestionSpecificPostData (ilPropertyFormGUI $form)
 Extracts the question specific values from the request and applies them to the data object. More...
 
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 populateQuestionSpecificFormPart (ilPropertyFormGUI $form)
 Adds the question specific forms parts to a question property form gui. More...
 
 populateAnswerSpecificFormPart (ilPropertyFormGUI $form)
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getAfterParticipationSuppressionQuestionPostVars ()
 Returns a list of postvars which will be suppressed in the form output when used in scoring adjustment. More...
 
 getLongMenuTextWithInputFieldsInsteadOfGaps ($user_solution=[], $solution=false, $graphical=false)
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
- Public Member Functions inherited from assQuestionGUI
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass (string $targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 
 buildFileDownloadLink ()
 
 supportsAdjustment ()
 
 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 the request 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...
 

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...
 
 buildEditForm ()
 
 getTemplateForPreviewAndTest (array $user_solution)
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 renderLatex ($content)
 Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in the browser. More...
 
 getSuggestedSolutionsRepo ()
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 
 resetSavedPreviewSession ()
 

Private Member Functions

 verifyAnswerOptions ()
 
 stripSlashesRecursive (array $data)
 
 trimArrayRecursive (array $data)
 
 convertPointsToFloat (array $correct_answers)
 
 getModalHtml (string &$modal_id)
 
 getTextGapTemplate ($key, $value, $solution, $ok=false, $graphical=false)
 
 getSelectGapTemplate ($key, $answers, $user_value, $solution, $ok=false, $graphical=false)
 

Private Attributes

const DEFAULT_MODAL_ID = 'ilGapModal'
 
readonly UIFactory $ui_factory
 
readonly UIRenderer $ui_renderer
 

Additional Inherited Members

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

Detailed Description

Definition at line 29 of file class.assLongMenuGUI.php.

Member Function Documentation

◆ buildEditForm()

assLongMenuGUI::buildEditForm ( )
protected
Returns
ilPropertyFormGUI

Reimplemented from assQuestionGUI.

Definition at line 200 of file class.assLongMenuGUI.php.

201 {
202 $form = $this->buildBasicEditFormObject();
203 $this->addQuestionFormCommandButtons($form);
204 $this->addBasicQuestionFormProperties($form);
206 $this->populateTaxonomyFormSection($form);
207
208 return $form;
209 }
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
Adds the question specific forms parts to a question property form gui.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
This class represents a property form user interface.

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ convertPointsToFloat()

assLongMenuGUI::convertPointsToFloat ( array  $correct_answers)
private

Definition at line 164 of file class.assLongMenuGUI.php.

166 : array {
167 return array_map(
168 function (array $v): array {
169 $v[1] = $this->refinery->kindlyTo()->float()->transform($v[1]);
170 return $v;
171 },
172 $correct_answers
173 );
174 }

Referenced by writeQuestionSpecificPostData().

+ Here is the caller graph for this function:

◆ editQuestion()

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

Reimplemented from assQuestionGUI.

Definition at line 176 of file class.assLongMenuGUI.php.

179 : bool {
180 $form = $this->editForm;
181 if ($form === null) {
182 $form = $this->buildEditForm();
183 }
184
185 /*
186 * sk 29.01.2025: This is a god aw-ful hack and one more sign,
187 * that the flow here needs to change, but we need this to set the
188 * question id on question creation (see: https://mantis.ilias.de/view.php?id=43705)
189 */
190 if ($this->object->getId() > 0) {
191 $this->ctrl->setParameterByClass(self::class, 'q_id', $this->object->getId());
192 }
193 $form->setFormAction($this->ctrl->getFormActionByClass(self::class));
194 $this->renderEditForm($form);
195 return false;
196 }
renderEditForm(ilPropertyFormGUI $form)
ilPropertyFormGUI $editForm

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ getAfterParticipationSuppressionQuestionPostVars()

assLongMenuGUI::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 552 of file class.assLongMenuGUI.php.

552 : array
553 {
554 return [];
555 }

◆ getAnswerFrequencyTableGUI()

assLongMenuGUI::getAnswerFrequencyTableGUI (   $parentGui,
  $parentCmd,
  $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

Definition at line 687 of file class.assLongMenuGUI.php.

688 {
689 global $DIC; /* @var ILIAS\DI\Container $DIC */
690
691 $table = parent::getAnswerFrequencyTableGUI(
692 $parentGui,
693 $parentCmd,
694 $relevantAnswers,
695 $questionIndex
696 );
697
698 $table->setTitle(
699 sprintf(
700 $DIC->language()->txt('tst_corrections_answers_tbl_subindex'),
701 $DIC->language()->txt('longmenu') . ' ' . ($questionIndex + 1)
702 )
703 );
704
705 return $table;
706 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26

References $DIC.

◆ getAnswersFrequency()

assLongMenuGUI::getAnswersFrequency (   $relevantAnswers,
  $questionIndex 
)

Reimplemented from assQuestionGUI.

Definition at line 664 of file class.assLongMenuGUI.php.

664 : array
665 {
666 $answers = [];
667
668 foreach ($relevantAnswers as $row) {
669 if ($row['value1'] != $questionIndex) {
670 continue;
671 }
672
673 if (!isset($answers[$row['value2']])) {
674 //$label = $this->getAnswerTextLabel($row['value1'], $row['value2']);
675
676 $answers[$row['value2']] = [
677 'answer' => $row['value2'], 'frequency' => 0
678 ];
679 }
680
681 $answers[$row['value2']]['frequency']++;
682 }
683
684 return $answers;
685 }

◆ getCommand()

assLongMenuGUI::getCommand (   $cmd)

Definition at line 50 of file class.assLongMenuGUI.php.

51 {
52 return $cmd;
53 }

◆ getLongMenuTextWithInputFieldsInsteadOfGaps()

assLongMenuGUI::getLongMenuTextWithInputFieldsInsteadOfGaps (   $user_solution = [],
  $solution = false,
  $graphical = false 
)

Definition at line 557 of file class.assLongMenuGUI.php.

557 : string
558 {
559 $return_value = '';
560 $text_array = preg_split("/\\[" . assLongMenu::GAP_PLACEHOLDER . " (\\d+)\\]/", $this->object->getLongMenuTextValue());
561 $correct_answers = $this->object->getCorrectAnswers();
562 $answers = $this->object->getAnswers();
563 foreach ($text_array as $key => $value) {
564 $answer_is_correct = false;
565 $user_value = '';
566 $return_value .= ilLegacyFormElementsUtil::prepareTextareaOutput($value, true);
567 if ($key < sizeof($text_array) - 1) {
568 if (!array_key_exists($key, $correct_answers)) {
569 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('longmenu_answeroptions_differ'));
570 continue;
571 }
572 if ($correct_answers[$key][2] === assLongMenu::ANSWER_TYPE_TEXT_VAL) {
573 if (array_key_exists($key, $user_solution)) {
574 $user_value = $user_solution[$key];
575 if (in_array($user_value, $correct_answers[$key][0])) {
576 $answer_is_correct = true;
577 }
578 }
579
580 $return_value .= $this->getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
581 } elseif ($correct_answers[$key][2] === assLongMenu::ANSWER_TYPE_SELECT_VAL) {
582 if (array_key_exists($key, $user_solution)) {
583 $user_value = $user_solution[$key];
584 if (in_array($user_value, $correct_answers[$key][0])) {
585 $answer_is_correct = true;
586 }
587 }
588 $return_value .= $this->getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
589 }
590 }
591 }
592 return $return_value;
593 }
getSelectGapTemplate($key, $answers, $user_value, $solution, $ok=false, $graphical=false)
getTextGapTemplate($key, $value, $solution, $ok=false, $graphical=false)
const ANSWER_TYPE_TEXT_VAL
const ANSWER_TYPE_SELECT_VAL
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,...

References assLongMenu\ANSWER_TYPE_SELECT_VAL, assLongMenu\ANSWER_TYPE_TEXT_VAL, assLongMenu\GAP_PLACEHOLDER, ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

+ Here is the call graph for this function:

◆ getModalHtml()

assLongMenuGUI::getModalHtml ( string &  $modal_id)
private

Definition at line 342 of file class.assLongMenuGUI.php.

342 : string
343 {
344 $modal = $this->ui_factory->modal()->interruptive('', '', '');
345 $doc = new DOMDocument();
346 @$doc->loadHTML($this->ui_renderer->render($modal));
347 $dialogs = $doc->getElementsByTagName('dialog');
348 $modal_id = $dialogs->item(0)->attributes->getNamedItem('id')->nodeValue ?? self::DEFAULT_MODAL_ID;
349 return $doc->saveHTML();
350 }

◆ getPreview()

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

Reimplemented from assQuestionGUI.

Definition at line 465 of file class.assLongMenuGUI.php.

468 : string {
469 $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : [];
470 $user_solution = array_values($user_solution);
471
472 $template = $this->getTemplateForPreviewAndTest($user_solution);
473
474 $question_output = $template->get();
475 if (!$show_question_only) {
476 $question_output = $this->getILIASPage($question_output);
477 }
478 return $question_output;
479 }
getTemplateForPreviewAndTest(array $user_solution)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.

◆ getSelectGapTemplate()

assLongMenuGUI::getSelectGapTemplate (   $key,
  $answers,
  $user_value,
  $solution,
  $ok = false,
  $graphical = false 
)
private

Definition at line 618 of file class.assLongMenuGUI.php.

618 : string
619 {
620 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_select_gap.html", true, true, "components/ILIAS/TestQuestionPool");
621 $tpl->setVariable('KEY', $key);
622 if ($solution) {
623 $tpl->setVariable('DISABLED', 'disabled');
624 $tpl->setVariable('JS_IGNORE', '_ignore');
625 $tpl->setCurrentBlock('best_solution');
626 if ($user_value == -1) {
627 $tpl->setVariable("SOLUTION", $this->lng->txt("please_select"));
628 } else {
630 'SOLUTION',
631 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($user_value)
632 );
633 }
634 if ($graphical) {
635 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
636 if ($ok) {
637 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
638 }
639 $tpl->setVariable("ICON_OK", $correctness_icon);
640 }
642 } else {
643 $tpl->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
644 foreach ($answers as $value) {
645 $tpl->setCurrentBlock('select_option');
647 'VALUE',
648 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($value)
649 );
650 if ($value === $user_value) {
651 $tpl->setVariable('SELECTED', 'selected');
652 }
654 }
655 }
656 return $tpl->get();
657 }
ilGlobalPageTemplate $tpl
generateCorrectnessIconsForCorrectness(int $correctness)
setCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
special template class to simplify handling of ITX/PEAR

References ILIAS\News\Common\Table\$tpl, ILIAS\UICore\GlobalTemplate\get(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\Repository\refinery(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

◆ getSolutionOutput()

assLongMenuGUI::getSolutionOutput ( int  $active_id,
?int  $pass = null,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_inline_feedback = true 
)

Reimplemented from assQuestionGUI.

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

372 : string {
373 if (($active_id > 0) && (!$show_correct_solution)) {
374 $user_solutions = $this->object->getSolutionValues($active_id, $pass, true);
375 } else {
376 $user_solutions = [];
377 foreach ($this->object->getCorrectAnswersForQuestionSolution($this->object->getId()) as $idx => $val) {
378 $user_solutions[] = [
379 'value1' => $idx,
380 'value2' => $val,
381 ];
382 }
383 }
384
385 return $this->renderSolutionOutput(
386 $user_solutions,
387 $active_id,
388 $pass,
389 $graphical_output,
390 $result_output,
391 $show_question_only,
392 $show_feedback,
393 $show_correct_solution,
394 $show_manual_scoring,
395 $show_question_text,
396 false,
397 $show_inline_feedback
398 );
399 }
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,)

◆ getSpecificFeedbackOutput()

assLongMenuGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

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

Reimplemented from assQuestionGUI.

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

517 : string
518 {
519 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
520 return '';
521 }
522
523 $feedback = '<table class="test_specific_feedback"><tbody>';
524 $gaps = $this->object->getCorrectAnswers();
525 foreach ($gaps as $index => $answer) {
526 $caption = assLongMenu::GAP_PLACEHOLDER . ' ';
527 $caption .= $index + 1 . ': ';
528
529 $feedback .= '<tr><td>';
530
531 $feedback .= $caption . '</td><td>';
532 $feedback .= $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
533 $this->object->getId(),
534 0,
535 $index
536 ) . '</td> </tr>';
537 }
538 $feedback .= '</tbody></table>';
540 }

References assLongMenu\GAP_PLACEHOLDER, ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

+ Here is the call graph for this function:

◆ getSubQuestionsIndex()

assLongMenuGUI::getSubQuestionsIndex ( )

Reimplemented from assQuestionGUI.

Definition at line 659 of file class.assLongMenuGUI.php.

659 : array
660 {
661 return array_keys($this->object->getAnswers());
662 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getTemplateForPreviewAndTest()

assLongMenuGUI::getTemplateForPreviewAndTest ( array  $user_solution)
protected

Definition at line 503 of file class.assLongMenuGUI.php.

503 : ilTemplate
504 {
505 $template = new ilTemplate('tpl.il_as_qpl_longmenu_question_output.html', true, true, 'components/ILIAS/TestQuestionPool');
506 $this->tpl->addJavaScript('assets/js/longMenuQuestionPlayer.js');
507 $this->tpl->addOnLoadCode('il.test.player.longmenu.init('
508 . $this->object->getMinAutoComplete() . ', '
509 . json_encode($this->object->getAvailableAnswerOptions())
510 . ')');
511
512 $template->setVariable('QUESTIONTEXT', $this->renderLatex($this->renderLatex($this->object->getQuestionForHTMLOutput())));
513 $template->setVariable('LONGMENU_TEXT', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution));
514 return $template;
515 }
getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution=[], $solution=false, $graphical=false)
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

Definition at line 481 of file class.assLongMenuGUI.php.

487 : string {
488 $user_solution = [];
489 if ($active_id) {
490 $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
491 foreach ($solutions as $idx => $solution_value) {
492 $user_solution[$solution_value['value1']] = $solution_value['value2'];
493 }
494 }
495
496 $template = $this->getTemplateForPreviewAndTest($user_solution);
497
498 $question_output = $template->get();
499 $page_output = $this->outQuestionPage('', $is_question_postponed, $active_id, $question_output);
500 return $page_output;
501 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)

◆ getTextGapTemplate()

assLongMenuGUI::getTextGapTemplate (   $key,
  $value,
  $solution,
  $ok = false,
  $graphical = false 
)
private

Definition at line 595 of file class.assLongMenuGUI.php.

595 : string
596 {
597 $tpl = new ilTemplate('tpl.il_as_qpl_longmenu_question_text_gap.html', true, true, 'components/ILIAS/TestQuestionPool');
598 if ($solution) {
599 $tpl->setVariable('DISABLED', 'disabled');
600 $tpl->setVariable('JS_IGNORE', '_ignore');
601 if ($graphical) {
602 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
603 if ($ok) {
604 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
605 }
606 $tpl->setVariable("ICON_OK", $correctness_icon);
607 }
608 }
609 if ($solution) {
610 $tpl->setVariable('SIZE', 'size="' . mb_strlen($value) . '"');
611 }
612 $tpl->setVariable('VALUE', htmlentities($value));
613 $tpl->setVariable('KEY', $key);
614
615 return $tpl->get();
616 }

References ILIAS\News\Common\Table\$tpl, ILIAS\UICore\GlobalTemplate\get(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

◆ populateAnswerSpecificFormPart()

assLongMenuGUI::populateAnswerSpecificFormPart ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form
Returns
ilPropertyFormGUI

Definition at line 356 of file class.assLongMenuGUI.php.

357 {
358 return $form;
359 }

◆ populateCorrectionsFormProperties()

assLongMenuGUI::populateCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

Definition at line 708 of file class.assLongMenuGUI.php.

708 : void
709 {
710 $correct_answers = $this->object->getCorrectAnswers();
711
712 foreach ($this->object->getAnswers() as $lm_index => $lm) {
713 $lm_values = [
714 'answers_all' => [0 => $lm],
715 'answers_all_count' => count($lm),
716 'answers_correct' => $correct_answers[$lm_index][0]
717 ];
718
719 $lm_points = $correct_answers[$lm_index][1];
720
721 $section = new ilFormSectionHeaderGUI();
722 $section->setTitle($this->lng->txt('longmenu') . ' ' . ($lm_index + 1));
723 $form->addItem($section);
724
725 $lm_input = new ilAssLongmenuCorrectionsInputGUI(
726 $this->lng->txt('answers'),
727 'longmenu_' . $lm_index
728 );
729
730 $lm_input->setRequired(true);
731
732 $lm_input->setValues($lm_values);
733
734 $form->addItem($lm_input);
735
736 $points_inp = new ilNumberInputGUI($this->lng->txt("points"), 'points_' . $lm_index);
737 $points_inp->setRequired(true);
738 $points_inp->allowDecimals(true);
739 $points_inp->setSize(4);
740 $points_inp->setMinValue(0);
741 $points_inp->setMinvalueShouldBeGreater(false);
742 $points_inp->setValue($lm_points);
743 $form->addItem($points_inp);
744 }
745 }
This class represents a section header in a property form.
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()

assLongMenuGUI::populateQuestionSpecificFormPart ( ilPropertyFormGUI  $form)

Adds the question specific forms parts to a question property form gui.

Implements ilGuiQuestionScoringAdjustable.

Definition at line 211 of file class.assLongMenuGUI.php.

212 {
213 $long_menu_text = new ilTextAreaInputGUI($this->lng->txt("longmenu_text"), 'longmenu_text');
214 $long_menu_text->setRequired(true);
215 $long_menu_text->setRows(10);
216 $long_menu_text->setCols(80);
217 if (!$this->object->getSelfAssessmentEditingMode()) {
218 if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_RTE) {
219 $long_menu_text->setRteTags(ilRTESettings::_getUsedHTMLTags("assessment"));
220 $long_menu_text->setRTESupport($this->object->getId(), "qpl", "assessment");
221 $long_menu_text->setUseRte(true);
222 }
223 } else {
225 $long_menu_text->setUseTagsForRteOnly(false);
226 }
227
228 $long_menu_text->setValue($this->object->getLongMenuTextValue());
229 $form->addItem($long_menu_text);
230
231 $tpl = new ilTemplate('tpl.il_as_qpl_longmenu_question_gap_button_code.html', true, true, 'components/ILIAS/TestQuestionPool');
232 $tpl->setVariable('INSERT_GAP', $this->lng->txt('insert_gap'));
234 $button = new ilCustomInputGUI('&nbsp;', '');
235 $button->setHtml($tpl->get());
236 $form->addItem($button);
237
238 $min_auto_complete = new ilNumberInputGUI($this->lng->txt('min_auto_complete'), 'min_auto_complete');
239
240 $auto_complete = $this->object->getMinAutoComplete();
241 if ($auto_complete === 0) {
243 }
244 $min_auto_complete->setDecimals(0);
245 $min_auto_complete->setValue($auto_complete);
246 $min_auto_complete->setMinValue(1);
247 $min_auto_complete->setMaxValue(99);
248 $min_auto_complete->setSize(5);
249 $form->addItem($min_auto_complete);
250 // identical scoring
251 $identical_scoring = new ilCheckboxInputGUI($this->lng->txt('identical_scoring'), 'identical_scoring');
252 $identical_scoring->setValue(1);
253 $identical_scoring->setChecked($this->object->getIdenticalScoring());
254 $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
255 $identical_scoring->setRequired(false);
256 $form->addItem($identical_scoring);
257 $hidden_text = new ilHiddenInputGUI('hidden_text_files');
258 $form->addItem($hidden_text);
259
260 $hidden_correct = new ilHiddenInputGUI('hidden_correct_answers');
261 $form->addItem($hidden_correct);
262
263 $long_menu_language = [
264 'edit' => '[' . $this->lng->txt('edit') . ']',
265 'type' => $this->lng->txt('type'),
266 'answers' => $this->lng->txt('answers'),
267 'answer_options' => $this->lng->txt('answer_options'),
268 'correct_answers' => $this->lng->txt('correct_answers') . ':',
269 'add_answers' => '[' . $this->lng->txt('add_answers') . ']',
270 'manual_editing' => $this->lng->txt('manual_editing')
271 ];
272
273 $question_parts = [
274 'list' => json_decode($this->object->getJsonStructure()) ?? [],
275 'gap_placeholder' => assLongMenu::GAP_PLACEHOLDER,
276 'last_updated_element' => 0,
277 'replacement_word' => '',
278 'filereader_usable' => false,
279 'max_input_fields' => assLongMenu::MAX_INPUT_FIELDS
280 ];
281 $answers = $this->object->getAnswersObject();
282
283 if ($this->request_data_collector->isset('hidden_text_files')) {
284 $question_parts['list'] = $this->trimArrayRecursive(
286 json_decode(
287 $this->request_data_collector->string('hidden_correct_answers')
288 ) ?? []
289 )
290 );
291 $answers = $this->request_data_collector->string('hidden_text_files');
292 }
293
294 $this->tpl->addJavaScript('assets/js/longMenuQuestionGapBuilder.js');
295 $this->tpl->addJavaScript('assets/js/longMenuQuestion.js');
296 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_gap.html", true, true, "components/ILIAS/TestQuestionPool");
297 $tpl->setVariable('MAX_INPUT_FIELDS', assLongMenu::MAX_INPUT_FIELDS);
298 $tpl->setVariable('GAP_PLACEHOLDER', assLongMenu::GAP_PLACEHOLDER);
299 $tpl->setVariable('SELECT_BOX', $this->lng->txt('insert_gap'));
300 $tpl->setVariable("SELECT", $this->lng->txt('answers_select'));
301 $tpl->setVariable("TEXT", $this->lng->txt('answers_text_box'));
302 $tpl->setVariable("POINTS", $this->lng->txt('points'));
303 $tpl->setVariable("INFO_TEXT_UPLOAD", $this->lng->txt('info_text_upload'));
304 $tpl->setVariable("TXT_BROWSE", $this->lng->txt('select_file'));
305 $tpl->setVariable('POINTS_ERROR', $this->lng->txt('enter_enough_positive_points'));
306 $tpl->setVariable('AUTOCOMPLETE_ERROR', $this->lng->txt('autocomplete_error'));
307 $tpl->setVariable('MISSING_VALUE', $this->lng->txt('msg_input_is_required'));
308 $tpl->setVariable('SAVE', $this->lng->txt('save'));
309 $tpl->setVariable('CANCEL', $this->lng->txt('cancel'));
310 $tpl->setVariable('ADD_BUTTON', $this->ui_renderer->render(
311 $this->ui_factory->button()->shy('', '')->withSymbol($this->ui_factory->symbol()->glyph()->add())
312 ));
313 $tpl->setVariable('REMOVE_BUTTON', $this->ui_renderer->render(
314 $this->ui_factory->button()->shy('', '')->withSymbol($this->ui_factory->symbol()->glyph()->remove())
315 ));
316 $tag_input = new ilTagInputGUI();
317 $tag_input->setPostVar('taggable');
318 $tag_input->setJsSelfInit(false);
319 $tag_input->setTypeAheadMinLength(1);
320 $tpl->setVariable('TAGGING_PROTOTYPE', $tag_input->render(''));
321
322 $modal_id = self::DEFAULT_MODAL_ID;
323 $tpl->setVariable('MY_MODAL', $this->getModalHtml($modal_id));
325 $this->tpl->addOnLoadCode(
326 'longMenuQuestion.Init(' .
327 implode(', ', [
328 json_encode($long_menu_language),
329 json_encode($question_parts),
330 $answers === '' ? '{}' : $answers,
331 json_encode($modal_id)
332 ])
333 . ');'
334 );
335
336 $button = new ilCustomInputGUI('&nbsp;', '');
337 $button->setHtml($tpl->get());
338 $form->addItem($button);
339 return $form;
340 }
trimArrayRecursive(array $data)
getModalHtml(string &$modal_id)
stripSlashesRecursive(array $data)
const MIN_LENGTH_AUTOCOMPLETE
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
This class represents a hidden form property in a property form.
static _getUsedHTMLTags(string $module='')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.

References ILIAS\News\Common\Table\$tpl, ilRTESettings\_getUsedHTMLTags(), ilPropertyFormGUI\addItem(), assQuestion\ADDITIONAL_CONTENT_EDITING_MODE_RTE, assLongMenu\GAP_PLACEHOLDER, ILIAS\UICore\GlobalTemplate\get(), ilAssSelfAssessmentQuestionFormatter\getSelfAssessmentTags(), ILIAS\Repository\lng(), assLongMenu\MAX_INPUT_FIELDS, assLongMenu\MIN_LENGTH_AUTOCOMPLETE, ILIAS\Repository\object(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

◆ renderSolutionOutput()

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

Reimplemented from assQuestionGUI.

Definition at line 401 of file class.assLongMenuGUI.php.

414 : ?string {
415
416 $user_solution = [];
417 foreach ($user_solutions as $idx => $solution_value) {
418 $user_solution[$solution_value["value1"]] = $solution_value["value2"];
419 }
420
421 $template = new ilTemplate("tpl.il_as_qpl_longmenu_question_output_solution.html", true, true, "components/ILIAS/TestQuestionPool");
422 if ($show_question_text) {
423 $template->setVariable("QUESTIONTEXT", $this->renderLatex($this->object->getQuestionForHTMLOutput()));
424 }
425 $template->setVariable(
426 'LONGMENU_TEXT_SOLUTION',
427 $this->renderLatex(
428 $this->getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution, true, $graphical_output)
429 )
430 );
431
432 $solution_template = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
433 $question_output = $template->get();
434 $feedback = '';
435 if ($show_feedback) {
436 if (!$this->isTestPresentationContext()) {
437 $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
438 $feedback .= strlen($fb) ? $fb : '';
439 }
440
441 $fb = $this->getSpecificFeedbackOutput([]);
442 $feedback .= strlen($fb) ? $fb : '';
443 }
444 if (strlen($feedback)) {
445 $cssClass = (
446 $this->hasCorrectSolution($active_id, $pass) ?
448 );
449
450 $solution_template->setVariable("ILC_FB_CSS_CLASS", $cssClass);
451 $solution_template->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
452 }
453
454 $solution_template->setVariable("SOLUTION_OUTPUT", $question_output);
455
456 $solution_output = $solution_template->get();
457
458 if (!$show_question_only) {
459 $solution_output = $this->getILIASPage($solution_output);
460 }
461
462 return $solution_output;
463 }
getSpecificFeedbackOutput(array $userSolution)
Returns the answer specific feedback for the question.
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)

◆ saveCorrectionsFormProperties()

assLongMenuGUI::saveCorrectionsFormProperties ( ilPropertyFormGUI  $form)

Reimplemented from assQuestionGUI.

Definition at line 747 of file class.assLongMenuGUI.php.

747 : void
748 {
749 $correct_answers = $this->object->getCorrectAnswers();
750
751 foreach ($this->object->getAnswers() as $lm_index => $lm) {
752 $points_input = $this->refinery->kindlyTo()->float()->transform(
753 $form->getInput('points_' . $lm_index)
754 );
755 $correct_answers_input = (array) $form->getInput('longmenu_' . $lm_index . '_tags');
756
757 foreach ($correct_answers_input as $idx => $answer) {
758 if (in_array($answer, $lm)) {
759 continue;
760 }
761
762 unset($correct_answers_input[$idx]);
763 }
764
765 $correct_answers[$lm_index][0] = array_values($correct_answers_input);
766 $correct_answers[$lm_index][1] = $points_input;
767 }
768
769 $this->object->setCorrectAnswers($correct_answers);
770 }
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(), ILIAS\Repository\object(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ stripSlashesRecursive()

assLongMenuGUI::stripSlashesRecursive ( array  $data)
private

Definition at line 132 of file class.assLongMenuGUI.php.

132 : array
133 {
134 return array_map(
135 function (int|float|string|array $v): int|float|string|array {
136 if (is_array($v)) {
137 return $this->stripSlashesRecursive($v);
138 }
139 if (is_int($v) || is_float($v)) {
140 return $v;
141 }
142 return ilUtil::stripSlashes($v);
143 },
144 $data
145 );
146 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$data
Definition: storeScorm.php:45

References $data, ilUtil\stripSlashes(), and stripSlashesRecursive().

Referenced by stripSlashesRecursive(), verifyAnswerOptions(), and writeQuestionSpecificPostData().

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

◆ trimArrayRecursive()

assLongMenuGUI::trimArrayRecursive ( array  $data)
private

Definition at line 148 of file class.assLongMenuGUI.php.

148 : array
149 {
150 return array_map(
151 function (int|float|string|array $v): int|float|string|array {
152 if (is_array($v)) {
153 return $this->trimArrayRecursive($v);
154 }
155 if (is_int($v) || is_float($v)) {
156 return $v;
157 }
158 return trim($v);
159 },
160 $data
161 );
162 }

References $data, and trimArrayRecursive().

Referenced by trimArrayRecursive(), and writeQuestionSpecificPostData().

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

◆ verifyAnswerOptions()

assLongMenuGUI::verifyAnswerOptions ( )
private

Definition at line 105 of file class.assLongMenuGUI.php.

105 : bool
106 {
107 $longmenu_text = $this->request_data_collector->raw('longmenu_text') ?? '';
108 $hidden_text_files = $this->request_data_collector->raw('hidden_text_files') ?? '';
109 $answer_options_from_text = preg_split(
110 "/\\[" . assLongMenu::GAP_PLACEHOLDER . " (\\d+)\\]/",
111 $longmenu_text
112 );
113
114 $answer_options_from_files = $this->stripSlashesRecursive(json_decode($hidden_text_files));
115 if (count($answer_options_from_text) - 1 !== count($answer_options_from_files)) {
116 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('longmenu_answeroptions_differ'));
117 return false;
118 }
119
120 $correct_answers = $this->stripSlashesRecursive(json_decode($this->request_data_collector->raw('hidden_correct_answers')));
121 foreach ($correct_answers as $answer) {
122 try {
123 $this->refinery->kindlyTo()->float()->transform($answer[1]);
124 } catch (\ILIAS\Refinery\ConstraintViolationException $e) {
125 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('points_non_numeric_or_negative_msg'));
126 return false;
127 }
128 }
129 return true;
130 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References Vendor\Package\$e, assLongMenu\GAP_PLACEHOLDER, ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and stripSlashesRecursive().

Referenced by writePostData().

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

◆ writePostData()

assLongMenuGUI::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 58 of file class.assLongMenuGUI.php.

58 : int
59 {
60 $this->editForm = $this->buildEditForm();
61 $this->editForm->setValuesByPost();
62 $check = $this->editForm->checkInput() && $this->verifyAnswerOptions();
63
64 if (!$check) {
65 $this->editQuestion();
66 return 1;
67 }
69 $this->writeQuestionSpecificPostData($this->editForm);
70 $custom_check = $this->object->checkQuestionCustomPart($this->editForm);
71 if (!$custom_check) {
72 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
73 $this->editQuestion();
74 return 1;
75 }
77 return 0;
78 }
$check
Definition: buildRTE.php:81
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from the request and applies them to the data object.

References $check, buildEditForm(), editQuestion(), ILIAS\Repository\lng(), assQuestionGUI\saveTaxonomyAssignments(), verifyAnswerOptions(), assQuestionGUI\writeQuestionGenericPostData(), and writeQuestionSpecificPostData().

+ Here is the call graph for this function:

◆ writeQuestionSpecificPostData()

assLongMenuGUI::writeQuestionSpecificPostData ( ilPropertyFormGUI  $form)

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

Implements ilGuiQuestionScoringAdjustable.

Definition at line 80 of file class.assLongMenuGUI.php.

80 : void
81 {
82 $min_auto_complete = (int) ($form->getInput('min_auto_complete') ?? assLongMenu::MIN_LENGTH_AUTOCOMPLETE);
83 $hidden_text_files = $this->request_data_collector->string('hidden_text_files');
84 $hidden_correct_answers = $this->request_data_collector->string('hidden_correct_answers');
85 $long_menu_type = $this->request_data_collector->intArray('long_menu_type');
86 $this->object->setLongMenuTextValue($this->request_data_collector->string('longmenu_text'));
87 $this->object->setAnswers($this->trimArrayRecursive($this->stripSlashesRecursive(json_decode($hidden_text_files))));
88 $this->object->setCorrectAnswers(
90 $this->trimArrayRecursive(
92 json_decode($hidden_correct_answers)
93 )
94 )
95 )
96 );
97 $this->object->setAnswerType(ilArrayUtil::stripSlashesRecursive($long_menu_type));
98 $this->object->setQuestion($this->request_data_collector->string('question'));
99 $this->object->setMinAutoComplete($min_auto_complete);
100 $this->object->setIdenticalScoring($this->request_data_collector->int('identical_scoring'));
101
103 }
convertPointsToFloat(array $correct_answers)
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")

References convertPointsToFloat(), ilPropertyFormGUI\getInput(), ILIAS\Repository\int(), assLongMenu\MIN_LENGTH_AUTOCOMPLETE, assQuestionGUI\saveTaxonomyAssignments(), ilArrayUtil\stripSlashesRecursive(), stripSlashesRecursive(), and trimArrayRecursive().

Referenced by writePostData().

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

Field Documentation

◆ $ui_factory

readonly UIFactory assLongMenuGUI::$ui_factory
private

Definition at line 33 of file class.assLongMenuGUI.php.

◆ $ui_renderer

readonly UIRenderer assLongMenuGUI::$ui_renderer
private

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

◆ DEFAULT_MODAL_ID

const assLongMenuGUI::DEFAULT_MODAL_ID = 'ilGapModal'
private

Definition at line 31 of file class.assLongMenuGUI.php.


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