ILIAS  trunk Revision v5.2.0beta1-34115-g3a2438be29
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 ()
 
 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)
 
- Public Member Functions inherited from assQuestionGUI
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 geCommentsPanelHTML ()
 
 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)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 

Protected Member Functions

 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 callSpecialQuestionCommands (string $cmd)
 
 writePostData (bool $always=false)
 {} 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)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 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)
 
 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...
 

Protected Attributes

const HAS_SPECIAL_QUESTION_COMMANDS = true
 
- Protected Attributes inherited from assQuestionGUI
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
ilLogger $logger
 
ILIAS TestQuestionPool QuestionInfoService $questioninfo
 
ILIAS Notes GUIService $notes_gui
 
ilCtrl $ctrl
 
ilPropertyFormGUI $editForm
 
ILIAS TestQuestionPool InternalRequestService $request
 
bool $parent_type_is_lm = false
 
assQuestionSuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

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 (?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 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

\ assFormulaQuestionGUI: ilFormPropertyDispatchGUI

Definition at line 28 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 public

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

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

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

Member Function Documentation

◆ callSpecialQuestionCommands()

assFormulaQuestionGUI::callSpecialQuestionCommands ( string  $cmd)
protected

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

References suggestRange().

52  : void
53  {
54  if (preg_match('/suggestrange_(\$r\d+)/', $cmd, $matches)) {
55  $this->suggestRange($matches[1]);
56  }
57  }
suggestRange(string $suggest_range_for_result)
+ 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 726 of file class.assFormulaQuestionGUI.php.

Referenced by isSaveCommand().

726  : bool
727  {
728  $resultunit = $result->getUnit();
729 
730  /*
731  * if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
732  * if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
733  * definition if the result-value or the unit-value should be the correct solution!!
734  *
735  */
736  if (is_object($resultunit)) {
737  return true;
738  } else {
739  return false;
740  }
741  }
+ Here is the caller graph for this function:

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

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

752  : bool
753  {
754  if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"])) {
755  $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
756  return false;
757  }
758 
759 
760  return true;
761  }
addErrorMessage(string $errormessage)
+ Here is the call graph for this function:

◆ getPreview()

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

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

References assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), assFormulaQuestionResult\getResultTypeByQstId(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

852  : string
853  {
854  $user_solution = array();
855 
856  if (is_object($this->getPreviewSession())) {
857  $solutions = (array) $this->getPreviewSession()->getParticipantsSolution();
858 
859  foreach ($solutions as $val1 => $val2) {
860  if (preg_match("/^(\\\$v\\d+)$/", $val1, $matches)) {
861  $user_solution[$matches[1]] = $val2;
862  } elseif (preg_match("/^(\\\$r\\d+)$/", $val1, $matches)) {
863  if (!array_key_exists($matches[1], $user_solution)) {
864  $user_solution[$matches[1]] = array();
865  }
866  $user_solution[$matches[1]]["value"] = $val2;
867  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches)) {
868  if (!array_key_exists($matches[1], $user_solution)) {
869  $user_solution[$matches[1]] = array();
870  }
871  $user_solution[$matches[1]]["unit"] = $val2;
872  }
873 
874  if (preg_match("/^(\\\$r\\d+)/", $val1, $matches) && !isset($user_solution[$matches[1]]["result_type"])) {
875  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
876  }
877  }
878  }
879 
880  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
881  $user_solution = $this->object->getInitialVariableSolutionValues();
882 
883  if (is_object($this->getPreviewSession())) {
884  $this->getPreviewSession()->setParticipantsSolution($user_solution);
885  }
886  }
887 
888  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'components/ILIAS/TestQuestionPool');
889  if (is_object($this->getPreviewSession())) {
890  $questiontext = $this->object->substituteVariables($user_solution);
891  } else {
892  $questiontext = $this->object->substituteVariables(array());
893  }
894  $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
895  $questionoutput = $template->get();
896  if (!$show_question_only) {
897  // get page object output
898  $questionoutput = $this->getILIASPage($questionoutput);
899  }
900  return $questionoutput;
901  }
static getResultTypeByQstId($a_qst_id, $a_result)
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...
+ 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

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

References ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\generateCorrectnessIconsForCorrectness(), assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), assQuestionGUI\hasCorrectSolution(), ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

785  : string {
786  $user_solution = $this->object->getVariableSolutionValuesForPass($active_id, $pass);
787 
788  if (($active_id > 0) && (!$show_correct_solution)) {
789  $user_solution["active_id"] = $active_id;
790  $user_solution["pass"] = $pass;
791  $solutions = $this->object->getSolutionValues($active_id, $pass);
792  foreach ($solutions as $idx => $solution_value) {
793  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
794  $user_solution[$matches[1]] = $solution_value["value2"];
795  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
796  if (!array_key_exists($matches[1], $user_solution)) {
797  $user_solution[$matches[1]] = array();
798  }
799  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
800  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
801  if (!array_key_exists($matches[1], $user_solution)) {
802  $user_solution[$matches[1]] = array();
803  }
804  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
805  }
806  }
807  } elseif ($active_id) {
808  $user_solution = $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
809  } elseif (is_object($this->getPreviewSession())) {
810  $solutionValues = array();
811 
812  $participantsSolution = $this->getPreviewSession()->getParticipantsSolution();
813  if (is_array($participantsSolution)) {
814  foreach ($participantsSolution as $val1 => $val2) {
815  $solutionValues[] = array('value1' => $val1, 'value2' => $val2);
816  }
817  }
818 
819  $user_solution = $this->object->getBestSolution($solutionValues);
820  }
821 
822  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'components/ILIAS/TestQuestionPool');
823  $correctness_icons = [
824  'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
825  'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
826  ];
827  $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, true, $result_output, $correctness_icons);
828 
829  $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
830  $questionoutput = $template->get();
831  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
832  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
833  if (strlen($feedback)) {
834  $cssClass = (
835  $this->hasCorrectSolution($active_id, $pass) ?
837  );
838 
839  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
840  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
841  }
842  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
843 
844  $solutionoutput = $solutiontemplate->get();
845  if (!$show_question_only) {
846  // get page object output
847  $solutionoutput = $this->getILIASPage($solutionoutput);
848  }
849  return $solutionoutput;
850  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
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...
getGenericFeedbackOutput(int $active_id, ?int $pass)
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

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

966  : string
967  {
968  return '';
969  }

◆ getTestOutput()

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

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

References ilObjTest\_getPass(), assFormulaQuestionResult\getResultTypeByQstId(), ILIAS\Repository\lng(), ILIAS\Repository\object(), assQuestionGUI\outQuestionPage(), and ilLegacyFormElementsUtil\prepareTextareaOutput().

904  : string
905  // hey.
906  {
907  $this->tpl->setOnScreenMessage('info', $this->lng->txt('enter_valid_values'));
908  // get the solution of the user for the active pass or from the last pass if allowed
909  $user_solution = array();
910  if ($active_id) {
911  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
912 
913  $actualPassIndex = null;
914  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
915  $actualPassIndex = ilObjTest::_getPass($active_id);
916  }
917 
918  foreach ($solutions as $idx => $solution_value) {
919  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
920  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
921  $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value["value2"], true);
922  }
923 
924  $user_solution[$matches[1]] = $solution_value["value2"];
925  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
926  if (!array_key_exists($matches[1], $user_solution)) {
927  $user_solution[$matches[1]] = array();
928  }
929  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
930  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
931  if (!array_key_exists($matches[1], $user_solution)) {
932  $user_solution[$matches[1]] = array();
933  }
934  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
935  }
936  if (preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && !isset($user_solution[$matches[1]]["result_type"])) {
937  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
938  }
939  }
940  }
941 
942  // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
943  $solutions = $this->object->getSolutionValues($active_id, $pass, true);
944  foreach ($solutions as $idx => $solution_value) {
945  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
946  $user_solution[$matches[1]] = $solution_value["value2"];
947  }
948  }
949 
950  if ($user_solution === []) {
951  $user_solution = $this->object->getVariableSolutionValuesForPass($active_id, $pass);
952  }
953 
954  // generate the question output
955  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'components/ILIAS/TestQuestionPool');
956 
957  $questiontext = $this->object->substituteVariables($user_solution);
958 
959  $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
960 
961  $questionoutput = $template->get();
962  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
963  return $pageoutput;
964  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getResultTypeByQstId($a_qst_id, $a_result)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
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...
+ Here is the call graph for this function:

◆ hasResultUnit()

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

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

Referenced by isSaveCommand().

709  : bool
710  {
711  if (array_key_exists($result->getResult(), $resultunits)) {
712  if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
713  return true;
714  }
715  }
716  return false;
717  }
+ Here is the caller graph for this function:

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References writePostData().

743  : void
744  {
745  $this->writePostData();
746  $this->editQuestion();
747  }
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

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

Referenced by writePostData().

191  : void
192  {
193  global $DIC;
194  $ilUser = $DIC['ilUser'];
195  $user_id = $ilUser->getId();
196  $question_id = $this->object->getId();
197  $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
198  $ilAssQuestionPreviewSession->setParticipantsSolution(array());
199  }
$DIC
Definition: xapitoken.php:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setQuestionSpecificTabs()

assFormulaQuestionGUI::setQuestionSpecificTabs ( ilTabsGUI  $ilTabs)
protected

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

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

47  : void
48  {
49  $ilTabs->addTarget('units', $this->ctrl->getLinkTargetByClass('ilLocalUnitConfigurationGUI', ''), '', 'illocalunitconfigurationgui');
50  }
addTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)
+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( string  $suggest_range_for_result)

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

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

Referenced by callSpecialQuestionCommands().

59  : void
60  {
61  if ($this->writePostData()) {
62  $this->tpl->setOnScreenMessage('info', $this->getErrorMessage());
63  }
64  $this->editQuestion(false, $suggest_range_for_result);
65  }
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writePostData()

assFormulaQuestionGUI::writePostData ( bool  $always = false)
protected

{}

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

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

Referenced by parseQuestion(), and suggestRange().

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


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