ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 (ilTemplate $tpl)
 
 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 $id.

31  {
32  parent::__construct();
33  $this->object = new assFormulaQuestion();
34  $this->newUnitId = null;
35  if ($id >= 0) {
36  $this->object->loadFromDb($id);
37  }
38  }
if(!array_key_exists('StateId', $_REQUEST)) $id
Class for single choice questions assFormulaQuestion is a class for single choice questions...

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

References $result.

Referenced by isSaveCommand().

772  {
773  $resultunit = $result->getUnit();
774 
775  /*
776  * if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
777  * if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
778  * definition if the result-value or the unit-value should be the correct solution!!
779  *
780  */
781  if (is_object($resultunit)) {
782  return true;
783  } else {
784  return false;
785  }
786  }
$result
+ Here is the caller graph for this function:

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

884  {
885  if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"])) {
886  $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
887  return false;
888  }
889 
890 
891  return true;
892  }
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 1004 of file class.assFormulaQuestionGUI.php.

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

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

References $pass, $template, 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().

927  {
928  // get the solution of the user for the active pass or from the last pass if allowed
929  $user_solution = array();
930  if (($active_id > 0) && (!$show_correct_solution)) {
931  $solutions = array();
932  include_once "./Modules/Test/classes/class.ilObjTest.php";
933  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
934  if (is_null($pass)) {
935  $pass = ilObjTest::_getPass($active_id);
936  }
937  }
938  $user_solution["active_id"] = $active_id;
939  $user_solution["pass"] = $pass;
940  $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
941  foreach ($solutions as $idx => $solution_value) {
942  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
943  $user_solution[$matches[1]] = $solution_value["value2"];
944  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
945  if (!array_key_exists($matches[1], $user_solution)) {
946  $user_solution[$matches[1]] = array();
947  }
948  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
949  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
950  if (!array_key_exists($matches[1], $user_solution)) {
951  $user_solution[$matches[1]] = array();
952  }
953  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
954  }
955  }
956  } elseif ($active_id) {
957  $solutions = null;
958  include_once "./Modules/Test/classes/class.ilObjTest.php";
959  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
960  if (is_null($pass)) {
961  $pass = ilObjTest::_getPass($active_id);
962  }
963  }
964  $user_solution = (array) $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
965  } elseif (is_object($this->getPreviewSession())) {
966  $solutionValues = array();
967 
968  $participantsSolution = $this->getPreviewSession()->getParticipantsSolution();
969  if (is_array($participantsSolution)) {
970  foreach ($participantsSolution as $val1 => $val2) {
971  $solutionValues[] = array('value1' => $val1, 'value2' => $val2);
972  }
973  }
974 
975  $user_solution = (array) $this->object->getBestSolution($solutionValues);
976  }
977 
978  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
979  $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, true, $result_output);
980 
981  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
982  $questionoutput = $template->get();
983  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
984  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
985  if (strlen($feedback)) {
986  $cssClass = (
987  $this->hasCorrectSolution($active_id, $pass) ?
989  );
990 
991  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
992  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
993  }
994  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
995 
996  $solutionoutput = $solutiontemplate->get();
997  if (!$show_question_only) {
998  // get page object output
999  $solutionoutput = $this->getILIASPage($solutionoutput);
1000  }
1001  return $solutionoutput;
1002  }
hasCorrectSolution($activeId, $passIndex)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
$template
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
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 1123 of file class.assFormulaQuestionGUI.php.

1124  {
1125  return '';
1126  }

◆ getTestOutput()

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

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

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

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

References $result.

Referenced by isSaveCommand().

755  {
756  if (array_key_exists($result->getResult(), $resultunits)) {
757  if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
758  return true;
759  }
760  }
761  return false;
762  }
$result
+ Here is the caller graph for this function:

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References writePostData().

789  {
790  $this->writePostData();
791  $this->editQuestion();
792  }
+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

References $DIC, and $ilUser.

Referenced by writePostData().

280  {
281  global $DIC;
282  $ilUser = $DIC['ilUser'];
283  $user_id = $ilUser->getId();
284  $question_id = $this->object->getId();
285  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
286  $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
287  $ilAssQuestionPreviewSession->setParticipantsSolution(array());
288  }
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
+ Here is the caller graph for this function:

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

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

870  {
871  $result = $this->writePostData();
872 
873  if ($result == 1) {
874  $this->editQuestion();
875  } else {
876  $this->saveTaxonomyAssignments();
877  $this->save();
878  }
879  }
$result
save()
save question
+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

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

795  {
796  global $DIC;
797  $ilUser = $DIC['ilUser'];
798  $old_id = $_GET["q_id"];
799  $result = $this->writePostData();
800  if ($result == 0) {
801  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
802  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
803  $this->saveTaxonomyAssignments();
804  $this->object->saveToDb();
805  $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
806  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
807  if (($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
808  $this->ctrl->redirect($this, "originalSyncForm");
809  return;
810  } elseif ($_GET["calling_test"]) {
811  require_once 'Modules/Test/classes/class.ilObjTest.php';
812  $test = new ilObjTest($_GET["calling_test"]);
813  #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
814  $q_id = $this->object->getId();
815  if (!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId())) {
816  global $DIC;
817  $tree = $DIC['tree'];
818  $ilDB = $DIC['ilDB'];
819  $ilPluginAdmin = $DIC['ilPluginAdmin'];
820 
821  include_once("./Modules/Test/classes/class.ilObjTest.php");
822  $_GET["ref_id"] = $_GET["calling_test"];
823  $test = new ilObjTest($_GET["calling_test"], true);
824 
825  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
826  $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
827 
828  $new_id = $test->insertQuestion(
829  $testQuestionSetConfigFactory->getQuestionSetConfig(),
830  $this->object->getId()
831  );
832 
833  $q_id = $new_id;
834  if (isset($_REQUEST['prev_qid'])) {
835  $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
836  }
837 
838  $this->ctrl->setParameter($this, 'q_id', $new_id);
839  $this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
840  #$this->ctrl->setParameter($this, 'test_ref_id', false);
841  }
842  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
843  if ($_REQUEST['test_express_mode']) {
845  } else {
846  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET["calling_test"]);
847  }
848  } else {
849  if ($this->object->getId() != $old_id) {
850  $this->callNewIdListeners($this->object->getId());
851  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
852  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
853  }
854  if (strcmp($_SESSION["info"], "") != 0) {
855  ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
856  } else {
857  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
858  }
859  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
860  }
861  } else {
862  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
863  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
864  $this->object->saveToDb();
865  $this->editQuestion();
866  }
867  }
$_SESSION["AccountId"]
$result
global $DIC
Definition: saml.php:7
$_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
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, $key, $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
global $DIC
Definition: saml.php:7
$_GET["client_id"]
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBackTab(ilTabsGUI $ilTabs)
$url
$key
Definition: croninfo.php:18
$_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 899 of file class.assFormulaQuestionGUI.php.

900  {
901  return true;
902  }

◆ writePostData()

assFormulaQuestionGUI::writePostData (   $always = false)
protected

{}

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

References $_POST, $key, $result, assQuestionGUI\addErrorMessage(), 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  // if(!$this->object->checkForDuplicateVariables())
194  // {
195 //
196  // $this->addErrorMessage($this->lng->txt("err_duplicate_variables"));
197  // $checked = FALSE;
198  // }
199  if (!$this->object->checkForDuplicateResults()) {
200  $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
201  $checked = false;
202  }
203 
204  foreach ($found_vars as $variable) {
205  if ($this->object->getVariable($variable) != null) {
206  $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"]);
207  $varObj->setRangeMinTxt($_POST["range_min_$variable"]);
208  $varObj->setRangeMaxTxt($_POST["range_max_$variable"]);
209  $this->object->addVariable($varObj);
210  }
211  }
212 
213  $tmp_form_vars = array();
214  $tmp_quest_vars = array();
215  foreach ($found_results as $result) {
216  $tmp_res_match = preg_match_all("/([$][v][0-9]*)/", $_POST["formula_$result"], $form_vars);
217  $tmp_form_vars = array_merge($tmp_form_vars, $form_vars[0]);
218 
219  $tmp_que_match = preg_match_all("/([$][v][0-9]*)/", $_POST['question'], $quest_vars);
220  $tmp_quest_vars = array_merge($tmp_quest_vars, $quest_vars[0]);
221  }
222  $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
223  $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
224 
225  if (count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0) {
226  $error_message = '';
227  if (count($result_has_undefined_vars) > 0) {
228  $error_message .= $this->lng->txt("res_contains_undef_var") . '<br>';
229  }
230  if (count($question_has_unused_vars) > 0) {
231  $error_message .= $this->lng->txt("que_contains_unused_var");
232  }
233  $checked = false;
234  if ($this->isSaveCommand()) {
235  ilUtil::sendFailure($error_message);
236  }
237  }
238  foreach ($found_results as $result) {
239  if (is_object($this->object->getUnitrepository()->getUnit($_POST["unit_$result"]))) {
240  $tmp_result_unit = $this->object->getUnitrepository()->getUnit($_POST["unit_$result"]);
241  } else {
242  $tmp_result_unit = null;
243  }
244 
245  if ($this->object->getResult($result) != null) {
246  $use_simple_rating = ($_POST["rating_advanced_$result"] == 1) ? false : true;
247  $resObj = new assFormulaQuestionResult(
248  $result,
249  $_POST["range_min_$result"],
250  $_POST["range_max_$result"],
251  $_POST["tolerance_$result"],
252  $tmp_result_unit,
253  $_POST["formula_$result"],
254  $_POST["points_$result"],
255  $_POST["precision_$result"],
256  $use_simple_rating,
257  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_sign_$result"] : "",
258  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_value_$result"] : "",
259  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_unit_$result"] : "",
260  $_POST["result_type_$result"] != 0 ? $_POST["result_type_$result"] : 0
261  );
262  $resObj->setRangeMinTxt($_POST["range_min_$result"]);
263  $resObj->setRangeMaxTxt($_POST["range_max_$result"]);
264  $this->object->addResult($resObj);
265  $this->object->addResultUnits($resObj, $_POST["units_$result"]);
266  }
267  }
268  if ($checked == false) {
269  return 1;
270  } else {
271  $this->resetSavedPreviewSession();
272  return 0;
273  }
274  } else {
275  return 1;
276  }
277  }
$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.
$key
Definition: croninfo.php:18
$_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: