ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
assFormulaQuestionGUI Class Reference

Single choice question GUI representation The assFormulaQuestionGUI class encapsulates the GUI representation for single choice questions. 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...
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type Sets the ILIAS tabs for this question type public. More...
 
 getCommand ($cmd)
 
 suggestRange ()
 Suggest a range for a result public. More...
 
 resetSavedPreviewSession ()
 
 isSaveCommand ()
 
 parseQuestion ()
 
 saveReturnFQ ()
 
 saveFQ ()
 
 checkInput ()
 check input fields More...
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() 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 ($userSolution)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 hasInlineFeedback ()
 this method can be overwritten per question type More...
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput ($userSolution)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $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)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 hasIntermediateSolution ($activeId, $passIndex)
 Check if the question has an intermediate solution. More...
 
 setUseIntermediateSolution ($use)
 
 getUseIntermediateSolution ()
 Get if intermediate solution should be used for solution output. More...
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=false, $user_post_solutions=false, $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFreuqencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 

Protected Member Functions

 writePostData ($always=false)
 {} More...
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 buildEditForm ()
 

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 ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants 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 SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $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'
 
- Protected Attributes inherited from assQuestionGUI
 $editForm
 
 $use_intermediate_solution = false
 

Detailed Description

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

References ILIAS\GlobalScreen\Provider\__construct().

31  {
33  $this->object = new assFormulaQuestion();
34  $this->newUnitId = null;
35  if ($id >= 0) {
36  $this->object->loadFromDb($id);
37  }
38  }
Class for single choice questions assFormulaQuestion is a class for single choice questions...
__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 782 of file class.assFormulaQuestionGUI.php.

References $result.

Referenced by isSaveCommand().

783  {
784  $resultunit = $result->getUnit();
785 
786  /*
787  * if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
788  * if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
789  * definition if the result-value or the unit-value should be the correct solution!!
790  *
791  */
792  if (is_object($resultunit)) {
793  return true;
794  } else {
795  return false;
796  }
797  }
$result
+ Here is the caller graph for this function:

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

895  {
896  if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"])) {
897  $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
898  return false;
899  }
900 
901 
902  return true;
903  }
addErrorMessage($errormessage)
$_POST["username"]
+ Here is the call graph for this function:

◆ getCommand()

assFormulaQuestionGUI::getCommand (   $cmd)

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

140  {
141  if (preg_match("/suggestrange_(.*?)/", $cmd, $matches)) {
142  $cmd = "suggestRange";
143  }
144  return $cmd;
145  }

◆ getPreview()

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

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

References assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), and assFormulaQuestionResult\getResultTypeByQstId().

1016  {
1017  $user_solution = array();
1018 
1019  if (is_object($this->getPreviewSession())) {
1020  $solutions = (array) $this->getPreviewSession()->getParticipantsSolution();
1021 
1022  foreach ($solutions as $val1 => $val2) {
1023  if (preg_match("/^(\\\$v\\d+)$/", $val1, $matches)) {
1024  $user_solution[$matches[1]] = $val2;
1025  } elseif (preg_match("/^(\\\$r\\d+)$/", $val1, $matches)) {
1026  if (!array_key_exists($matches[1], $user_solution)) {
1027  $user_solution[$matches[1]] = array();
1028  }
1029  $user_solution[$matches[1]]["value"] = $val2;
1030  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches)) {
1031  if (!array_key_exists($matches[1], $user_solution)) {
1032  $user_solution[$matches[1]] = array();
1033  }
1034  $user_solution[$matches[1]]["unit"] = $val2;
1035  }
1036 
1037  if (preg_match("/^(\\\$r\\d+)/", $val1, $matches) && $user_solution[$matches[1]]["result_type"] == 0) {
1038  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
1039  }
1040  }
1041  }
1042 
1043  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
1044  $user_solution = $this->object->getInitialVariableSolutionValues();
1045 
1046  if (is_object($this->getPreviewSession())) {
1047  $this->getPreviewSession()->setParticipantsSolution($user_solution);
1048  }
1049  }
1050 
1051  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1052  if (is_object($this->getPreviewSession())) {
1053  $questiontext = $this->object->substituteVariables($user_solution, false, false, false);
1054  } else {
1055  $questiontext = $this->object->substituteVariables(array());
1056  }
1057  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
1058  $questionoutput = $template->get();
1059  if (!$show_question_only) {
1060  // get page object output
1061  $questionoutput = $this->getILIASPage($questionoutput);
1062  }
1063  return $questionoutput;
1064  }
static getResultTypeByQstId($a_qst_id, $a_result)
getILIASPage($html="")
Returns the ILIAS Page around a question.
+ 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 928 of file class.assFormulaQuestionGUI.php.

References $pass, ilObjTest\_getPass(), ilObjTest\_getUsePreviousAnswers(), ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, assQuestionGUI\getGenericFeedbackOutput(), assQuestionGUI\getILIASPage(), assQuestionGUI\getPreviewSession(), assQuestionGUI\getUseIntermediateSolution(), and assQuestionGUI\hasCorrectSolution().

938  {
939  // get the solution of the user for the active pass or from the last pass if allowed
940  $user_solution = array();
941  if (($active_id > 0) && (!$show_correct_solution)) {
942  $solutions = array();
943  include_once "./Modules/Test/classes/class.ilObjTest.php";
944  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
945  if (is_null($pass)) {
946  $pass = ilObjTest::_getPass($active_id);
947  }
948  }
949  $user_solution["active_id"] = $active_id;
950  $user_solution["pass"] = $pass;
951  $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
952  foreach ($solutions as $idx => $solution_value) {
953  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
954  $user_solution[$matches[1]] = $solution_value["value2"];
955  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
956  if (!array_key_exists($matches[1], $user_solution)) {
957  $user_solution[$matches[1]] = array();
958  }
959  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
960  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
961  if (!array_key_exists($matches[1], $user_solution)) {
962  $user_solution[$matches[1]] = array();
963  }
964  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
965  }
966  }
967  } elseif ($active_id) {
968  $solutions = null;
969  include_once "./Modules/Test/classes/class.ilObjTest.php";
970  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
971  if (is_null($pass)) {
972  $pass = ilObjTest::_getPass($active_id);
973  }
974  }
975  $user_solution = (array) $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
976  } elseif (is_object($this->getPreviewSession())) {
977  $solutionValues = array();
978 
979  $participantsSolution = $this->getPreviewSession()->getParticipantsSolution();
980  if (is_array($participantsSolution)) {
981  foreach ($participantsSolution as $val1 => $val2) {
982  $solutionValues[] = array('value1' => $val1, 'value2' => $val2);
983  }
984  }
985 
986  $user_solution = (array) $this->object->getBestSolution($solutionValues);
987  }
988 
989  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
990  $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, true, $result_output);
991 
992  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
993  $questionoutput = $template->get();
994  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
995  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
996  if (strlen($feedback)) {
997  $cssClass = (
998  $this->hasCorrectSolution($active_id, $pass) ?
1000  );
1001 
1002  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
1003  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
1004  }
1005  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
1006 
1007  $solutionoutput = $solutiontemplate->get();
1008  if (!$show_question_only) {
1009  // get page object output
1010  $solutionoutput = $this->getILIASPage($solutionoutput);
1011  }
1012  return $solutionoutput;
1013  }
hasCorrectSolution($activeId, $passIndex)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
static _getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput (   $userSolution)

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

1135  {
1136  return '';
1137  }

◆ getTestOutput()

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

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

References $pass, ilObjTest\_getPass(), assFormulaQuestionResult\getResultTypeByQstId(), assQuestionGUI\outQuestionPage(), and ilUtil\sendInfo().

1069  {
1070  ilUtil::sendInfo($this->lng->txt('enter_valid_values'));
1071  // get the solution of the user for the active pass or from the last pass if allowed
1072  $user_solution = array();
1073  if ($active_id) {
1074  $solutions = (array) $this->object->getTestOutputSolutions($active_id, $pass);
1075 
1076  $actualPassIndex = null;
1077  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1078  require_once 'Modules/Test/classes/class.ilObjTest.php';
1079  $actualPassIndex = ilObjTest::_getPass($active_id);
1080  }
1081 
1082  foreach ($solutions as $idx => $solution_value) {
1083  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1084  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1085  $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value["value2"], true);
1086  }
1087 
1088  $user_solution[$matches[1]] = $solution_value["value2"];
1089  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
1090  if (!array_key_exists($matches[1], $user_solution)) {
1091  $user_solution[$matches[1]] = array();
1092  }
1093  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1094  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
1095  if (!array_key_exists($matches[1], $user_solution)) {
1096  $user_solution[$matches[1]] = array();
1097  }
1098  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1099  }
1100 
1101  if (preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && $user_solution[$matches[1]]["result_type"] == 0) {
1102  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
1103  }
1104  }
1105  }
1106 
1107  // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
1108  $solutions = $this->object->getSolutionValues($active_id, $pass, true);
1109  foreach ($solutions as $idx => $solution_value) {
1110  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1111  $user_solution[$matches[1]] = $solution_value["value2"];
1112  }
1113  }
1114  // fau.
1115 
1116  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
1117  foreach ($this->object->getInitialVariableSolutionValues() as $val1 => $val2) {
1118  $this->object->saveCurrentSolution($active_id, $pass, $val1, $val2, true);
1119  }
1120  }
1121 
1122  // generate the question output
1123  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1124 
1125  $questiontext = $this->object->substituteVariables($user_solution);
1126 
1127  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
1128 
1129  $questionoutput = $template->get();
1130  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1131  return $pageoutput;
1132  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getResultTypeByQstId($a_qst_id, $a_result)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
+ Here is the call graph for this function:

◆ hasResultUnit()

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

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

References $result.

Referenced by isSaveCommand().

766  {
767  if (array_key_exists($result->getResult(), $resultunits)) {
768  if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
769  return true;
770  }
771  }
772  return false;
773  }
$result
+ Here is the caller graph for this function:

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References writePostData().

800  {
801  $this->writePostData();
802  $this->editQuestion();
803  }
+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

References $DIC, and $ilUser.

Referenced by writePostData().

286  {
287  global $DIC;
288  $ilUser = $DIC['ilUser'];
289  $user_id = $ilUser->getId();
290  $question_id = $this->object->getId();
291  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
292  $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
293  $ilAssQuestionPreviewSession->setParticipantsSolution(array());
294  }
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

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

881  {
882  $result = $this->writePostData();
883 
884  if ($result == 1) {
885  $this->editQuestion();
886  } else {
887  $this->saveTaxonomyAssignments();
888  $this->save();
889  }
890  }
$result
save()
save question
+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

References $_GET, $_SESSION, $DIC, $ilDB, $ilUser, $result, $test, assQuestion\_isWriteable(), assQuestion\_questionExistsInTest(), assQuestionGUI\callNewIdListeners(), ilTestExpressPage\getReturnToPageLink(), ilUtil\redirect(), assQuestionGUI\saveTaxonomyAssignments(), and writePostData().

806  {
807  global $DIC;
808  $ilUser = $DIC['ilUser'];
809  $old_id = $_GET["q_id"];
810  $result = $this->writePostData();
811  if ($result == 0) {
812  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
813  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
814  $this->saveTaxonomyAssignments();
815  $this->object->saveToDb();
816  $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
817  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
818  if (($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
819  $this->ctrl->redirect($this, "originalSyncForm");
820  return;
821  } elseif ($_GET["calling_test"]) {
822  require_once 'Modules/Test/classes/class.ilObjTest.php';
823  $test = new ilObjTest($_GET["calling_test"]);
824  #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
825  $q_id = $this->object->getId();
826  if (!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId())) {
827  global $DIC;
828  $tree = $DIC['tree'];
829  $ilDB = $DIC['ilDB'];
830  $ilPluginAdmin = $DIC['ilPluginAdmin'];
831 
832  include_once("./Modules/Test/classes/class.ilObjTest.php");
833  $_GET["ref_id"] = $_GET["calling_test"];
834  $test = new ilObjTest($_GET["calling_test"], true);
835 
836  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
837  $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
838 
839  $new_id = $test->insertQuestion(
840  $testQuestionSetConfigFactory->getQuestionSetConfig(),
841  $this->object->getId()
842  );
843 
844  $q_id = $new_id;
845  if (isset($_REQUEST['prev_qid'])) {
846  $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
847  }
848 
849  $this->ctrl->setParameter($this, 'q_id', $new_id);
850  $this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
851  #$this->ctrl->setParameter($this, 'test_ref_id', false);
852  }
853  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
854  if ($_REQUEST['test_express_mode']) {
856  } else {
857  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET["calling_test"]);
858  }
859  } else {
860  if ($this->object->getId() != $old_id) {
861  $this->callNewIdListeners($this->object->getId());
862  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
863  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
864  }
865  if (strcmp($_SESSION["info"], "") != 0) {
866  ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
867  } else {
868  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
869  }
870  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
871  }
872  } else {
873  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
874  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
875  $this->object->saveToDb();
876  $this->editQuestion();
877  }
878  }
$_SESSION["AccountId"]
$result
$_GET["client_id"]
callNewIdListeners($a_new_id)
Call the new id listeners.
static getReturnToPageLink($q_id=null)
$ilUser
Definition: imgupload.php:18
static _questionExistsInTest($question_id, $test_id)
global $ilDB
$DIC
Definition: xapitoken.php:46
static redirect($a_script)
$test
Definition: Utf8Test.php:84
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
+ Here is the call graph for this function:

◆ setQuestionTabs()

assFormulaQuestionGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type Sets the ILIAS tabs for this question type public.

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

References $_GET, $_POST, $DIC, $url, assQuestionGUI\addBackTab(), assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), and assQuestionGUI\addTab_QuestionPreview().

46  {
47  global $DIC;
48  $rbacsystem = $DIC['rbacsystem'];
49  $ilTabs = $DIC['ilTabs'];
50 
51  $ilTabs->clearTargets();
52 
53  $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
54  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
55  $q_type = $this->object->getQuestionType();
56 
57  if (strlen($q_type)) {
58  $classname = $q_type . "GUI";
59  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
60  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
61  }
62 
63  if ($_GET["q_id"]) {
64  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
65  // edit page
66  $ilTabs->addTarget(
67  "edit_page",
68  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
69  array("edit", "insert", "exec_pg"),
70  "",
71  "",
72  $force_active
73  );
74  }
75 
76  $this->addTab_QuestionPreview($ilTabs);
77  }
78 
79  $force_active = false;
80  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
81  $url = "";
82 
83  if ($classname) {
84  $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
85  }
86  $commands = $_POST["cmd"];
87  if (is_array($commands)) {
88  foreach ($commands as $key => $value) {
89  if (preg_match("/^suggestrange_.*/", $key, $matches)) {
90  $force_active = true;
91  }
92  }
93  }
94  // edit question properties
95  $ilTabs->addTarget(
96  "edit_question",
97  $url,
98  array(
99  "editQuestion", "save", "cancel", "addSuggestedSolution",
100  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
101  "parseQuestion", "saveEdit", "suggestRange"
102  ),
103  $classname,
104  "",
105  $force_active
106  );
107  }
108 
109  if ($_GET["q_id"]) {
110  // add tab for question feedback within common class assQuestionGUI
111  $this->addTab_QuestionFeedback($ilTabs);
112  }
113 
114  if ($_GET["q_id"]) {
115  // add tab for question hint within common class assQuestionGUI
116  $this->addTab_QuestionHints($ilTabs);
117  }
118 
119  // Unit editor
120  if ($_GET['q_id']) {
121  // add tab for question hint within common class assQuestionGUI
122  $this->addTab_Units($ilTabs);
123  }
124 
125  // Assessment of questions sub menu entry
126  if ($_GET["q_id"]) {
127  $ilTabs->addTarget(
128  "statistics",
129  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
130  array("assessment"),
131  $classname,
132  ""
133  );
134  }
135 
136  $this->addBackTab($ilTabs);
137  }
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBackTab(ilTabsGUI $ilTabs)
$DIC
Definition: xapitoken.php:46
$url
$_POST["username"]
+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

Suggest a range for a result public.

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

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

152  {
153  if ($this->writePostData()) {
155  }
156  $this->editQuestion();
157  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

◆ supportsIntermediateSolutionOutput()

assFormulaQuestionGUI::supportsIntermediateSolutionOutput ( )

Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution()

Returns
bool

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

911  {
912  return true;
913  }

◆ writePostData()

assFormulaQuestionGUI::writePostData (   $always = false)
protected

{}

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

References $_POST, Vendor\Package\$e, $result, assQuestionGUI\addErrorMessage(), ilAssQuestionLifecycle\getInstance(), isSaveCommand(), resetSavedPreviewSession(), ilUtil\sendFailure(), assFormulaQuestionVariable\setRangeMinTxt(), and ilUtil\stripOnlySlashes().

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

163  {
164  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
165  $checked = true;
166  if (!$hasErrors) {
167  $this->object->setTitle($_POST["title"]);
168  $this->object->setAuthor($_POST["author"]);
169  $this->object->setComment($_POST["comment"]);
170  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
171  $questiontext = ilUtil::stripOnlySlashes($_POST["question"]);
172  $this->object->setQuestion($questiontext);
173  $this->object->setEstimatedWorkingTime(
174  $_POST["Estimated"]["hh"],
175  $_POST["Estimated"]["mm"],
176  $_POST["Estimated"]["ss"]
177  );
178 
179  $this->object->parseQuestionText();
180  $found_vars = array();
181  $found_results = array();
182 
183 
184  foreach ($_POST as $key => $value) {
185  if (preg_match("/^unit_(\\\$v\d+)$/", $key, $matches)) {
186  array_push($found_vars, $matches[1]);
187  }
188  if (preg_match("/^unit_(\\\$r\d+)$/", $key, $matches)) {
189  array_push($found_results, $matches[1]);
190  }
191  }
192 
193  try {
194  $lifecycle = ilAssQuestionLifecycle::getInstance($_POST['lifecycle']);
195  $this->object->setLifecycle($lifecycle);
197  }
198 
199  // if(!$this->object->checkForDuplicateVariables())
200  // {
201 //
202  // $this->addErrorMessage($this->lng->txt("err_duplicate_variables"));
203  // $checked = FALSE;
204  // }
205  if (!$this->object->checkForDuplicateResults()) {
206  $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
207  $checked = false;
208  }
209 
210  foreach ($found_vars as $variable) {
211  if ($this->object->getVariable($variable) != null) {
212  $varObj = new assFormulaQuestionVariable($variable, $_POST["range_min_$variable"], $_POST["range_max_$variable"], $this->object->getUnitrepository()->getUnit($_POST["unit_$variable"]), $_POST["precision_$variable"], $_POST["intprecision_$variable"]);
213  $varObj->setRangeMinTxt($_POST["range_min_$variable"]);
214  $varObj->setRangeMaxTxt($_POST["range_max_$variable"]);
215  $this->object->addVariable($varObj);
216  }
217  }
218 
219  $tmp_form_vars = array();
220  $tmp_quest_vars = array();
221  foreach ($found_results as $result) {
222  $tmp_res_match = preg_match_all("/([$][v][0-9]*)/", $_POST["formula_$result"], $form_vars);
223  $tmp_form_vars = array_merge($tmp_form_vars, $form_vars[0]);
224 
225  $tmp_que_match = preg_match_all("/([$][v][0-9]*)/", $_POST['question'], $quest_vars);
226  $tmp_quest_vars = array_merge($tmp_quest_vars, $quest_vars[0]);
227  }
228  $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
229  $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
230 
231  if (count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0) {
232  $error_message = '';
233  if (count($result_has_undefined_vars) > 0) {
234  $error_message .= $this->lng->txt("res_contains_undef_var") . '<br>';
235  }
236  if (count($question_has_unused_vars) > 0) {
237  $error_message .= $this->lng->txt("que_contains_unused_var");
238  }
239  $checked = false;
240  if ($this->isSaveCommand()) {
241  ilUtil::sendFailure($error_message);
242  }
243  }
244  foreach ($found_results as $result) {
245  if (is_object($this->object->getUnitrepository()->getUnit($_POST["unit_$result"]))) {
246  $tmp_result_unit = $this->object->getUnitrepository()->getUnit($_POST["unit_$result"]);
247  } else {
248  $tmp_result_unit = null;
249  }
250 
251  if ($this->object->getResult($result) != null) {
252  $use_simple_rating = ($_POST["rating_advanced_$result"] == 1) ? false : true;
253  $resObj = new assFormulaQuestionResult(
254  $result,
255  $_POST["range_min_$result"],
256  $_POST["range_max_$result"],
257  $_POST["tolerance_$result"],
258  $tmp_result_unit,
259  $_POST["formula_$result"],
260  $_POST["points_$result"],
261  $_POST["precision_$result"],
262  $use_simple_rating,
263  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_sign_$result"] : "",
264  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_value_$result"] : "",
265  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_unit_$result"] : "",
266  $_POST["result_type_$result"] != 0 ? $_POST["result_type_$result"] : 0
267  );
268  $resObj->setRangeMinTxt($_POST["range_min_$result"]);
269  $resObj->setRangeMaxTxt($_POST["range_max_$result"]);
270  $this->object->addResult($resObj);
271  $this->object->addResultUnits($resObj, $_POST["units_$result"]);
272  }
273  }
274  if ($checked == false) {
275  return 1;
276  } else {
277  $this->resetSavedPreviewSession();
278  return 0;
279  }
280  } else {
281  return 1;
282  }
283  }
$result
addErrorMessage($errormessage)
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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