ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
assFormulaQuestionGUI 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 assFormulaQuestionGUI:
+ Collaboration diagram for assFormulaQuestionGUI:

Public Member Functions

 __construct ($id=-1)
 assFormulaQuestionGUI constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestionGUI object. More...
 
 suggestRange ()
 
 parseQuestion ()
 
 checkInput ()
 check input fields 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)
 
 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...
 
- 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 ()
 

Protected Member Functions

 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 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 ()
 
 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 ()
 

Protected Attributes

const HAS_SPECIAL_QUESTION_COMMANDS = true
 
- 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...
 
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
 

Private Member Functions

 getSuggestRangeOnLoadCode (string $result)
 
 hasResultUnit ($result, $unit_id, $resultunits)
 
 canUseAdvancedRating ($result)
 Check if advanced rating can be used for a result. More...
 

Private Attributes

UIFactory $ui_factory
 
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'
 

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 Single choice question GUI representation The assFormulaQuestionGUI class encapsulates the GUI representation for single choice 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
Version
Id
class.assFormulaQuestionGUI.php 1235 2010-02-15 15:21:18Z hschottm

\ @ilCtrl_Calls assFormulaQuestionGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assFormulaQuestionGUI::__construct (   $id = -1)

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

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

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

45 {
47 global $DIC;
48 $this->ui_factory = $DIC->ui()->factory();
49 $this->ui_renderer = $DIC->ui()->renderer();
50
51 $this->object = new assFormulaQuestion();
52 if ($id >= 0) {
53 $this->object->loadFromDb($id);
54 }
55 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class for single choice questions assFormulaQuestion is a class for single choice questions.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ canUseAdvancedRating()

assFormulaQuestionGUI::canUseAdvancedRating (   $result)
private

Check if advanced rating can be used for a result.

This is only possible if there is exactly one possible correct unit for the result, otherwise it is impossible to determine wheather the unit is correct or the value.

Returns
boolean True if advanced rating could be used, false otherwise

Definition at line 734 of file class.assFormulaQuestionGUI.php.

734 : bool
735 {
736 $resultunit = $result->getUnit();
737
738 /*
739 * if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
740 * if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
741 * definition if the result-value or the unit-value should be the correct solution!!
742 *
743 */
744 if (is_object($resultunit)) {
745 return true;
746 } else {
747 return false;
748 }
749 }

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

Definition at line 763 of file class.assFormulaQuestionGUI.php.

763 : bool
764 {
765 $title = $this->request_data_collector->string('title');
766 $author = $this->request_data_collector->string('author');
767 $question = $this->request_data_collector->string('question');
768
769 if (empty($title) || empty($author) || empty($question)) {
770 $this->addErrorMessage($this->lng->txt('fill_out_all_required_fields'));
771 return false;
772 }
773
774 return true;
775 }
addErrorMessage(string $errormessage)

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getPreview()

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

Reimplemented from assQuestionGUI.

Definition at line 895 of file class.assFormulaQuestionGUI.php.

898 : string {
899 $user_solution = [];
900 if (is_object($this->getPreviewSession())) {
901 $solutions = $this->getPreviewSession()->getParticipantsSolution() ?? [];
902 foreach ($solutions as $val1 => $val2) {
903 if (preg_match('/^(\$v\d+)$/', $val1, $matches)) {
904 $user_solution[$matches[1]] = $val2;
905 } elseif (preg_match('/^(\$r\d+)$/', $val1, $matches)) {
906 if (!array_key_exists($matches[1], $user_solution)) {
907 $user_solution[$matches[1]] = [];
908 }
909 $user_solution[$matches[1]]['value'] = $val2;
910 } elseif (preg_match('/^(\$r\d+)_unit$/', $val1, $matches)) {
911 if (!array_key_exists($matches[1], $user_solution)) {
912 $user_solution[$matches[1]] = [];
913 }
914 $user_solution[$matches[1]]['unit'] = $val2;
915 }
916
917 if (preg_match('/^(\$r\d+)/', $val1, $matches) && !isset($user_solution[$matches[1]]['result_type'])) {
918 $user_solution[$matches[1]]['result_type'] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
919 }
920 }
921 }
922
923 if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
924 $user_solution = $this->object->getInitialVariableSolutionValues();
925
926 if (is_object($this->getPreviewSession())) {
927 $this->getPreviewSession()->setParticipantsSolution($user_solution);
928 }
929 }
930
931 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'components/ILIAS/TestQuestionPool');
932 if (is_object($this->getPreviewSession())) {
933 $questiontext = $this->object->substituteVariables($user_solution);
934 } else {
935 $questiontext = $this->object->substituteVariables([]);
936 }
937 $template->setVariable("QUESTIONTEXT", $this->renderLatex(
939 ));
940 $questionoutput = $template->get();
941 if (!$show_question_only) {
942 // get page object output
943 $questionoutput = $this->getILIASPage($questionoutput);
944 }
945 return $questionoutput;
946 }
static getResultTypeByQstId($a_qst_id, $a_result)
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
special template class to simplify handling of ITX/PEAR

References assFormulaQuestionResult\getResultTypeByQstId(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getSolutionOutput()

assFormulaQuestionGUI::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 777 of file class.assFormulaQuestionGUI.php.

788 : string {
789 $user_solution = [];
790 if ($pass !== null) {
791 $user_solution = $this->object->getVariableSolutionValuesForPass($active_id, $pass);
792 } else {
793 $user_solution = array_reduce(
794 $this->object->fetchAllVariables($this->object->getQuestion()),
795 static function (array $c, assFormulaQuestionVariable $v): array {
796 $c[$v->getVariable()] = $v->getVariable();
797 return $c;
798 },
799 []
800 );
801 }
802 if (($active_id > 0) && (!$show_correct_solution)) {
803 $user_solution['active_id'] = $active_id;
804 $user_solution['pass'] = $pass;
805 $solutions = $this->object->getSolutionValues($active_id, $pass);
806 foreach ($solutions as $solution_value) {
807 if (preg_match('/^(\$v\d+)$/', $solution_value['value1'], $matches)) {
808 $user_solution[$matches[1]] = $solution_value['value2'];
809 } elseif (preg_match('/^(\$r\d+)$/', $solution_value['value1'], $matches)) {
810 if (!array_key_exists($matches[1], $user_solution)) {
811 $user_solution[$matches[1]] = [];
812 }
813 $user_solution[$matches[1]]["value"] = $solution_value['value2'];
814 } elseif (preg_match('/^(\$r\d+)_unit$/', $solution_value['value1'], $matches)) {
815 if (!array_key_exists($matches[1], $user_solution)) {
816 $user_solution[$matches[1]] = [];
817 }
818 $user_solution[$matches[1]]['unit'] = $solution_value['value2'];
819 }
820 }
821 } elseif ($active_id !== 0) {
822 $user_solution = $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
823 } elseif (is_object($this->getPreviewSession())) {
824 $solutionValues = [];
825 $participants_solution = $this->getPreviewSession()->getParticipantsSolution();
826 if (is_array($participants_solution)) {
827 foreach ($participants_solution as $val1 => $val2) {
828 $solutionValues[] = ['value1' => $val1, 'value2' => $val2];
829 }
830 }
831 $user_solution = $this->object->getBestSolution($solutionValues);
832 }
833
834 return $this->renderSolutionOutput(
835 $user_solution,
836 $active_id,
837 $pass,
838 $graphical_output,
839 $result_output,
840 $show_question_only,
841 $show_feedback,
842 $show_correct_solution,
843 $show_manual_scoring,
844 $show_question_text,
845 false,
846 $show_inline_feedback
847 );
848 }
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,)
$c
Definition: deliver.php:25

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

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

Reimplemented from assQuestionGUI.

Definition at line 1013 of file class.assFormulaQuestionGUI.php.

1013 : string
1014 {
1015 return '';
1016 }

◆ getSuggestRangeOnLoadCode()

assFormulaQuestionGUI::getSuggestRangeOnLoadCode ( string  $result)
private

Definition at line 701 of file class.assFormulaQuestionGUI.php.

701 : Closure
702 {
703 return static function ($id) use ($result): string {
704 return "document.getElementById('$id').addEventListener('click', "
705 . '(e) => {'
706 . ' e.target.setAttribute("name", "cmd[suggestRange]");'
707 . ' let input = document.createElement("input");'
708 . ' input.type = "hidden";'
709 . ' input.name = "suggest_range_for";'
710 . " input.value = '$result';"
711 . ' e.target.form.appendChild(input);'
712 . ' e.target.form.requestSubmit(e.target);'
713 . '});';
714 };
715 }

References $id.

◆ getTestOutput()

assFormulaQuestionGUI::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 948 of file class.assFormulaQuestionGUI.php.

954 : string {
955 $this->tpl->setOnScreenMessage('info', $this->lng->txt('enter_valid_values'));
956 // get the solution of the user for the active pass or from the last pass if allowed
957 $user_solution = [];
958 if ($active_id) {
959 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
960 $actualPassIndex = null;
961 if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
962 $actualPassIndex = ilObjTest::_getPass($active_id);
963 }
964 foreach ($solutions as $idx => $solution_value) {
965 if (preg_match('/^(\$v\d+)$/', $solution_value['value1'], $matches)) {
966 if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
967 $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value['value2'], true);
968 }
969 $user_solution[$matches[1]] = $solution_value['value2'];
970 } elseif (preg_match('/^(\$r\d+)$/', $solution_value['value1'], $matches)) {
971 if (!array_key_exists($matches[1], $user_solution)) {
972 $user_solution[$matches[1]] = [];
973 }
974 $user_solution[$matches[1]]['value'] = $solution_value['value2'];
975 } elseif (preg_match('/^(\$r\d+)_unit$/', $solution_value['value1'], $matches)) {
976 if (!array_key_exists($matches[1], $user_solution)) {
977 $user_solution[$matches[1]] = [];
978 }
979 $user_solution[$matches[1]][['unit']] = $solution_value['value2'];
980 }
981 if (preg_match('/^(\$r\d+)/', $solution_value['value1'], $matches) && !isset($user_solution[$matches[1]]['result_type'])) {
982 $user_solution[$matches[1]]['result_type'] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value['value1']);
983 }
984 }
985 }
986
987 // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
988 $solutions = $this->object->getSolutionValues($active_id, $pass, true);
989 foreach ($solutions as $idx => $solution_value) {
990 if (preg_match('/^(\$v\d+)$/', $solution_value['value1'], $matches)) {
991 $user_solution[$matches[1]] = $solution_value['value2'];
992 }
993 }
994
995 if ($user_solution === []) {
996 $user_solution = $this->object->getVariableSolutionValuesForPass($active_id, $pass);
997 }
998
999 // generate the question output
1000 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'components/ILIAS/TestQuestionPool');
1001
1002 $questiontext = $this->object->substituteVariables($user_solution);
1003
1004 $template->setVariable("QUESTIONTEXT", $this->renderLatex(
1006 ));
1007
1008 $questionoutput = $template->get();
1009 $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
1010 return $pageoutput;
1011 }
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

References ilObjTest\_getPass(), assFormulaQuestionResult\getResultTypeByQstId(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ hasResultUnit()

assFormulaQuestionGUI::hasResultUnit (   $result,
  $unit_id,
  $resultunits 
)
private

Definition at line 717 of file class.assFormulaQuestionGUI.php.

717 : bool
718 {
719 if (array_key_exists($result->getResult(), $resultunits)) {
720 if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
721 return true;
722 }
723 }
724 return false;
725 }

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

Definition at line 751 of file class.assFormulaQuestionGUI.php.

751 : void
752 {
754 $this->writePostData();
757 $this->editQuestion();
758 }
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)

◆ renderSolutionOutput()

assFormulaQuestionGUI::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 850 of file class.assFormulaQuestionGUI.php.

863 : ?string {
864 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'components/ILIAS/TestQuestionPool');
865 $correctness_icons = [
866 'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
867 'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
868 ];
869 $questiontext = $this->object->substituteVariables($user_solutions, $graphical_output, true, $result_output, $correctness_icons);
870 $template->setVariable("QUESTIONTEXT", $this->renderLatex(
872 ));
873 $questionoutput = $template->get();
874 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
875 $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
876 if (strlen($feedback)) {
877 $cssClass = (
878 $this->hasCorrectSolution($active_id, $pass) ?
880 );
881 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
882 $solutiontemplate->setVariable("FEEDBACK", $this->renderLatex(
884 ));
885 }
886 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
887
888 $solutionoutput = $solutiontemplate->get();
889 if (!$show_question_only) {
890 $solutionoutput = $this->getILIASPage($solutionoutput);
891 }
892 return $solutionoutput;
893 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)

◆ setQuestionSpecificTabs()

assFormulaQuestionGUI::setQuestionSpecificTabs ( ilTabsGUI  $ilTabs)
protected

Reimplemented from assQuestionGUI.

Definition at line 57 of file class.assFormulaQuestionGUI.php.

57 : void
58 {
59 $this->ctrl->setParameterByClass(ilLocalUnitConfigurationGUI::class, 'q_id', $this->object->getId());
60 $ilTabs->addTarget('units', $this->ctrl->getLinkTargetByClass(ilLocalUnitConfigurationGUI::class, ''), '', 'illocalunitconfigurationgui');
61 }
addTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)

References ilTabsGUI\addTarget(), ILIAS\Repository\ctrl(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

Definition at line 63 of file class.assFormulaQuestionGUI.php.

63 : void
64 {
66 $suggest_range_for_result = $this->request_data_collector->string('suggest_range_for');
67 if ($this->writePostData()) {
68 $this->tpl->setOnScreenMessage('info', $this->getErrorMessage());
69 }
71 $this->editQuestion(false, null, $suggest_range_for_result);
72 }

References assQuestionGUI\editQuestion(), assQuestionGUI\getErrorMessage(), assQuestionGUI\setAdditionalContentEditingModeFromPost(), assQuestionGUI\setTestSpecificProperties(), and writePostData().

+ Here is the call graph for this function:

◆ writePostData()

assFormulaQuestionGUI::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 77 of file class.assFormulaQuestionGUI.php.

77 : int
78 {
79 $hasErrors = (!$always) ? $this->editQuestion(true) : false;
80 $checked = true;
81 if (!$hasErrors) {
82 $this->object->setTitle($this->request_data_collector->string('title'));
83 $this->object->setAuthor($this->request_data_collector->string('author'));
84 $this->object->setComment($this->request_data_collector->string('comment'));
85 $this->object->setQuestion($this->request_data_collector->string('question'));
86
87 $this->object->parseQuestionText();
88 $found_vars = [];
89 $found_results = [];
90
91 foreach ($this->request_data_collector->getParsedBody() as $key => $value) {
92 if (preg_match("/^unit_(\\\$v\d+)$/", $key, $matches)) {
93 array_push($found_vars, $matches[1]);
94 }
95 if (preg_match("/^unit_(\\\$r\d+)$/", $key, $matches)) {
96 array_push($found_results, $matches[1]);
97 }
98 }
99
100 try {
101 $lifecycle = ilAssQuestionLifecycle::getInstance($this->request_data_collector->string('lifecycle'));
102 $this->object->setLifecycle($lifecycle);
104 }
105
106 if (!$this->object->checkForDuplicateResults()) {
107 $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
108 $checked = false;
109 }
110
111 foreach ($found_vars as $variable) {
112 if ($this->object->getVariable($variable) != null) {
113 $unit = $this->request_data_collector->int("unit_{$variable}");
114 $varObj = new assFormulaQuestionVariable(
115 $variable,
116 $this->request_data_collector->float("range_min_{$variable}") ?? 0.0,
117 $this->request_data_collector->float("range_max_{$variable}") ?? 0.0,
118 $unit !== null ? $this->object->getUnitrepository()->getUnit(
119 $unit
120 ) : null,
121 $this->request_data_collector->float("precision_{$variable}"),
122 $this->request_data_collector->float("intprecision_{$variable}")
123 );
124 $this->object->addVariable($varObj);
125 }
126 }
127
128 $tmp_form_vars = [];
129 $tmp_quest_vars = [];
130 foreach ($found_results as $result) {
131 $tmp_res_match = preg_match_all(
132 '/([$][v][0-9]*)/',
133 $this->request_data_collector->string("formula_{$result}"),
134 $form_vars
135 );
136 $tmp_form_vars = array_merge($tmp_form_vars, $form_vars[0]);
137
138 $tmp_que_match = preg_match_all(
139 '/([$][v][0-9]*)/',
140 $this->request_data_collector->string('question'),
141 $quest_vars
142 );
143 $tmp_quest_vars = array_merge($tmp_quest_vars, $quest_vars[0]);
144 }
145 $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
146 $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
147
148 if ($result_has_undefined_vars !== [] || $question_has_unused_vars !== []) {
149 $error_message = '';
150 if (count($result_has_undefined_vars) > 0) {
151 $error_message .= $this->lng->txt("res_contains_undef_var") . '<br>';
152 }
153 if (count($question_has_unused_vars) > 0) {
154 $error_message .= $this->lng->txt("que_contains_unused_var");
155 }
156 $checked = false;
157 if ($this->isSaveCommand()) {
158 $this->tpl->setOnScreenMessage('failure', $error_message);
159 }
160 }
161 foreach ($found_results as $result) {
162 if ($this->object->getResult($result) != null) {
163 $unit = $this->request_data_collector->int("unit_{$result}");
164 $resObj = new assFormulaQuestionResult(
165 $result,
166 $this->request_data_collector->float("range_min_{$result}") ?? 0.0,
167 $this->request_data_collector->float("range_max_{$result}") ?? 0.0,
168 $this->request_data_collector->float("tolerance_{$result}") ?? 0.0,
169 $unit !== null ? $this->object->getUnitrepository()->getUnit(
170 $unit
171 ) : null,
172 $this->request_data_collector->string("formula_{$result}"),
173 $this->request_data_collector->float("points_{$result}"),
174 $this->request_data_collector->float("precision_{$result}"),
175 $this->request_data_collector->int("rating_advanced_{$result}") !== 1,
176 $this->request_data_collector->int("rating_advanced_{$result}") === 1 ? $this->request_data_collector->float("rating_sign_{$result}") : null,
177 $this->request_data_collector->int("rating_advanced_{$result}") === 1 ? $this->request_data_collector->float("rating_value_{$result}") : null,
178 $this->request_data_collector->int("rating_advanced_{$result}") === 1 ? $this->request_data_collector->float("rating_unit_{$result}") : null,
179 $this->request_data_collector->int("result_type_{$result}")
180 );
181 $this->object->addResult($resObj);
182 $available_units = $this->request_data_collector->intArray("units_{$result}");
183 if (!empty($available_units)) {
184 $this->object->addResultUnits($resObj, $available_units);
185 }
186 }
187 }
188 if ($checked === false) {
189 $this->editQuestion();
190 return 1;
191 } else {
194 return 0;
195 }
196 } else {
197 return 1;
198 }
199 }
$lifecycle
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References Vendor\Package\$e, $lifecycle, assQuestionGUI\addErrorMessage(), assQuestionGUI\editQuestion(), ilAssQuestionLifecycle\getInstance(), assQuestionGUI\isSaveCommand(), ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\resetSavedPreviewSession(), and assQuestionGUI\saveTaxonomyAssignments().

Referenced by suggestRange().

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

Field Documentation

◆ $ui_factory

UIFactory assFormulaQuestionGUI::$ui_factory
private

Definition at line 35 of file class.assFormulaQuestionGUI.php.

◆ $ui_renderer

UIRenderer assFormulaQuestionGUI::$ui_renderer
private

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

◆ HAS_SPECIAL_QUESTION_COMMANDS

const assFormulaQuestionGUI::HAS_SPECIAL_QUESTION_COMMANDS = true
protected

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


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