? 613352_grade_summary_block.patch
? LICENSE.txt
Index: gradebook.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gradebook/gradebook.module,v
retrieving revision 1.15.4.2.2.14
diff -u -r1.15.4.2.2.14 gradebook.module
--- gradebook.module	18 Nov 2009 11:51:15 -0000	1.15.4.2.2.14
+++ gradebook.module	20 Nov 2009 02:30:01 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: gradebook.module,v 1.15.4.2.2.14 2009/11/18 11:51:15 mgn Exp $
+// $Id$
 /**
  * @file
  * Provides a simple gradebook
@@ -958,6 +958,7 @@
 function _gradebook_block_list() {
   $block = array();
   $block[0]['info'] = t('My Assignments');
+  $block[1]['info'] = t('My Course Grades');
   return $block;
 }
 
@@ -1006,6 +1007,34 @@
         $block['content'] = '<div class="gradebook_block">'. $block['content'] .'</div>';
       }
       break;
+    case 1:
+      global $user;
+      $user = user_load(array('uid' => $user->uid));
+      $uid = $user->uid;
+      // Get overall grades for each user all grades assignments for user and display in a block.
+      $vid = gradebookapi_get_vid();
+      $result = db_query('SELECT DISTINCT t.tid FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE h.parent = 0 AND t.vid = %d', $vid);
+      $headers = array(t('Course'), t('Grade'));
+      $rows = array();
+      while ($tid = db_result($result)) {
+        $gradebook = gradebookapi_gradebook_load($tid);
+        if (gradebookapi_is_student($gradebook)) {
+          $grade = gradebookapi_get_term_grade($uid, $gradebook->tid);
+          $row = array();
+          $row[] = l($gradebook->name,'gradebook/'. $tid);
+          // Get the term grades.
+          $row[] = theme('gradebook_term_grade', $gradebook, $grade, TRUE);
+          $rows[] = $row;
+        }
+      }
+      if (!empty($rows)) {
+        $block['subject'] =  t('Course Grades');
+        $block['content'] = theme('table', $headers, $rows);
+        if (!empty($block['content'])) {
+          $block['content'] = '<div class="gradebook_summary_block">'. $block['content'] .'</div>';
+        }
+      }
+      break;
   }
   return $block;
 }
