ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFormulaInputGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
5 include_once("./Services/Math/classes/class.EvalMath.php");
6 
15 {
21  function setValue($a_value)
22  {
23  $this->value = str_replace(',', '.', $a_value);
24  }
25 
31  function checkInput()
32  {
33  global $lng;
34 
36  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
37  {
38  $this->setAlert($lng->txt("msg_input_is_required"));
39 
40  return false;
41  }
42  else
43  {
44  $eval = new EvalMath();
45  $eval->suppress_errors = true;
46  $result = $eval->e(str_replace(",", ".", ilUtil::stripSlashes($_POST[$this->getPostVar()], FALSE)));
47  if ($result === false)
48  {
49  $this->setAlert($lng->txt("form_msg_formula_is_required"));
50  return false;
51  }
52  }
53 
54  return $this->checkSubItemsInput();
55  }
56 }
57 ?>