ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 ()
 
 resetSavedPreviewSession ()
 
 parseQuestion ()
 
 checkInput ()
 check input fields More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 getSpecificFeedbackOutput (array $userSolution)
 
- Public Member Functions inherited from assQuestionGUI
 editQuestion (bool $checkonly=false, ?bool $is_save_cmd=null)
 
 getSpecificFeedbackOutput (array $userSolution)
 Returns the answer specific feedback for the question. More...
 
 getSolutionOutput (int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
 
 getPreview (bool $show_question_only=false, bool $show_inline_feedback=false)
 
 getTestOutput (int $active_id, int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 renderSolutionOutput (mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
 
 getObject ()
 
 setObject (assQuestion $question)
 
 setCopyToExistingPoolOnSave (?int $pool_ref_id)
 
 getCopyToExistingPoolOnSave ()
 
 setCopyToNewPoolOnSave (?string $pool_title)
 
 getCopyToNewPoolOnSave ()
 
 setMoveAfterQuestionId (?int $question_id)
 
 getMoveAfterQuestionId ()
 
 hasInlineFeedback ()
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getCommentsPanelHTML ()
 
 executeCommand ()
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext (string $presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled (bool $previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose (string $renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext (string $editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI (?ilTestQuestionNavigationGUI $navigationGUI)
 
 setTaxonomyIds (array $taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass (string $targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder (\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd (string $questionActionCmd)
 
 getQuestionActionCmd ()
 
 assessment ()
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 
 getILIASPage (string $html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 
 syncQuestion ()
 
 saveReturn ()
 
 saveQuestion ()
 
 setAdditionalContentEditingModeFromPost ()
 
 getContextPath ($cont_obj, int $a_endnode_id, int $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber (int $nr)
 
 getSequenceNumber ()
 
 setQuestionCount (int $a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage (string $errormessage)
 
 addErrorMessage (string $errormessage)
 
 getQuestionType ()
 
 getAsValueAttribute (string $a_value)
 
 addQuestionFormCommandButtons (ilPropertyFormGUI $form)
 
 addBasicQuestionFormProperties (ilPropertyFormGUI $form)
 
 getGenericFeedbackOutput (int $active_id, ?int $pass)
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 outQuestionType ()
 
 saveSuggestedSolution ()
 
 cancelSuggestedSolution ()
 
 suggestedsolution (bool $save=false)
 
 outSolutionExplorer ()
 
 saveSuggestedSolutionType ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, string $classname)
 
 getEditQuestionTabCommands ()
 
 isAutosaveable ()
 
 outQuestionForTest (string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getFormEncodingType ()
 
 setPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 getPreviewSession ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFrequencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 isInLearningModuleContext ()
 
 setInLearningModuleContext (bool $flag)
 
 cmdNeedsExistingQuestion (string $cmd)
 
 setContextAllowsSyncToPool (bool $sync_allowed)
 
 needsSyncQuery ()
 
 getQuestionSyncModal (string $cmd, string $cmd_class='')
 
 getAutoSavedSolutionOutput (int $active_id, int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false)
 
 buildFileDownloadLink ()
 

Protected Member Functions

 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 writePostData (bool $always=false)
 {} More...
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm (ilPropertyFormGUI $form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 setTestSpecificProperties ()
 
 addNumberOfTriesToFormIfNecessary (ilPropertyFormGUI $form)
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 genericFeedbackOutputBuilder (int $active_id, ?int $pass)
 
 getTypeOptions ()
 
 createSuggestedSolutionLinkingTo (string $type, string $target)
 
 setDefaultTabs (ilTabsGUI $tabs_gui)
 
 setQuestionSpecificTabs (ilTabsGUI $tabs_gui)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 
 addTab_Question (ilTabsGUI $tabs_gui)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction (string $form_action, int $active_id, int $pass)
 
 addBackTab (ilTabsGUI $tabs_gui)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 generateCorrectnessIconsForCorrectness (int $correctness)
 
 renderLatex ($content)
 Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in the browser. More...
 
 getSuggestedSolutionsRepo ()
 
 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 
 addSaveOnEnterOnLoadCode ()
 

Protected Attributes

const HAS_SPECIAL_QUESTION_COMMANDS = true
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
const SUGGESTED_SOLUTION_COMMANDS_CANCEL = 'cancelSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_SAVE = 'saveSuggestedSolution'
 
const SUGGESTED_SOLUTION_COMMANDS_DEFAULT = 'suggestedsolution'
 
const QUESTION_SAVE_CMDS
 
const ADDITIONAL_CMDS_NEEDING_EXISTING_QST
 There are functions that need an existing question. More...
 
ilLogger $logger
 
GeneralQuestionPropertiesRepository $questionrepository
 
GUIService $notes_gui
 
ilCtrl $ctrl
 
assQuestion $object
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
Refinery $refinery
 
 $error
 
string $errormessage
 
int $sequence_no
 sequence number in test More...
 
int $question_count
 question count in test More...
 
ilPropertyFormGUI $editForm = null
 
readonly ilTestLegacyFormsHelper $forms_helper
 
readonly RequestDataCollector $request_data_collector
 
bool $parent_type_is_lm = false
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo = null
 

Private Member Functions

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

Private Attributes

UIFactory $ui_factory
 
UIRenderer $ui_renderer
 

Additional Inherited Members

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

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Single choice question GUI representation The assFormulaQuestionGUI class encapsulates the GUI representation for single choice questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
Id
class.assFormulaQuestionGUI.php 1235 2010-02-15 15:21:18Z hschottm

\ assFormulaQuestionGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assFormulaQuestionGUI::__construct (   $id = -1)

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

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

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

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

45  {
47  global $DIC;
48  $this->ui_factory = $DIC->ui()->factory();
49  $this->ui_renderer = $DIC->ui()->renderer();
50 
51  $this->object = new assFormulaQuestion();
52  if ($id >= 0) {
53  $this->object->loadFromDb($id);
54  }
55  }
Class for single choice questions assFormulaQuestion is a class for single choice questions...
global $DIC
Definition: shib_login.php:26
$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

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

Referenced by resetSavedPreviewSession().

744  : bool
745  {
746  $resultunit = $result->getUnit();
747 
748  /*
749  * if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
750  * if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
751  * definition if the result-value or the unit-value should be the correct solution!!
752  *
753  */
754  if (is_object($resultunit)) {
755  return true;
756  } else {
757  return false;
758  }
759  }
+ Here is the caller graph for this function:

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

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

773  : bool
774  {
775  $title = $this->request_data_collector->string('title');
776  $author = $this->request_data_collector->string('author');
777  $question = $this->request_data_collector->string('question');
778 
779  if (empty($title) || empty($author) || empty($question)) {
780  $this->addErrorMessage($this->lng->txt('fill_out_all_required_fields'));
781  return false;
782  }
783 
784  return true;
785  }
addErrorMessage(string $errormessage)
+ Here is the call graph for this function:

◆ getPreview()

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

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

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

908  : string {
909  $user_solution = [];
910  if (is_object($this->getPreviewSession())) {
911  $solutions = $this->getPreviewSession()->getParticipantsSolution() ?? [];
912  foreach ($solutions as $val1 => $val2) {
913  if (preg_match('/^(\$v\d+)$/', $val1, $matches)) {
914  $user_solution[$matches[1]] = $val2;
915  } elseif (preg_match('/^(\$r\d+)$/', $val1, $matches)) {
916  if (!array_key_exists($matches[1], $user_solution)) {
917  $user_solution[$matches[1]] = [];
918  }
919  $user_solution[$matches[1]]['value'] = $val2;
920  } elseif (preg_match('/^(\$r\d+)_unit$/', $val1, $matches)) {
921  if (!array_key_exists($matches[1], $user_solution)) {
922  $user_solution[$matches[1]] = [];
923  }
924  $user_solution[$matches[1]]['unit'] = $val2;
925  }
926 
927  if (preg_match('/^(\$r\d+)/', $val1, $matches) && !isset($user_solution[$matches[1]]['result_type'])) {
928  $user_solution[$matches[1]]['result_type'] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
929  }
930  }
931  }
932 
933  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
934  $user_solution = $this->object->getInitialVariableSolutionValues();
935 
936  if (is_object($this->getPreviewSession())) {
937  $this->getPreviewSession()->setParticipantsSolution($user_solution);
938  }
939  }
940 
941  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'components/ILIAS/TestQuestionPool');
942  if (is_object($this->getPreviewSession())) {
943  $questiontext = $this->object->substituteVariables($user_solution);
944  } else {
945  $questiontext = $this->object->substituteVariables([]);
946  }
947  $template->setVariable("QUESTIONTEXT", $this->renderLatex(
949  ));
950  $questionoutput = $template->get();
951  if (!$show_question_only) {
952  // get page object output
953  $questionoutput = $this->getILIASPage($questionoutput);
954  }
955  return $questionoutput;
956  }
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
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 ( int  $active_id,
?int  $pass = null,
bool  $graphical_output = false,
bool  $result_output = false,
bool  $show_question_only = true,
bool  $show_feedback = false,
bool  $show_correct_solution = false,
bool  $show_manual_scoring = false,
bool  $show_question_text = true,
bool  $show_inline_feedback = true 
)

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

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

798  : string {
799  $user_solution = [];
800  if ($pass !== null) {
801  $user_solution = $this->object->getVariableSolutionValuesForPass($active_id, $pass);
802  } else {
803  $user_solution = array_reduce(
804  $this->object->fetchAllVariables($this->object->getQuestion()),
805  static function (array $c, assFormulaQuestionVariable $v): array {
806  $c[$v->getVariable()] = $v->getVariable();
807  return $c;
808  },
809  []
810  );
811  }
812  if (($active_id > 0) && (!$show_correct_solution)) {
813  $user_solution['active_id'] = $active_id;
814  $user_solution['pass'] = $pass;
815  $solutions = $this->object->getSolutionValues($active_id, $pass);
816  foreach ($solutions as $solution_value) {
817  if (preg_match('/^(\$v\d+)$/', $solution_value['value1'], $matches)) {
818  $user_solution[$matches[1]] = $solution_value['value2'];
819  } elseif (preg_match('/^(\$r\d+)$/', $solution_value['value1'], $matches)) {
820  if (!array_key_exists($matches[1], $user_solution)) {
821  $user_solution[$matches[1]] = [];
822  }
823  $user_solution[$matches[1]]["value"] = $solution_value['value2'];
824  } elseif (preg_match('/^(\$r\d+)_unit$/', $solution_value['value1'], $matches)) {
825  if (!array_key_exists($matches[1], $user_solution)) {
826  $user_solution[$matches[1]] = [];
827  }
828  $user_solution[$matches[1]]['unit'] = $solution_value['value2'];
829  }
830  }
831  } elseif ($active_id !== 0) {
832  $user_solution = $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
833  } elseif (is_object($this->getPreviewSession())) {
834  $solutionValues = [];
835  $participants_solution = $this->getPreviewSession()->getParticipantsSolution();
836  if (is_array($participants_solution)) {
837  foreach ($participants_solution as $val1 => $val2) {
838  $solutionValues[] = ['value1' => $val1, 'value2' => $val2];
839  }
840  }
841  $user_solution = $this->object->getBestSolution($solutionValues);
842  }
843 
844  return $this->renderSolutionOutput(
845  $user_solution,
846  $active_id,
847  $pass,
848  $graphical_output,
849  $result_output,
850  $show_question_only,
851  $show_feedback,
852  $show_correct_solution,
853  $show_manual_scoring,
854  $show_question_text,
855  false,
856  $show_inline_feedback
857  );
858  }
renderSolutionOutput(mixed $user_solutions, int $active_id, ?int $pass, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_autosave_title=false, bool $show_inline_feedback=false,)
$c
Definition: deliver.php:25
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput ( array  $userSolution)

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

1023  : string
1024  {
1025  return '';
1026  }

◆ getSuggestRangeOnLoadCode()

assFormulaQuestionGUI::getSuggestRangeOnLoadCode ( string  $result)
private

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

References $id.

Referenced by resetSavedPreviewSession().

711  : Closure
712  {
713  return static function ($id) use ($result): string {
714  return "document.getElementById('$id').addEventListener('click', "
715  . '(e) => {'
716  . ' e.target.setAttribute("name", "cmd[suggestRange]");'
717  . ' let input = document.createElement("input");'
718  . ' input.type = "hidden";'
719  . ' input.name = "suggest_range_for";'
720  . " input.value = '$result';"
721  . ' e.target.form.appendChild(input);'
722  . ' e.target.form.requestSubmit(e.target);'
723  . '});';
724  };
725  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ getTestOutput()

assFormulaQuestionGUI::getTestOutput ( int  $active_id,
int  $pass,
bool  $is_question_postponed = false,
array|bool  $user_post_solutions = false,
bool  $show_specific_inline_feedback = false 
)

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

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

964  : string {
965  $this->tpl->setOnScreenMessage('info', $this->lng->txt('enter_valid_values'));
966  // get the solution of the user for the active pass or from the last pass if allowed
967  $user_solution = [];
968  if ($active_id) {
969  $solutions = $this->object->getTestOutputSolutions($active_id, $pass);
970  $actualPassIndex = null;
971  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
972  $actualPassIndex = ilObjTest::_getPass($active_id);
973  }
974  foreach ($solutions as $idx => $solution_value) {
975  if (preg_match('/^(\$v\d+)$/', $solution_value['value1'], $matches)) {
976  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
977  $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value['value2'], true);
978  }
979  $user_solution[$matches[1]] = $solution_value['value2'];
980  } elseif (preg_match('/^(\$r\d+)$/', $solution_value['value1'], $matches)) {
981  if (!array_key_exists($matches[1], $user_solution)) {
982  $user_solution[$matches[1]] = [];
983  }
984  $user_solution[$matches[1]]['value'] = $solution_value['value2'];
985  } elseif (preg_match('/^(\$r\d+)_unit$/', $solution_value['value1'], $matches)) {
986  if (!array_key_exists($matches[1], $user_solution)) {
987  $user_solution[$matches[1]] = [];
988  }
989  $user_solution[$matches[1]][['unit']] = $solution_value['value2'];
990  }
991  if (preg_match('/^(\$r\d+)/', $solution_value['value1'], $matches) && !isset($user_solution[$matches[1]]['result_type'])) {
992  $user_solution[$matches[1]]['result_type'] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value['value1']);
993  }
994  }
995  }
996 
997  // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
998  $solutions = $this->object->getSolutionValues($active_id, $pass, true);
999  foreach ($solutions as $idx => $solution_value) {
1000  if (preg_match('/^(\$v\d+)$/', $solution_value['value1'], $matches)) {
1001  $user_solution[$matches[1]] = $solution_value['value2'];
1002  }
1003  }
1004 
1005  if ($user_solution === []) {
1006  $user_solution = $this->object->getVariableSolutionValuesForPass($active_id, $pass);
1007  }
1008 
1009  // generate the question output
1010  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'components/ILIAS/TestQuestionPool');
1011 
1012  $questiontext = $this->object->substituteVariables($user_solution);
1013 
1014  $template->setVariable("QUESTIONTEXT", $this->renderLatex(
1016  ));
1017 
1018  $questionoutput = $template->get();
1019  $pageoutput = $this->outQuestionPage("", $is_question_postponed, $active_id, $questionoutput);
1020  return $pageoutput;
1021  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
static getResultTypeByQstId($a_qst_id, $a_result)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 727 of file class.assFormulaQuestionGUI.php.

Referenced by resetSavedPreviewSession().

727  : bool
728  {
729  if (array_key_exists($result->getResult(), $resultunits)) {
730  if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
731  return true;
732  }
733  }
734  return false;
735  }
+ Here is the caller graph for this function:

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

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

761  : void
762  {
764  $this->writePostData();
765  $this->addSaveOnEnterOnLoadCode();
766  $this->setTestSpecificProperties();
767  $this->editQuestion();
768  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
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 860 of file class.assFormulaQuestionGUI.php.

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

Referenced by getSolutionOutput().

873  : ?string {
874  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'components/ILIAS/TestQuestionPool');
875  $correctness_icons = [
876  'correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK),
877  'not_correct' => $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK)
878  ];
879  $questiontext = $this->object->substituteVariables($user_solutions, $graphical_output, true, $result_output, $correctness_icons);
880  $template->setVariable("QUESTIONTEXT", $this->renderLatex(
882  ));
883  $questionoutput = $template->get();
884  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "components/ILIAS/TestQuestionPool");
885  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput((int) $active_id, $pass) : "";
886  if (strlen($feedback)) {
887  $cssClass = (
888  $this->hasCorrectSolution($active_id, $pass) ?
890  );
891  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
892  $solutiontemplate->setVariable("FEEDBACK", $this->renderLatex(
894  ));
895  }
896  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
897 
898  $solutionoutput = $solutiontemplate->get();
899  if (!$show_question_only) {
900  $solutionoutput = $this->getILIASPage($solutionoutput);
901  }
902  return $solutionoutput;
903  }
hasCorrectSolution($activeId, $passIndex)
generateCorrectnessIconsForCorrectness(int $correctness)
renderLatex($content)
Wrap content with latex in a LatexContent UI component and render it to be processed by MathJax in th...
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
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 ( )

◆ setQuestionSpecificTabs()

assFormulaQuestionGUI::setQuestionSpecificTabs ( ilTabsGUI  $ilTabs)
protected

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

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

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

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

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

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

63  : void
64  {
66  $suggest_range_for_result = $this->request_data_collector->string('suggest_range_for');
67  if ($this->writePostData()) {
68  $this->tpl->setOnScreenMessage('info', $this->getErrorMessage());
69  }
71  $this->editQuestion(false, null, $suggest_range_for_result);
72  }
editQuestion(bool $checkonly=false, ?bool $is_save_cmd=null)
writePostData(bool $always=false)
{}
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ writePostData()

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

{}

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

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

Referenced by parseQuestion(), and suggestRange().

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

Field Documentation

◆ $ui_factory

UIFactory assFormulaQuestionGUI::$ui_factory
private

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

◆ $ui_renderer

UIRenderer assFormulaQuestionGUI::$ui_renderer
private

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

◆ HAS_SPECIAL_QUESTION_COMMANDS

const assFormulaQuestionGUI::HAS_SPECIAL_QUESTION_COMMANDS = true
protected

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


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