ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
assFormulaQuestionGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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...
 
 suggestRange (string $suggest_range_for_result)
 Suggest a range for a result public. More...
 
 resetSavedPreviewSession ()
 
 isSaveCommand ()
 
 parseQuestion ()
 
 saveReturnFQ ()
 
 saveFQ ()
 
 checkInput ()
 check input fields More...
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() 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 ($userSolution)
 
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor More...
 
 hasInlineFeedback ()
 this method can be overwritten per question type More...
 
 addHeaderAction ()
 
 redrawHeaderAction ()
 
 getHeaderAction ()
 
 getNotesHTML ()
 
 executeCommand ()
 execute command More...
 
 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 (ilGlobalTemplateInterface $tpl)
 
 getPresentationJavascripts ()
 
 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="", $inlineFeedbackEnabled=false)
 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 ($userSolution)
 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)
 
 supportsIntermediateSolutionOutput ()
 Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution() More...
 
 hasIntermediateSolution ($activeId, $passIndex)
 Check if the question has an intermediate solution. More...
 
 setUseIntermediateSolution ($use)
 
 getUseIntermediateSolution ()
 Get if intermediate solution should be used for solution output. More...
 
 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 ()
 
 buildFocusAnchorHtml ()
 
 isAnswerFreuqencyStatisticSupported ()
 
 getSubQuestionsIndex ()
 
 getAnswersFrequency ($relevantAnswers, $questionIndex)
 
 getAnswerFrequencyTableGUI ($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
 
 prepareReprintableCorrectionsForm (ilPropertyFormGUI $form)
 
 populateCorrectionsFormProperties (ilPropertyFormGUI $form)
 
 saveCorrectionsFormProperties (ilPropertyFormGUI $form)
 

Protected Member Functions

 callSpecialQuestionCommands (string $cmd)
 
 writePostData ($always=false)
 {} More...
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
- Protected Member Functions inherited from assQuestionGUI
 hasSpecialQuestionCommands ()
 
 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)
 
 setDefaultTabs (ilTabsGUI $ilTabs)
 
 setQuestionSpecificTabs (ilTabsGUI $ilTabs)
 
 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_Question (ilTabsGUI $tabsGUI)
 
 hasCorrectSolution ($activeId, $passIndex)
 
 writeQuestionGenericPostData ()
 
 completeTestOutputFormAction ($formAction, $active_id, $pass)
 
 addBackTab (ilTabsGUI $ilTabs)
 
 buildBasicEditFormObject ()
 
 escapeTemplatePlaceholders (string $text)
 
 buildEditForm ()
 
 addSaveOnEnterOnLoadCode ()
 

Protected Attributes

const HAS_SPECIAL_QUESTION_COMMANDS = true
 
- Protected Attributes inherited from assQuestionGUI
const HAS_SPECIAL_QUESTION_COMMANDS = false
 
 $ctrl
 
 $editForm
 
 $use_intermediate_solution = false
 

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
 
 $request
 
 $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'
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning assFormulaQuestionGUI: ilFormPropertyDispatchGUI

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

References ILIAS\GlobalScreen\Provider\__construct().

32  {
34  $this->object = new assFormulaQuestion();
35  $this->newUnitId = null;
36  if ($id >= 0) {
37  $this->object->loadFromDb($id);
38  }
39  }
Class for single choice questions assFormulaQuestion is a class for single choice questions...
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ callSpecialQuestionCommands()

assFormulaQuestionGUI::callSpecialQuestionCommands ( string  $cmd)
protected

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

References assQuestionGUI\addSaveOnEnterOnLoadCode(), and suggestRange().

41  : void
42  {
43  if (preg_match('/suggestrange_(\$r\d+)/', $cmd, $matches)) {
44  $this->addSaveOnEnterOnLoadCode();
45  $this->suggestRange($matches[1]);
46  }
47  }
suggestRange(string $suggest_range_for_result)
Suggest a range for a result public.
+ Here is the call graph for this function:

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

References $result.

Referenced by isSaveCommand().

704  {
705  $resultunit = $result->getUnit();
706 
707  /*
708  * if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
709  * if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
710  * definition if the result-value or the unit-value should be the correct solution!!
711  *
712  */
713  if (is_object($resultunit)) {
714  return true;
715  } else {
716  return false;
717  }
718  }
$result
+ Here is the caller graph for this function:

◆ checkInput()

assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

825  {
826  if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"])) {
827  $this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
828  return false;
829  }
830 
831 
832  return true;
833  }
addErrorMessage($errormessage)
$_POST["username"]
+ Here is the call graph for this function:

◆ getPreview()

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

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

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

946  {
947  $user_solution = array();
948 
949  if (is_object($this->getPreviewSession())) {
950  $solutions = (array) $this->getPreviewSession()->getParticipantsSolution();
951 
952  foreach ($solutions as $val1 => $val2) {
953  if (preg_match("/^(\\\$v\\d+)$/", $val1, $matches)) {
954  $user_solution[$matches[1]] = $val2;
955  } elseif (preg_match("/^(\\\$r\\d+)$/", $val1, $matches)) {
956  if (!array_key_exists($matches[1], $user_solution)) {
957  $user_solution[$matches[1]] = array();
958  }
959  $user_solution[$matches[1]]["value"] = $val2;
960  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches)) {
961  if (!array_key_exists($matches[1], $user_solution)) {
962  $user_solution[$matches[1]] = array();
963  }
964  $user_solution[$matches[1]]["unit"] = $val2;
965  }
966 
967  if (preg_match("/^(\\\$r\\d+)/", $val1, $matches) && $user_solution[$matches[1]]["result_type"] == 0) {
968  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $val1);
969  }
970  }
971  }
972 
973  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
974  $user_solution = $this->object->getInitialVariableSolutionValues();
975 
976  if (is_object($this->getPreviewSession())) {
977  $this->getPreviewSession()->setParticipantsSolution($user_solution);
978  }
979  }
980 
981  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
982  if (is_object($this->getPreviewSession())) {
983  $questiontext = $this->object->substituteVariables($user_solution, false, false, false);
984  } else {
985  $questiontext = $this->object->substituteVariables(array());
986  }
987  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
988  $questionoutput = $template->get();
989  if (!$show_question_only) {
990  // get page object output
991  $questionoutput = $this->getILIASPage($questionoutput);
992  }
993  return $questionoutput;
994  }
static getResultTypeByQstId($a_qst_id, $a_result)
getILIASPage($html="")
Returns the ILIAS Page around a question.
+ 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
string The solution output of the question as HTML code

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

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

868  {
869  // get the solution of the user for the active pass or from the last pass if allowed
870  $user_solution = array();
871  if (($active_id > 0) && (!$show_correct_solution)) {
872  $solutions = array();
873  include_once "./Modules/Test/classes/class.ilObjTest.php";
874  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
875  if (is_null($pass)) {
876  $pass = ilObjTest::_getPass($active_id);
877  }
878  }
879  $user_solution["active_id"] = $active_id;
880  $user_solution["pass"] = $pass;
881  $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
882  foreach ($solutions as $idx => $solution_value) {
883  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
884  $user_solution[$matches[1]] = $solution_value["value2"];
885  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
886  if (!array_key_exists($matches[1], $user_solution)) {
887  $user_solution[$matches[1]] = array();
888  }
889  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
890  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
891  if (!array_key_exists($matches[1], $user_solution)) {
892  $user_solution[$matches[1]] = array();
893  }
894  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
895  }
896  }
897  } elseif ($active_id) {
898  $solutions = null;
899  include_once "./Modules/Test/classes/class.ilObjTest.php";
900  if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
901  if (is_null($pass)) {
902  $pass = ilObjTest::_getPass($active_id);
903  }
904  }
905  $user_solution = (array) $this->object->getBestSolution($this->object->getSolutionValues($active_id, $pass));
906  } elseif (is_object($this->getPreviewSession())) {
907  $solutionValues = array();
908 
909  $participantsSolution = $this->getPreviewSession()->getParticipantsSolution();
910  if (is_array($participantsSolution)) {
911  foreach ($participantsSolution as $val1 => $val2) {
912  $solutionValues[] = array('value1' => $val1, 'value2' => $val2);
913  }
914  }
915 
916  $user_solution = (array) $this->object->getBestSolution($solutionValues);
917  }
918 
919  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
920  $questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, true, $result_output);
921 
922  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
923  $questionoutput = $template->get();
924  $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
925  $feedback = ($show_feedback) ? $this->getGenericFeedbackOutput($active_id, $pass) : "";
926  if (strlen($feedback)) {
927  $cssClass = (
928  $this->hasCorrectSolution($active_id, $pass) ?
930  );
931 
932  $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
933  $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
934  }
935  $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
936 
937  $solutionoutput = $solutiontemplate->get();
938  if (!$show_question_only) {
939  // get page object output
940  $solutionoutput = $this->getILIASPage($solutionoutput);
941  }
942  return $solutionoutput;
943  }
hasCorrectSolution($activeId, $passIndex)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
getILIASPage($html="")
Returns the ILIAS Page around a question.
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 (   $userSolution)

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

1065  {
1066  return '';
1067  }

◆ getTestOutput()

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

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

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

999  {
1000  ilUtil::sendInfo($this->lng->txt('enter_valid_values'));
1001  // get the solution of the user for the active pass or from the last pass if allowed
1002  $user_solution = array();
1003  if ($active_id) {
1004  $solutions = (array) $this->object->getTestOutputSolutions($active_id, $pass);
1005 
1006  $actualPassIndex = null;
1007  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1008  require_once 'Modules/Test/classes/class.ilObjTest.php';
1009  $actualPassIndex = ilObjTest::_getPass($active_id);
1010  }
1011 
1012  foreach ($solutions as $idx => $solution_value) {
1013  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1014  if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) {
1015  $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value["value2"], true);
1016  }
1017 
1018  $user_solution[$matches[1]] = $solution_value["value2"];
1019  } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) {
1020  if (!array_key_exists($matches[1], $user_solution)) {
1021  $user_solution[$matches[1]] = array();
1022  }
1023  $user_solution[$matches[1]]["value"] = $solution_value["value2"];
1024  } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) {
1025  if (!array_key_exists($matches[1], $user_solution)) {
1026  $user_solution[$matches[1]] = array();
1027  }
1028  $user_solution[$matches[1]]["unit"] = $solution_value["value2"];
1029  }
1030 
1031  if (preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && $user_solution[$matches[1]]["result_type"] == 0) {
1032  $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
1033  }
1034  }
1035  }
1036 
1037  // fau: testNav - take question variables always from authorized solution because they are saved with this flag, even if an authorized solution is not saved
1038  $solutions = $this->object->getSolutionValues($active_id, $pass, true);
1039  foreach ($solutions as $idx => $solution_value) {
1040  if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
1041  $user_solution[$matches[1]] = $solution_value["value2"];
1042  }
1043  }
1044  // fau.
1045 
1046  if (!$this->object->hasRequiredVariableSolutionValues($user_solution)) {
1047  foreach ($this->object->getInitialVariableSolutionValues() as $val1 => $val2) {
1048  $this->object->saveCurrentSolution($active_id, $pass, $val1, $val2, true);
1049  }
1050  }
1051 
1052  // generate the question output
1053  $template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
1054 
1055  $questiontext = $this->object->substituteVariables($user_solution);
1056 
1057  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
1058 
1059  $questionoutput = $template->get();
1060  $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
1061  return $pageoutput;
1062  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getResultTypeByQstId($a_qst_id, $a_result)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
+ Here is the call graph for this function:

◆ hasResultUnit()

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

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

References $result.

Referenced by isSaveCommand().

687  {
688  if (array_key_exists($result->getResult(), $resultunits)) {
689  if (array_key_exists($unit_id, $resultunits[$result->getResult()])) {
690  return true;
691  }
692  }
693  return false;
694  }
$result
+ Here is the caller graph for this function:

◆ isSaveCommand()

◆ parseQuestion()

assFormulaQuestionGUI::parseQuestion ( )

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

References assQuestionGUI\addSaveOnEnterOnLoadCode(), and writePostData().

721  {
722  $this->writePostData();
723  $this->addSaveOnEnterOnLoadCode();
724  $this->editQuestion();
725  }
+ Here is the call graph for this function:

◆ resetSavedPreviewSession()

assFormulaQuestionGUI::resetSavedPreviewSession ( )

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

References $DIC, and $ilUser.

Referenced by writePostData().

188  {
189  global $DIC;
190  $ilUser = $DIC['ilUser'];
191  $user_id = $ilUser->getId();
192  $question_id = $this->object->getId();
193  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
194  $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id);
195  $ilAssQuestionPreviewSession->setParticipantsSolution(array());
196  }
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
+ Here is the caller graph for this function:

◆ saveFQ()

assFormulaQuestionGUI::saveFQ ( )

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

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

811  {
812  $result = $this->writePostData();
813 
814  if ($result == 1) {
815  $this->editQuestion();
816  } else {
817  $this->saveTaxonomyAssignments();
818  $this->save();
819  }
820  }
$result
save()
save question
+ Here is the call graph for this function:

◆ saveReturnFQ()

assFormulaQuestionGUI::saveReturnFQ ( )

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

References $_GET, $_SESSION, $DIC, $ilDB, $ilUser, $result, $test, assQuestion\_isWriteable(), assQuestion\_questionExistsInTest(), assQuestionGUI\callNewIdListeners(), ilAssQuestionPreviewGUI\CMD_SHOW, assQuestionGUI\saveTaxonomyAssignments(), and writePostData().

741  {
742  global $DIC;
743  $ilUser = $DIC['ilUser'];
744  $old_id = $_GET["q_id"];
745  $result = $this->writePostData();
746  if ($result == 0) {
747  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
748  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
749  $this->saveTaxonomyAssignments();
750  $this->object->saveToDb();
751  $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
752  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
753  if (($_GET["calling_test"] || (isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer'])) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
754  $this->ctrl->redirect($this, "originalSyncForm");
755  return;
756  } elseif ($_GET["calling_test"]) {
757  require_once 'Modules/Test/classes/class.ilObjTest.php';
758  $test = new ilObjTest($_GET["calling_test"]);
759  #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
760  $q_id = $this->object->getId();
761  if (!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId())) {
762  global $DIC;
763  $tree = $DIC['tree'];
764  $ilDB = $DIC['ilDB'];
765  $ilPluginAdmin = $DIC['ilPluginAdmin'];
766 
767  include_once("./Modules/Test/classes/class.ilObjTest.php");
768  $_GET["ref_id"] = $_GET["calling_test"];
769  $test = new ilObjTest($_GET["calling_test"], true);
770 
771  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
772  $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
773 
774  $new_id = $test->insertQuestion(
775  $testQuestionSetConfigFactory->getQuestionSetConfig(),
776  $this->object->getId()
777  );
778 
779  $q_id = $new_id;
780  if (isset($_REQUEST['prev_qid'])) {
781  $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
782  }
783 
784  $this->ctrl->setParameter($this, 'q_id', $new_id);
785  $this->ctrl->setParameter($this, 'calling_test', $this->request->getQueryParams()["calling_test"]);
786  }
787  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
788  $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
789  } else {
790  if ($this->object->getId() != $old_id) {
791  $this->callNewIdListeners($this->object->getId());
792  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
793  $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
794  }
795  if (strcmp($_SESSION["info"], "") != 0) {
796  ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
797  } else {
798  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
799  }
800  $this->ctrl->redirectByClass("ilAssQuestionPreviewGUI", ilAssQuestionPreviewGUI::CMD_SHOW);
801  }
802  } else {
803  $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
804  $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
805  $this->object->saveToDb();
806  $this->editQuestion();
807  }
808  }
$_SESSION["AccountId"]
$result
$_GET["client_id"]
callNewIdListeners($a_new_id)
Call the new id listeners.
global $DIC
Definition: goto.php:24
static _questionExistsInTest($question_id, $test_id)
global $ilDB
$ilUser
Definition: imgupload.php:18
$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:

◆ setQuestionSpecificTabs()

assFormulaQuestionGUI::setQuestionSpecificTabs ( ilTabsGUI  $ilTabs)
protected

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

References $_GET, and ilTabsGUI\addTarget().

728  {
729  // Unit editor
730  if ($_GET['q_id']) {
731  $ilTabs->addTarget(
732  'units',
733  $this->ctrl->getLinkTargetByClass('ilLocalUnitConfigurationGUI', ''),
734  '',
735  'illocalunitconfigurationgui'
736  );
737  }
738  }
$_GET["client_id"]
addTarget( $a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
+ Here is the call graph for this function:

◆ suggestRange()

assFormulaQuestionGUI::suggestRange ( string  $suggest_range_for_result)

Suggest a range for a result public.

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

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

Referenced by callSpecialQuestionCommands().

54  {
55  if ($this->writePostData()) {
57  }
58  $this->editQuestion(false, $suggest_range_for_result);
59  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportsIntermediateSolutionOutput()

assFormulaQuestionGUI::supportsIntermediateSolutionOutput ( )

Question type specific support of intermediate solution output The function getSolutionOutput respects getUseIntermediateSolution()

Returns
bool

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

841  {
842  return true;
843  }

◆ writePostData()

assFormulaQuestionGUI::writePostData (   $always = false)
protected

{}

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

References $_POST, Vendor\Package\$e, $result, assQuestionGUI\addErrorMessage(), ilAssQuestionLifecycle\getInstance(), isSaveCommand(), resetSavedPreviewSession(), ilUtil\sendFailure(), assFormulaQuestionVariable\setRangeMinTxt(), and ilUtil\stripOnlySlashes().

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

65  {
66  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
67  $checked = true;
68  if (!$hasErrors) {
69  $this->object->setTitle($_POST["title"]);
70  $this->object->setAuthor($_POST["author"]);
71  $this->object->setComment($_POST["comment"]);
72  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
73  $questiontext = ilUtil::stripOnlySlashes($_POST["question"]);
74  $this->object->setQuestion($questiontext);
75  $this->object->setEstimatedWorkingTime(
76  $_POST["Estimated"]["hh"],
77  $_POST["Estimated"]["mm"],
78  $_POST["Estimated"]["ss"]
79  );
80 
81  $this->object->parseQuestionText();
82  $found_vars = array();
83  $found_results = array();
84 
85 
86  foreach ($_POST as $key => $value) {
87  if (preg_match("/^unit_(\\\$v\d+)$/", $key, $matches)) {
88  array_push($found_vars, $matches[1]);
89  }
90  if (preg_match("/^unit_(\\\$r\d+)$/", $key, $matches)) {
91  array_push($found_results, $matches[1]);
92  }
93  }
94 
95  try {
96  $lifecycle = ilAssQuestionLifecycle::getInstance($_POST['lifecycle']);
97  $this->object->setLifecycle($lifecycle);
99  }
100 
101  // if(!$this->object->checkForDuplicateVariables())
102  // {
103 //
104  // $this->addErrorMessage($this->lng->txt("err_duplicate_variables"));
105  // $checked = FALSE;
106  // }
107  if (!$this->object->checkForDuplicateResults()) {
108  $this->addErrorMessage($this->lng->txt("err_duplicate_results"));
109  $checked = false;
110  }
111 
112  foreach ($found_vars as $variable) {
113  if ($this->object->getVariable($variable) != null) {
114  $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"]);
115  $varObj->setRangeMinTxt($_POST["range_min_$variable"]);
116  $varObj->setRangeMaxTxt($_POST["range_max_$variable"]);
117  $this->object->addVariable($varObj);
118  }
119  }
120 
121  $tmp_form_vars = array();
122  $tmp_quest_vars = array();
123  foreach ($found_results as $result) {
124  $tmp_res_match = preg_match_all("/([$][v][0-9]*)/", $_POST["formula_$result"], $form_vars);
125  $tmp_form_vars = array_merge($tmp_form_vars, $form_vars[0]);
126 
127  $tmp_que_match = preg_match_all("/([$][v][0-9]*)/", $_POST['question'], $quest_vars);
128  $tmp_quest_vars = array_merge($tmp_quest_vars, $quest_vars[0]);
129  }
130  $result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
131  $question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
132 
133  if (count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0) {
134  $error_message = '';
135  if (count($result_has_undefined_vars) > 0) {
136  $error_message .= $this->lng->txt("res_contains_undef_var") . '<br>';
137  }
138  if (count($question_has_unused_vars) > 0) {
139  $error_message .= $this->lng->txt("que_contains_unused_var");
140  }
141  $checked = false;
142  if ($this->isSaveCommand()) {
143  ilUtil::sendFailure($error_message);
144  }
145  }
146  foreach ($found_results as $result) {
147  if (is_object($this->object->getUnitrepository()->getUnit($_POST["unit_$result"]))) {
148  $tmp_result_unit = $this->object->getUnitrepository()->getUnit($_POST["unit_$result"]);
149  } else {
150  $tmp_result_unit = null;
151  }
152 
153  if ($this->object->getResult($result) != null) {
154  $use_simple_rating = ($_POST["rating_advanced_$result"] == 1) ? false : true;
155  $resObj = new assFormulaQuestionResult(
156  $result,
157  $_POST["range_min_$result"],
158  $_POST["range_max_$result"],
159  $_POST["tolerance_$result"],
160  $tmp_result_unit,
161  $_POST["formula_$result"],
162  $_POST["points_$result"],
163  $_POST["precision_$result"],
164  $use_simple_rating,
165  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_sign_$result"] : "",
166  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_value_$result"] : "",
167  ($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_unit_$result"] : "",
168  $_POST["result_type_$result"] != 0 ? $_POST["result_type_$result"] : 0
169  );
170  $resObj->setRangeMinTxt($_POST["range_min_$result"]);
171  $resObj->setRangeMaxTxt($_POST["range_max_$result"]);
172  $this->object->addResult($resObj);
173  $this->object->addResultUnits($resObj, $_POST["units_$result"]);
174  }
175  }
176  if ($checked == false) {
177  return 1;
178  } else {
179  $this->resetSavedPreviewSession();
180  return 0;
181  }
182  } else {
183  return 1;
184  }
185  }
$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.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ HAS_SPECIAL_QUESTION_COMMANDS

const assFormulaQuestionGUI::HAS_SPECIAL_QUESTION_COMMANDS = true
protected

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


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