ILIAS  release_8 Revision v8.24
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 (string $suggest_range_for_result)
 
 resetSavedPreviewSession ()
 
 isSaveCommand ()
 
 parseQuestion ()
 
 saveReturnFQ ()
 
 saveFQ ()
 
 checkInput ()
 check input fields More...
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 Get the question solution output. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
- Public Member Functions inherited from assQuestionGUI
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 cancel ()
 
 originalSyncForm (string $return_to="", string $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 
 save ()
 
 saveReturn ()
 
 apply ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 outAdditionalOutput ()
 Why are you here? Some magic for plugins? More...
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addNewIdListener ($a_object, string $a_method, string $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners (int $a_new_id)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 suggestedsolution ()
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 

Protected Member Functions

 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 callSpecialQuestionCommands (string $cmd)
 
 writePostData (bool $always=false)
 {Evaluates a posted edit form and writes the form data in the question object.
Returns
integer A positive value, if one of the required fields wasn't set, else 0
} More...
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Protected Attributes

const HAS_SPECIAL_QUESTION_COMMANDS = true
 
- Protected Attributes inherited from assQuestionGUI
const SUGGESTED_SOLUTION_COMMANDS
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 

Private Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI (string $question_type='', int $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants (string $guiClassName, string $cmdConstantNameBegin='CMD_')
 
static prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output where latex code may be in it If the text is HTML-free, CHR(13) will be converted to a line break. More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const CORRECTNESS_NOT_OK = 0
 
const CORRECTNESS_MOSTLY_OK = 1
 
const CORRECTNESS_OK = 2
 
const ALLOWED_PLAIN_TEXT_TAGS = "<em>, <strong>"
 sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. More...
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 

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

41 {
43 $this->object = new assFormulaQuestion();
44 if ($id >= 0) {
45 $this->object->loadFromDb($id);
46 }
47 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ callSpecialQuestionCommands()

assFormulaQuestionGUI::callSpecialQuestionCommands ( string  $cmd)
protected

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

54 : void
55 {
56 if (preg_match('/suggestrange_(\$r\d+)/', $cmd, $matches)) {
58 $this->suggestRange($matches[1]);
59 }
60 }
suggestRange(string $suggest_range_for_result)

References assQuestionGUI\addSaveOnEnterOnLoadCode(), and suggestRange().

+ Here is the call graph for this function:

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

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

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

837 : bool
838 {
839 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"])) {
840 $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
841 return false;
842 }
843
844
845 return true;
846 }
addErrorMessage(string $errormessage)

References assQuestionGUI\addErrorMessage(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

937 : string
938 {
939 $user_solution = array();
940
941 if (is_object($this->getPreviewSession())) {
942 $solutions = (array) $this->getPreviewSession()->getParticipantsSolution();
943
944 foreach ($solutions as $val1 => $val2) {
945 if (preg_match("/^(\\\$v\\d+)$/", $val1, $matches)) {
946 $user_solution[$matches[1]] = $val2;
947 } elseif (preg_match("/^(\\\$r\\d+)$/", $val1, $matches)) {
948 if (!array_key_exists($matches[1], $user_solution)) {
949 $user_solution[$matches[1]] = array();
950 }
951 $user_solution[$matches[1]]["value"] = $val2;
952 } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches)) {
953 if (!array_key_exists($matches[1], $user_solution)) {
954 $user_solution[$matches[1]] = array();
955 }
956 $user_solution[$matches[1]]["unit"] = $val2;
957 }
958
959 if (preg_match("/^(\\\$r\\d+)/", $val1, $matches) && !isset($user_solution[$matches[1]]["result_type"])) {
960 $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
961 }
962 }
963 }
964
965 if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
966 $user_solution = $this->object->getInitialVariableSolutionValues();
967
968 if (is_object($this->getPreviewSession())) {
969 $this->getPreviewSession()->setParticipantsSolution($user_solution);
970 }
971 }
972
973 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
974 if (is_object($this->getPreviewSession())) {
975 $questiontext = $this->object->substituteVariables($user_solution);
976 } else {
977 $questiontext = $this->object->substituteVariables(array());
978 }
979 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
980 $questionoutput = $template->get();
981 if (!$show_question_only) {
982 // get page object output
983 $questionoutput = $this->getILIASPage($questionoutput);
984 }
985 return $questionoutput;
986 }
static getResultTypeByQstId($a_qst_id, $a_result)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
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 (   $active_id,
  $pass = null,
  $graphicalOutput = false,
  $result_output = false,
  $show_question_only = true,
  $show_feedback = false,
  $show_correct_solution = false,
  $show_manual_scoring = false,
  $show_question_text = true 
)

Get the question solution output.

Parameters
integer$active_idThe active user id
integer$passThe test pass
boolean$graphicalOutputShow visual feedback for right/wrong answers
boolean$result_outputShow the reached points for parts of the question
boolean$show_question_onlyShow the question without the ILIAS content around
boolean$show_feedbackShow the question feedback
boolean$show_correct_solutionShow the correct solution instead of the user solution
boolean$show_manual_scoringShow specific information for the manual scoring output
Returns
string The solution output of the question as HTML code

Reimplemented from assQuestionGUI.

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

870 : string {
871 // get the solution of the user for the active pass or from the last pass if allowed
872 $user_solution = array();
873 if (($active_id > 0) && (!$show_correct_solution)) {
874 $user_solution["active_id"] = $active_id;
875 $user_solution["pass"] = $pass;
876 $solutions = $this->object->getSolutionValues($active_id, $pass);
877 foreach ($solutions as $idx => $solution_value) {
878 if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
879 $user_solution[$matches[1]] = $solution_value["value2"];
880 } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
881 if (!array_key_exists($matches[1], $user_solution)) {
882 $user_solution[$matches[1]] = array();
883 }
884 $user_solution[$matches[1]]["value"] = $solution_value["value2"];
885 } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
886 if (!array_key_exists($matches[1], $user_solution)) {
887 $user_solution[$matches[1]] = array();
888 }
889 $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
890 }
891 }
892 } elseif ($active_id) {
893 $user_solution = $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
894 } elseif (is_object($this->getPreviewSession())) {
895 $solutionValues = array();
896
897 $participantsSolution = $this->getPreviewSession()->getParticipantsSolution();
898 if (is_array($participantsSolution)) {
899 foreach ($participantsSolution as $val1 => $val2) {
900 $solutionValues[] = array('value1' => $val1, 'value2' => $val2);
901 }
902 }
903
904 $user_solution = $this->object->getBestSolution($solutionValues);
905 }
906
907 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
908 $correctness_icons = [
909 'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
910 'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
911 ];
912 $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, true, $result_output, $correctness_icons);
913
914 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
915 $questionoutput = $template->get();
916 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
917 $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
918 if (strlen($feedback)) {
919 $cssClass = (
920 $this->hasCorrectSolution($active_id, $pass) ?
922 );
923
924 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
925 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
926 }
927 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
928
929 $solutionoutput = $solutiontemplate->get();
930 if (!$show_question_only) {
931 // get page object output
932 $solutionoutput = $this->getILIASPage($solutionoutput);
933 }
934 return $solutionoutput;
935 }
getGenericFeedbackOutput(int $active_id, ?int $pass)
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)

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

1055 : string
1056 {
1057 return '';
1058 }

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

989 : string
990 // hey.
991 {
992 $this->tpl->setOnScreenMessage('info', $this->lng->txt('enter_valid_values'));
993 // get the solution of the user for the active pass or from the last pass if allowed
994 $user_solution = array();
995 if ($active_id) {
996 $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
997
998 $actualPassIndex = null;
999 if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1000 require_once 'Modules/Test/classes/class.ilObjTest.php';
1001 $actualPassIndex = ilObjTest::_getPass($active_id);
1002 }
1003
1004 foreach ($solutions as $idx => $solution_value) {
1005 if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1006 if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1007 $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value["value2"], true);
1008 }
1009
1010 $user_solution[$matches[1]] = $solution_value["value2"];
1011 } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
1012 if (!array_key_exists($matches[1], $user_solution)) {
1013 $user_solution[$matches[1]] = array();
1014 }
1015 $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1016 } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
1017 if (!array_key_exists($matches[1], $user_solution)) {
1018 $user_solution[$matches[1]] = array();
1019 }
1020 $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1021 }
1022 if (preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && !isset($user_solution[$matches[1]]["result_type"])) {
1023 $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
1024 }
1025 }
1026 }
1027
1028 // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
1029 $solutions = $this->object->getSolutionValues($active_id, $pass, true);
1030 foreach ($solutions as $idx => $solution_value) {
1031 if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1032 $user_solution[$matches[1]] = $solution_value["value2"];
1033 }
1034 }
1035 // fau.
1036
1037 if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
1038 foreach ($this->object->getInitialVariableSolutionValues() as $val1 => $val2) {
1039 $this->object->saveCurrentSolution($active_id, $pass, $val1, $val2, true);
1040 }
1041 }
1042
1043 // generate the question output
1044 $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1045
1046 $questiontext = $this->object->substituteVariables($user_solution);
1047
1048 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
1049
1050 $questionoutput = $template->get();
1051 $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1052 return $pageoutput;
1053 }
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(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ hasResultUnit()

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

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

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

◆ isSaveCommand()

assFormulaQuestionGUI::isSaveCommand ( )

Reimplemented from assQuestionGUI.

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

206 : bool
207 {
208 return in_array($this->ctrl->getCmd(), array('saveFQ', 'saveEdit', 'saveReturnFQ'));
209 }

References ILIAS\Repository\ctrl().

Referenced by writePostData().

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

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

748 : void
749 {
750 $this->writePostData();
752 $this->editQuestion();
753 }
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...

References assQuestionGUI\addSaveOnEnterOnLoadCode(), and writePostData().

+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

195 : void
196 {
197 global $DIC;
198 $ilUser = $DIC['ilUser'];
199 $user_id = $ilUser->getId();
200 $question_id = $this->object->getId();
201 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
202 $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
203 $ilAssQuestionPreviewSession->setParticipantsSolution(array());
204 }
global $DIC
Definition: feed.php:28

References $DIC, assQuestionGUI\$ilUser, and ilObject\getId().

Referenced by writePostData().

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

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

823 : void
824 {
825 $result = $this->writePostData();
826
827 if ($result == 1) {
828 $this->editQuestion();
829 } else {
831 $this->save();
832 }
833 }

References assQuestionGUI\save(), assQuestionGUI\saveTaxonomyAssignments(), and writePostData().

+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

755 : void
756 {
757 global $DIC;
758 $ilUser = $DIC['ilUser'];
759 $old_id = $this->request->getQuestionId();
760 $result = $this->writePostData();
761 if ($result == 0) {
762 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
763 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
765 $this->object->saveToDb();
766 $originalexists = false;
767 if ($this->object->getOriginalId() != null && $this->object->_questionExistsInPool($this->object->getOriginalId())) {
768 $originalexists = true;
769 }
770 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
771 if (($this->request->raw("calling_test") || ($this->request->isset('calling_consumer') && (int) $this->request->raw('calling_consumer')))
772 && $originalexists && assQuestion::_isWriteable($this->object->getOriginalId(), $ilUser->getId())) {
773 $this->ctrl->redirect($this, "originalSyncForm");
774 } elseif ($this->request->raw("calling_test")) {
775 require_once 'Modules/Test/classes/class.ilObjTest.php';
776 $test = new ilObjTest($this->request->raw("calling_test"));
777 $q_id = $this->object->getId();
778 if (!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId())) {
779 global $DIC;
780 $tree = $DIC['tree'];
781 $ilDB = $DIC['ilDB'];
782 $component_repository = $DIC['component.repository'];
783
784 $test = new ilObjTest($this->request->raw("calling_test"), true);
785
786 $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $component_repository, $test);
787
788 $test->insertQuestion(
789 $testQuestionSetConfigFactory->getQuestionSetConfig(),
790 $this->object->getId(),
791 true
792 );
793
794 if ($this->request->isset('prev_qid')) {
795 $test->moveQuestionAfter($this->object->getId(), $this->request->raw('prev_qid'));
796 }
797
798 $this->ctrl->setParameter($this, 'calling_test', $this->request->raw("calling_test"));
799 }
800 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
801 $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
802 } else {
803 if ($this->object->getId() != $old_id) {
804 $this->callNewIdListeners($this->object->getId());
805 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
806 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
807 }
808 if (ilSession::get('info') != null) {
809 $this->tpl->setOnScreenMessage('success', ilSession::get('info') . "<br />" . $this->lng->txt("msg_obj_modified"), true);
810 } else {
811 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
812 }
813 $this->ctrl->redirectByClass("ilAssQuestionPreviewGUI", ilAssQuestionPreviewGUI::CMD_SHOW);
814 }
815 } else {
816 $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
817 $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
818 $this->object->saveToDb();
819 $this->editQuestion();
820 }
821 }
callNewIdListeners(int $a_new_id)
ilComponentRepository $component_repository
static _questionExistsInTest(int $question_id, int $test_id)
static _isWriteable(int $question_id, int $user_id)
setPref(string $a_keyword, ?string $a_value)
writePref(string $a_keyword, string $a_value)
static get(string $a_var)

References assQuestionGUI\$component_repository, $DIC, assQuestionGUI\$ilDB, assQuestionGUI\$ilUser, assQuestionGUI\$tree, assQuestion\_isWriteable(), assQuestion\_questionExistsInTest(), assQuestionGUI\callNewIdListeners(), ilAssQuestionPreviewGUI\CMD_SHOW, ILIAS\Repository\ctrl(), ilSession\get(), ilObject\getId(), ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\saveTaxonomyAssignments(), ilObjUser\setPref(), writePostData(), and ilObjUser\writePref().

+ Here is the call graph for this function:

◆ setQuestionSpecificTabs()

assFormulaQuestionGUI::setQuestionSpecificTabs ( ilTabsGUI  $ilTabs)
protected

Reimplemented from assQuestionGUI.

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

49 : void
50 {
51 $ilTabs->addTarget('units', $this->ctrl->getLinkTargetByClass('ilLocalUnitConfigurationGUI', ''), '', 'illocalunitconfigurationgui');
52 }
addTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)

References assQuestionGUI\$ilTabs, ilTabsGUI\addTarget(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( string  $suggest_range_for_result)

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

62 : void
63 {
64 if ($this->writePostData()) {
65 $this->tpl->setOnScreenMessage('info', $this->getErrorMessage());
66 }
67 $this->editQuestion(false, $suggest_range_for_result);
68 }

References assQuestionGUI\getErrorMessage(), and writePostData().

Referenced by callSpecialQuestionCommands().

+ Here is the call graph for this function:
+ Here is the caller 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 73 of file class.assFormulaQuestionGUI.php.

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

References Vendor\Package\$e, ILIAS\LTI\ToolProvider\$key, assQuestionGUI\addErrorMessage(), ilAssQuestionLifecycle\getInstance(), isSaveCommand(), ILIAS\Repository\lng(), ILIAS\Repository\object(), resetSavedPreviewSession(), and ilUtil\stripOnlySlashes().

Referenced by parseQuestion(), saveFQ(), saveReturnFQ(), and suggestRange().

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

Field Documentation

◆ HAS_SPECIAL_QUESTION_COMMANDS

const assFormulaQuestionGUI::HAS_SPECIAL_QUESTION_COMMANDS = true
protected

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


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