ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
49  protected $gap_size;
50 
51 
64  public function __construct($answertext = "", $points = 0.0, $order = 0)
65  {
66  parent::__construct($answertext, $points, $order, -1);
67  $this->lowerBound = null;
68  $this->upperBound = null;
69  $this->gap_size = 0;
70  }
71 
72  // fau: fixGapFormula - allow formula evaluation when checking bounds, save bound text instead of number
79  public function setLowerBound($bound)
80  {
81  $boundvalue = $this->getNumericValueFromText($bound);
82  $value = $this->getNumericValueFromAnswerText();
83 
84  if ($boundvalue === false || $boundvalue > $value) {
85  $this->lowerBound = $this->getAnswertext();
86  } else {
87  $this->lowerBound = $bound;
88  }
89  }
90 
97  public function setUpperBound($bound)
98  {
99  $boundvalue = $this->getNumericValueFromText($bound);
100  $value = $this->getNumericValueFromAnswerText();
101 
102  if ($boundvalue === false || $boundvalue < $value) {
103  $this->upperBound = $this->getAnswertext();
104  } else {
105  $this->upperBound = $bound;
106  }
107  }
108 
109  protected function getNumericValueFromAnswerText()
110  {
111  return $this->getNumericValueFromText($this->getAnswertext());
112  }
113 
114  protected function getNumericValueFromText($text)
115  {
116  include_once("./Services/Math/classes/class.EvalMath.php");
117  $eval = new EvalMath();
118  $eval->suppress_errors = true;
119  return $eval->e(str_replace(",", ".", ilUtil::stripSlashes($text, false)));
120  }
121  // fau.
122 
128  public function getLowerBound()
129  {
130  return $this->lowerBound;
131  }
132 
138  public function getUpperBound()
139  {
140  return $this->upperBound;
141  }
142 
146  public function setGapSize($gap_size)
147  {
148  $this->gap_size = $gap_size;
149  }
150 
154  public function getGapSize()
155  {
156  return $this->gap_size;
157  }
158 }
Class for cloze question numeric answers.
getLowerBound()
Returns the lower bound.
setUpperBound($bound)
Sets the upper bound.
getUpperBound()
Returns the upper bound.
setLowerBound($bound)
Sets the lower boind.
Class for simple answers.
$text
Definition: errorreport.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getAnswertext()
Gets the answer text.
__construct($answertext="", $points=0.0, $order=0)
assAnswerCloze constructor