ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
assFormulaQuestionGUI Class Reference

Single choice question GUI representation The assFormulaQuestionGUI class encapsulates the GUI representation for single choice questions. More...

+ Inheritance diagram for assFormulaQuestionGUI:
+ Collaboration diagram for assFormulaQuestionGUI:

Public Member Functions

 __construct ($id=-1)
 assFormulaQuestionGUI constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestionGUI object. More...
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type Sets the ILIAS tabs for this question type public. More...
 
 getCommand ($cmd)
 
 suggestRange ()
 Suggest a range for a result public. More...
 
 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=NULL, $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...
 
 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...
 
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode. 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=NULL, $is_question_postponed=FALSE, $user_post_solutions=FALSE, $show_specific_inline_feedback=FALSE)
 
 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...
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 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)
 
 writeQuestionGenericPostData ()
 
 getFormEncodingType ()
 
 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 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.

References $result.

Referenced by isSaveCommand().

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
+ Here is the caller graph for this function:

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

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  }
$_POST['username']
Definition: cron.php:12
addErrorMessage($errormessage)
+ Here is the call graph for this function:

◆ getCommand()

assFormulaQuestionGUI::getCommand (   $cmd)

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

References $cmd.

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

◆ getPreview()

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

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

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

1085  {
1086  $user_solution = array();
1087 
1088  if( is_object($this->getPreviewSession()) )
1089  {
1090  $solutions = $this->getPreviewSession()->getParticipantsSolution();
1091 
1092  foreach($solutions as $val1 => $val2)
1093  {
1094  if(preg_match("/^(\\\$v\\d+)$/", $val1, $matches))
1095  {
1096  $user_solution[$matches[1]] = $val2;
1097  }
1098  else if(preg_match("/^(\\\$r\\d+)$/", $val1, $matches))
1099  {
1100 
1101  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1102  $user_solution[$matches[1]]["value"] = $val2;
1103  }
1104  else if(preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches))
1105  {
1106  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1107  $user_solution[$matches[1]]["unit"] = $val2;
1108  }
1109 
1110  if(preg_match("/^(\\\$r\\d+)/", $val1, $matches) && $user_solution[$matches[1]]["result_type"] == 0)
1111  {
1112  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
1113  }
1114  }
1115  }
1116 
1117  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1118  if( is_object($this->getPreviewSession()) )
1119  {
1120  $questiontext = $this->object->substituteVariables($user_solution, false, false, false, $this->getPreviewSession());
1121  }
1122  else
1123  {
1124  $questiontext = $this->object->substituteVariables();
1125  }
1126  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1127  $questionoutput = $template->get();
1128  if(!$show_question_only)
1129  {
1130  // get page object output
1131  $questionoutput = $this->getILIASPage($questionoutput);
1132  }
1133  return $questionoutput;
1134  }
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
The solution output of the question as HTML code

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

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

1011  {
1012  // get the solution of the user for the active pass or from the last pass if allowed
1013  $user_solution = "";
1014  if(($active_id > 0) && (!$show_correct_solution))
1015  {
1016  $solutions = NULL;
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 = $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 = $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, $this->getPreviewSession());
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)) $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput( $feedback, true ));
1073  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
1074 
1075  $solutionoutput = $solutiontemplate->get();
1076  if(!$show_question_only)
1077  {
1078  // get page object output
1079  $solutionoutput = $this->getILIASPage($solutionoutput);
1080  }
1081  return $solutionoutput;
1082  }
_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
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

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

1189  {
1190  return '';
1191  }

◆ getTestOutput()

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

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

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

1137  {
1138  ilUtil::sendInfo($this->lng->txt('enter_valid_values'));
1139  // get the solution of the user for the active pass or from the last pass if allowed
1140  $user_solution = null;
1141  if($active_id)
1142  {
1143  $solutions = NULL;
1144  include_once "./Modules/Test/classes/class.ilObjTest.php";
1145  if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
1146 
1147  $user_solution["active_id"] = $active_id;
1148  $user_solution["pass"] = $pass;
1149  $solutions =& $this->object->getSolutionValues($active_id, $pass);
1150 
1151  foreach($solutions as $idx => $solution_value)
1152  {
1153  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1154  {
1155  $user_solution[$matches[1]] = $solution_value["value2"];
1156  }
1157  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
1158  {
1159 
1160  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1161  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1162  }
1163  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
1164  {
1165  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1166  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1167  }
1168 
1169  if(preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && $user_solution[$matches[1]]["result_type"] == 0)
1170  {
1171  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
1172  }
1173  }
1174  }
1175 
1176  // generate the question output
1177  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1178 
1179  $questiontext = $this->object->substituteVariables($user_solution);
1180 
1181  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1182 
1183  $questionoutput = $template->get();
1184  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1185  return $pageoutput;
1186  }
_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
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 829 of file class.assFormulaQuestionGUI.php.

References $result.

Referenced by isSaveCommand().

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  }
$result
+ Here is the caller graph for this function:

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References assQuestionGUI\writePostData().

866  {
867  $this->writePostData();
868  $this->editQuestion();
869  }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

References $ilUser.

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  }
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

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

960  {
961  $result = $this->writePostData();
962 
963  if($result == 1)
964  {
965  $this->editQuestion();
966  }
967  else
968  {
969  $this->saveTaxonomyAssignments();
970  $this->save();
971  }
972  }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$result
save()
save question
+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

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

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());
880  $this->saveTaxonomyAssignments();
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  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
$result
$_GET["client_id"]
callNewIdListeners($a_new_id)
Call the new id listeners.
_questionExistsInTest($question_id, $test_id)
static getReturnToPageLink($q_id=null)
global $ilUser
Definition: imgupload.php:15
global $ilDB
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
static redirect($a_script)
http redirect to other script
_isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
$test
Definition: Utf8Test.php:85
+ 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, assQuestionGUI\addBackTab(), assQuestionGUI\addTab_QuestionFeedback(), assQuestionGUI\addTab_QuestionHints(), and assQuestionGUI\addTab_QuestionPreview().

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_QuestionPreview(ilTabsGUI $tabsGUI)
$_POST['username']
Definition: cron.php:12
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBackTab(ilTabsGUI $ilTabs)
+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

Suggest a range for a result public.

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

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

149  {
150  if($this->writePostData())
151  {
153  }
154  $this->editQuestion();
155  }
writePostData()
Evaluates a posted edit form and writes the form data in the question object.
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)

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.

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

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  }
$_POST['username']
Definition: cron.php:12
$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.
+ Here is the call graph for this function:

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