Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/export.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/export.py	(revision 16913)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/export.py	(revision 16914)
@@ -72,4 +72,5 @@
                 remark = 'nottaken'
             ticket.remark = remark
+            ticket.stdnt = level_obj.student
             tickets.append(ticket)
             allticketcodes.append(ticket.code)
@@ -90,14 +91,13 @@
     # Remove failed or missed tickets if they have been passed later
     obsolete = list()
-    passed_tickets = [i for i in tickets if i.remark == 'passed']
-    for passed_ticket in passed_tickets:
-        for ticket in tickets:
-            student = ticket.student
-            if not student:
-                student = ticket.stdnt  # missed ticket
-            if student == passed_ticket.student \
-                and ticket.code == passed_ticket.code \
-                and ticket.remark != 'passed':
-                obsolete.append(ticket)
+    for student in students:
+        print student.student_id
+        all_tickets = [i for i in tickets if student == i.stdnt]
+        passed_tickets = [i for i in all_tickets if i.remark == 'passed']
+        for passed_ticket in passed_tickets:
+            for ticket in all_tickets:
+                 if ticket.code == passed_ticket.code \
+                    and ticket.remark != 'passed':
+                    obsolete.append(ticket)
     for ticket in set(obsolete):
         tickets.remove(ticket)
