ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 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 ($active_id, $pass)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 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="")
 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 ($active_id, $pass)
 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)
 
 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 ()
 

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

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.

31  {
32  parent::__construct();
33  $this->object = new assFormulaQuestion();
34  $this->newUnitId = null;
35  if($id >= 0)
36  {
37  $this->object->loadFromDb($id);
38  }
39  }
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 847 of file class.assFormulaQuestionGUI.php.

References $result.

Referenced by isSaveCommand().

848  {
849  $resultunit = $result->getUnit();
850 
851  /*
852  * if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
853  * if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
854  * definition if the result-value or the unit-value should be the correct solution!!
855  *
856  */
857  if(is_object($resultunit))
858  {
859  return true;
860  }
861  else
862  {
863  return false;
864  }
865  }
$result
+ Here is the caller graph for this function:

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

979  {
980  if((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
981  {
982  $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
983  return FALSE;
984  }
985 
986 
987  return TRUE;
988  }
addErrorMessage($errormessage)
$_POST["username"]
+ Here is the call graph for this function:

◆ getCommand()

assFormulaQuestionGUI::getCommand (   $cmd)

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

References $cmd.

137  {
138  if(preg_match("/suggestrange_(.*?)/", $cmd, $matches))
139  {
140  $cmd = "suggestRange";
141  }
142  return $cmd;
143  }
$cmd
Definition: sahs_server.php:35

◆ getPreview()

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

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

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

1095  {
1096  $user_solution = array();
1097 
1098  if( is_object($this->getPreviewSession()) )
1099  {
1100  $solutions = (array)$this->getPreviewSession()->getParticipantsSolution();
1101 
1102  foreach($solutions as $val1 => $val2)
1103  {
1104  if(preg_match("/^(\\\$v\\d+)$/", $val1, $matches))
1105  {
1106  $user_solution[$matches[1]] = $val2;
1107  }
1108  else if(preg_match("/^(\\\$r\\d+)$/", $val1, $matches))
1109  {
1110 
1111  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1112  $user_solution[$matches[1]]["value"] = $val2;
1113  }
1114  else if(preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches))
1115  {
1116  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1117  $user_solution[$matches[1]]["unit"] = $val2;
1118  }
1119 
1120  if(preg_match("/^(\\\$r\\d+)/", $val1, $matches) && $user_solution[$matches[1]]["result_type"] == 0)
1121  {
1122  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
1123  }
1124  }
1125  }
1126 
1127  if( !$this->object->hasRequiredVariableSolutionValues($user_solution) )
1128  {
1129  $user_solution = $this->object->getInitialVariableSolutionValues();
1130 
1131  if( is_object($this->getPreviewSession()) )
1132  {
1133  $this->getPreviewSession()->setParticipantsSolution($user_solution);
1134  }
1135  }
1136 
1137  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1138  if( is_object($this->getPreviewSession()) )
1139  {
1140  $questiontext = $this->object->substituteVariables($user_solution, false, false, false);
1141  }
1142  else
1143  {
1144  $questiontext = $this->object->substituteVariables(array());
1145  }
1146  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1147  $questionoutput = $template->get();
1148  if(!$show_question_only)
1149  {
1150  // get page object output
1151  $questionoutput = $this->getILIASPage($questionoutput);
1152  }
1153  return $questionoutput;
1154  }
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
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
+ 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
The solution output of the question as HTML code

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

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

1013  {
1014  // get the solution of the user for the active pass or from the last pass if allowed
1015  $user_solution = array();
1016  if(($active_id > 0) && (!$show_correct_solution))
1017  {
1018  $solutions = array();
1019  include_once "./Modules/Test/classes/class.ilObjTest.php";
1020  if(!ilObjTest::_getUsePreviousAnswers($active_id, true))
1021  {
1022  if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
1023  }
1024  $user_solution["active_id"] = $active_id;
1025  $user_solution["pass"] = $pass;
1026  $solutions =& $this->object->getSolutionValues($active_id, $pass);
1027  foreach($solutions as $idx => $solution_value)
1028  {
1029  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1030  {
1031  $user_solution[$matches[1]] = $solution_value["value2"];
1032  }
1033  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
1034  {
1035  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1036  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1037  }
1038  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
1039  {
1040  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1041  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1042  }
1043  }
1044  }
1045  else if($active_id)
1046  {
1047  $solutions = NULL;
1048  include_once "./Modules/Test/classes/class.ilObjTest.php";
1049  if(!ilObjTest::_getUsePreviousAnswers($active_id, true))
1050  {
1051  if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
1052  }
1053  $user_solution = (array)$this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
1054  }
1055  elseif( is_object($this->getPreviewSession()) )
1056  {
1057  $solutionValues = array();
1058 
1059  foreach($this->getPreviewSession()->getParticipantsSolution() as $val1 => $val2)
1060  {
1061  $solutionValues[] = array('value1' => $val1, 'value2' => $val2);
1062  }
1063 
1064  $user_solution = (array)$this->object->getBestSolution($solutionValues);
1065  }
1066 
1067  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
1068  $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, TRUE, $result_output);
1069 
1070  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1071  $questionoutput = $template->get();
1072  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
1073  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
1074  if (strlen($feedback))
1075  {
1076  $cssClass = ( $this->hasCorrectSolution($active_id, $pass) ?
1078  );
1079 
1080  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
1081  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback, true ));
1082  }
1083  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
1084 
1085  $solutionoutput = $solutiontemplate->get();
1086  if(!$show_question_only)
1087  {
1088  // get page object output
1089  $solutionoutput = $this->getILIASPage($solutionoutput);
1090  }
1091  return $solutionoutput;
1092  }
hasCorrectSolution($activeId, $passIndex)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
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 (   $active_id,
  $pass 
)

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

1236  {
1237  return '';
1238  }

◆ getTestOutput()

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

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

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

1159  {
1160  ilUtil::sendInfo($this->lng->txt('enter_valid_values'));
1161  // get the solution of the user for the active pass or from the last pass if allowed
1162  $user_solution = array();
1163  if($active_id)
1164  {
1165  $solutions = (array)$this->object->getTestOutputSolutions($active_id, $pass);
1166 
1167  $actualPassIndex = null;
1168  if( $this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled() )
1169  {
1170  require_once 'Modules/Test/classes/class.ilObjTest.php';
1171  $actualPassIndex = ilObjTest::_getPass($active_id);
1172  }
1173 
1174  foreach($solutions as $idx => $solution_value)
1175  {
1176  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1177  {
1178  if( $this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled() )
1179  {
1180  $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value["value2"], true);
1181  }
1182 
1183  $user_solution[$matches[1]] = $solution_value["value2"];
1184  }
1185  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
1186  {
1187 
1188  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1189  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1190  }
1191  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
1192  {
1193  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1194  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1195  }
1196 
1197  if(preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && $user_solution[$matches[1]]["result_type"] == 0)
1198  {
1199  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
1200  }
1201  }
1202  }
1203 
1204 // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
1205  $solutions = $this->object->getSolutionValues($active_id, $pass, true);
1206  foreach($solutions as $idx => $solution_value)
1207  {
1208  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1209  {
1210  $user_solution[$matches[1]] = $solution_value["value2"];
1211  }
1212  }
1213 // fau.
1214 
1215  if( !$this->object->hasRequiredVariableSolutionValues($user_solution) )
1216  {
1217  foreach($this->object->getInitialVariableSolutionValues() as $val1 => $val2)
1218  {
1219  $this->object->saveCurrentSolution($active_id, $pass, $val1, $val2, true);
1220  }
1221  }
1222 
1223  // generate the question output
1224  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1225 
1226  $questiontext = $this->object->substituteVariables($user_solution);
1227 
1228  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1229 
1230  $questionoutput = $template->get();
1231  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1232  return $pageoutput;
1233  }
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.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
+ Here is the call graph for this function:

◆ hasResultUnit()

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

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

References $result.

Referenced by isSaveCommand().

832  {
833  if (array_key_exists($result->getResult(), $resultunits))
834  {
835  if (array_key_exists($unit_id, $resultunits[$result->getResult()])) return TRUE;
836  }
837  return FALSE;
838  }
$result
+ Here is the caller graph for this function:

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References writePostData().

868  {
869  $this->writePostData();
870  $this->editQuestion();
871  }
+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

References $ilUser, and array.

Referenced by writePostData().

302  {
303  global $ilUser;
304  $user_id = $ilUser->getId();
305  $question_id = $this->object->getId();
306  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
307  $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
308  $ilAssQuestionPreviewSession->setParticipantsSolution(array());
309  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

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

962  {
963  $result = $this->writePostData();
964 
965  if($result == 1)
966  {
967  $this->editQuestion();
968  }
969  else
970  {
971  $this->saveTaxonomyAssignments();
972  $this->save();
973  }
974  }
$result
save()
save question
+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

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

874  {
875  global $ilUser;
876  $old_id = $_GET["q_id"];
877  $result = $this->writePostData();
878  if ($result == 0)
879  {
880  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
881  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
882  $this->saveTaxonomyAssignments();
883  $this->object->saveToDb();
884  $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
885  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
886  if (($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int)$_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
887  {
888  $this->ctrl->redirect($this, "originalSyncForm");
889  return;
890  }
891  elseif ($_GET["calling_test"])
892  {
893  require_once 'Modules/Test/classes/class.ilObjTest.php';
894  $test = new ilObjTest($_GET["calling_test"]);
895  #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
896  $q_id = $this->object->getId();
897  if(!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()))
898  {
899  global $tree, $ilDB, $ilPluginAdmin;
900 
901  include_once("./Modules/Test/classes/class.ilObjTest.php");
902  $_GET["ref_id"] = $_GET["calling_test"];
903  $test = new ilObjTest($_GET["calling_test"], true);
904 
905  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
906  $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
907 
908  $new_id = $test->insertQuestion(
909  $testQuestionSetConfigFactory->getQuestionSetConfig(), $this->object->getId()
910  );
911 
912  $q_id = $new_id;
913  if(isset($_REQUEST['prev_qid']))
914  {
915  $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
916  }
917 
918  $this->ctrl->setParameter($this, 'q_id', $new_id);
919  $this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
920  #$this->ctrl->setParameter($this, 'test_ref_id', false);
921 
922  }
923  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
924  if($_REQUEST['test_express_mode'])
925  {
927  }
928  else
929  {
930  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET["calling_test"]);
931  }
932  }
933  else
934  {
935  if ($this->object->getId() != $old_id)
936  {
937  $this->callNewIdListeners($this->object->getId());
938  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
939  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
940  }
941  if (strcmp($_SESSION["info"], "") != 0)
942  {
943  ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
944  }
945  else
946  {
947  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
948  }
949  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
950  }
951  }
952  else
953  {
954  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
955  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
956  $this->object->saveToDb();
957  $this->editQuestion();
958  }
959  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_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)
Create new PHPExcel object
obj_idprivate
global $ilDB
static redirect($a_script)
http redirect to other 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 46 of file class.assFormulaQuestionGUI.php.

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

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

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

Suggest a range for a result public.

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

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

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

◆ writePostData()

assFormulaQuestionGUI::writePostData (   $always = false)
protected

{}

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

References $_POST, $result, assQuestionGUI\addErrorMessage(), array, isSaveCommand(), object, resetSavedPreviewSession(), ilUtil\sendFailure(), assFormulaQuestionVariable\setRangeMinTxt(), and ilUtil\stripOnlySlashes().

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

162  {
163  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
164  $checked = true;
165  if(!$hasErrors)
166  {
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  {
186  if(preg_match("/^unit_(\\\$v\d+)$/", $key, $matches))
187  {
188  array_push($found_vars, $matches[1]);
189  }
190  if(preg_match("/^unit_(\\\$r\d+)$/", $key, $matches))
191  {
192  array_push($found_results, $matches[1]);
193  }
194  }
195 
196 // if(!$this->object->checkForDuplicateVariables())
197 // {
198 //
199 // $this->addErrorMessage($this->lng->txt("err_duplicate_variables"));
200 // $checked = FALSE;
201 // }
202  if(!$this->object->checkForDuplicateResults())
203  {
204  $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
205  $checked = FALSE;
206  }
207 
208  foreach($found_vars as $variable)
209  {
210  if($this->object->getVariable($variable) != null)
211  {
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  {
223  $tmp_res_match = preg_match_all("/([$][v][0-9]*)/", $_POST["formula_$result"], $form_vars);
224  $tmp_form_vars = array_merge($tmp_form_vars,$form_vars[0]);
225 
226  $tmp_que_match = preg_match_all("/([$][v][0-9]*)/", $_POST['question'] , $quest_vars);
227  $tmp_quest_vars= array_merge($tmp_quest_vars,$quest_vars[0]);
228  }
229  $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
230  $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
231 
232  if(count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0)
233  {
234  $error_message = '';
235  if(count($result_has_undefined_vars) > 0)
236  {
237  $error_message .= $this->lng->txt("res_contains_undef_var"). '<br>';
238  }
239  if(count($question_has_unused_vars) > 0)
240  {
241  $error_message .= $this->lng->txt("que_contains_unused_var");
242  }
243  $checked = false;
244  if($this->isSaveCommand())
245  {
246  ilUtil::sendFailure($error_message);
247  }
248  }
249  foreach($found_results as $result)
250  {
251  if(is_object($this->object->getUnitrepository()->getUnit($_POST["unit_$result"])))
252  {
253  $tmp_result_unit = $this->object->getUnitrepository()->getUnit($_POST["unit_$result"]);
254  }
255  else
256  {
257  $tmp_result_unit = NULL;
258  }
259 
260  if($this->object->getResult($result) != null)
261  {
262  $use_simple_rating = ($_POST["rating_advanced_$result"] == 1) ? FALSE : TRUE;
263  $resObj = new assFormulaQuestionResult(
264  $result,
265  $_POST["range_min_$result"],
266  $_POST["range_max_$result"],
267  $_POST["tolerance_$result"],
268 
269  $tmp_result_unit,
270  $_POST["formula_$result"],
271  $_POST["points_$result"],
272  $_POST["precision_$result"],
273  $use_simple_rating,
274  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_sign_$result"] : "",
275  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_value_$result"] : "",
276  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_unit_$result"] : "",
277  $_POST["result_type_$result"] != 0 ? $_POST["result_type_$result"] : 0
278  );
279  $resObj->setRangeMinTxt($_POST["range_min_$result"]);
280  $resObj->setRangeMaxTxt($_POST["range_max_$result"]);
281  $this->object->addResult($resObj);
282  $this->object->addResultUnits($resObj, $_POST["units_$result"]);
283  }
284  }
285  if($checked == false)
286  {
287  return 1;
288  }
289  else
290  {
291  $this->resetSavedPreviewSession();
292  return 0;
293  }
294  }
295  else
296  {
297  return 1;
298  }
299  }
$result
addErrorMessage($errormessage)
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Create new PHPExcel object
obj_idprivate
$_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: