~ubuntu-branches/ubuntu/saucy/moodle/saucy

« back to all changes in this revision

Viewing changes to grade/grading/form/rubric/lib.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-09-09 15:22:35 UTC
  • mfrom: (1.1.17) (3.1.29 sid)
  • Revision ID: package-import@ubuntu.com-20130909152235-f5g7gphaseb84qeu
Tags: 2.5.2-1
* New upstream version: 2.5.2.
  - Incorporates S3 security patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
814
814
    /**
815
815
     * Calculates the grade to be pushed to the gradebook
816
816
     *
817
 
     * @return int the valid grade from $this->get_controller()->get_grade_range()
 
817
     * @return float|int the valid grade from $this->get_controller()->get_grade_range()
818
818
     */
819
819
    public function get_grade() {
820
 
        global $DB, $USER;
821
820
        $grade = $this->get_rubric_filling();
822
821
 
823
822
        if (!($scores = $this->get_controller()->get_min_max_score()) || $scores['maxscore'] <= $scores['minscore']) {
836
835
        foreach ($grade['criteria'] as $id => $record) {
837
836
            $curscore += $this->get_controller()->get_definition()->rubric_criteria[$id]['levels'][$record['levelid']]['score'];
838
837
        }
839
 
        return round(($curscore-$scores['minscore'])/($scores['maxscore']-$scores['minscore'])*($maxgrade-$mingrade), 0) + $mingrade;
 
838
        $gradeoffset = ($curscore-$scores['minscore'])/($scores['maxscore']-$scores['minscore'])*($maxgrade-$mingrade);
 
839
        if ($this->get_controller()->get_allow_grade_decimals()) {
 
840
            return $gradeoffset + $mingrade;
 
841
        }
 
842
        return round($gradeoffset, 0) + $mingrade;
840
843
    }
841
844
 
842
845
    /**