ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 @access public. More...
 
 getCommand ($cmd)
 
 suggestRange ()
 Suggest a range for a result @access public. More...
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. 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)
 Returns the answer specific feedback for the question. More...
 
- 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 ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getOutputMode ()
 
 setOutputMode ($outputMode)
 
 isPdfOutputMode ()
 
 isContentEditingOutputMode ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
_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...
 
 _getGUIClassNameForId ($a_q_id)
 
 _getClassNameForQType ($q_type)
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 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 ()
 

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 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 OUTPUT_MODE_SCREEN = 'outModeScreen'
 
const OUTPUT_MODE_PDF = 'outModePdf'
 
const OUTPUT_MODE_CONTENT_EDITING = 'outModeUsrSol'
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 getPreviousSolutionProvidedMessage ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 isLastSolutionSubmitAuthorized ($active_id, $pass)
 fetches solutions from database and prefers intermediate solutions, but falls back to authorized solutions. More...
 
 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)
 
 getTestOutputSolutions ($activeId, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 

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

Definition at line 21 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 @access public

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

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

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

References $result.

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

977 {
978 if((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
979 {
980 $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
981 return FALSE;
982 }
983
984
985 return TRUE;
986 }
addErrorMessage($errormessage)
$_POST['username']
Definition: cron.php:12

References $_POST, and assQuestionGUI\addErrorMessage().

+ Here is the call graph for this function:

◆ getCommand()

assFormulaQuestionGUI::getCommand (   $cmd)

Reimplemented from assQuestionGUI.

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

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

References $cmd.

◆ getPreview()

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

Reimplemented from assQuestionGUI.

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

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

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

+ 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

Reimplemented from assQuestionGUI.

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

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

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

+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

Returns the answer specific feedback for the question.

This method should be overwritten by the actual question.

Todo:
Mark this method abstract!
Parameters
integer$active_idActive ID of the user
integer$passActive pass
Returns
string HTML Code with the answer specific feedback @access public

Reimplemented from assQuestionGUI.

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

1233 {
1234 return '';
1235 }

◆ getTestOutput()

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

Reimplemented from assQuestionGUI.

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

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

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

+ Here is the call graph for this function:

◆ hasResultUnit()

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

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

830 {
831 if (array_key_exists($result->getResult(), $resultunits))
832 {
833 if (array_key_exists($unit_id, $resultunits[$result->getResult()])) return TRUE;
834 }
835 return FALSE;
836 }

References $result.

◆ isSaveCommand()

assFormulaQuestionGUI::isSaveCommand ( )

Reimplemented from assQuestionGUI.

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

312 {
313 return in_array($this->ctrl->getCmd(), array('saveFQ', 'saveEdit', 'saveReturnFQ'));
314 }

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

866 {
867 $this->writePostData();
868 $this->editQuestion();
869 }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.

References assQuestionGUI\writePostData().

+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

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 }
global $ilUser
Definition: imgupload.php:15

References $ilUser.

Referenced by writePostData().

+ Here is the caller graph for this function:

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

960 {
961 $result = $this->writePostData();
962
963 if($result == 1)
964 {
965 $this->editQuestion();
966 }
967 else
968 {
970 $this->save();
971 }
972 }

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

+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

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

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

+ 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 @access public.

Reimplemented from assQuestionGUI.

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

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

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

+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

Suggest a range for a result @access public.

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

149 {
150 if($this->writePostData())
151 {
153 }
154 $this->editQuestion();
155 }

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

+ Here is the call graph for this function:

◆ writePostData()

assFormulaQuestionGUI::writePostData (   $always = false)

Evaluates a posted edit form and writes the form data in the question object.

Returns
integer A positive value, if one of the required fields wasn't set, else 0

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

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 }
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ Here is the call graph for this function:

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