Index: main/waeup.aaue/trunk/src/waeup/aaue/students/export.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/export.py	(revision 16838)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/export.py	(revision 16859)
@@ -19,5 +19,5 @@
 """
 import grok
-from zope.component import getUtility
+from zope.component import getUtility, createObject
 from waeup.kofa.utils.batching import ExporterBase
 from waeup.kofa.utils.helpers import iface_names
@@ -37,4 +37,58 @@
 
 
+def get_tickets_for_ict(students, previous=0, **kw):
+    """
+    """
+    tickets = []
+    #code = kw.get('code', None)
+    level = kw.get('level', None)
+    session = kw.get('session', None)
+    ct_level = kw.get('ct_level', None)
+    ct_session = kw.get('ct_session', None)
+    ct_semester = kw.get('ct_semester', None)
+    allticketcodes = list()
+    for level_obj in get_levels(students, previous, **kw):
+
+
+        for ticket in level_obj.values():
+            if ct_level not in ('all', None):
+                if level_obj.level in (10, 999, 1000, None)  \
+                    and int(ct_level) != level_obj.level:
+                    continue
+                if level_obj.level not in range(
+                    int(ct_level), int(ct_level)+100, 10):
+                    continue
+            if ct_session not in ('all', None) and \
+                int(ct_session) != level_obj.level_session:
+                continue
+            if ct_semester not in ('all', None) and \
+                int(ct_semester) != ticket.semester:
+                continue
+            if ticket.total_score is not None:
+                if ticket.total_score < ticket.passmark:
+                    remark = 'failed'
+                else:
+                    remark = 'passed'
+            else:
+                remark = 'nottaken'
+            ticket.remark = remark
+            tickets.append(ticket)
+            allticketcodes.append(ticket.code)
+        # collect missed tickets for each study level
+        certificate = getattr(
+            level_obj.student.get('studycourse', None), 'certificate', None)
+        if certificate:
+            for certcourse in certificate.values():
+                if certcourse.level != level_obj.level:
+                    continue
+                if certcourse.getCourseCode() not in allticketcodes:
+                    ticket = createObject(u'waeup.CourseTicket')
+                    ticket.code = certcourse.getCourseCode()
+                    ticket.remark = 'missed'
+                    ticket.course_category = certcourse.course_category
+                    ticket.stdnt = level_obj.student
+                    tickets.append(ticket)
+    return tickets
+
 class CustomStudentExporter(NigeriaStudentExporter):
     """Exporter for Students.
@@ -70,9 +124,11 @@
         ['level', 'code', 'level_session'])) + ('student_id',
         'certcode', 'display_fullname', 'matric_number', 'state', 'grade',
-        'total_score', 'total_credits')
+        'total_score', 'total_credits', 'previous')
 
     def mangle_value(self, value, name, context=None):
         """The mangler determines the student's id and fullname.
         """
+        if name == 'previous':
+            return self.previous
         if context is not None:
             student = context.student
@@ -215,2 +271,27 @@
             StudentExporter, self).mangle_value(
             value, name, context=context)
+
+class OutstandingCourses2Exporter(grok.GlobalUtility, StudentExporterBase):
+    """
+    """
+    grok.name('outstandingcourses_2')
+
+    title = u'Outstanding Courses V2'
+
+    fields = ('student_id', 'matric_number', 'certcode', 'display_fullname',
+              'code', 'course_category', 'remark')
+
+    def filter_func(self, x, **kw):
+        return get_tickets_for_ict(x, **kw)
+
+    def mangle_value(self, value, name, context=None):
+        """The mangler determines the student's id and fullname.
+        """
+        if context is not None:
+            student = context.student
+            if not student:
+                student = getattr(context, 'stdnt', None)
+            if name in ('student_id', 'display_fullname', 'matric_number',
+                'certcode') and student is not None:
+                value = getattr(student, name, None)
+        return ExporterBase().mangle_value(value, name, context=context)
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py	(revision 16838)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py	(revision 16859)
@@ -12,5 +12,6 @@
     CustomCourseTicketExporter,
     LevelReportDataExporter,
-    CustomStudentStudyCourseExporter)
+    CustomStudentStudyCourseExporter,
+    OutstandingCourses2Exporter)
 from waeup.aaue.testing import FunctionalLayer
 
@@ -226,3 +227,28 @@
         return
 
-
+class OutstandingCourses2ExporterTest(StudentImportExportSetup):
+
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(OutstandingCourses2ExporterTest, self).setUp()
+        self.setup_for_export()
+        return
+
+    def test_export_all(self):
+        # we can really export all course tickets
+        # set values we can expect in export file
+        self.setup_student(self.student)
+        self.student['studycourse']['100']['CRS1'].course_category = 'C'
+        exporter = OutstandingCourses2Exporter()
+        exporter.export_all(self.app, self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'student_id,matric_number,certcode,display_fullname,code,'
+            'course_category,remark\r\n'
+            'A111111,234,CERT1,"TESTER, Anna M.",CRS1,C,nottaken\r\n'
+            )
+        return
+
+
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 16838)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 16859)
@@ -617,4 +617,5 @@
             'trimmedpayments',
             'trimmed',
+            'outstandingcourses_2'
             )
 
