ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 
 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 ($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)
 
 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,)
 
 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)
 
 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)
 

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)
 
 genericFeedbackOutputBuilder (string $feedback_correct, string $feedback_incorrect, int $active_id, ?int $pass)
 
 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...
 
 addSaveOnEnterOnLoadCode ()
 

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
 
Refinery $refinery
 
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 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 public

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

References $id, and ILIAS\MetaData\Repository\Validation\Data\__construct().

41  {
43  $this->object = new assFormulaQuestion();
44  if ($id >= 0) {
45  $this->object->loadFromDb($id);
46  }
47  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(VocabulariesInterface $vocabularies)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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.

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

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

Referenced by isSaveCommand().

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

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

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

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

◆ getPreview()

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

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

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

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

References Vendor\Package\$c, assQuestionGUI\getPreviewSession(), assFormulaQuestionVariable\getVariable(), ILIAS\Repository\object(), and renderSolutionOutput().

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

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

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

1002  : string
1003  {
1004  return '';
1005  }

◆ getTestOutput()

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

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

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

942  : string
943  // hey.
944  {
945  $this->tpl->setOnScreenMessage('info', $this->lng->txt('enter_valid_values'));
946  // get the solution of the user for the active pass or from the last pass if allowed
947  $user_solution = [];
948  if ($active_id) {
949  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
950  $actualPassIndex = null;
951  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
952  $actualPassIndex = ilObjTest::_getPass($active_id);
953  }
954 
955  foreach ($solutions as $idx => $solution_value) {
956  if (preg_match("/^(\\\$v\\d+)$/", $solution_value['value1'], $matches)) {
957  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
958  $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value['value2'], true);
959  }
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  $solutions = $this->object->getSolutionValues($active_id, $pass, true);
980  foreach ($solutions as $idx => $solution_value) {
981  if (preg_match("/^(\\\$v\\d+)$/", $solution_value['value1'], $matches)) {
982  $user_solution[$matches[1]] = $solution_value['value2'];
983  }
984  }
985 
986  if ($user_solution === []) {
987  $user_solution = $this->object->getVariableSolutionValuesForPass($active_id, $pass);
988  }
989 
990  // generate the question output
991  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
992 
993  $questiontext = $this->object->substituteVariables($user_solution);
994 
995  $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
996 
997  $questionoutput = $template->get();
998  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
999  return $pageoutput;
1000  }
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 704 of file class.assFormulaQuestionGUI.php.

Referenced by isSaveCommand().

704  : bool
705  {
706  if (array_key_exists($result->getResult(), $resultunits)) {
707  if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
708  return true;
709  }
710  }
711  return false;
712  }
+ Here is the caller graph for this function:

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

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

738  : void
739  {
740  $this->writePostData();
741  $this->addSaveOnEnterOnLoadCode();
742  $this->editQuestion();
743  }
writePostData(bool $always=false)
{}
+ Here is the call graph for this function:

◆ 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 
)

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

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

Referenced by getSolutionOutput().

860  : ?string {
861  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
862  $correctness_icons = [
863  'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
864  'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
865  ];
866  $questiontext = $this->object->substituteVariables($user_solutions, $graphical_output, true, $result_output, $correctness_icons);
867  $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true));
868  $questionoutput = $template->get();
869  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
870  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
871  if (strlen($feedback)) {
872  $cssClass = (
873  $this->hasCorrectSolution($active_id, $pass) ?
875  );
876 
877  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
878  $solutiontemplate->setVariable("FEEDBACK", ilLegacyFormElementsUtil::prepareTextareaOutput($feedback, true));
879  }
880  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
881 
882  $solutionoutput = $solutiontemplate->get();
883  if (!$show_question_only) {
884  // get page object output
885  $solutionoutput = $this->getILIASPage($solutionoutput);
886  }
887  return $solutionoutput;
888  }
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:
+ Here is the caller graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

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

Referenced by writePostData().

184  : void
185  {
186  global $DIC;
187  $ilUser = $DIC['ilUser'];
188  $user_id = $ilUser->getId();
189  $question_id = $this->object->getId();
190  $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
191  $ilAssQuestionPreviewSession->setParticipantsSolution([]);
192  }
global $DIC
Definition: feed.php:28
+ 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 49 of file class.assFormulaQuestionGUI.php.

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

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

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

Referenced by callSpecialQuestionCommands().

62  : void
63  {
64  if ($this->writePostData()) {
65  $this->tpl->setOnScreenMessage('info', $this->getErrorMessage());
66  }
67  $this->editQuestion(false, $suggest_range_for_result);
68  }
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 73 of file class.assFormulaQuestionGUI.php.

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

Referenced by parseQuestion(), and suggestRange().

73  : int
74  {
75  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
76  $checked = true;
77  if (!$hasErrors) {
78  $this->object->setTitle($this->request->string('title'));
79  $this->object->setAuthor($this->request->string('author'));
80  $this->object->setComment($this->request->string('comment'));
81  $this->object->setQuestion($this->request->string('question'));
82 
83  $this->object->parseQuestionText();
84  $found_vars = [];
85  $found_results = [];
86 
87  foreach ($this->request->getParsedBody() as $key => $value) {
88  if (preg_match("/^unit_(\\\$v\d+)$/", $key, $matches)) {
89  array_push($found_vars, $matches[1]);
90  }
91  if (preg_match("/^unit_(\\\$r\d+)$/", $key, $matches)) {
92  array_push($found_results, $matches[1]);
93  }
94  }
95 
96  try {
97  $lifecycle = ilAssQuestionLifecycle::getInstance($_POST['lifecycle']);
98  $this->object->setLifecycle($lifecycle);
100  }
101 
102  if (!$this->object->checkForDuplicateResults()) {
103  $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
104  $checked = false;
105  }
106 
107  foreach ($found_vars as $variable) {
108  if ($this->object->getVariable($variable) != null) {
109  $varObj = new assFormulaQuestionVariable(
110  $variable,
111  str_replace(',', '.', $_POST["range_min_{$variable}"]),
112  str_replace(',', '.', $_POST["range_max_{$variable}"]),
113  isset($_POST["unit_{$variable}"]) ? $this->object->getUnitrepository()->getUnit(
114  $_POST["unit_{$variable}"]
115  ) : null,
116  (int) $this->request->float("precision_{$variable}"),
117  (int) $this->request->float("intprecision_{$variable}")
118  );
119  $this->object->addVariable($varObj);
120  }
121  }
122 
123  $tmp_form_vars = [];
124  $tmp_quest_vars = [];
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 ($this->object->getResult($result) != null) {
150  $resObj = new assFormulaQuestionResult(
151  $result,
152  str_replace(',', '.', $_POST["range_min_{$result}"]),
153  str_replace(',', '.', $_POST["range_max_{$result}"]),
154  $this->request->float("tolerance_{$result}"),
155  isset($_POST["unit_{$result}"]) ? $this->object->getUnitrepository()->getUnit(
156  $_POST["unit_{$result}"]
157  ) : null,
158  $this->request->string("formula_{$result}"),
159  $this->request->float("points_{$result}"),
160  (int) $this->request->float("precision_{$result}"),
161  $this->request->int("rating_advanced_{$result}") !== 1,
162  $this->request->int("rating_advanced_{$result}") === 1 ? $this->request->float("rating_sign_{$result}") : null,
163  $this->request->int("rating_advanced_{$result}") === 1 ? $this->request->float("rating_value_{$result}") : null,
164  $this->request->int("rating_advanced_{$result}") === 1 ? $this->request->float("rating_unit_{$result}") : null,
165  $this->request->int("result_type_{$result}")
166  );
167  $this->object->addResult($resObj);
168  $this->object->addResultUnits($resObj, $_POST["units_{$result}"] ?? []);
169  }
170  }
171  if ($checked == false) {
172  $this->editQuestion();
173  return 1;
174  } else {
175  $this->saveTaxonomyAssignments();
176  $this->resetSavedPreviewSession();
177  return 0;
178  }
179  } else {
180  return 1;
181  }
182  }
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)
+ 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: