Permalink
Browse files

MDL-32249 completion: Round course grades and remove hardcoded string

  • Loading branch information...
1 parent bd44a3b commit 2e67e5ecbb407cf80dc25f2c2fc7135eaea61ae5 Aaron Barnes committed Apr 11, 2012
Showing with 8 additions and 7 deletions.
  1. +1 −0 lang/en/completion.php
  2. +7 −7 lib/completion/completion_criteria_grade.php
View
@@ -118,6 +118,7 @@
$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';
@@ -154,14 +154,14 @@ public function get_type_title() {
* @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) {
- return $grade.'% ('.$gradepass.'% to pass)';
+ $grade = round($grade, 2);
+ return $grade.'% ('.get_string('gradetopass', 'completion', $gradepass).')';
} else {
- return $gradepass.'% to pass';
+ return get_string('gradetopass', 'completion', $gradetopass);
}
}
@@ -231,10 +231,10 @@ public function get_details($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'] = '';
- $grade = (float)$this->get_grade($completion);
+ $grade = round($this->get_grade($completion), 2);
if ($grade) {
$details['status'] = $grade.'%';
}

0 comments on commit 2e67e5e

Please sign in to comment.