ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 ()
 
 supportsAdjustment ()
 

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...
 
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
 

Private Member Functions

 getSuggestRangeOnLoadCode (string $result)
 
 hasResultUnit ($result, $unit_id, $resultunits)
 
 canUseAdvancedRating ($result)
 Check if advanced rating can be used for a result. More...
 
 populateVariablesInUserSolution (int $active_id, ?int $pass, array $user_solution)
 

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

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

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

767 : bool
768 {
769 $title = $this->request_data_collector->string('title');
770 $author = $this->request_data_collector->string('author');
771 $question = $this->request_data_collector->string('question');
772
773 if (empty($title) || empty($author) || empty($question)) {
774 $this->addErrorMessage($this->lng->txt('fill_out_all_required_fields'));
775 return false;
776 }
777
778 return true;
779 }
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 887 of file class.assFormulaQuestionGUI.php.

890 : string {
891 $user_solution = [];
892 if (is_object($this->getPreviewSession())) {
893 $solutions = $this->getPreviewSession()->getParticipantsSolution() ?? [];
894 foreach ($solutions as $val1 => $val2) {
895 if (preg_match('/^(\$v\d+)$/', $val1, $matches)) {
896 $user_solution[$matches[1]] = $val2;
897 } elseif (preg_match('/^(\$r\d+)$/', $val1, $matches)) {
898 if (!array_key_exists($matches[1], $user_solution)) {
899 $user_solution[$matches[1]] = [];
900 }
901 $user_solution[$matches[1]]['value'] = $val2;
902 } elseif (preg_match('/^(\$r\d+)_unit$/', $val1, $matches)) {
903 if (!array_key_exists($matches[1], $user_solution)) {
904 $user_solution[$matches[1]] = [];
905 }
906 $user_solution[$matches[1]]['unit'] = $val2;
907 }
908
909 if (preg_match('/^(\$r\d+)/', $val1, $matches) && !isset($user_solution[$matches[1]]['result_type'])) {
910 $user_solution[$matches[1]]['result_type'] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
911 }
912 }
913 }
914
915 if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
916 $user_solution = $this->object->getInitialVariableSolutionValues();
917
918 if (is_object($this->getPreviewSession())) {
919 $this->getPreviewSession()->setParticipantsSolution($user_solution);
920 }
921 }
922
923 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'components/ILIAS/TestQuestionPool');
924 if (is_object($this->getPreviewSession())) {
925 $questiontext = $this->object->substituteVariables($user_solution);
926 } else {
927 $questiontext = $this->object->substituteVariables([]);
928 }
929 $template->setVariable("QUESTIONTEXT", $this->renderLatex(
931 ));
932 $questionoutput = $template->get();
933 if (!$show_question_only) {
934 // get page object output
935 $questionoutput = $this->getILIASPage($questionoutput);
936 }
937 return $questionoutput;
938 }
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 781 of file class.assFormulaQuestionGUI.php.

792 : string {
793 if ($active_id > 0 && !$show_correct_solution) {
794 $user_solution = $this->object->buildBasicUserSolutionsArray(
795 $active_id,
796 $pass
797 );
798
799 $user_solution = array_merge(
800 $user_solution,
802 $active_id,
803 $pass,
804 $user_solution
805 )
806 );
807 } elseif ($active_id !== 0) {
808 $user_solution = $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
809 } elseif (is_object($this->getPreviewSession())) {
810 $solution_values = [];
811 $participants_solution = $this->getPreviewSession()->getParticipantsSolution();
812 if (is_array($participants_solution)) {
813 foreach ($participants_solution as $val1 => $val2) {
814 $solution_values[] = ['value1' => $val1, 'value2' => $val2];
815 }
816 }
817 $user_solution = $this->object->getBestSolution($solution_values);
818 } else {
819 $user_solution = $this->populateVariablesInUserSolution(
820 $active_id,
821 $pass,
822 []
823 );
824 }
825
826 return $this->renderSolutionOutput(
827 $user_solution,
828 $active_id,
829 $pass,
830 $graphical_output,
831 $result_output,
832 $show_question_only,
833 $show_feedback,
834 $show_correct_solution,
835 $show_manual_scoring,
836 $show_question_text,
837 false,
838 $show_inline_feedback
839 );
840 }
populateVariablesInUserSolution(int $active_id, ?int $pass, array $user_solution)
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()

assFormulaQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

Returns the answer specific feedback for the question.

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

Reimplemented from assQuestionGUI.

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

1005 : string
1006 {
1007 return '';
1008 }

◆ getSuggestRangeOnLoadCode()

assFormulaQuestionGUI::getSuggestRangeOnLoadCode ( string  $result)
private

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

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

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

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

721 : bool
722 {
723 if (array_key_exists($result->getResult(), $resultunits)) {
724 if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
725 return true;
726 }
727 }
728 return false;
729 }

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

755 : void
756 {
758 $this->writePostData();
761 $this->editQuestion();
762 }
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)

◆ populateVariablesInUserSolution()

assFormulaQuestionGUI::populateVariablesInUserSolution ( int  $active_id,
?int  $pass,
array  $user_solution 
)
private

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

1014 : array {
1015 if ($pass !== null) {
1016 return $this->object->resolveVariableSolutionValuesForPass(
1017 $active_id,
1018 $pass,
1019 $user_solution
1020 );
1021 }
1022
1023 return array_reduce(
1024 $this->object->fetchAllVariables($this->object->getQuestion()),
1025 static function (array $c, assFormulaQuestionVariable $v): array {
1026 $c[$v->getVariable()] = $v->getVariable();
1027 return $c;
1028 },
1029 $user_solution
1030 );
1031 }

◆ 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 842 of file class.assFormulaQuestionGUI.php.

855 : ?string {
856 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'components/ILIAS/TestQuestionPool');
857 $correctness_icons = [
858 'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
859 'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
860 ];
861 $questiontext = $this->object->substituteVariables($user_solutions, $graphical_output, true, $result_output, $correctness_icons);
862 $template->setVariable("QUESTIONTEXT", $this->renderLatex(
864 ));
865 $questionoutput = $template->get();
866 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
867 $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
868 if (strlen($feedback)) {
869 $cssClass = (
870 $this->hasCorrectSolution($active_id, $pass) ?
872 );
873 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
874 $solutiontemplate->setVariable("FEEDBACK", $this->renderLatex(
876 ));
877 }
878 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
879
880 $solutionoutput = $solutiontemplate->get();
881 if (!$show_question_only) {
882 $solutionoutput = $this->getILIASPage($solutionoutput);
883 }
884 return $solutionoutput;
885 }
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 = new ilAssQuestionLifecycle($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

References Vendor\Package\$e, $lifecycle, assQuestionGUI\addErrorMessage(), assQuestionGUI\editQuestion(), 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: