Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py	(revision 10275)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py	(revision 10276)
@@ -519,5 +519,4 @@
         fields = super(StudentStudyLevelProcessor, self).available_fields
         fields.remove('total_credits')
-        fields.remove('gpa')
         return  fields
 
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 10275)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 10276)
@@ -1337,5 +1337,5 @@
     grok.template('studylevelmanagepage')
     form_fields = grok.AutoFields(IStudentStudyLevel).omit(
-        'validation_date', 'validated_by', 'total_credits', 'gpa')
+        'validation_date', 'validated_by', 'total_credits')
     pnav = 4
     taboneactions = [_('Save'),_('Cancel')]
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 10275)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 10276)
@@ -567,9 +567,9 @@
         )
 
-    gpa = schema.Int(
-        title = _(u'GPA'),
-        required = False,
-        readonly = True,
-        )
+    #gpa = schema.Int(
+    #    title = _(u'GPA'),
+    #    required = False,
+    #    readonly = True,
+    #    )
 
     def addCourseTicket(ticket, course):
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py	(revision 10275)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py	(revision 10276)
@@ -133,6 +133,4 @@
             tickets_3 = []
             tickets = sorted(level_val.values(), key=lambda ticket: ticket.code)
-            sgpa = 0.0
-            session_credits_counted = 0
             for ticket in tickets:
                 if ticket.semester == 1:
@@ -142,11 +140,8 @@
                 elif ticket.semester == 3:
                     tickets_3.append(ticket)
-                if ticket.score:
-                    total_credits_counted += ticket.credits
-                    session_credits_counted += ticket.credits
-                    cgpa += ticket.credits * ticket.weight
-                    sgpa += ticket.credits * ticket.weight
-            if session_credits_counted:
-                sgpa = round(sgpa/session_credits_counted, 2)
+            gpa_params = level_val.gpa_params
+            sgpa = gpa_params[0]
+            total_credits_counted += gpa_params[1]
+            cgpa += gpa_params[2]
             levels.append(
                 dict(level_key=level_key,
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py	(revision 10275)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py	(revision 10276)
@@ -29,4 +29,7 @@
 from waeup.kofa.utils.helpers import attrs_to_fields
 from waeup.kofa.students.vocabularies import StudyLevelSource
+
+def find_carry_over(ticket):
+    return None
 
 def getGradeWeightFromScore(score):
@@ -87,14 +90,21 @@
 
     @property
-    def gpa(self):
-        gpa = 0.0
+    def gpa_params(self):
+        weighted_credits = 0.0
         credits_counted = 0
+        level_gpa = 0.0
         for ticket in self.values():
-            if ticket.score:
+            if ticket.carry_over is False and ticket.score:
+                if ticket.score < ticket.passmark:
+                    co_ticket = find_carry_over(ticket)
+                    if co_ticket is not None:
+                        credits_counted += co_ticket.credits
+                        weighted_credits += co_ticket.credits * co_ticket.weight
+                    continue
                 credits_counted += ticket.credits
-                gpa += ticket.credits * ticket.weight
+                weighted_credits += ticket.credits * ticket.weight
         if credits_counted:
-            gpa = round(gpa/credits_counted, 2)
-        return gpa
+            level_gpa = round(weighted_credits/credits_counted, 2)
+        return level_gpa, credits_counted, weighted_credits
 
     @property
@@ -145,5 +155,5 @@
 
 StudentStudyLevel = attrs_to_fields(
-    StudentStudyLevel, omit=['total_credits', 'gpa'])
+    StudentStudyLevel, omit=['total_credits'])
 
 class StudentStudyLevelFactory(grok.GlobalUtility):
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 10275)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 10276)
@@ -785,5 +785,5 @@
         self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C')
         self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3)
-        # We add another ticket to check if GPA will be correctly calculated
+        # We add another ticket to check if GPAwill be correctly calculated
         # (and rounded)
         courseticket = createObject('waeup.CourseTicket')
@@ -797,6 +797,10 @@
         self.student['studycourse']['100']['COURSE2'] = courseticket
         self.browser.open(self.student_path + '/studycourse/100')
-        self.assertTrue('<div>3.57</div>' in self.browser.contents)
-        self.assertEqual(self.student['studycourse']['100'].gpa, 3.57)
+        # total credits
+        self.assertEqual(self.student['studycourse']['100'].gpa_params[1], 23)
+        # weigheted credits = 3 * 10 + 4 * 13
+        self.assertEqual(self.student['studycourse']['100'].gpa_params[2], 82.0)
+        # sgpa = 82 / 23
+        self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.57)
         # Carry-over courses will be collected when next level is created
         self.browser.open(self.student_path + '/studycourse/manage')
@@ -1836,6 +1840,6 @@
         self.student['studycourse']['110']['COURSE2'] = courseticket
         self.student['studycourse']['100']['COURSE1'].score = 55
-        self.assertEqual(self.student['studycourse']['100'].gpa, 3.0)
-        self.assertEqual(self.student['studycourse']['110'].gpa, 4.0)
+        self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.0)
+        self.assertEqual(self.student['studycourse']['110'].gpa_params[0], 4.0)
         # Get transcript data
         td = self.student['studycourse'].getTranscriptData()
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 10275)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 10276)
@@ -402,8 +402,8 @@
         self.assertEqual(
             result,
-            'gpa,level,level_session,level_verdict,total_credits,'
+            'level,level_session,level_verdict,total_credits,'
             'validated_by,validation_date,'
             'student_id,number_of_tickets,certcode\r\n'
-            '0.0,,,0,0,,,,0,\r\n'
+            ',,0,0,,,,0,\r\n'
             )
         return
@@ -420,8 +420,8 @@
         self.assertEqual(
             result,
-            'gpa,level,level_session,level_verdict,total_credits,'
+            'level,level_session,level_verdict,total_credits,'
             'validated_by,validation_date,'
             'student_id,number_of_tickets,certcode\r\n'
-            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
+            '100,2012,A,100,,,A111111,1,CERT1\r\n'
             )
         return
@@ -436,8 +436,8 @@
         self.assertEqual(
             result,
-            'gpa,level,level_session,level_verdict,total_credits,'
+            'level,level_session,level_verdict,total_credits,'
             'validated_by,validation_date,'
             'student_id,number_of_tickets,certcode\r\n'
-            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
+            '100,2012,A,100,,,A111111,1,CERT1\r\n'
             )
         return
@@ -451,8 +451,8 @@
         self.assertEqual(
             result,
-            'gpa,level,level_session,level_verdict,total_credits,'
+            'level,level_session,level_verdict,total_credits,'
             'validated_by,validation_date,'
             'student_id,number_of_tickets,certcode\r\n'
-            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
+            '100,2012,A,100,,,A111111,1,CERT1\r\n'
             )
         return
@@ -470,8 +470,8 @@
         self.assertEqual(
             result,
-            'gpa,level,level_session,level_verdict,total_credits,'
+            'level,level_session,level_verdict,total_credits,'
             'validated_by,validation_date,'
             'student_id,number_of_tickets,certcode\r\n'
-            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
+            '100,2012,A,100,,,A111111,1,CERT1\r\n'
             )
         return
