Index: main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/studylevel.py
===================================================================
--- main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/studylevel.py	(revision 18235)
+++ main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/studylevel.py	(revision 18307)
@@ -21,4 +21,5 @@
 """
 import grok
+import decimal
 from zope.component.interfaces import IFactory
 from zope.interface import implementedBy
@@ -30,4 +31,5 @@
 from kofacustom.unidel.students.interfaces import (
     ICustomStudentStudyLevel, ICustomCourseTicket)
+from kofacustom.unidel.students.utils import MINIMUM_UNITS_THRESHOLD
 
 
@@ -91,4 +93,119 @@
                total_credits, credits_passed)
 
+    @property
+    def passed_params(self):
+        """Determine the number and credits of passed and failed courses.
+        This method is used for level reports.
+        """
+        passed = failed = 0
+        courses_failed = ''
+        credits_failed = 0
+        credits_passed = 0
+        courses_not_taken = ''
+        courses_passed = ''
+        for ticket in self.values():
+            if ticket.total_score is not None:
+                if ticket.total_score < ticket.passmark:
+                    failed += 1
+                    credits_failed += ticket.credits
+                    if ticket.mandatory or ticket.course_category == 'C':
+                        courses_failed += 'm_%s_m ' % ticket.code
+                    else:
+                        courses_failed += '%s ' % ticket.code
+                else:
+                    passed += 1
+                    credits_passed += ticket.credits
+                    courses_passed += '%s ' % ticket.code
+            else:
+                courses_not_taken += '%s ' % ticket.code
+        if not len(courses_failed):
+            courses_failed = 'Nil'
+        if not len(courses_not_taken):
+            courses_not_taken = 'Nil'
+        return (passed, failed, credits_passed,
+                credits_failed, courses_failed,
+                courses_not_taken, courses_passed)
+
+    # only AAUE and Unidel
+    @property
+    def remark(self):
+        certificate = getattr(self.__parent__,'certificate',None)
+        end_level = getattr(certificate, 'end_level', None)
+        study_mode = getattr(certificate, 'study_mode', None)
+        tcrg = getattr(certificate, 'custom_float_1', None)
+        value = decimal.Decimal(str(self.cumulative_params[0]))
+        cgpa = round(value,2)
+        #cgpa = self.cumulative_params[0]
+        is_dp = False
+        if study_mode and study_mode.startswith('dp'):
+            is_dp = True
+        failed_limit = 1.5
+        if self.student.entry_session < 2013:
+            failed_limit = 1.0
+        # final level student remark
+        if end_level and self.level >= end_level:
+            if self.level > end_level:
+                # spill-over level
+                if self.gpa_params[1] == 0:
+                    # no credits taken
+                    return 'NER'
+            elif self.cumulative_params[4] < tcrg:
+                return 'FRNS'
+            if self.level_verdict in ('FRNS', 'NER', 'NYV'):
+                return self.level_verdict
+            if '_m' in self.passed_params[4]:
+                return 'FRNS'
+            if not self.cumulative_params[0]:
+                return 'FRNS'
+            if len(self.passed_params[5]) \
+                and not self.passed_params[5] == 'Nil':
+                return 'FRNS'
+            if self.cumulative_params[1] < 60:
+                return 'FRNS'
+            if cgpa < failed_limit:
+                return 'Fail'
+            dummy, repeat = divmod(self.level, 100)
+            if cgpa < 5.1 and repeat == 20:
+                # Irrespective of the CGPA of a student, if the He/She has
+                # 3rd Extension, such student will be graduated with a "Pass".
+                return 'Pass'
+            if cgpa < 1.5:
+                if is_dp:
+                    return 'Fail'
+                return 'Pass'
+            if cgpa < 2.4:
+                if is_dp:
+                    return 'Pass'
+                return '3s_rd_s'
+            if cgpa < 3.5:
+                if is_dp:
+                    return 'Merit'
+                return '2s_2_s'
+            if cgpa < 4.5:
+                if is_dp:
+                    return 'Credit'
+                return '2s_1_s'
+            if cgpa < 5.1:
+                if is_dp:
+                    return 'Distinction'
+                return '1s_st_s'
+            return 'N/A'
+        # returning student remark
+        if self.level_verdict in ('FRNS', 'NER', 'NYV'):
+            return 'Probation'
+        if self.level_verdict == 'D':
+            return 'Withdrawn'
+        if self.gpa_params[1] == 0:
+            # no credits taken
+            return 'NER'
+        if self.gpa_params[1] < MINIMUM_UNITS_THRESHOLD:
+            # credits taken below limit
+            return 'Probation'
+        if cgpa < failed_limit:
+            return 'Probation'
+        if cgpa < 5.1:
+            return 'Proceed'
+        return 'N/A'
+
 CustomStudentStudyLevel = attrs_to_fields(
     CustomStudentStudyLevel, omit=['total_credits', 'gpa',
