]> git.mjollnir.org Git - moodle.git/commitdiff
Creating course grade_category and course grade_item when not yet created and overvie...
authornicolasconnault <nicolasconnault>
Mon, 8 Oct 2007 09:54:51 +0000 (09:54 +0000)
committernicolasconnault <nicolasconnault>
Mon, 8 Oct 2007 09:54:51 +0000 (09:54 +0000)
grade/report/overview/lib.php

index d4b0424a5797a8830d4f2e9839abd08d2bf66153..11b31bc16927743e9127a0366133324b6d58167d 100644 (file)
@@ -81,7 +81,11 @@ class grade_report_overview extends grade_report {
         if ($courses = get_courses('all', null, 'c.id, c.shortname')) {
             foreach ($courses as $course) {
                 // Get course grade_item
-                $grade_item = grade_item::fetch(array('itemtype' => 'course', 'courseid' => $course->id));
+                if (!$grade_item = grade_item::fetch(array('itemtype' => 'course', 'courseid' => $course->id))) {
+                    // Create the course item if it doesn't already exist.
+                    $coursecat = grade_category::fetch_course_category($course->id);
+                    $grade_item = $coursecat->get_grade_item();
+                } 
 
                 // Get the grade
                 $finalgrade = get_field('grade_grades', 'finalgrade', 'itemid', $grade_item->id, 'userid', $this->user->id);