51        function __construct(
$result, 
$range_min, 
$range_max, 
$tolerance, 
$unit, 
$formula, 
$points, 
$precision, 
$rating_simple = TRUE, 
$rating_sign = 33, 
$rating_value = 34, 
$rating_unit = 33, 
$result_type = 0)
 
   54                #       $this->setRangeMin((is_numeric($range_min)) ? $range_min : NULL); 
   55                #       $this->setRangeMax((is_numeric($range_max)) ? $range_max : NULL); 
   80                if(preg_match_all(
"/(\\\$r\\d+)/ims", 
$formula, $matches))
 
  102                return "(".$formula.
")";
 
  108                $resultunits = array();
 
  114                include_once 
"./Services/Math/classes/class.ilMath.php";
 
  115                include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  117                if(preg_match_all(
"/(\\\$v\\d+)/ims", 
$formula, $matches))
 
  119                        foreach($matches[1] as $variable)
 
  121                                $varObj  = $variables[$variable];
 
  122                                if(!is_object($varObj))
 
  126                                $value   = $varObj->getBaseValue();
 
  127                                $formula = preg_replace(
"/\\\$" . substr($variable, 1) . 
"(?![0-9]+)/", 
"(".$value.
")" . 
"\\1", 
$formula);
 
  131                $math->suppress_errors = TRUE;
 
  135                if(is_object($this->
getUnit()))
 
  142                if($use_precision == 
true)
 
  158                include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  161                while($i < 1000 && !$inRange)
 
  164                        if(preg_match_all(
"/(\\\$v\\d+)/ims", 
$formula, $matches))
 
  166                                foreach($matches[1] as $variable)
 
  168                                        $varObj = $variables[$variable];
 
  169                                        if(!is_object($varObj))
 
  173                                        $varObj->setRandomValue();
 
  174                                        $formula = preg_replace(
"/\\\$" . substr($variable, 1) . 
"(?![0-9]+)/", 
"(".$varObj->getBaseValue().
")" . 
"\\1", 
$formula);
 
  178                        $math->suppress_errors = TRUE;
 
  180                        $inRange               = (is_numeric(
$result)) ? TRUE : FALSE;
 
  206                include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  209                for($i = 0; $i < 1000; $i++)
 
  212                        if(preg_match_all(
"/(\\\$v\\d+)/ims", 
$formula, $matches))
 
  214                                foreach($matches[1] as $variable)
 
  216                                        $varObj = $variables[$variable];
 
  217                                        if(!is_object($varObj))
 
  221                                        $varObj->setRandomValue();
 
  222                                        $formula = preg_replace(
"/\\\$" . substr($variable, 1) . 
"(?![0-9]+)/", 
"(".$varObj->getBaseValue().
")" . 
"\\1", 
$formula);
 
  226                        $math->suppress_errors = TRUE;
 
  231                include_once 
"./Services/Math/classes/class.ilMath.php";
 
  232                if(is_object($this->
getUnit()))
 
  255                $value=str_replace(
' ', 
'',$value);
 
  257                include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  258                include_once 
"./Services/Math/classes/class.ilMath.php";
 
  261                $check_valid_chars = 
true;
 
  263                if(preg_match_all(
"/(\\\$v\\d+)/ims", 
$formula, $matches))
 
  265                        foreach($matches[1] as $variable)
 
  267                                $varObj = $variables[$variable];
 
  268                                if(!is_object($varObj))
 
  273                                if($varObj->getUnit() != NULL)
 
  276                                        if($varObj->getUnit()->getBaseUnit() != -1) #$this->
getUnit() != NULL)
 
  278                                                $tmp_value = $varObj->getValue() * $varObj->getUnit()->getFactor();
 
  282                                                $tmp_value = $varObj->getValue();
 
  287                                        $tmp_value = $varObj->getValue();
 
  290                                $formula = preg_replace(
"/\\\$" . substr($variable, 1) . 
"(?![0-9]+)/", 
"(".$tmp_value.
")" . 
"\\1", 
$formula);
 
  295                $math->suppress_errors = 
false;
 
  301                $has_valid_chars = preg_match(
"/^-?([0-9]*)(,|\\.|\\/){0,1}([0-9]*)([eE][\\+|-]([0-9])+)?$/", $value, $matches);
 
  302                if(!$has_valid_chars)
 
  304                        $check_valid_chars = 
false;
 
  306                else if($matches[2] == 
'/' && strtolower($matches[4]) == 
"e" && (!strlen($matches[1]) || !strlen($matches[3]) || $matches[3] == 0))
 
  308                        $check_valid_chars = 
false;
 
  314                                if(substr_count($value, 
'.') == 1 || substr_count($value, 
',') == 1)
 
  317                                        $frac_value = str_replace(
',', 
'.', $exp_val);
 
  321                                        $frac_value = $value;
 
  326                                if(substr_count($value, 
'/') >= 1)
 
  328                                        $check_fraction = FALSE;
 
  332                                        $check_fraction = TRUE; 
 
  338                                $exp_val = explode(
'/', $value);
 
  339                                if(count($exp_val) == 1)
 
  344                                                $check_fraction = TRUE;
 
  348                                                $check_fraction = FALSE;
 
  355                                        $frac_value = str_replace(
',', 
'.', $frac_value);
 
  359                                                $check_fraction = TRUE;
 
  364                                                if(!self::isCoprimeFraction($exp_val[0], $exp_val[1]))
 
  366                                                        $check_fraction = FALSE;
 
  371                                if(substr_count($value, 
'.') >= 1 || substr_count($value, 
',') >= 1)
 
  373                                        $check_fraction = FALSE;
 
  379                                if(substr_count($value, 
'.') == 1 || substr_count($value, 
',') == 1)
 
  381                                        $frac_value = str_replace(
',', 
'.', $value);
 
  383                                elseif( substr_count($value, 
'/') == 1 )
 
  385                                        $exp_val = explode(
'/', $value);
 
  390                                        $frac_value = $value;
 
  393                                $check_fraction = TRUE;
 
  398                if(is_object($this->
getUnit()))
 
  403                        if($this->
getUnit()->getBaseUnit() != -1)
 
  419                        if((
int)
$unit->getFactor() == 1)
 
  431                        if(isset($frac_value))
 
  438                if(isset($frac_value))
 
  454                if(is_object($this->
getUnit()))
 
  458                                if(
$unit->getId() != $this->getUnit()->getId())
 
  464                return $checkvalue && $checkunit && $check_fraction && $check_valid_chars;
 
  469                include_once 
"./Services/Math/classes/class.ilMath.php";
 
  473                if(($b1 <= $v1) && ($b2 >= $v1)) 
return TRUE;
 
  479                if((($v1 >= 0) && ($v2 >= 0)) || (($v1 <= 0) && ($v2 <= 0)))
 
  506                        include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  507                        include_once 
"./Services/Math/classes/class.ilMath.php";
 
  510                        if(preg_match_all(
"/(\\\$v\\d+)/ims", 
$formula, $matches))
 
  512                                foreach($matches[1] as $variable)
 
  514                                        $varObj = $variables[$variable];
 
  515                                        if(!is_object($varObj))
 
  519                                        if($varObj->getUnit() != NULL)
 
  522                                                if($varObj->getUnit()->getBaseUnit() != -1)
 
  524                                                        $tmp_value = $varObj->getValue() * $varObj->getUnit()->getFactor();
 
  528                                                        $tmp_value = $varObj->getValue();
 
  533                                                $tmp_value = $varObj->getValue();
 
  535                                        $formula = preg_replace(
"/\\\$" . substr($variable, 1) . 
"(?![0-9]+)/", 
"(".$tmp_value.
")" . 
"\\1", 
$formula);
 
  540                        $math->suppress_errors = TRUE;
 
  547                                        if((substr_count($value, 
'.') == 1) || (substr_count($value, 
',') == 1))
 
  550                                                $frac_value = str_replace(
',', 
'.', $exp_val);
 
  554                                                $frac_value = $value;
 
  556                                        $check_fraction = TRUE;
 
  559                                        $exp_val = explode(
'/', $value);
 
  560                                        if(count($exp_val) == 1)
 
  565                                                        $check_fraction = TRUE;
 
  569                                                        $check_fraction = FALSE;
 
  577                                                        $check_fraction = TRUE;
 
  582                                        $exp_val = explode(
'/', $value);
 
  583                                        if(count($exp_val) == 1)
 
  585                                                $check_fraction = FALSE;
 
  590                                                if(self::isCoprimeFraction($exp_val[0], $exp_val[1]))
 
  592                                                        $check_fraction = TRUE;
 
  598                                        $check_fraction = TRUE;
 
  603                        if(is_object($this->
getUnit()))
 
  606                                if($this->
getUnit()->getBaseUnit() != -1)
 
  619                                if(isset($frac_value))
 
  633                        if(is_object($this->
getUnit()))
 
  635                                $base1 = $units[
$unit];
 
  636                                if(is_object($base1)) $base1 = $units[$base1->getBaseUnit()];
 
  637                                $base2 = $units[$this->
getUnit()->getBaseUnit()];
 
  638                                if(is_object($base1) && is_object($base2) && $base1->getId() == $base2->getId())
 
  653                                return array(
"points" => $this->
getPoints());
 
  657                                return array(
"points" => 0);
 
  662                        include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  663                        include_once 
"./Services/Math/classes/class.ilMath.php";
 
  666                        if(preg_match_all(
"/(\\\$v\\d+)/ims", 
$formula, $matches))
 
  668                                foreach($matches[1] as $variable)
 
  670                                        $varObj  = $variables[$variable];
 
  671                                        $formula = preg_replace(
"/\\\$" . substr($variable, 1) . 
"(?![0-9]+)/", 
"(".$varObj->getBaseValue().
")" . 
"\\1", 
$formula);
 
  675                        $math->suppress_errors = TRUE;
 
  677                        if(is_object($this->
getUnit()))
 
  701                        if(is_object($this->
getUnit()))
 
  703                                $base1 = $units[
$unit];
 
  704                                if(is_object($base1)) $base1 = $units[$base1->getBaseUnit()];
 
  705                                $base2 = $units[$this->
getUnit()->getBaseUnit()];
 
  706                                if(is_object($base1) && is_object($base2) && $base1->getId() == $base2->getId())
 
  713                        $details[
'points'] = $totalpoints;
 
  741                include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  743                $math->suppress_errors = TRUE;
 
  759                        if(is_object($this->
getUnit()))
 
  761                                include_once 
"./Services/Math/classes/class.ilMath.php";
 
  777                include_once 
"./Services/Math/classes/class.EvalMath.php";
 
  779                $math->suppress_errors = TRUE;
 
  794                        if(is_object($this->
getUnit()))
 
  796                                include_once 
"./Services/Math/classes/class.ilMath.php";
 
  895                $this->result_type = $a_result_type;
 
  929                        FROM il_qpl_qst_fq_res 
  930                        WHERE question_fi = %s 
  932                        array(
'integer', 
'text'),
 
  933                        array($a_qst_id, $a_result));
 
  937                return $row[
'result_type'];
 
  945                return $gcd == 1 ? true : 
false;
 
  950                $to_string   = (string) $decimal_value;
 
  951                $is_negative = strpos($to_string, 
'-') === 0;
 
  954                        $decimal_value = substr($decimal_value, 1);
 
  960                $b = 1 / $decimal_value;
 
  965                                $h1 = $a * $h1 + $h2;
 
  968                                $k1 = $a * $k1 + $k2;
 
  971                        }
while ((abs($decimal_value - $h1 / $k1) > $decimal_value * 
$tolerance) || ( $k1 < 0 || $b < 0 ));
 
  980                        $checkResult = ($h1/$k1);
 
  985                        $checkResult = ($h1/$k1)*-1;
 
  987                if($to_string == $checkResult.
'' || $checkResult.
'' == 
$result)
 
  993                        return array($to_string,
$result);
 
 1015                        SELECT * FROM il_qpl_qst_fq_res_unit  
 1016                        WHERE question_fi = %s 
 1018                        array(
'integer'), array($question_id));
 
 1023                        $this->available_units[
$row[
'result']][] = 
$row[
'unit_fi'] ;
 
static _mul($left_operand, $right_operand, $scale=50)
static _round($value, $precision=0)
static _div($left_operand, $right_operand, $scale=50)
static _equals($value1, $value2, $scale)
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.