Formats the grade to the specified decimal points
@param float $grade
@return string
488686
private function activity_format_grade($grade) {
        if (is_null($grade)) {
            return get_string('notyetgraded', 'block_activity_results');
        }
        return format_float($grade, $this->config->decimalpoints);
    }
917048
public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
    {
        return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
    }
1056211
public function withPrefix($values, string $currency = null, int $decimal_points = null): string
    {
        [$className, $value] = $this->classAndValue($values, $currency);

        return (new $className)->prefix($value, $decimal_points);
    }
461020
public function display_grade($grade, $editable, $userid, $modified) {
        if ($this->is_downloading()) {
            if ($this->assignment->get_instance()->grade >= 0) {
                if ($grade == -1 || $grade === null) {
                    return '';
                }
                $gradeitem = $this->assignment->get_grade_item();
                return format_float($grade, $gradeitem->get_decimals());
            } else {
                // This is a custom scale.
                $scale = $this->assignment->display_grade($grade, false);
                if ($scale == '-') {
                    $scale = '';
                }
                return $scale;
            }
        }
        return $this->assignment->display_grade($grade, $editable, $userid, $modified);
    }
487109
public function numberFormat()
    {
        $num = (float) ((string) $this->getRequiredParameter('number'));
        $decimals = intval((string)$this->getParameter('decimals'));
        return number_format($num, $decimals);
    }
1072726
public function setGrade($grade)
    {
        $allowedValues = $this->getGradeAllowableValues();
        if (!is_null($grade) && !in_array($grade, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'grade', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['grade'] = $grade;

        return $this;
    }
1209293
public function get_grade() {
        $grade = $this->get_rubric_filling();

        if (!($scores = $this->get_controller()->get_min_max_score()) || $scores['maxscore'] <= $scores['minscore']) {
            return -1;
        }

        $graderange = array_keys($this->get_controller()->get_grade_range());
        if (empty($graderange)) {
            return -1;
        }
        sort($graderange);
        $mingrade = $graderange[0];
        $maxgrade = $graderange[sizeof($graderange) - 1];

        $curscore = 0;
        foreach ($grade['criteria'] as $id => $record) {
            $curscore += $this->get_controller()->get_definition()->rubric_criteria[$id]['levels'][$record['levelid']]['score'];
        }

        $allowdecimals = $this->get_controller()->get_allow_grade_decimals();
        $options = $this->get_controller()->get_options();

        if ($options['lockzeropoints']) {
            // Grade calculation method when 0-level is locked.
            $grade = max($mingrade, $curscore / $scores['maxscore'] * $maxgrade);
            return $allowdecimals ? $grade : round($grade, 0);
        } else {
            // Alternative grade calculation method.
            $gradeoffset = ($curscore - $scores['minscore']) / ($scores['maxscore'] - $scores['minscore']) * ($maxgrade - $mingrade);
            return ($allowdecimals ? $gradeoffset : round($gradeoffset, 0)) + $mingrade;
        }
    }
1198263
public function text_for_gradebook(stdClass $grade) {
        $feedbackcomments = $this->get_feedback_comments($grade->id);
        if ($feedbackcomments) {
            return $feedbackcomments->commenttext;
        }
        return '';
    }
410406
public function format_feedback($feedback, $grade = null) {
        $string = $feedback->feedback;
        if (!empty($grade)) {
            // Rewrite links to get the export working for 36, refer MDL-63488.
            $string = file_rewrite_pluginfile_urls(
                $feedback->feedback,
                'pluginfile.php',
                $grade->get_context()->id,
                GRADE_FILE_COMPONENT,
                GRADE_FEEDBACK_FILEAREA,
                $grade->id
            );
        }

        return strip_tags(format_text($string, $feedback->feedbackformat));
    }
860836
public function formatSimple()
    {
        return number_format(
            $this->getValue(),
            $this->currency->getPrecision(),
            $this->currency->getDecimalMark(),
            $this->currency->getThousandsSeparator()
        );
    }
1186382
public function numberFormat($decimals = 0, $thousandSeparator = '.', $decimalSeparator = ',')
    {
        $decimalSeparator = $thousandSeparator === '.' ? ',' : '.';

        return number_format($this->amount, $decimals, $decimalSeparator, $thousandSeparator);
    }
95762
public function format($number) {
    if ((float) $number != $number) {
      throw new \InvalidArgumentException('Number has no valid float value.');
    }
    $sign = (int) ($number < 0);

    // Split the number in major and minor units, and make sure there is a
    // minor unit at all.
    $number = explode('.', abs($number));
    $number += array(
      self::MINOR => '',
    );

    $digits = array(
      str_split($number[self::MAJOR]),
      strlen($number[self::MINOR]) ? str_split($number[self::MINOR]) : array(),
    );

    $symbols = $this->cloneNumberPatternSymbols($this->symbols[$sign]);
    $this->process($symbols[$sign][self::MAJOR], $digits[self::MAJOR]);
    // Integer formatting defaults from right to left, but minor units should
    // be formatted from left to right, so reverse all data and results.
    $symbols_minor = array_reverse($symbols[$sign][self::MINOR]);
    $this->process($symbols_minor, array_reverse($digits[self::MINOR]));
    foreach ($symbols[$sign][self::MINOR] as $symbol) {
      if (!is_null($symbol->replacement)) {
        $symbol->replacement = strrev($symbol->replacement);
      }
    }

    // Prepare the output string.
    $output = array(
      self::MAJOR => '',
      self::MINOR => '',
    );
    foreach ($symbols[$sign] as $fragment => $fragment_symbols) {
      $this->replacePlaceholders($fragment_symbols);
      foreach ($fragment_symbols as $symbol) {
        $output[$fragment] .= !is_null($symbol->replacement) ? $symbol->replacement : $symbol->symbol;
      }
    }

    return $output[self::MAJOR] . $this->getReplacement(self::SYMBOL_SPECIAL_DECIMAL_SEPARATOR) . $output[self::MINOR];
  }
394714
public static function format($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',')
    {
        return \number_format($number, $decimals, $decPoint, $thousandsSep);
    }
88560
public function format_grade_for_log(stdClass $grade) {
        global $DB;

        $user = $DB->get_record('user', array('id' => $grade->userid), '*', MUST_EXIST);

        $info = get_string('gradestudent', 'assign', array('id'=>$user->id, 'fullname'=>fullname($user)));
        if ($grade->grade != '') {
            $info .= get_string('grade') . ': ' . $this->display_grade($grade->grade, false) . '. ';
        } else {
            $info .= get_string('nograde', 'assign');
        }
        return $info;
    }
1337416
protected function validate_grade($value) {
        if ($value !== null) {
            if ($value <= 0) {
                return new lang_string('invalidgrade', 'core_competency');
            }

            // TODO MDL-52243 Use a core method to validate the grade_scale item.
            // Check if grade exist in the scale item values.
            $competency = $this->get_competency();
            if (!array_key_exists($value - 1, $competency->get_scale()->scale_items)) {
                return new lang_string('invalidgrade', 'core_competency');
            }
        }

        return true;
    }
885120
public function format_grade($grade, $gradedisplayconst = null) {
        $displaytype = $this->displaytype;
        if (is_array($this->displaytype) && !is_null($gradedisplayconst)) {
            $displaytype = $gradedisplayconst;
        }

        $gradeitem = $this->grade_items[$grade->itemid];

        // We are going to store the min and max so that we can "reset" the grade_item for later.
        $grademax = $gradeitem->grademax;
        $grademin = $gradeitem->grademin;

        // Updating grade_item with this grade_grades min and max.
        $gradeitem->grademax = $grade->get_grade_max();
        $gradeitem->grademin = $grade->get_grade_min();

        $formattedgrade = grade_format_gradevalue($grade->finalgrade, $gradeitem, false, $displaytype, $this->decimalpoints);

        // Resetting the grade item in case it is reused.
        $gradeitem->grademax = $grademax;
        $gradeitem->grademin = $grademin;

        return $formattedgrade;
    }
785375
public function formatCurrency($value, $currency, $precision=2)
    {
        $newValue = trim($value, " \0\x0B$currency");
        if (!is_numeric($newValue)) {
            return $value;
        }

        $pattern = $this->getPattern($value, 'Intl_NumberFormatCurrency');

        if ($newValue == round($newValue)) {
            // if no fraction digits available, don't show any
            $value = $this->formatNumberWithPattern($pattern, $newValue, 0, 0);
        } else {
            // show given count of fraction digits otherwise
            $value = $this->formatNumberWithPattern($pattern, $newValue, $precision, $precision);
        }

        return str_replace('¤', $currency, $value);
    }