MDL-50959 gradebook: fix XML grade export
authorSimey Lameze <simey@moodle.com>
Thu, 17 Sep 2015 00:36:20 +0000 (08:36 +0800)
committerDavid Monllao <davidm@moodle.com>
Thu, 17 Sep 2015 02:34:50 +0000 (10:34 +0800)
grade/export/xml/grade_export_xml.php

index 4f3d99f..c91122b 100644 (file)
@@ -68,7 +68,6 @@ class grade_export_xml extends grade_export {
             foreach ($userdata->grades as $itemid => $grade) {
                 $grade_item = $this->grade_items[$itemid];
                 $grade->grade_item =& $grade_item;
             foreach ($userdata->grades as $itemid => $grade) {
                 $grade_item = $this->grade_items[$itemid];
                 $grade->grade_item =& $grade_item;
-                $gradestr = $this->format_grade($grade, $this->displaytype); // no formating for now
 
                 // MDL-11669, skip exported grades or bad grades (if setting says so)
                 if ($export_tracking) {
 
                 // MDL-11669, skip exported grades or bad grades (if setting says so)
                 if ($export_tracking) {
@@ -90,10 +89,15 @@ class grade_export_xml extends grade_export {
                 fwrite($handle,  "\t\t<student>{$user->idnumber}</student>\n");
                 // Format and display the grade in the selected display type (real, letter, percentage).
                 if (is_array($this->displaytype)) {
                 fwrite($handle,  "\t\t<student>{$user->idnumber}</student>\n");
                 // Format and display the grade in the selected display type (real, letter, percentage).
                 if (is_array($this->displaytype)) {
+                    // Grades display type came from the return of export_bulk_export_data() on grade publishing.
                     foreach ($this->displaytype as $gradedisplayconst) {
                         $gradestr = $this->format_grade($grade, $gradedisplayconst);
                         fwrite($handle,  "\t\t<score>$gradestr</score>\n");
                     }
                     foreach ($this->displaytype as $gradedisplayconst) {
                         $gradestr = $this->format_grade($grade, $gradedisplayconst);
                         fwrite($handle,  "\t\t<score>$gradestr</score>\n");
                     }
+                } else {
+                    // Grade display type submitted directly from the grade export form.
+                    $gradestr = $this->format_grade($grade, $this->displaytype);
+                    fwrite($handle,  "\t\t<score>$gradestr</score>\n");
                 }
 
                 if ($this->export_feedback) {
                 }
 
                 if ($this->export_feedback) {