3 * format grade using lang specific decimal point and thousand separator
4 * the result is suitable for printing on html page
5 * @param float $gradeval raw grade value pulled from db
6 * @return string $gradeval formatted grade value
8 function get_grade_clean($gradeval) {
11 if (is_null($gradeval)) {
14 // decimal points as specified by user
15 $decimals = get_user_preferences('grade_report_decimalpoints', $CFG->grade_report_decimalpoints);
16 $gradeval = number_format($gradeval, $decimals, get_string('decpoint', 'langconfig'), get_string('thousandsep', 'langconfig'));
22 // commenting this out, if this is added, we also need to find the number of decimal place preserved
23 // so it can go into number_format
25 $gradeval = rtrim(trim($gradeval, "0"), ".");
34 * Given a user input grade, format it to standard format i.e. no thousand separator, and . as decimal point
35 * @param string $gradeval grade value from user input, language specific format
36 * @return string - grade value for storage, en format
38 function format_grade($gradeval) {
40 $decimalpt = get_string('decpoint', 'langconfig');
41 $thousandsep = get_string('thousandsep', 'langconfig');
42 // replace decimal point with '.';
43 $gradeval = str_replace($decimalpt, '.', $gradeval);
44 // thousand separator is not useful
45 $gradeval = str_replace($thousandsep, '', $gradeval);
47 return clean_param($gradeval, PARAM_NUMBER);