ILIAS  release_4-4 Revision
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...
 
 isSaveCommand ()
 
 parseQuestion ()
 
 saveReturnFQ ()
 
 saveFQ ()
 
 checkInput ()
 check input fields More...
 
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
 
 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)
 
 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 (ilTestPlayerAbstractGUI $linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 assessment ()
 output assessment More...
 
_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...
 
 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 ()
 
 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 ()
 
 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'
 
 $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
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 writeQuestionGenericPostData ()
 

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

References $result.

Referenced by isSaveCommand().

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

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

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

◆ getCommand()

assFormulaQuestionGUI::getCommand (   $cmd)

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

References $cmd.

147  {
148  if(preg_match("/suggestrange_(.*?)/", $cmd, $matches))
149  {
150  $cmd = "suggestRange";
151  }
152  return $cmd;
153  }
$cmd
Definition: sahs_server.php:35

◆ getPreview()

assFormulaQuestionGUI::getPreview (   $show_question_only = FALSE)

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

References assQuestionGUI\getILIASPage().

1082  {
1083  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1084  $questiontext = $this->object->substituteVariables();
1085  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1086  $questionoutput = $template->get();
1087  if(!$show_question_only)
1088  {
1089  // get page object output
1090  $questionoutput = $this->getILIASPage($questionoutput);
1091  }
1092  return $questionoutput;
1093  }
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 1010 of file class.assFormulaQuestionGUI.php.

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

1021  {
1022  // get the solution of the user for the active pass or from the last pass if allowed
1023  $user_solution = "";
1024  if(($active_id > 0) && (!$show_correct_solution))
1025  {
1026  $solutions = NULL;
1027  include_once "./Modules/Test/classes/class.ilObjTest.php";
1028  if(!ilObjTest::_getUsePreviousAnswers($active_id, true))
1029  {
1030  if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
1031  }
1032  $user_solution["active_id"] = $active_id;
1033  $user_solution["pass"] = $pass;
1034  $solutions =& $this->object->getSolutionValues($active_id, $pass);
1035  foreach($solutions as $idx => $solution_value)
1036  {
1037  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1038  {
1039  $user_solution[$matches[1]] = $solution_value["value2"];
1040  }
1041  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
1042  {
1043  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1044  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1045  }
1046  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
1047  {
1048  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1049  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1050  }
1051  }
1052  }
1053  else if($active_id)
1054  {
1055  $solutions = NULL;
1056  include_once "./Modules/Test/classes/class.ilObjTest.php";
1057  if(!ilObjTest::_getUsePreviousAnswers($active_id, true))
1058  {
1059  if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
1060  }
1061  $user_solution = $this->object->getBestSolution($active_id, $pass);
1062  }
1063 
1064  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
1065  $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, TRUE, $result_output);
1066 
1067  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1068  $questionoutput = $template->get();
1069  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
1070  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
1071 
1072  $solutionoutput = $solutiontemplate->get();
1073  if(!$show_question_only)
1074  {
1075  // get page object output
1076  $solutionoutput = $this->getILIASPage($solutionoutput);
1077  }
1078  return $solutionoutput;
1079  }
_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.
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

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

1148  {
1149  return '';
1150  }

◆ getTestOutput()

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

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

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

Referenced by outQuestionForTest().

1096  {
1097  ilUtil::sendInfo($this->lng->txt('enter_valid_values'));
1098  // get the solution of the user for the active pass or from the last pass if allowed
1099  $user_solution = null;
1100  if($active_id)
1101  {
1102  $solutions = NULL;
1103  include_once "./Modules/Test/classes/class.ilObjTest.php";
1104  if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
1105 
1106  $user_solution["active_id"] = $active_id;
1107  $user_solution["pass"] = $pass;
1108  $solutions =& $this->object->getSolutionValues($active_id, $pass);
1109 
1110  foreach($solutions as $idx => $solution_value)
1111  {
1112  if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
1113  {
1114  $user_solution[$matches[1]] = $solution_value["value2"];
1115  }
1116  else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
1117  {
1118 
1119  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1120  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1121  }
1122  else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
1123  {
1124  if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
1125  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1126  }
1127 
1128  if(preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && $user_solution[$matches[1]]["result_type"] == 0)
1129  {
1130  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
1131  }
1132  }
1133  }
1134 
1135  // generate the question output
1136  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1137 
1138  $questiontext = $this->object->substituteVariables($user_solution);
1139 
1140  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1141 
1142  $questionoutput = $template->get();
1143  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1144  return $pageoutput;
1145  }
_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:
+ Here is the caller graph for this function:

◆ hasResultUnit()

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

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

References $result.

Referenced by isSaveCommand().

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

◆ isSaveCommand()

◆ outQuestionForTest()

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

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

References $pass, and getTestOutput().

990  {
991 
992  $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions, $show_feedback);
993 
994  $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
995  $this->tpl->setVariable("FORMACTION", $formaction);
996  }
getTestOutput($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
+ Here is the call graph for this function:

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References assQuestionGUI\writePostData().

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

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

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

961  {
962  $result = $this->writePostData();
963 
964  if($result == 1)
965  {
966  $this->editQuestion();
967  }
968  else
969  {
970  $this->saveTaxonomyAssignments();
971  $this->save();
972  }
973  }
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 872 of file class.assFormulaQuestionGUI.php.

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

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

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

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

Suggest a range for a result public.

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

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

160  {
161  if($this->writePostData())
162  {
164  }
165  $this->editQuestion();
166  }
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 172 of file class.assFormulaQuestionGUI.php.

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

173  {
174  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
175  $checked = true;
176  if(!$hasErrors)
177  {
178  $this->object->setTitle($_POST["title"]);
179  $this->object->setAuthor($_POST["author"]);
180  $this->object->setComment($_POST["comment"]);
181  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
182  $questiontext = ilUtil::stripOnlySlashes($_POST["question"]);
183  $this->object->setQuestion($questiontext);
184  $this->object->setEstimatedWorkingTime(
185  $_POST["Estimated"]["hh"],
186  $_POST["Estimated"]["mm"],
187  $_POST["Estimated"]["ss"]
188  );
189 
190  $this->object->parseQuestionText();
191  $found_vars = array();
192  $found_results = array();
193 
194 
195  foreach($_POST as $key => $value)
196  {
197  if(preg_match("/^unit_(\\\$v\d+)$/", $key, $matches))
198  {
199  array_push($found_vars, $matches[1]);
200  }
201  if(preg_match("/^unit_(\\\$r\d+)$/", $key, $matches))
202  {
203  array_push($found_results, $matches[1]);
204  }
205  }
206 
207 // if(!$this->object->checkForDuplicateVariables())
208 // {
209 //
210 // $this->addErrorMessage($this->lng->txt("err_duplicate_variables"));
211 // $checked = FALSE;
212 // }
213  if(!$this->object->checkForDuplicateResults())
214  {
215  $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
216  $checked = FALSE;
217  }
218 
219  foreach($found_vars as $variable)
220  {
221  if($this->object->getVariable($variable) != null)
222  {
223  $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"]);
224  $varObj->setRangeMinTxt($_POST["range_min_$variable"]);
225  $varObj->setRangeMaxTxt($_POST["range_max_$variable"]);
226  $this->object->addVariable($varObj);
227  }
228  }
229 
230  $tmp_form_vars = array();
231  $tmp_quest_vars = array();
232  foreach($found_results as $result)
233  {
234  $tmp_res_match = preg_match_all("/([$][v][0-9]*)/", $_POST["formula_$result"], $form_vars);
235  $tmp_form_vars = array_merge($tmp_form_vars,$form_vars[0]);
236 
237  $tmp_que_match = preg_match_all("/([$][v][0-9]*)/", $_POST['question'] , $quest_vars);
238  $tmp_quest_vars= array_merge($tmp_quest_vars,$quest_vars[0]);
239  }
240  $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
241  $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
242 
243  if(count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0)
244  {
245  $error_message = '';
246  if(count($result_has_undefined_vars) > 0)
247  {
248  $error_message .= $this->lng->txt("res_contains_undef_var"). '<br>';
249  }
250  if(count($question_has_unused_vars) > 0)
251  {
252  $error_message .= $this->lng->txt("que_contains_unused_var");
253  }
254  $checked = false;
255  if($this->isSaveCommand())
256  {
257  ilUtil::sendFailure($error_message);
258  }
259  }
260  foreach($found_results as $result)
261  {
262  if(is_object($this->object->getUnitrepository()->getUnit($_POST["unit_$result"])))
263  {
264  $tmp_result_unit = $this->object->getUnitrepository()->getUnit($_POST["unit_$result"]);
265  }
266  else
267  {
268  $tmp_result_unit = NULL;
269  }
270 
271  if($this->object->getResult($result) != null)
272  {
273  $use_simple_rating = ($_POST["rating_advanced_$result"] == 1) ? FALSE : TRUE;
274  $resObj = new assFormulaQuestionResult(
275  $result,
276  $_POST["range_min_$result"],
277  $_POST["range_max_$result"],
278  $_POST["tolerance_$result"],
279 
280  $tmp_result_unit,
281  $_POST["formula_$result"],
282  $_POST["points_$result"],
283  $_POST["precision_$result"],
284  $use_simple_rating,
285  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_sign_$result"] : "",
286  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_value_$result"] : "",
287  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_unit_$result"] : "",
288  $_POST["result_type_$result"] != 0 ? $_POST["result_type_$result"] : 0
289  );
290  $resObj->setRangeMinTxt($_POST["range_min_$result"]);
291  $resObj->setRangeMaxTxt($_POST["range_max_$result"]);
292  $this->object->addResult($resObj);
293  $this->object->addResultUnits($resObj, $_POST["units_$result"]);
294  }
295  }
296  if($checked == false)
297  {
298  return 1;
299  }
300  else
301  {
302  return 0;
303  }
304  }
305  else
306  {
307  return 1;
308  }
309  }
$_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: