diff --git a/grade/export/lib.php b/grade/export/lib.php index 7dd9a847650..e8179438434 100644 --- a/grade/export/lib.php +++ b/grade/export/lib.php @@ -237,7 +237,24 @@ abstract class grade_export { if (is_array($this->displaytype) && !is_null($gradedisplayconst)) { $displaytype = $gradedisplayconst; } - return grade_format_gradevalue($grade->finalgrade, $this->grade_items[$grade->itemid], false, $displaytype, $this->decimalpoints); + + $gradeitem = $this->grade_items[$grade->itemid]; + + // We are going to store the min and max so that we can "reset" the grade_item for later. + $grademax = $gradeitem->grademax; + $grademin = $gradeitem->grademin; + + // Updating grade_item with this grade_grades min and max. + $gradeitem->grademax = $grade->get_grade_max(); + $gradeitem->grademin = $grade->get_grade_min(); + + $formattedgrade = grade_format_gradevalue($grade->finalgrade, $gradeitem, false, $displaytype, $this->decimalpoints); + + // Resetting the grade item in case it is reused. + $gradeitem->grademax = $grademax; + $gradeitem->grademin = $grademin; + + return $formattedgrade; } /** diff --git a/grade/export/txt/tests/behat/export.feature b/grade/export/txt/tests/behat/export.feature index 99fc29cce29..5670d2cddeb 100644 --- a/grade/export/txt/tests/behat/export.feature +++ b/grade/export/txt/tests/behat/export.feature @@ -19,6 +19,7 @@ Feature: I need to export grades as text And the following "activities" exist: | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | | assign | C1 | a1 | Test assignment name | Submit your online text | 1 | + | assign | C1 | a2 | Test assignment name 2 | Submit your online text | 1 | And I log in as "teacher1" And I follow "Course 1" And I navigate to "Grades" node in "Course administration" @@ -59,6 +60,8 @@ Feature: I need to export grades as text Then I should see "Student,1" And I should see "80.00 %" And I should see "B-" + And I should not see "40.00 %" + And I should not see ",F," @javascript Scenario: Export grades as text using real, percentages and letters @@ -71,4 +74,6 @@ Feature: I need to export grades as text Then I should see "Student,1" And I should see "80.00" And I should see "80.00 %" - And I should see "B-" \ No newline at end of file + And I should see "B-" + And I should not see "40.00 %" + And I should not see ",F," \ No newline at end of file