ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assFormulaQuestionGUI Class Reference

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

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

Public Member Functions

 __construct ($id=-1)
 assFormulaQuestionGUI constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestionGUI object. More...
 
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type Sets the ILIAS tabs for this question type public. More...
 
 getCommand ($cmd)
 
 suggestRange ()
 Suggest a range for a result public. More...
 
 resetSavedPreviewSession ()
 
 isSaveCommand ()
 
 parseQuestion ()
 
 saveReturnFQ ()
 
 saveFQ ()
 
 checkInput ()
 check input fields More...
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 Get the question solution output. More...
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 getTestOutput ($active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
 
 getSpecificFeedbackOutput ($active_id, $pass)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 
 getType ()
 needed for page editor compliance More...
 
 getPresentationContext ()
 
 setPresentationContext ($presentationContext)
 
 isTestPresentationContext ()
 
 isPreviousSolutionPrefilled ()
 
 setPreviousSolutionPrefilled ($previousSolutionPrefilled)
 
 getRenderPurpose ()
 
 setRenderPurpose ($renderPurpose)
 
 isRenderPurposePrintPdf ()
 
 isRenderPurposePreview ()
 
 isRenderPurposeInputValue ()
 
 isRenderPurposePlayback ()
 
 isRenderPurposeDemoplay ()
 
 renderPurposeSupportsFormHtml ()
 
 getEditContext ()
 
 setEditContext ($editContext)
 
 isAuthoringEditContext ()
 
 isAdjustmentEditContext ()
 
 setAdjustmentEditContext ()
 
 getNavigationGUI ()
 
 setNavigationGUI ($navigationGUI)
 
 setTaxonomyIds ($taxonomyIds)
 
 getTaxonomyIds ()
 
 setTargetGui ($linkTargetGui)
 
 setTargetGuiClass ($targetGuiClass)
 
 getTargetGuiClass ()
 
 setQuestionHeaderBlockBuilder ($questionHeaderBlockBuilder)
 
 getQuestionHeaderBlockBuilder ()
 
 setQuestionActionCmd ($questionActionCmd)
 
 getQuestionActionCmd ()
 
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation. More...
 
 populateJavascriptFilesRequiredForWorkForm (ilTemplate $tpl)
 
 getQuestionTemplate ()
 get question template More...
 
 getILIASPage ($html="")
 Returns the ILIAS Page around a question. More...
 
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page More...
 
 cancel ()
 cancel action More...
 
 originalSyncForm ($return_to="", $return_to_feedback='')
 
 sync ()
 
 cancelSync ()
 
 saveEdit ()
 save question More...
 
 save ()
 save question More...
 
 saveReturn ()
 save question More...
 
 apply ()
 apply changes More...
 
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree More...
 
 setSequenceNumber ($nr)
 
 getSequenceNumber ()
 
 setQuestionCount ($a_question_count)
 
 getQuestionCount ()
 
 getErrorMessage ()
 
 setErrorMessage ($errormessage)
 
 addErrorMessage ($errormessage)
 
 outAdditionalOutput ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute. More...
 
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved. More...
 
 callNewIdListeners ($a_new_id)
 Call the new id listeners. More...
 
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form. More...
 
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time. More...
 
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question. More...
 
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 getGenericFeedbackOutputForCorrectSolution ()
 
 getGenericFeedbackOutputForIncorrectSolution ()
 
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question. More...
 
 outQuestionType ()
 
 showSuggestedSolution ()
 
 suggestedsolution ()
 Allows to add suggested solutions for questions. More...
 
 outSolutionExplorer ()
 
 saveSuggestedSolution ()
 
 cancelExplorer ()
 
 outPageSelector ()
 
 outChapterSelector ()
 
 outGlossarySelector ()
 
 linkChilds ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 isSaveCommand ()
 
 setQuestionTabs ()
 
 addTab_SuggestedSolution (ilTabsGUI $tabs, $classname)
 
 getEditQuestionTabCommands ()
 
 getSolutionOutput ( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
 
 isAutosaveable ()
 
 getPreview ($show_question_only=false, $showInlineFeedback=false)
 
 outQuestionForTest ( $formaction, $active_id, $pass, $is_question_postponed=false, $user_post_solutions=false, $show_specific_inline_feedback=false)
 
 magicAfterTestOutput ()
 
 getTestOutput ( $active_id, $pass, $is_question_postponed, $user_post_solutions, $show_specific_inline_feedback)
 
 getFormEncodingType ()
 
 setPreviewSession ($previewSession)
 
 getPreviewSession ()
 
 showHints ()
 

Protected Member Functions

 writePostData ($always=false)
 {} More...
 
- Protected Member Functions inherited from assQuestionGUI
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 renderEditForm ($form)
 
 getUseUnchangedAnswerCheckboxHtml ()
 
 getPreviousSolutionProvidedMessage ()
 
 getPreviousSolutionConfirmationCheckboxHtml ()
 
 saveTaxonomyAssignments ()
 
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 
 getBasicEditQuestionTabCommands ()
 
 getAdditionalEditQuestionCommands ()
 
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI More...
 
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI More...
 
 addTab_QuestionPreview (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 buildEditForm ()
 

Private Member Functions

 hasResultUnit ($result, $unit_id, $resultunits)
 
 canUseAdvancedRating ($result)
 Check if advanced rating can be used for a result. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestionGUI
static _getQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls. More...
 
static _getGUIClassNameForId ($a_q_id)
 
static _getClassNameForQType ($q_type)
 
static getCommandsFromClassConstants ($guiClassName, $cmdConstantNameBegin='CMD_')
 extracts values of all constants of given class with given prefix as array can be used to get all possible commands in case of these commands are defined as constants More...
 
- Data Fields inherited from assQuestionGUI
const FORM_MODE_EDIT = 'edit'
 
const FORM_MODE_ADJUST = 'adjust'
 
const FORM_ENCODING_URLENCODE = 'application/x-www-form-urlencoded'
 
const FORM_ENCODING_MULTIPART = 'multipart/form-data'
 
const SESSION_PREVIEW_DATA_BASE_INDEX = 'ilAssQuestionPreviewAnswers'
 
 $object
 
 $tpl
 
 $lng
 
 $error
 
 $errormessage
 
 $sequence_no
 sequence number in test More...
 
 $question_count
 question count in test More...
 
const PRESENTATION_CONTEXT_TEST = 'pContextTest'
 
const PRESENTATION_CONTEXT_RESULTS = 'pContextResults'
 
const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'
 
const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'
 
const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'
 
const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'
 
const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'
 
const EDIT_CONTEXT_AUTHORING = 'authoring'
 
const EDIT_CONTEXT_ADJUSTMENT = 'adjustment'
 
- Protected Attributes inherited from assQuestionGUI
 $editForm
 

Detailed Description

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

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
Id
class.assFormulaQuestionGUI.php 1235 2010-02-15 15:21:18Z hschottm

assFormulaQuestionGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

assFormulaQuestionGUI::__construct (   $id = -1)

assFormulaQuestionGUI constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestionGUI object.

Parameters
integer$idThe database id of a multiple choice question object public

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

References $id.

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

Member Function Documentation

◆ canUseAdvancedRating()

assFormulaQuestionGUI::canUseAdvancedRating (   $result)
private

Check if advanced rating can be used for a result.

This is only possible if there is exactly one possible correct unit for the result, otherwise it is impossible to determine wheather the unit is correct or the value.

Returns
boolean True if advanced rating could be used, false otherwise

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

References $result.

Referenced by isSaveCommand().

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

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

876  {
877  if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"])) {
878  $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
879  return false;
880  }
881 
882 
883  return true;
884  }
addErrorMessage($errormessage)
$_POST["username"]
+ Here is the call graph for this function:

◆ getCommand()

assFormulaQuestionGUI::getCommand (   $cmd)

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

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

◆ getPreview()

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

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

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

983  {
984  $user_solution = array();
985 
986  if (is_object($this->getPreviewSession())) {
987  $solutions = (array) $this->getPreviewSession()->getParticipantsSolution();
988 
989  foreach ($solutions as $val1 => $val2) {
990  if (preg_match("/^(\\\$v\\d+)$/", $val1, $matches)) {
991  $user_solution[$matches[1]] = $val2;
992  } elseif (preg_match("/^(\\\$r\\d+)$/", $val1, $matches)) {
993  if (!array_key_exists($matches[1], $user_solution)) {
994  $user_solution[$matches[1]] = array();
995  }
996  $user_solution[$matches[1]]["value"] = $val2;
997  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches)) {
998  if (!array_key_exists($matches[1], $user_solution)) {
999  $user_solution[$matches[1]] = array();
1000  }
1001  $user_solution[$matches[1]]["unit"] = $val2;
1002  }
1003 
1004  if (preg_match("/^(\\\$r\\d+)/", $val1, $matches) && $user_solution[$matches[1]]["result_type"] == 0) {
1005  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
1006  }
1007  }
1008  }
1009 
1010  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
1011  $user_solution = $this->object->getInitialVariableSolutionValues();
1012 
1013  if (is_object($this->getPreviewSession())) {
1014  $this->getPreviewSession()->setParticipantsSolution($user_solution);
1015  }
1016  }
1017 
1018  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1019  if (is_object($this->getPreviewSession())) {
1020  $questiontext = $this->object->substituteVariables($user_solution, false, false, false);
1021  } else {
1022  $questiontext = $this->object->substituteVariables(array());
1023  }
1024  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
1025  $questionoutput = $template->get();
1026  if (!$show_question_only) {
1027  // get page object output
1028  $questionoutput = $this->getILIASPage($questionoutput);
1029  }
1030  return $questionoutput;
1031  }
$template
static getResultTypeByQstId($a_qst_id, $a_result)
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:

◆ getSolutionOutput()

assFormulaQuestionGUI::getSolutionOutput (   $active_id,
  $pass = null,
  $graphicalOutput = false,
  $result_output = false,
  $show_question_only = true,
  $show_feedback = false,
  $show_correct_solution = false,
  $show_manual_scoring = false,
  $show_question_text = true 
)

Get the question solution output.

Parameters
integer$active_idThe active user id
integer$passThe test pass
boolean$graphicalOutputShow visual feedback for right/wrong answers
boolean$result_outputShow the reached points for parts of the question
boolean$show_question_onlyShow the question without the ILIAS content around
boolean$show_feedbackShow the question feedback
boolean$show_correct_solutionShow the correct solution instead of the user solution
boolean$show_manual_scoringShow specific information for the manual scoring output
Returns
The solution output of the question as HTML code

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

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

908  {
909  // get the solution of the user for the active pass or from the last pass if allowed
910  $user_solution = array();
911  if (($active_id > 0) && (!$show_correct_solution)) {
912  $solutions = array();
913  include_once "./Modules/Test/classes/class.ilObjTest.php";
914  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
915  if (is_null($pass)) {
916  $pass = ilObjTest::_getPass($active_id);
917  }
918  }
919  $user_solution["active_id"] = $active_id;
920  $user_solution["pass"] = $pass;
921  $solutions =&$this->object->getSolutionValues($active_id, $pass);
922  foreach ($solutions as $idx => $solution_value) {
923  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
924  $user_solution[$matches[1]] = $solution_value["value2"];
925  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
926  if (!array_key_exists($matches[1], $user_solution)) {
927  $user_solution[$matches[1]] = array();
928  }
929  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
930  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
931  if (!array_key_exists($matches[1], $user_solution)) {
932  $user_solution[$matches[1]] = array();
933  }
934  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
935  }
936  }
937  } elseif ($active_id) {
938  $solutions = null;
939  include_once "./Modules/Test/classes/class.ilObjTest.php";
940  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
941  if (is_null($pass)) {
942  $pass = ilObjTest::_getPass($active_id);
943  }
944  }
945  $user_solution = (array) $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
946  } elseif (is_object($this->getPreviewSession())) {
947  $solutionValues = array();
948 
949  foreach ($this->getPreviewSession()->getParticipantsSolution() as $val1 => $val2) {
950  $solutionValues[] = array('value1' => $val1, 'value2' => $val2);
951  }
952 
953  $user_solution = (array) $this->object->getBestSolution($solutionValues);
954  }
955 
956  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
957  $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, true, $result_output);
958 
959  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
960  $questionoutput = $template->get();
961  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
962  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
963  if (strlen($feedback)) {
964  $cssClass = (
965  $this->hasCorrectSolution($active_id, $pass) ?
967  );
968 
969  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
970  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
971  }
972  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
973 
974  $solutionoutput = $solutiontemplate->get();
975  if (!$show_question_only) {
976  // get page object output
977  $solutionoutput = $this->getILIASPage($solutionoutput);
978  }
979  return $solutionoutput;
980  }
hasCorrectSolution($activeId, $passIndex)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
$template
getILIASPage($html="")
Returns the ILIAS Page around a question.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
static _getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
+ Here is the call graph for this function:

◆ getSpecificFeedbackOutput()

assFormulaQuestionGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

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

1102  {
1103  return '';
1104  }

◆ getTestOutput()

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

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

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

1036  {
1037  ilUtil::sendInfo($this->lng->txt('enter_valid_values'));
1038  // get the solution of the user for the active pass or from the last pass if allowed
1039  $user_solution = array();
1040  if ($active_id) {
1041  $solutions = (array) $this->object->getTestOutputSolutions($active_id, $pass);
1042 
1043  $actualPassIndex = null;
1044  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1045  require_once 'Modules/Test/classes/class.ilObjTest.php';
1046  $actualPassIndex = ilObjTest::_getPass($active_id);
1047  }
1048 
1049  foreach ($solutions as $idx => $solution_value) {
1050  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1051  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1052  $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value["value2"], true);
1053  }
1054 
1055  $user_solution[$matches[1]] = $solution_value["value2"];
1056  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
1057  if (!array_key_exists($matches[1], $user_solution)) {
1058  $user_solution[$matches[1]] = array();
1059  }
1060  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1061  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
1062  if (!array_key_exists($matches[1], $user_solution)) {
1063  $user_solution[$matches[1]] = array();
1064  }
1065  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1066  }
1067 
1068  if (preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && $user_solution[$matches[1]]["result_type"] == 0) {
1069  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
1070  }
1071  }
1072  }
1073 
1074  // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
1075  $solutions = $this->object->getSolutionValues($active_id, $pass, true);
1076  foreach ($solutions as $idx => $solution_value) {
1077  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1078  $user_solution[$matches[1]] = $solution_value["value2"];
1079  }
1080  }
1081  // fau.
1082 
1083  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
1084  foreach ($this->object->getInitialVariableSolutionValues() as $val1 => $val2) {
1085  $this->object->saveCurrentSolution($active_id, $pass, $val1, $val2, true);
1086  }
1087  }
1088 
1089  // generate the question output
1090  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1091 
1092  $questiontext = $this->object->substituteVariables($user_solution);
1093 
1094  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
1095 
1096  $questionoutput = $template->get();
1097  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1098  return $pageoutput;
1099  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
$template
static getResultTypeByQstId($a_qst_id, $a_result)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
+ Here is the call graph for this function:

◆ hasResultUnit()

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

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

References $result.

Referenced by isSaveCommand().

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

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References writePostData().

785  {
786  $this->writePostData();
787  $this->editQuestion();
788  }
+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

References $ilUser, and array.

Referenced by writePostData().

278  {
279  global $ilUser;
280  $user_id = $ilUser->getId();
281  $question_id = $this->object->getId();
282  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
283  $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
284  $ilAssQuestionPreviewSession->setParticipantsSolution(array());
285  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

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

862  {
863  $result = $this->writePostData();
864 
865  if ($result == 1) {
866  $this->editQuestion();
867  } else {
868  $this->saveTaxonomyAssignments();
869  $this->save();
870  }
871  }
$result
save()
save question
+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

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

791  {
792  global $ilUser;
793  $old_id = $_GET["q_id"];
794  $result = $this->writePostData();
795  if ($result == 0) {
796  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
797  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
798  $this->saveTaxonomyAssignments();
799  $this->object->saveToDb();
800  $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
801  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
802  if (($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
803  $this->ctrl->redirect($this, "originalSyncForm");
804  return;
805  } elseif ($_GET["calling_test"]) {
806  require_once 'Modules/Test/classes/class.ilObjTest.php';
807  $test = new ilObjTest($_GET["calling_test"]);
808  #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
809  $q_id = $this->object->getId();
810  if (!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId())) {
811  global $tree, $ilDB, $ilPluginAdmin;
812 
813  include_once("./Modules/Test/classes/class.ilObjTest.php");
814  $_GET["ref_id"] = $_GET["calling_test"];
815  $test = new ilObjTest($_GET["calling_test"], true);
816 
817  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
818  $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
819 
820  $new_id = $test->insertQuestion(
821  $testQuestionSetConfigFactory->getQuestionSetConfig(),
822  $this->object->getId()
823  );
824 
825  $q_id = $new_id;
826  if (isset($_REQUEST['prev_qid'])) {
827  $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
828  }
829 
830  $this->ctrl->setParameter($this, 'q_id', $new_id);
831  $this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
832  #$this->ctrl->setParameter($this, 'test_ref_id', false);
833  }
834  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
835  if ($_REQUEST['test_express_mode']) {
837  } else {
838  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET["calling_test"]);
839  }
840  } else {
841  if ($this->object->getId() != $old_id) {
842  $this->callNewIdListeners($this->object->getId());
843  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
844  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
845  }
846  if (strcmp($_SESSION["info"], "") != 0) {
847  ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
848  } else {
849  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
850  }
851  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
852  }
853  } else {
854  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
855  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
856  $this->object->saveToDb();
857  $this->editQuestion();
858  }
859  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_SESSION["AccountId"]
$result
$_GET["client_id"]
callNewIdListeners($a_new_id)
Call the new id listeners.
static getReturnToPageLink($q_id=null)
$ilUser
Definition: imgupload.php:18
static _questionExistsInTest($question_id, $test_id)
Create new PHPExcel object
obj_idprivate
global $ilDB
static redirect($a_script)
$test
Definition: Utf8Test.php:84
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
+ Here is the call graph for this function:

◆ setQuestionTabs()

assFormulaQuestionGUI::setQuestionTabs ( )

Sets the ILIAS tabs for this question type Sets the ILIAS tabs for this question type public.

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

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

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  $classname = $q_type . "GUI";
57  $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
58  $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
59  }
60 
61  if ($_GET["q_id"]) {
62  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
63  // edit page
64  $ilTabs->addTarget(
65  "edit_page",
66  $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
67  array("edit", "insert", "exec_pg"),
68  "",
69  "",
70  $force_active
71  );
72  }
73 
74  $this->addTab_QuestionPreview($ilTabs);
75  }
76 
77  $force_active = false;
78  if ($rbacsystem->checkAccess('write', $_GET["ref_id"])) {
79  $url = "";
80 
81  if ($classname) {
82  $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
83  }
84  $commands = $_POST["cmd"];
85  if (is_array($commands)) {
86  foreach ($commands as $key => $value) {
87  if (preg_match("/^suggestrange_.*/", $key, $matches)) {
88  $force_active = true;
89  }
90  }
91  }
92  // edit question properties
93  $ilTabs->addTarget(
94  "edit_properties",
95  $url,
96  array(
97  "editQuestion", "save", "cancel", "addSuggestedSolution",
98  "cancelExplorer", "linkChilds", "removeSuggestedSolution",
99  "parseQuestion", "saveEdit", "suggestRange"
100  ),
101  $classname,
102  "",
103  $force_active
104  );
105  }
106 
107  if ($_GET["q_id"]) {
108  // add tab for question feedback within common class assQuestionGUI
109  $this->addTab_QuestionFeedback($ilTabs);
110  }
111 
112  if ($_GET["q_id"]) {
113  // add tab for question hint within common class assQuestionGUI
114  $this->addTab_QuestionHints($ilTabs);
115  }
116 
117  // Unit editor
118  if ($_GET['q_id']) {
119  // 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  $ilTabs->addTarget(
126  "statistics",
127  $this->ctrl->getLinkTargetByClass($classname, "assessment"),
128  array("assessment"),
129  $classname,
130  ""
131  );
132  }
133 
134  $this->addBackTab($ilTabs);
135  }
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
$_GET["client_id"]
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
Create styles array
The data for the language used.
addBackTab(ilTabsGUI $ilTabs)
$url
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( )

Suggest a range for a result public.

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

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

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

◆ writePostData()

assFormulaQuestionGUI::writePostData (   $always = false)
protected

{}

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

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

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

161  {
162  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
163  $checked = true;
164  if (!$hasErrors) {
165  $this->object->setTitle($_POST["title"]);
166  $this->object->setAuthor($_POST["author"]);
167  $this->object->setComment($_POST["comment"]);
168  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
169  $questiontext = ilUtil::stripOnlySlashes($_POST["question"]);
170  $this->object->setQuestion($questiontext);
171  $this->object->setEstimatedWorkingTime(
172  $_POST["Estimated"]["hh"],
173  $_POST["Estimated"]["mm"],
174  $_POST["Estimated"]["ss"]
175  );
176 
177  $this->object->parseQuestionText();
178  $found_vars = array();
179  $found_results = array();
180 
181 
182  foreach ($_POST as $key => $value) {
183  if (preg_match("/^unit_(\\\$v\d+)$/", $key, $matches)) {
184  array_push($found_vars, $matches[1]);
185  }
186  if (preg_match("/^unit_(\\\$r\d+)$/", $key, $matches)) {
187  array_push($found_results, $matches[1]);
188  }
189  }
190 
191  // if(!$this->object->checkForDuplicateVariables())
192  // {
193 //
194  // $this->addErrorMessage($this->lng->txt("err_duplicate_variables"));
195  // $checked = FALSE;
196  // }
197  if (!$this->object->checkForDuplicateResults()) {
198  $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
199  $checked = false;
200  }
201 
202  foreach ($found_vars as $variable) {
203  if ($this->object->getVariable($variable) != null) {
204  $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"]);
205  $varObj->setRangeMinTxt($_POST["range_min_$variable"]);
206  $varObj->setRangeMaxTxt($_POST["range_max_$variable"]);
207  $this->object->addVariable($varObj);
208  }
209  }
210 
211  $tmp_form_vars = array();
212  $tmp_quest_vars = array();
213  foreach ($found_results as $result) {
214  $tmp_res_match = preg_match_all("/([$][v][0-9]*)/", $_POST["formula_$result"], $form_vars);
215  $tmp_form_vars = array_merge($tmp_form_vars, $form_vars[0]);
216 
217  $tmp_que_match = preg_match_all("/([$][v][0-9]*)/", $_POST['question'], $quest_vars);
218  $tmp_quest_vars= array_merge($tmp_quest_vars, $quest_vars[0]);
219  }
220  $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
221  $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
222 
223  if (count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0) {
224  $error_message = '';
225  if (count($result_has_undefined_vars) > 0) {
226  $error_message .= $this->lng->txt("res_contains_undef_var") . '<br>';
227  }
228  if (count($question_has_unused_vars) > 0) {
229  $error_message .= $this->lng->txt("que_contains_unused_var");
230  }
231  $checked = false;
232  if ($this->isSaveCommand()) {
233  ilUtil::sendFailure($error_message);
234  }
235  }
236  foreach ($found_results as $result) {
237  if (is_object($this->object->getUnitrepository()->getUnit($_POST["unit_$result"]))) {
238  $tmp_result_unit = $this->object->getUnitrepository()->getUnit($_POST["unit_$result"]);
239  } else {
240  $tmp_result_unit = null;
241  }
242 
243  if ($this->object->getResult($result) != null) {
244  $use_simple_rating = ($_POST["rating_advanced_$result"] == 1) ? false : true;
245  $resObj = new assFormulaQuestionResult(
246  $result,
247  $_POST["range_min_$result"],
248  $_POST["range_max_$result"],
249  $_POST["tolerance_$result"],
250  $tmp_result_unit,
251  $_POST["formula_$result"],
252  $_POST["points_$result"],
253  $_POST["precision_$result"],
254  $use_simple_rating,
255  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_sign_$result"] : "",
256  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_value_$result"] : "",
257  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_unit_$result"] : "",
258  $_POST["result_type_$result"] != 0 ? $_POST["result_type_$result"] : 0
259  );
260  $resObj->setRangeMinTxt($_POST["range_min_$result"]);
261  $resObj->setRangeMaxTxt($_POST["range_max_$result"]);
262  $this->object->addResult($resObj);
263  $this->object->addResultUnits($resObj, $_POST["units_$result"]);
264  }
265  }
266  if ($checked == false) {
267  return 1;
268  } else {
269  $this->resetSavedPreviewSession();
270  return 0;
271  }
272  } else {
273  return 1;
274  }
275  }
$result
addErrorMessage($errormessage)
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Create new PHPExcel object
obj_idprivate
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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