ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 108 of file class.assFormulaQuestionVariable.php.

109 {
110 if(!is_object($this->getUnit()))
111 {
112 return $this->value;
113 }
114 else
115 {
116 include_once "./Services/Math/classes/class.ilMath.php";
117 return ilMath::_mul($this->value, $this->getUnit()->getFactor());
118 }
119 }
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 187 of file class.assFormulaQuestionVariable.php.

188 {
189 return $this->intprecision;
190 }

References $intprecision.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getPrecision()

assFormulaQuestionVariable::getPrecision ( )

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

127 {
128 //@todo TEST
129
130 return (int)$this->precision;
131 }

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
51 include_once "./Services/Math/classes/class.ilMath.php";
52 $mul = ilMath::_pow(10, $this->getPrecision());
53 $r1 = round(ilMath::_mul($this->getRangeMin(), $mul));
54 $r2 = round(ilMath::_mul($this->getRangeMax(), $mul));
55 $calcval = $this->getRangeMin() - 1;
56//test
57
58 $roundedRangeMIN = round($this->getRangeMin(), $this->getPrecision());
59 $roundedRangeMAX = round($this->getRangeMax(), $this->getPrecision());
60 while($calcval < $roundedRangeMIN || $calcval > $roundedRangeMAX)
61
62
63// while($calcval < $this->getRangeMin() || $calcval > $this->getRangeMax())
64 {
65 $rnd = mt_rand($r1, $r2);
66 $calcval = ilMath::_div($rnd, $mul, $this->getPrecision());
67 if(($this->getPrecision() == 0) && ($this->getIntprecision() != 0))
68 {
69 if($this->getIntprecision() > 0)
70 {
71 $modulo = $calcval % $this->getIntprecision();
72 if($modulo != 0)
73 {
74 if($modulo < ilMath::_div($this->getIntprecision(), 2))
75 {
76 $calcval = ilMath::_sub($calcval, $modulo, $this->getPrecision());
77 }
78 else
79 {
80 $calcval = ilMath::_add($calcval, ilMath::_sub($this->getIntprecision(), $modulo, $this->getPrecision()), $this->getPrecision());
81 }
82 }
83 }
84 }
85 }
86 return $calcval;
87 }
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)

References ilMath\_add(), ilMath\_div(), ilMath\_mul(), ilMath\_pow(), ilMath\_sub(), getIntprecision(), getPrecision(), getRangeMax(), and getRangeMin().

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 167 of file class.assFormulaQuestionVariable.php.

168 {
169 return (double)$this->range_max;
170 }

References $range_max.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getRangeMaxTxt()

assFormulaQuestionVariable::getRangeMaxTxt ( )

◆ getRangeMin()

assFormulaQuestionVariable::getRangeMin ( )

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

154 {
155 return (double)$this->range_min;
156 }

References $range_min.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getRangeMinTxt()

assFormulaQuestionVariable::getRangeMinTxt ( )

◆ getUnit()

assFormulaQuestionVariable::getUnit ( )

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

178 {
179 return $this->unit;
180 }

References $unit.

Referenced by getBaseValue().

+ Here is the caller graph for this function:

◆ getValue()

assFormulaQuestionVariable::getValue ( )

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

104 {
105 return $this->value;
106 }

References $value.

◆ getVariable()

assFormulaQuestionVariable::getVariable ( )

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

139 {
140 return $this->variable;
141 }

References $variable.

◆ setIntprecision()

assFormulaQuestionVariable::setIntprecision (   $intprecision)

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

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

References $intprecision.

◆ setPrecision()

assFormulaQuestionVariable::setPrecision (   $precision)

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

122 {
123 $this->precision = $precision;
124 }

References $precision.

◆ setRandomValue()

assFormulaQuestionVariable::setRandomValue ( )

Definition at line 89 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 158 of file class.assFormulaQuestionVariable.php.

159 {
160 include_once "./Services/Math/classes/class.EvalMath.php";
161 $math = new EvalMath();
162 $math->suppress_errors = TRUE;
163 $result = $math->evaluate($range_max);
164 $this->range_max = $result;
165 }
$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 192 of file class.assFormulaQuestionVariable.php.

193 {
194 $this->range_max_txt = $range_max_txt;
195 }

References $range_max_txt.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setRangeMin()

assFormulaQuestionVariable::setRangeMin (   $range_min)

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

144 {
145 include_once "./Services/Math/classes/class.EvalMath.php";
146 $math = new EvalMath();
147 $math->suppress_errors = TRUE;
148 $result = $math->evaluate($range_min);
149
150 $this->range_min = $result;
151 }

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 202 of file class.assFormulaQuestionVariable.php.

203 {
204 $this->range_min_txt = $range_min_txt;
205 }

References $range_min_txt.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setUnit()

assFormulaQuestionVariable::setUnit (   $unit)

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

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

References $unit.

◆ setValue()

assFormulaQuestionVariable::setValue (   $value)

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

99 {
100 $this->value = $value;
101 }

References $value.

Referenced by setRandomValue().

+ Here is the caller graph for this function:

◆ setVariable()

assFormulaQuestionVariable::setVariable (   $variable)

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

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

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: