Index: /WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTables.py	(revision 4035)
+++ /WAeUP_SRP/trunk/WAeUPTables.py	(revision 4036)
@@ -1668,4 +1668,50 @@
     ###)
     
+    def getYearGroupAverage(self,session_id,level_id): ###(
+        query = Eq('session_id',session_id) & Eq('level_id',level_id)
+        course_results = self.course_results.evalAdvancedQuery(query)
+        yga1 = 0
+        counter1 = 0
+        yga2 = 0
+        counter2 = 0
+        yga3 = 0
+        counter3 = 0        
+        #import pdb;pdb.set_trace()
+        for brain in course_results:
+            try:
+                if not float(brain.ca1) + float(brain.ca2) + float(brain.exam) > 0:
+                    continue
+                code = brain.code                
+                res = self.courses_catalog.evalAdvancedQuery(Eq('code',code))
+                if res:
+                    course = res[0]
+                    # The courses_catalog contains strings and integers in its semester field.
+                    # Maybe this can be fixed by reindexing the catalog. The schema of course says 'CPS Int Field'.
+                    semester = str(course.semester)
+                else:
+                    semester = ''
+                if semester == '1':
+                    counter1 += 1
+                    yga1 += float(brain.ca1) + float(brain.ca2) + float(brain.exam)
+                elif semester == '2':
+                    counter2 += 1
+                    yga2 += float(brain.ca1) + float(brain.ca2) + float(brain.exam)          
+                if semester == '3':
+                    counter3 += 1
+                    yga3 += float(brain.ca1) + float(brain.ca2) + float(brain.exam)
+            except:
+                continue                
+        if counter1:
+            yga1 /= counter1
+            yga1 = '%.2f' % yga1    
+        if counter2:
+            yga2 /= counter2
+            yga2 = '%.2f' % yga2   
+        if counter3:
+            yga3 /= counter3
+            yga3 = '%.2f' % yga3                                    
+        return yga1, yga2, yga3, counter1, counter2, counter3
+    ###)
+    
     def exportRemoveAllCourses(self,student_id,export=False,remove=False): ###(
         ""
Index: /WAeUP_SRP/trunk/skins/waeup_ois/academic_report_slip.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_ois/academic_report_slip.pt	(revision 4035)
+++ /WAeUP_SRP/trunk/skins/waeup_ois/academic_report_slip.pt	(revision 4036)
@@ -12,5 +12,5 @@
                                        term_complete info/complete1;
                                        term options/term;
-                                       sem_series python:(('Term One','normal1','complete1','score_calc_average_1'),('Term Two','normal2','complete2','score_calc_average_2'),('Term Three','normal3','complete3','score_calc_average_3'));
+                                       sem_series python:(('Term One','normal1','complete1','score_calc_average_1','yga1','counter1'),('Term Two','normal2','complete2','score_calc_average_2','yga2','counter2'),('Term Three','normal3','complete3','score_calc_average_3','yga3','counter3'));
                                        sem python:sem_series[int(term)-1];
                                        ">
@@ -32,4 +32,7 @@
                 <td>Student's Average:</td><td tal:content="python:info[sem[3]]"></td> 
             </tr>
+            <tr>
+                <td>Year Group Average:</td><td> <span tal:content="python:info[sem[4]]" /> (<span tal:content="python:info[sem[5]]" /> students)</td> 
+            </tr>            
         </table>
         <br />   <br />                 
Index: /WAeUP_SRP/trunk/skins/waeup_ois/getStudyLevelInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_ois/getStudyLevelInfo.py	(revision 4035)
+++ /WAeUP_SRP/trunk/skins/waeup_ois/getStudyLevelInfo.py	(revision 4036)
@@ -141,4 +141,12 @@
 info['score_calc_average_3'] =  '%.2f' % score_calc_average_3  
 
+session_id = level_doc.session
+yga1,yga2,yga3,counter1,counter2,counter3 = course_results.getYearGroupAverage(session_id,level_id)
+info['yga1'] = yga1
+info['yga2'] = yga2
+info['yga3'] = yga3
+info['counter1'] = counter1
+info['counter2'] = counter2
+info['counter3'] = counter3
 
 #end customization
