ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
assFormulaQuestionVariable Class Reference

Formula Question Variable. More...

+ Collaboration diagram for assFormulaQuestionVariable:

Public Member Functions

 __construct ($variable, $range_min, $range_max, $unit=null, $precision=0, $intprecision=1)
 assFormulaQuestionVariable constructor More...
 
 getRandomValue ()
 
 setRandomValue ()
 
 setValue ($value)
 
 getValue ()
 
 getBaseValue ()
 
 setPrecision ($precision)
 
 getPrecision ()
 
 setVariable ($variable)
 
 getVariable ()
 
 setRangeMin ($range_min)
 
 getRangeMin ()
 
 setRangeMax ($range_max)
 
 getRangeMax ()
 
 setUnit ($unit)
 
 getUnit ()
 
 setIntprecision ($intprecision)
 
 getIntprecision ()
 
 setRangeMaxTxt ($range_max_txt)
 
 getRangeMaxTxt ()
 
 setRangeMinTxt ($range_min_txt)
 
 getRangeMinTxt ()
 

Private Attributes

 $variable
 
 $range_min
 
 $range_max
 
 $unit
 
 $value
 
 $precision
 
 $intprecision
 
 $range_min_txt
 
 $range_max_txt
 

Detailed Description

Formula Question Variable.

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.assFormulaQuestionVariable.php 465 2009-06-29 08:27:36Z hschottm

Definition at line 10 of file class.assFormulaQuestionVariable.php.

Constructor & Destructor Documentation

◆ __construct()

assFormulaQuestionVariable::__construct (   $variable,
  $range_min,
  $range_max,
  $unit = null,
  $precision = 0,
  $intprecision = 1 
)

assFormulaQuestionVariable constructor

Parameters
string$variableVariable name
float$range_minRange minimum
float$range_maxRange maximum
object$unitUnit
integer$precisionNumber of decimal places of the value
integer$intprecisionValues with precision 0 must be divisible by this value @access public

Definition at line 33 of file class.assFormulaQuestionVariable.php.

References $intprecision, $precision, $range_max, $range_min, $unit, $variable, setRangeMax(), setRangeMaxTxt(), setRangeMin(), and setRangeMinTxt().

+ Here is the call graph for this function:

Member Function Documentation

◆ getBaseValue()

assFormulaQuestionVariable::getBaseValue ( )

Definition at line 106 of file class.assFormulaQuestionVariable.php.

107 {
108 if (!is_object($this->getUnit())) {
109 return $this->value;
110 } else {
111 include_once "./Services/Math/classes/class.ilMath.php";
112 return ilMath::_mul($this->value, $this->getUnit()->getFactor());
113 }
114 }
static _mul($left_operand, $right_operand, $scale=50)

References $value, ilMath\_mul(), and getUnit().

+ Here is the call graph for this function:

◆ getIntprecision()

assFormulaQuestionVariable::getIntprecision ( )

Definition at line 182 of file class.assFormulaQuestionVariable.php.

183 {
184 return $this->intprecision;
185 }

References $intprecision.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getPrecision()

assFormulaQuestionVariable::getPrecision ( )

Definition at line 121 of file class.assFormulaQuestionVariable.php.

122 {
123 //@todo TEST
124
125 return (int) $this->precision;
126 }

References $precision.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getRandomValue()

assFormulaQuestionVariable::getRandomValue ( )

Definition at line 46 of file class.assFormulaQuestionVariable.php.

47 {
48
49// @todo check this
50 if ($this->getIntprecision() > $this->getRangeMax()){
51 global $DIC;
52 $lng = $DIC['lng'];
53 ilUtil::sendFailure($lng->txt('err_divider_too_big'));
54 }
55
56 include_once "./Services/Math/classes/class.ilMath.php";
57 $mul = ilMath::_pow(10, $this->getPrecision());
58 $r1 = round(ilMath::_mul($this->getRangeMin(), $mul));
59 $r2 = round(ilMath::_mul($this->getRangeMax(), $mul));
60 $calcval = $this->getRangeMin() - 1;
61 //test
62
63 $roundedRangeMIN = round($this->getRangeMin(), $this->getPrecision());
64 $roundedRangeMAX = round($this->getRangeMax(), $this->getPrecision());
65 while ($calcval < $roundedRangeMIN || $calcval > $roundedRangeMAX) {
66
67
68// while($calcval < $this->getRangeMin() || $calcval > $this->getRangeMax())
69 $rnd = mt_rand($r1, $r2);
70 $calcval = ilMath::_div($rnd, $mul, $this->getPrecision());
71 if (($this->getPrecision() == 0) && ($this->getIntprecision() != 0)) {
72 if ($this->getIntprecision() > 0) {
73 $modulo = $calcval % $this->getIntprecision();
74 if ($modulo != 0) {
75 if ($modulo < ilMath::_div($this->getIntprecision(), 2)) {
76 $calcval = ilMath::_sub($calcval, $modulo, $this->getPrecision());
77 } else {
78 $calcval = ilMath::_add($calcval, ilMath::_sub($this->getIntprecision(), $modulo, $this->getPrecision()), $this->getPrecision());
79 }
80 }
81 }
82 }
83 }
84 return $calcval;
85 }
static _div($left_operand, $right_operand, $scale=50)
static _pow($left_operand, $right_operand, $scale=50)
static _sub($left_operand, $right_operand, $scale=50)
static _add($left_operand, $right_operand, $scale=50)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$lng
$DIC
Definition: xapitoken.php:46

References $DIC, $lng, ilMath\_add(), ilMath\_div(), ilMath\_mul(), ilMath\_pow(), ilMath\_sub(), getIntprecision(), getPrecision(), getRangeMax(), getRangeMin(), and ilUtil\sendFailure().

Referenced by setRandomValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRangeMax()

assFormulaQuestionVariable::getRangeMax ( )

Definition at line 162 of file class.assFormulaQuestionVariable.php.

163 {
164 return (double) $this->range_max;
165 }

References $range_max.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getRangeMaxTxt()

assFormulaQuestionVariable::getRangeMaxTxt ( )

◆ getRangeMin()

assFormulaQuestionVariable::getRangeMin ( )

Definition at line 148 of file class.assFormulaQuestionVariable.php.

149 {
150 return (double) $this->range_min;
151 }

References $range_min.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getRangeMinTxt()

assFormulaQuestionVariable::getRangeMinTxt ( )

◆ getUnit()

assFormulaQuestionVariable::getUnit ( )

Definition at line 172 of file class.assFormulaQuestionVariable.php.

173 {
174 return $this->unit;
175 }

References $unit.

Referenced by getBaseValue().

+ Here is the caller graph for this function:

◆ getValue()

assFormulaQuestionVariable::getValue ( )

Definition at line 101 of file class.assFormulaQuestionVariable.php.

102 {
103 return $this->value;
104 }

References $value.

◆ getVariable()

assFormulaQuestionVariable::getVariable ( )

Definition at line 133 of file class.assFormulaQuestionVariable.php.

134 {
135 return $this->variable;
136 }

References $variable.

◆ setIntprecision()

assFormulaQuestionVariable::setIntprecision (   $intprecision)

Definition at line 177 of file class.assFormulaQuestionVariable.php.

178 {
179 $this->intprecision = $intprecision;
180 }

References $intprecision.

◆ setPrecision()

assFormulaQuestionVariable::setPrecision (   $precision)

Definition at line 116 of file class.assFormulaQuestionVariable.php.

117 {
118 $this->precision = $precision;
119 }

References $precision.

◆ setRandomValue()

assFormulaQuestionVariable::setRandomValue ( )

Definition at line 87 of file class.assFormulaQuestionVariable.php.

References getRandomValue(), and setValue().

+ Here is the call graph for this function:

◆ setRangeMax()

assFormulaQuestionVariable::setRangeMax (   $range_max)

Definition at line 153 of file class.assFormulaQuestionVariable.php.

154 {
155 include_once "./Services/Math/classes/class.EvalMath.php";
156 $math = new EvalMath();
157 $math->suppress_errors = true;
158 $result = $math->evaluate($range_max);
159 $this->range_max = $result;
160 }
$result

References $range_max, and $result.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setRangeMaxTxt()

assFormulaQuestionVariable::setRangeMaxTxt (   $range_max_txt)

Definition at line 187 of file class.assFormulaQuestionVariable.php.

188 {
189 $this->range_max_txt = $range_max_txt;
190 }

References $range_max_txt.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setRangeMin()

assFormulaQuestionVariable::setRangeMin (   $range_min)

Definition at line 138 of file class.assFormulaQuestionVariable.php.

139 {
140 include_once "./Services/Math/classes/class.EvalMath.php";
141 $math = new EvalMath();
142 $math->suppress_errors = true;
143 $result = $math->evaluate($range_min);
144
145 $this->range_min = $result;
146 }

References $range_min, and $result.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setRangeMinTxt()

assFormulaQuestionVariable::setRangeMinTxt (   $range_min_txt)

Definition at line 197 of file class.assFormulaQuestionVariable.php.

198 {
199 $this->range_min_txt = $range_min_txt;
200 }

References $range_min_txt.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setUnit()

assFormulaQuestionVariable::setUnit (   $unit)

Definition at line 167 of file class.assFormulaQuestionVariable.php.

168 {
169 $this->unit = $unit;
170 }

References $unit.

◆ setValue()

assFormulaQuestionVariable::setValue (   $value)

Definition at line 96 of file class.assFormulaQuestionVariable.php.

97 {
98 $this->value = $value;
99 }

References $value.

Referenced by setRandomValue().

+ Here is the caller graph for this function:

◆ setVariable()

assFormulaQuestionVariable::setVariable (   $variable)

Definition at line 128 of file class.assFormulaQuestionVariable.php.

129 {
130 $this->variable = $variable;
131 }

References $variable.

Field Documentation

◆ $intprecision

assFormulaQuestionVariable::$intprecision
private

◆ $precision

assFormulaQuestionVariable::$precision
private

Definition at line 17 of file class.assFormulaQuestionVariable.php.

Referenced by __construct(), getPrecision(), and setPrecision().

◆ $range_max

assFormulaQuestionVariable::$range_max
private

Definition at line 14 of file class.assFormulaQuestionVariable.php.

Referenced by __construct(), getRangeMax(), and setRangeMax().

◆ $range_max_txt

assFormulaQuestionVariable::$range_max_txt
private

Definition at line 20 of file class.assFormulaQuestionVariable.php.

Referenced by getRangeMaxTxt(), and setRangeMaxTxt().

◆ $range_min

assFormulaQuestionVariable::$range_min
private

Definition at line 13 of file class.assFormulaQuestionVariable.php.

Referenced by __construct(), getRangeMin(), and setRangeMin().

◆ $range_min_txt

assFormulaQuestionVariable::$range_min_txt
private

Definition at line 19 of file class.assFormulaQuestionVariable.php.

Referenced by getRangeMinTxt(), and setRangeMinTxt().

◆ $unit

assFormulaQuestionVariable::$unit
private

Definition at line 15 of file class.assFormulaQuestionVariable.php.

Referenced by __construct(), getUnit(), and setUnit().

◆ $value

assFormulaQuestionVariable::$value
private

Definition at line 16 of file class.assFormulaQuestionVariable.php.

Referenced by getBaseValue(), getValue(), and setValue().

◆ $variable

assFormulaQuestionVariable::$variable
private

Definition at line 12 of file class.assFormulaQuestionVariable.php.

Referenced by __construct(), getVariable(), and setVariable().


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