ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
5require_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 function setLowerBound($bound)
80 {
81 $boundvalue = $this->getNumericValueFromText($bound);
82 $value = $this->getNumericValueFromAnswerText();
83
84 if ($boundvalue === false || $boundvalue > $value)
85 {
86 $this->lowerBound = $this->getAnswertext();
87 }
88 else
89 {
90 $this->lowerBound = $bound;
91 }
92 }
93
100 public function setUpperBound($bound)
101 {
102 $boundvalue = $this->getNumericValueFromText($bound);
103 $value = $this->getNumericValueFromAnswerText();
104
105 if ($boundvalue === false || $boundvalue < $value)
106 {
107 $this->upperBound = $this->getAnswertext();
108 }
109 else
110 {
111 $this->upperBound = $bound;
112 }
113 }
114
115 protected function getNumericValueFromAnswerText()
116 {
117 return $this->getNumericValueFromText($this->getAnswertext());
118 }
119
120 protected function getNumericValueFromText($text)
121 {
122 include_once("./Services/Math/classes/class.EvalMath.php");
123 $eval = new EvalMath();
124 $eval->suppress_errors = true;
125 return $eval->e(str_replace(",", ".", ilUtil::stripSlashes($text, FALSE)));
126 }
127// fau.
128
134 public function getLowerBound()
135 {
136 return $this->lowerBound;
137 }
138
144 public function getUpperBound()
145 {
146 return $this->upperBound;
147 }
148
152 public function setGapSize($gap_size)
153 {
154 $this->gap_size = $gap_size;
155 }
156
160 public function getGapSize()
161 {
162 return $this->gap_size;
163 }
164}
Class for simple answers.
getAnswertext()
Gets the answer text.
Class for cloze question numeric answers.
setUpperBound($bound)
Sets the upper bound.
getLowerBound()
Returns the lower bound.
setLowerBound($bound)
Sets the lower boind.
getUpperBound()
Returns the upper bound.
__construct($answertext="", $points=0.0, $order=0)
assAnswerCloze constructor
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$text