ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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
 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

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().

{
$this->variable = $variable;
$this->unit = $unit;
$this->value = NULL;
$this->precision = $precision;
$this->intprecision = $intprecision;
}

+ Here is the call graph for this function:

Member Function Documentation

assFormulaQuestionVariable::getBaseValue ( )

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

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

{
if(!is_object($this->getUnit()))
{
return $this->value;
}
else
{
include_once "./Services/Math/classes/class.ilMath.php";
return ilMath::_mul($this->value, $this->getUnit()->getFactor());
}
}

+ Here is the call graph for this function:

assFormulaQuestionVariable::getIntprecision ( )

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

References $intprecision.

Referenced by getRandomValue().

{
}

+ Here is the caller graph for this function:

assFormulaQuestionVariable::getPrecision ( )

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

References $precision.

Referenced by getRandomValue().

{
//@todo TEST
return (int)$this->precision;
}

+ Here is the caller graph for this function:

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().

{
// @todo check this
include_once "./Services/Math/classes/class.ilMath.php";
$mul = ilMath::_pow(10, $this->getPrecision());
$r1 = round(ilMath::_mul($this->getRangeMin(), $mul));
$r2 = round(ilMath::_mul($this->getRangeMax(), $mul));
$calcval = $this->getRangeMin() - 1;
//test
$roundedRangeMIN = round($this->getRangeMin(), $this->getPrecision());
$roundedRangeMAX = round($this->getRangeMax(), $this->getPrecision());
while($calcval < $roundedRangeMIN || $calcval > $roundedRangeMAX)
// while($calcval < $this->getRangeMin() || $calcval > $this->getRangeMax())
{
$rnd = mt_rand($r1, $r2);
$calcval = ilMath::_div($rnd, $mul, $this->getPrecision());
if(($this->getPrecision() == 0) && ($this->getIntprecision() != 0))
{
if($this->getIntprecision() > 0)
{
$modulo = $calcval % $this->getIntprecision();
if($modulo != 0)
{
if($modulo < ilMath::_div($this->getIntprecision(), 2))
{
$calcval = ilMath::_sub($calcval, $modulo, $this->getPrecision());
}
else
{
$calcval = ilMath::_add($calcval, ilMath::_sub($this->getIntprecision(), $modulo, $this->getPrecision()), $this->getPrecision());
}
}
}
}
}
return $calcval;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assFormulaQuestionVariable::getRangeMax ( )

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

References $range_max.

Referenced by getRandomValue().

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

+ Here is the caller graph for this function:

assFormulaQuestionVariable::getRangeMaxTxt ( )

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

References $range_max_txt.

{
}
assFormulaQuestionVariable::getRangeMin ( )

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

References $range_min.

Referenced by getRandomValue().

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

+ Here is the caller graph for this function:

assFormulaQuestionVariable::getRangeMinTxt ( )

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

References $range_min_txt.

{
}
assFormulaQuestionVariable::getUnit ( )

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

References $unit.

Referenced by getBaseValue().

{
return $this->unit;
}

+ Here is the caller graph for this function:

assFormulaQuestionVariable::getValue ( )

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

References $value.

{
return $this->value;
}
assFormulaQuestionVariable::getVariable ( )

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

References $variable.

{
}
assFormulaQuestionVariable::setIntprecision (   $intprecision)

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

References $intprecision.

{
$this->intprecision = $intprecision;
}
assFormulaQuestionVariable::setPrecision (   $precision)

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

References $precision.

{
$this->precision = $precision;
}
assFormulaQuestionVariable::setRandomValue ( )

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

References getRandomValue(), and setValue().

{
$this->setValue($this->getRandomValue());
}

+ Here is the call graph for this function:

assFormulaQuestionVariable::setRangeMax (   $range_max)

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

References $range_max, and $result.

Referenced by __construct().

{
include_once "./Services/Math/classes/class.EvalMath.php";
$math = new EvalMath();
$math->suppress_errors = TRUE;
$result = $math->evaluate($range_max);
$this->range_max = $result;
}

+ Here is the caller graph for this function:

assFormulaQuestionVariable::setRangeMaxTxt (   $range_max_txt)

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

References $range_max_txt.

Referenced by __construct().

{
$this->range_max_txt = $range_max_txt;
}

+ Here is the caller graph for this function:

assFormulaQuestionVariable::setRangeMin (   $range_min)

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

References $range_min, and $result.

Referenced by __construct().

{
include_once "./Services/Math/classes/class.EvalMath.php";
$math = new EvalMath();
$math->suppress_errors = TRUE;
$result = $math->evaluate($range_min);
$this->range_min = $result;
}

+ Here is the caller graph for this function:

assFormulaQuestionVariable::setRangeMinTxt (   $range_min_txt)

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

References $range_min_txt.

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

{
$this->range_min_txt = $range_min_txt;
}

+ Here is the caller graph for this function:

assFormulaQuestionVariable::setUnit (   $unit)

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

References $unit.

{
$this->unit = $unit;
}
assFormulaQuestionVariable::setValue (   $value)

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

References $value.

Referenced by setRandomValue().

{
$this->value = $value;
}

+ Here is the caller graph for this function:

assFormulaQuestionVariable::setVariable (   $variable)

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

References $variable.

{
$this->variable = $variable;
}

Field Documentation

assFormulaQuestionVariable::$intprecision
private
assFormulaQuestionVariable::$precision
private

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

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

assFormulaQuestionVariable::$range_max
private

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

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

assFormulaQuestionVariable::$range_max_txt
private

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

Referenced by getRangeMaxTxt(), and setRangeMaxTxt().

assFormulaQuestionVariable::$range_min
private

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

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

assFormulaQuestionVariable::$range_min_txt
private

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

Referenced by getRangeMinTxt(), and setRangeMinTxt().

assFormulaQuestionVariable::$unit
private

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

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

assFormulaQuestionVariable::$value
private

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

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

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: