ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 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 101 of file class.assFormulaQuestionVariable.php.

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

102  {
103  if (!is_object($this->getUnit())) {
104  return $this->value;
105  } else {
106  include_once "./Services/Math/classes/class.ilMath.php";
107  return ilMath::_mul($this->value, $this->getUnit()->getFactor());
108  }
109  }
static _mul($left_operand, $right_operand, $scale=50)
+ Here is the call graph for this function:

◆ getIntprecision()

assFormulaQuestionVariable::getIntprecision ( )

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

References $intprecision.

Referenced by getRandomValue().

+ Here is the caller graph for this function:

◆ getPrecision()

assFormulaQuestionVariable::getPrecision ( )

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

References $precision.

Referenced by getRandomValue().

117  {
118  //@todo TEST
119 
120  return (int) $this->precision;
121  }
+ Here is the caller graph for this function:

◆ getRandomValue()

assFormulaQuestionVariable::getRandomValue ( )

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

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

Referenced by setRandomValue().

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  $rnd = mt_rand($r1, $r2);
65  $calcval = ilMath::_div($rnd, $mul, $this->getPrecision());
66  if (($this->getPrecision() == 0) && ($this->getIntprecision() != 0)) {
67  if ($this->getIntprecision() > 0) {
68  $modulo = $calcval % $this->getIntprecision();
69  if ($modulo != 0) {
70  if ($modulo < ilMath::_div($this->getIntprecision(), 2)) {
71  $calcval = ilMath::_sub($calcval, $modulo, $this->getPrecision());
72  } else {
73  $calcval = ilMath::_add($calcval, ilMath::_sub($this->getIntprecision(), $modulo, $this->getPrecision()), $this->getPrecision());
74  }
75  }
76  }
77  }
78  }
79  return $calcval;
80  }
static _div($left_operand, $right_operand, $scale=50)
static _pow($left_operand, $right_operand, $scale=50)
static _add($left_operand, $right_operand, $scale=50)
static _mul($left_operand, $right_operand, $scale=50)
static _sub($left_operand, $right_operand, $scale=50)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRangeMax()

assFormulaQuestionVariable::getRangeMax ( )

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

References $range_max.

Referenced by getRandomValue().

158  {
159  return (double) $this->range_max;
160  }
+ Here is the caller graph for this function:

◆ getRangeMaxTxt()

assFormulaQuestionVariable::getRangeMaxTxt ( )

◆ getRangeMin()

assFormulaQuestionVariable::getRangeMin ( )

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

References $range_min.

Referenced by getRandomValue().

144  {
145  return (double) $this->range_min;
146  }
+ Here is the caller graph for this function:

◆ getRangeMinTxt()

assFormulaQuestionVariable::getRangeMinTxt ( )

◆ getUnit()

assFormulaQuestionVariable::getUnit ( )

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

References $unit.

Referenced by getBaseValue().

+ Here is the caller graph for this function:

◆ getValue()

assFormulaQuestionVariable::getValue ( )

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

References $value.

◆ getVariable()

assFormulaQuestionVariable::getVariable ( )

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

References $variable.

Referenced by assFormulaQuestionGUI\isSaveCommand().

+ Here is the caller graph for this function:

◆ setIntprecision()

assFormulaQuestionVariable::setIntprecision (   $intprecision)

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

References $intprecision.

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

◆ setPrecision()

assFormulaQuestionVariable::setPrecision (   $precision)

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

References $precision.

112  {
113  $this->precision = $precision;
114  }

◆ setRandomValue()

assFormulaQuestionVariable::setRandomValue ( )

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

References $range_max, and $result.

Referenced by __construct().

149  {
150  include_once "./Services/Math/classes/class.EvalMath.php";
151  $math = new EvalMath();
152  $math->suppress_errors = true;
153  $result = $math->evaluate($range_max);
154  $this->range_max = $result;
155  }
$result
+ Here is the caller graph for this function:

◆ setRangeMaxTxt()

assFormulaQuestionVariable::setRangeMaxTxt (   $range_max_txt)

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

References $range_max_txt.

Referenced by __construct().

183  {
184  $this->range_max_txt = $range_max_txt;
185  }
+ Here is the caller graph for this function:

◆ setRangeMin()

assFormulaQuestionVariable::setRangeMin (   $range_min)

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

References $range_min, and $result.

Referenced by __construct().

134  {
135  include_once "./Services/Math/classes/class.EvalMath.php";
136  $math = new EvalMath();
137  $math->suppress_errors = true;
138  $result = $math->evaluate($range_min);
139 
140  $this->range_min = $result;
141  }
$result
+ Here is the caller graph for this function:

◆ setRangeMinTxt()

assFormulaQuestionVariable::setRangeMinTxt (   $range_min_txt)

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

References $range_min_txt.

Referenced by __construct(), and assFormulaQuestionGUI\writePostData().

193  {
194  $this->range_min_txt = $range_min_txt;
195  }
+ Here is the caller graph for this function:

◆ setUnit()

assFormulaQuestionVariable::setUnit (   $unit)

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

References $unit.

163  {
164  $this->unit = $unit;
165  }

◆ setValue()

assFormulaQuestionVariable::setValue (   $value)

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

References $value.

Referenced by setRandomValue().

92  {
93  $this->value = $value;
94  }
+ Here is the caller graph for this function:

◆ setVariable()

assFormulaQuestionVariable::setVariable (   $variable)

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

References $variable.

124  {
125  $this->variable = $variable;
126  }

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: