ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
assFormulaQuestionGUI Class Reference

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

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

Public Member Functions

 __construct ($id=-1)
 assFormulaQuestionGUI constructor The constructor takes possible arguments an creates an instance of the assFormulaQuestionGUI object.
 setQuestionTabs ()
 Sets the ILIAS tabs for this question type Sets the ILIAS tabs for this question type public.
 getCommand ($cmd)
 suggestRange ()
 Suggest a range for a result public.
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object.
 isSaveCommand ()
 parseQuestion ()
 saveReturnFQ ()
 saveFQ ()
 checkInput ()
 check input fields
 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.
 getPreview ($show_question_only=FALSE)
 getTestOutput ($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
 getSpecificFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
- Public Member Functions inherited from assQuestionGUI
 __construct ()
 assQuestionGUI constructor
executeCommand ()
 execute command
 getType ()
 needed for page editor compliance
 setTaxonomyIds ($taxonomyIds)
 getTaxonomyIds ()
 setTargetGui (ilTestPlayerAbstractGUI $linkTargetGui)
 setTargetGuiClass ($targetGuiClass)
 getTargetGuiClass ()
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 assessment ()
 output assessment
_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.
 _getGUIClassNameForId ($a_q_id)
 _getClassNameForQType ($q_type)
createQuestionGUI ($question_type, $question_id=-1)
 Creates a question gui representation.
 getQuestionTemplate ()
 get question template
 getILIASPage ($html="")
 Returns the ILIAS Page around a question.
 outQuestionPage ($a_temp_var, $a_postponed=false, $active_id="", $html="")
 output question page
 cancel ()
 cancel action
 originalSyncForm ($return_to="", $return_to_feedback= '')
 sync ()
 cancelSync ()
 saveEdit ()
 save question
 save ()
 save question
 saveReturn ()
 save question
 apply ()
 apply changes
 getContextPath ($cont_obj, $a_endnode_id, $a_startnode_id=1)
 get context path in content object tree
 setSequenceNumber ($nr)
 getSequenceNumber ()
 setQuestionCount ($a_question_count)
 getQuestionCount ()
 getErrorMessage ()
 setErrorMessage ($errormessage)
 addErrorMessage ($errormessage)
 outAdditionalOutput ()
 getQuestionType ()
 Returns the question type string.
 getAsValueAttribute ($a_value)
 Returns a HTML value attribute.
 addNewIdListener (&$a_object, $a_method, $a_parameters="")
 Add a listener that is notified with the new question ID, when a new question is saved.
 callNewIdListeners ($a_new_id)
 Call the new id listeners.
 addQuestionFormCommandButtons ($form)
 Add the command buttons of a question properties form.
 addBasicQuestionFormProperties ($form)
 Add basic question form properties: assessment: title, author, description, question, working time.
 getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode.
 getAnswerFeedbackOutput ($active_id, $pass)
 Returns the answer generic feedback depending on the results of the question.
 getGenericFeedbackOutput ($active_id, $pass)
 Returns the answer specific feedback for the question.
 outQuestionType ()
 showSuggestedSolution ()
 suggestedsolution ()
 Allows to add suggested solutions for questions.
 outSolutionExplorer ()
 saveSuggestedSolution ()
 cancelExplorer ()
 outPageSelector ()
 outChapterSelector ()
 outGlossarySelector ()
 linkChilds ()
 addPG ()
 addST ()
 addGIT ()
 isAutosaveable ()
 showHints ()

Private Member Functions

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

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
- 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
 $question_count
 question count in test
- Protected Member Functions inherited from assQuestionGUI
 saveTaxonomyAssignments ()
 populateTaxonomyFormSection (ilPropertyFormGUI $form)
 addTab_QuestionFeedback (ilTabsGUI $tabs)
 adds the feedback tab to ilTabsGUI
 addTab_QuestionHints (ilTabsGUI $tabs)
 adds the hints tab to ilTabsGUI
 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

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.

References assQuestionGUI\__construct().

{
$this->object = new assFormulaQuestion();
$this->newUnitId = null;
if($id >= 0)
{
$this->object->loadFromDb($id);
}
}

+ Here is the call graph for this function:

Member Function Documentation

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.

{
$resultunit = $result->getUnit();
/*
* if there is a result-unit (unit selectbox) selected it is possible to use advanced rating
* if there is no result-unit selected it is NOT possible to use advanced rating, because there is no
* definition if the result-value or the unit-value should be the correct solution!!
*
*/
if(is_object($resultunit))
{
return true;
}
else
{
return false;
}
}
assFormulaQuestionGUI::checkInput ( )

check input fields

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

References $_POST, and assQuestionGUI\addErrorMessage().

{
if((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
{
$this->addErrorMessage($this->lng->txt("fill_out_all_required_fields"));
return FALSE;
}
return TRUE;
}

+ Here is the call graph for this function:

assFormulaQuestionGUI::getCommand (   $cmd)

Reimplemented from assQuestionGUI.

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

References $cmd.

{
if(preg_match("/suggestrange_(.*?)/", $cmd, $matches))
{
$cmd = "suggestRange";
}
return $cmd;
}
assFormulaQuestionGUI::getPreview (   $show_question_only = FALSE)

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

References assQuestionGUI\getILIASPage().

{
$template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
$questiontext = $this->object->substituteVariables();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$questionoutput = $template->get();
if(!$show_question_only)
{
// get page object output
$questionoutput = $this->getILIASPage($questionoutput);
}
return $questionoutput;
}

+ Here is the call graph for this function:

assFormulaQuestionGUI::getSolutionOutput (   $active_id,
  $pass = NULL,
  $graphicalOutput = FALSE,
  $result_output = FALSE,
  $show_question_only = TRUE,
  $show_feedback = FALSE,
  $show_correct_solution = FALSE,
  $show_manual_scoring = FALSE,
  $show_question_text = TRUE 
)

Get the question solution output.

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

Reimplemented from assQuestionGUI.

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

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

{
// get the solution of the user for the active pass or from the last pass if allowed
$user_solution = "";
if(($active_id > 0) && (!$show_correct_solution))
{
$solutions = NULL;
include_once "./Modules/Test/classes/class.ilObjTest.php";
if(!ilObjTest::_getUsePreviousAnswers($active_id, true))
{
if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
}
$user_solution["active_id"] = $active_id;
$user_solution["pass"] = $pass;
$solutions =& $this->object->getSolutionValues($active_id, $pass);
foreach($solutions as $idx => $solution_value)
{
if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
{
$user_solution[$matches[1]] = $solution_value["value2"];
}
else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["value"] = $solution_value["value2"];
}
else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["unit"] = $solution_value["value2"];
}
}
}
else if($active_id)
{
$solutions = NULL;
include_once "./Modules/Test/classes/class.ilObjTest.php";
if(!ilObjTest::_getUsePreviousAnswers($active_id, true))
{
if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
}
$user_solution = $this->object->getBestSolution($active_id, $pass);
}
$template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output_solution.html", true, true, 'Modules/TestQuestionPool');
$questiontext = $this->object->substituteVariables($user_solution, $graphicalOutput, TRUE, $result_output);
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$questionoutput = $template->get();
$solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
$solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
$solutionoutput = $solutiontemplate->get();
if(!$show_question_only)
{
// get page object output
$solutionoutput = $this->getILIASPage($solutionoutput);
}
return $solutionoutput;
}

+ Here is the call graph for this function:

assFormulaQuestionGUI::getSpecificFeedbackOutput (   $active_id,
  $pass 
)

Returns the answer specific feedback for the question.

This method should be overwritten by the actual question.

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

Reimplemented from assQuestionGUI.

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

{
return '';
}
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().

{
ilUtil::sendInfo($this->lng->txt('enter_valid_values'));
// get the solution of the user for the active pass or from the last pass if allowed
$user_solution = null;
if($active_id)
{
$solutions = NULL;
include_once "./Modules/Test/classes/class.ilObjTest.php";
if(is_null($pass)) $pass = ilObjTest::_getPass($active_id);
$user_solution["active_id"] = $active_id;
$user_solution["pass"] = $pass;
$solutions =& $this->object->getSolutionValues($active_id, $pass);
foreach($solutions as $idx => $solution_value)
{
if(preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches))
{
$user_solution[$matches[1]] = $solution_value["value2"];
}
else if(preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["value"] = $solution_value["value2"];
}
else if(preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches))
{
if(!array_key_exists($matches[1], $user_solution)) $user_solution[$matches[1]] = array();
$user_solution[$matches[1]]["unit"] = $solution_value["value2"];
}
if(preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && $user_solution[$matches[1]]["result_type"] == 0)
{
$user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]);
}
}
}
// generate the question output
$template = new ilTemplate("tpl.il_as_qpl_formulaquestion_output.html", true, true, 'Modules/TestQuestionPool');
$questiontext = $this->object->substituteVariables($user_solution);
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
$questionoutput = $template->get();
$pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
return $pageoutput;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
if (array_key_exists($result->getResult(), $resultunits))
{
if (array_key_exists($unit_id, $resultunits[$result->getResult()])) return TRUE;
}
return FALSE;
}
assFormulaQuestionGUI::isSaveCommand ( )

Reimplemented from assQuestionGUI.

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

Referenced by writePostData().

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

+ Here is the caller graph for this function:

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

{
$test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions, $show_feedback);
$this->tpl->setVariable("QUESTION_OUTPUT", $test_output);
$this->tpl->setVariable("FORMACTION", $formaction);
}

+ Here is the call graph for this function:

assFormulaQuestionGUI::parseQuestion ( )

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

References assQuestionGUI\writePostData().

{
$this->writePostData();
$this->editQuestion();
}

+ Here is the call graph for this function:

assFormulaQuestionGUI::saveFQ ( )

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

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

{
$result = $this->writePostData();
if($result == 1)
{
$this->editQuestion();
}
else
{
$this->save();
}
}

+ Here is the call graph for this function:

assFormulaQuestionGUI::saveReturnFQ ( )

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

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

{
global $ilUser;
$old_id = $_GET["q_id"];
$result = $this->writePostData();
if ($result == 0)
{
$ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
$ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
$this->object->saveToDb();
$originalexists = $this->object->_questionExistsInPool($this->object->original_id);
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
{
$this->ctrl->redirect($this, "originalSyncForm");
return;
}
elseif ($_GET["calling_test"])
{
require_once 'Modules/Test/classes/class.ilObjTest.php';
$test = new ilObjTest($_GET["calling_test"]);
#var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
$q_id = $this->object->getId();
if(!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()))
{
global $tree, $ilDB, $ilPluginAdmin;
include_once("./Modules/Test/classes/class.ilObjTest.php");
$_GET["ref_id"] = $_GET["calling_test"];
$test = new ilObjTest($_GET["calling_test"], true);
require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
$testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
$new_id = $test->insertQuestion(
$testQuestionSetConfigFactory->getQuestionSetConfig(), $this->object->getId()
);
$q_id = $new_id;
if(isset($_REQUEST['prev_qid']))
{
$test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
}
$this->ctrl->setParameter($this, 'q_id', $new_id);
$this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
#$this->ctrl->setParameter($this, 'test_ref_id', false);
}
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
if($_REQUEST['test_express_mode'])
{
}
else
{
ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET["calling_test"]);
}
}
else
{
if ($this->object->getId() != $old_id)
{
$this->callNewIdListeners($this->object->getId());
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
$this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
}
if (strcmp($_SESSION["info"], "") != 0)
{
ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
}
else
{
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
}
$this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
}
}
else
{
$ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
$ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
$this->object->saveToDb();
$this->editQuestion();
}
}

+ Here is the call graph for this function:

assFormulaQuestionGUI::setQuestionTabs ( )

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

Reimplemented from assQuestionGUI.

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

References $_GET, $_POST, $ref_id, assQuestionGUI\addTab_QuestionFeedback(), and assQuestionGUI\addTab_QuestionHints().

{
global $rbacsystem, $ilTabs;
$this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$q_type = $this->object->getQuestionType();
if(strlen($q_type))
{
$classname = $q_type . "GUI";
$this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
$this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
}
if($_GET["q_id"])
{
if ($rbacsystem->checkAccess('write', $_GET["ref_id"]))
{
// edit page
$ilTabs->addTarget("edit_page",
$this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
array("edit", "insert", "exec_pg"),
"", "", $force_active);
}
// edit page
$ilTabs->addTarget("preview",
$this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "preview"),
array("preview"),
"ilAssQuestionPageGUI", "", $force_active);
}
$force_active = false;
if($rbacsystem->checkAccess('write', $_GET["ref_id"]))
{
$url = "";
if($classname) $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
$commands = $_POST["cmd"];
if(is_array($commands))
{
foreach($commands as $key => $value)
{
if(preg_match("/^suggestrange_.*/", $key, $matches))
{
$force_active = true;
}
}
}
// edit question properties
$ilTabs->addTarget("edit_properties",
$url,
array(
"editQuestion", "save", "cancel", "addSuggestedSolution",
"cancelExplorer", "linkChilds", "removeSuggestedSolution",
"parseQuestion", "saveEdit", "suggestRange"
),
$classname, "", $force_active);
}
if($_GET["q_id"])
{
// add tab for question feedback within common class assQuestionGUI
$this->addTab_QuestionFeedback($ilTabs);
}
if($_GET["q_id"])
{
// add tab for question hint within common class assQuestionGUI
$this->addTab_QuestionHints($ilTabs);
}
// Unit editor
if($_GET['q_id'])
{
// add tab for question hint within common class assQuestionGUI
$this->addTab_Units($ilTabs);
}
// Assessment of questions sub menu entry
if($_GET["q_id"])
{
$ilTabs->addTarget("statistics",
$this->ctrl->getLinkTargetByClass($classname, "assessment"),
array("assessment"),
$classname, "");
}
if(($_GET["calling_test"] > 0) || ($_GET["test_ref_id"] > 0))
{
$ref_id = $_GET["calling_test"];
if(strlen($ref_id) == 0) $ref_id = $_GET["test_ref_id"];
$ilTabs->setBackTarget($this->lng->txt("backtocallingtest"), "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
}
else
{
$ilTabs->setBackTarget($this->lng->txt("qpl"), $this->ctrl->getLinkTargetByClass("ilobjquestionpoolgui", "questions"));
}
}

+ Here is the call graph for this function:

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

{
if($this->writePostData())
{
}
$this->editQuestion();
}

+ Here is the call graph for this function:

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

{
$hasErrors = (!$always) ? $this->editQuestion(true) : false;
$checked = true;
if(!$hasErrors)
{
$this->object->setTitle($_POST["title"]);
$this->object->setAuthor($_POST["author"]);
$this->object->setComment($_POST["comment"]);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$questiontext = ilUtil::stripOnlySlashes($_POST["question"]);
$this->object->setQuestion($questiontext);
$this->object->setEstimatedWorkingTime(
$_POST["Estimated"]["hh"],
$_POST["Estimated"]["mm"],
$_POST["Estimated"]["ss"]
);
$this->object->parseQuestionText();
$found_vars = array();
$found_results = array();
foreach($_POST as $key => $value)
{
if(preg_match("/^unit_(\\\$v\d+)$/", $key, $matches))
{
array_push($found_vars, $matches[1]);
}
if(preg_match("/^unit_(\\\$r\d+)$/", $key, $matches))
{
array_push($found_results, $matches[1]);
}
}
// if(!$this->object->checkForDuplicateVariables())
// {
//
// $this->addErrorMessage($this->lng->txt("err_duplicate_variables"));
// $checked = FALSE;
// }
if(!$this->object->checkForDuplicateResults())
{
$this->addErrorMessage($this->lng->txt("err_duplicate_results"));
$checked = FALSE;
}
foreach($found_vars as $variable)
{
if($this->object->getVariable($variable) != null)
{
$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"]);
$varObj->setRangeMinTxt($_POST["range_min_$variable"]);
$varObj->setRangeMaxTxt($_POST["range_max_$variable"]);
$this->object->addVariable($varObj);
}
}
$tmp_form_vars = array();
$tmp_quest_vars = array();
foreach($found_results as $result)
{
$tmp_res_match = preg_match_all("/([$][v][0-9]*)/", $_POST["formula_$result"], $form_vars);
$tmp_form_vars = array_merge($tmp_form_vars,$form_vars[0]);
$tmp_que_match = preg_match_all("/([$][v][0-9]*)/", $_POST['question'] , $quest_vars);
$tmp_quest_vars= array_merge($tmp_quest_vars,$quest_vars[0]);
}
$result_has_undefined_vars = array_diff($tmp_form_vars, $found_vars);
$question_has_unused_vars = array_diff($tmp_quest_vars, $tmp_form_vars);
if(count($result_has_undefined_vars) > 0 || count($question_has_unused_vars) > 0)
{
$error_message = '';
if(count($result_has_undefined_vars) > 0)
{
$error_message .= $this->lng->txt("res_contains_undef_var"). '<br>';
}
if(count($question_has_unused_vars) > 0)
{
$error_message .= $this->lng->txt("que_contains_unused_var");
}
$checked = false;
if($this->isSaveCommand())
{
ilUtil::sendFailure($error_message);
}
}
foreach($found_results as $result)
{
if(is_object($this->object->getUnitrepository()->getUnit($_POST["unit_$result"])))
{
$tmp_result_unit = $this->object->getUnitrepository()->getUnit($_POST["unit_$result"]);
}
else
{
$tmp_result_unit = NULL;
}
if($this->object->getResult($result) != null)
{
$use_simple_rating = ($_POST["rating_advanced_$result"] == 1) ? FALSE : TRUE;
$resObj = new assFormulaQuestionResult(
$result,
$_POST["range_min_$result"],
$_POST["range_max_$result"],
$_POST["tolerance_$result"],
$tmp_result_unit,
$_POST["formula_$result"],
$_POST["points_$result"],
$_POST["precision_$result"],
$use_simple_rating,
($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_sign_$result"] : "",
($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_value_$result"] : "",
($_POST["rating_advanced_$result"] == 1) ? $_POST["rating_unit_$result"] : "",
$_POST["result_type_$result"] != 0 ? $_POST["result_type_$result"] : 0
);
$resObj->setRangeMinTxt($_POST["range_min_$result"]);
$resObj->setRangeMaxTxt($_POST["range_max_$result"]);
$this->object->addResult($resObj);
$this->object->addResultUnits($resObj, $_POST["units_$result"]);
}
}
if($checked == false)
{
return 1;
}
else
{
return 0;
}
}
else
{
return 1;
}
}

+ Here is the call graph for this function:


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