protected function errors_to_grade($numerrors) {
        $grade = 100.00000;
        for ($i = 1; $i <= $numerrors; $i++) {
            if (isset($this->mappings[$i])) {
                $grade = $this->mappings[$i]->grade;
            }
        }
        if ($grade > 100.00000) {
            $grade = 100.00000;
        }
        if ($grade < 0.00000) {
            $grade = 0.00000;
        }
        return grade_floatval($grade);
    }
protected function errors_to_grade($numerrors) {
        $grade = 100.00000;
        for ($i = 1; $i <= $numerrors; $i++) {
            if (isset($this->mappings[$i])) {
                $grade = $this->mappings[$i]->grade;
            }
        }
        if ($grade > 100.00000) {
            $grade = 100.00000;
        }
        if ($grade < 0.00000) {
            $grade = 0.00000;
        }
        return grade_floatval($grade);
    }
protected function errors_to_grade ( $ numerrors ) { $ grade = 100.00000 ; for ( $ i = 1 ; $ i <= $ numerrors ; $ i ++ ) { if ( isset ( $ this -> mappings [ $ i ] ) ) { $ grade = $ this -> mappings [ $ i ] -> grade ; } } if ( $ grade > 100.00000 ) { $ grade = 100.00000 ; } if ( $ grade < 0.00000 ) { $ grade = 0.00000 ; } return grade_floatval ( $ grade ) ; }
Returns a grade 0.00000 to 100.00000 for the given number of errors

This is where we use the mapping table defined by the teacher. If a grade for the given
number of errors (negative assertions) is not defined, the most recently defined one is used.
Example of the defined mapping:
Number of errors | Grade
0 | 100%  (always)
1 | -     (not defined)
2 | 80%
3 | 60%
4 | -
5 | 30%
6 | 0%
With this mapping, one error is mapped to 100% grade and 4 errors is mapped to 60%.

@param mixed $numerrors Number of errors
@return float          Raw grade (0.00000 to 100.00000) for the given number of negative assertions
Returns a grade 0 . 00000 to 100 . 00000 for the given number of errors