MDL-32249 completion: Round course grades and remove hardcoded string
authorAaron Barnes <aaronb@catalyst.net.nz>
Wed, 11 Apr 2012 06:54:40 +0000 (18:54 +1200)
committerAaron Barnes <aaronb@catalyst.net.nz>
Mon, 23 Apr 2012 00:18:44 +0000 (12:18 +1200)
lang/en/completion.php
lib/completion/completion_criteria_grade.php

index c55779e..93ed608 100644 (file)
@@ -118,6 +118,7 @@ $string['datepassed']='Date passed';
 $string['daysafterenrolment']='Days after enrolment';
 $string['durationafterenrolment']='Duration after enrolment';
 $string['fraction']='Fraction';
 $string['daysafterenrolment']='Days after enrolment';
 $string['durationafterenrolment']='Duration after enrolment';
 $string['fraction']='Fraction';
+$string['gradetopass']='{$a} to pass';
 $string['inprogress']='In progress';
 $string['manualcompletionby']='Manual completion by';
 $string['manualselfcompletion']='Manual self completion';
 $string['inprogress']='In progress';
 $string['manualcompletionby']='Manual completion by';
 $string['manualselfcompletion']='Manual self completion';
index e452454..ef195a2 100644 (file)
@@ -156,14 +156,14 @@ class completion_criteria_grade extends completion_criteria {
      * @return string
      */
     public function get_status($completion) {
      * @return string
      */
     public function get_status($completion) {
-        // Cast as floats to get rid of excess decimal places
-        $grade = (float) $this->get_grade($completion);
-        $gradepass = (float) $this->gradepass;
+        $grade = $this->get_grade($completion);
+        $gradepass = round($this->gradepass, 2).'%';
 
         if ($grade) {
 
         if ($grade) {
-            return $grade.'% ('.$gradepass.'% to pass)';
+            $grade = round($grade, 2);
+            return $grade.'% ('.get_string('gradetopass', 'completion', $gradepass).')';
         } else {
         } else {
-            return $gradepass.'% to pass';
+            return get_string('gradetopass', 'completion', $gradetopass);
         }
     }
 
         }
     }
 
@@ -232,10 +232,10 @@ class completion_criteria_grade extends completion_criteria {
         $details = array();
         $details['type'] = get_string('coursegrade', 'completion');
         $details['criteria'] = get_string('passinggrade', 'completion');
         $details = array();
         $details['type'] = get_string('coursegrade', 'completion');
         $details['criteria'] = get_string('passinggrade', 'completion');
-        $details['requirement'] = ((float)$this->gradepass).'%';
+        $details['requirement'] = round($this->gradepass, 2).'%';
         $details['status'] = '';
 
         $details['status'] = '';
 
-        $grade = (float)$this->get_grade($completion);
+        $grade = round($this->get_grade($completion), 2);
         if ($grade) {
             $details['status'] = $grade.'%';
         }
         if ($grade) {
             $details['status'] = $grade.'%';
         }