Calculates the real value of a grade

@param float $value percentual value from 0 to 100
@param float $max   the maximal grade
@return string
767680
public function real_grade_value($value, $max) {
        $localized = true;
        if (is_null($value) or $value === '') {
            return null;
        } elseif ($max == 0) {
            return 0;
        } else {
            return format_float($max * $value / 100, $this->gradedecimals, $localized);
        }
    }
905483
public function setMax($value)
    {
        $this->max = $value === null ? null : (int) $value;

        return $this;
    }
270702
public static function GAMMALN($value)
    {
        $value    = PHPExcel_Calculation_Functions::flattenSingleValue($value);

        if (is_numeric($value)) {
            if ($value <= 0) {
                return PHPExcel_Calculation_Functions::NaN();
            }
            return log(self::gamma($value));
        }
        return PHPExcel_Calculation_Functions::VALUE();
    }
844705
public function max($value)
    {
        $this->requiresCurrentField();
        $this->newObj['$max'][$this->currentField] = $value;
        return $this;
    }
536743
public static function VALUE($value = '')
    {
        $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);

        if (!is_numeric($value)) {
            $numberValue = str_replace(
                PHPExcel_Shared_String::getThousandsSeparator(),
                '',
                trim($value, " \t\n\r\0\x0B" . PHPExcel_Shared_String::getCurrencyCode())
            );
            if (is_numeric($numberValue)) {
                return (float) $numberValue;
            }

            $dateSetting = PHPExcel_Calculation_Functions::getReturnDateType();
            PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);

            if (strpos($value, ':') !== false) {
                $timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($value);
                if ($timeValue !== PHPExcel_Calculation_Functions::VALUE()) {
                    PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
                    return $timeValue;
                }
            }
            $dateValue = PHPExcel_Calculation_DateTime::DATEVALUE($value);
            if ($dateValue !== PHPExcel_Calculation_Functions::VALUE()) {
                PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
                return $dateValue;
            }
            PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);

            return PHPExcel_Calculation_Functions::VALUE();
        }
        return (float) $value;
    }
91150
public function check($value, IValidationData $data = null) {
        if (is_numeric($value)) {
            return $value <= $this->max;
        }

        return false;
    }
192725
protected function parseValue($value){
		switch( true ){
			case ($value === 'false' || $value === 'true'):
				return  ( $value === 'true' ) ? true : false ;
			
			case ctype_digit($value):
				return (int) $value; 

			case is_float($value):
				return (float) $value;

			default:
				return $value;
		}
	}
145733
public static function isGte($value, $max)
    {
        is_array($max) && $max = $max[0];
        if (!is_numeric($value)) {
            return false;
        } else {
            return $value >= $max;
        }
    }
749967
public static function isOptionalNumberRange($value, $min, $max)
    {
        /* No additional validations when the value is null. */
        if (null === $value) {

            return true;
        }

        return self::isRequiredNumberRange($value, $min, $max);
    }
1347357
public static function isGt($value, $max)
    {
        is_array($max) && $max = $max[0];
        if (!is_numeric($value)) {
            return false;
        } elseif (function_exists('bccomp')) {
            return bccomp($value, $max, 14) == 1;
        } else {
            return $value > $max;
        }
    }
776837
private function auto_update_max() {
        global $CFG, $DB;
        if ($this->aggregation != GRADE_AGGREGATE_SUM) {
            // not needed at all
            return;
        }

        // Find grade items of immediate children (category or grade items) and force site settings.
        $this->load_grade_item();
        $depends_on = $this->grade_item->depends_on();

        // Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they
        // wish to update the grades.
        $gradebookcalculationfreeze = 'gradebook_calculations_freeze_' . $this->courseid;
        $oldextracreditcalculation = isset($CFG->$gradebookcalculationfreeze) && ($CFG->$gradebookcalculationfreeze <= 20150627);
        // Only run if the gradebook isn't frozen.
        if (!$oldextracreditcalculation) {
            // Don't automatically update the max for calculated items.
            if ($this->grade_item->is_calculated()) {
                return;
            }
        }

        $items = false;
        if (!empty($depends_on)) {
            list($usql, $params) = $DB->get_in_or_equal($depends_on);
            $sql = "SELECT *
                      FROM {grade_items}
                     WHERE id $usql";
            $items = $DB->get_records_sql($sql, $params);
        }

        if (!$items) {

            if ($this->grade_item->grademax != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE) {
                $this->grade_item->grademax  = 0;
                $this->grade_item->grademin  = 0;
                $this->grade_item->gradetype = GRADE_TYPE_VALUE;
                $this->grade_item->update('aggregation');
            }
            return;
        }

        //find max grade possible
        $maxes = array();

        foreach ($items as $item) {

            if ($item->aggregationcoef > 0) {
                // extra credit from this activity - does not affect total
                continue;
            } else if ($item->aggregationcoef2 <= 0) {
                // Items with a weight of 0 do not affect the total.
                continue;
            }

            if ($item->gradetype == GRADE_TYPE_VALUE) {
                $maxes[$item->id] = $item->grademax;

            } else if ($item->gradetype == GRADE_TYPE_SCALE) {
                $maxes[$item->id] = $item->grademax; // 0 = nograde, 1 = first scale item, 2 = second scale item
            }
        }

        if ($this->can_apply_limit_rules()) {
            // Apply droplow and keephigh.
            $this->apply_limit_rules($maxes, $items);
        }
        $max = array_sum($maxes);

        // update db if anything changed
        if ($this->grade_item->grademax != $max or $this->grade_item->grademin != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE) {
            $this->grade_item->grademax  = $max;
            $this->grade_item->grademin  = 0;
            $this->grade_item->gradetype = GRADE_TYPE_VALUE;
            $this->grade_item->update('aggregation');
        }
    }
1312272
protected function isValueTooHigh($value)
    {
        // check if the value is not to high.
        if ($this->max !== null) {
            if (((function_exists('bcsub') && floatval(bcsub(
                $this->max,
                $value,
                4
            )) < 0) || $value > $this->max) && ((string)$this->max) != ((string)$value)
            ) {
                return true;
            }
        }
        return false;
    }
932766
function Check($value)
    {
        if (!ctype_digit(Str::TrimLeft($value, '-')))
            $this->error = self::HasNonDigits;
        else
        {
            $floatValue = (float)$value;
            if ($floatValue < $this->min)
            {
                 $this->error = self::ExceedsMin;
            }
            else if ($floatValue > $this->max)
                $this->error = self::ExceedsMax;
        }
        return $this->error == '';
    }
1124769
public static function float($value){

		$value = static::_nullValue($value);

		if($value !== null){

			// Avoid decimal separator nonsense
			$value = str_replace(',', '.', $value);
			$value = (float) $value;
		}

		return $value;
	}
1035596
private function getRatio(string $value) : float
    {
        if (strpos($value, '%') !== false) {
            $result = ((float)str_replace('%', '', $value)) / 100;
        } else {
            $result = $value;
        }

        return (float)$result;
    }
627769
private function getPercentage($value)
    {
        $percentage = ($value - $this->min) / ($this->max - $this->min) * 100;

        return $percentage;
    }
1296750
public function _validation_numeric_max($val, $max_val)
	{
		return $this->_empty($val) || floatval($val) <= floatval($max_val);
	}