ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.assAnswerCloze.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
5 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
6 
24 {
33  protected $lowerBound;
34 
43  protected $upperBound;
44 
57  public function __construct($answertext = "", $points = 0.0, $order = 0)
58  {
60  $this->lowerBound = NULL;
61  $this->upperBound = NULL;
62  }
63 
70  function setLowerBound($bound)
71  {
72  $bound = str_replace(",", ".", $bound);
73  if ($bound > $this->getAnswertext() || strlen($bound) == 0)
74  {
75  $bound = $this->getAnswertext();
76  }
77 
78  if ( is_numeric($bound) )
79  {
80  $this->lowerBound = $bound;
81  }
82  else
83  {
84  // unreachable
85  // $this->lowerBound = $this->getAnswertext();
86  }
87  }
88 
95  public function setUpperBound($bound)
96  {
97  $bound = str_replace(",", ".", $bound);
98 
99  $value = $this->getNumericValueFromAnswerText();
100 
101  if ($bound < $value || strlen($bound) == 0)
102  {
103  $bound = $value;
104  }
105 
106  if ( is_numeric($bound) )
107  {
108  $this->upperBound = $bound;
109  }
110  else
111  {
112  $this->upperBound = $this->getAnswertext();
113  }
114  }
115 
116  protected function getNumericValueFromAnswerText()
117  {
118  include_once("./Services/Math/classes/class.EvalMath.php");
119  $eval = new EvalMath();
120  $eval->suppress_errors = true;
121  return $eval->e(str_replace(",", ".", ilUtil::stripSlashes($this->getAnswertext(), FALSE)));
122  }
123 
129  public function getLowerBound()
130  {
131  return $this->lowerBound;
132  }
133 
139  public function getUpperBound()
140  {
141  return $this->upperBound;
142  }
143 }