Changeset 16859 for main/waeup.aaue/trunk
- Timestamp:
- 4 Mar 2022, 21:27:24 (3 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/export.py
r16617 r16859 19 19 """ 20 20 import grok 21 from zope.component import getUtility 21 from zope.component import getUtility, createObject 22 22 from waeup.kofa.utils.batching import ExporterBase 23 23 from waeup.kofa.utils.helpers import iface_names … … 37 37 38 38 39 def get_tickets_for_ict(students, previous=0, **kw): 40 """ 41 """ 42 tickets = [] 43 #code = kw.get('code', None) 44 level = kw.get('level', None) 45 session = kw.get('session', None) 46 ct_level = kw.get('ct_level', None) 47 ct_session = kw.get('ct_session', None) 48 ct_semester = kw.get('ct_semester', None) 49 allticketcodes = list() 50 for level_obj in get_levels(students, previous, **kw): 51 52 53 for ticket in level_obj.values(): 54 if ct_level not in ('all', None): 55 if level_obj.level in (10, 999, 1000, None) \ 56 and int(ct_level) != level_obj.level: 57 continue 58 if level_obj.level not in range( 59 int(ct_level), int(ct_level)+100, 10): 60 continue 61 if ct_session not in ('all', None) and \ 62 int(ct_session) != level_obj.level_session: 63 continue 64 if ct_semester not in ('all', None) and \ 65 int(ct_semester) != ticket.semester: 66 continue 67 if ticket.total_score is not None: 68 if ticket.total_score < ticket.passmark: 69 remark = 'failed' 70 else: 71 remark = 'passed' 72 else: 73 remark = 'nottaken' 74 ticket.remark = remark 75 tickets.append(ticket) 76 allticketcodes.append(ticket.code) 77 # collect missed tickets for each study level 78 certificate = getattr( 79 level_obj.student.get('studycourse', None), 'certificate', None) 80 if certificate: 81 for certcourse in certificate.values(): 82 if certcourse.level != level_obj.level: 83 continue 84 if certcourse.getCourseCode() not in allticketcodes: 85 ticket = createObject(u'waeup.CourseTicket') 86 ticket.code = certcourse.getCourseCode() 87 ticket.remark = 'missed' 88 ticket.course_category = certcourse.course_category 89 ticket.stdnt = level_obj.student 90 tickets.append(ticket) 91 return tickets 92 39 93 class CustomStudentExporter(NigeriaStudentExporter): 40 94 """Exporter for Students. … … 70 124 ['level', 'code', 'level_session'])) + ('student_id', 71 125 'certcode', 'display_fullname', 'matric_number', 'state', 'grade', 72 'total_score', 'total_credits' )126 'total_score', 'total_credits', 'previous') 73 127 74 128 def mangle_value(self, value, name, context=None): 75 129 """The mangler determines the student's id and fullname. 76 130 """ 131 if name == 'previous': 132 return self.previous 77 133 if context is not None: 78 134 student = context.student … … 215 271 StudentExporter, self).mangle_value( 216 272 value, name, context=context) 273 274 class OutstandingCourses2Exporter(grok.GlobalUtility, StudentExporterBase): 275 """ 276 """ 277 grok.name('outstandingcourses_2') 278 279 title = u'Outstanding Courses V2' 280 281 fields = ('student_id', 'matric_number', 'certcode', 'display_fullname', 282 'code', 'course_category', 'remark') 283 284 def filter_func(self, x, **kw): 285 return get_tickets_for_ict(x, **kw) 286 287 def mangle_value(self, value, name, context=None): 288 """The mangler determines the student's id and fullname. 289 """ 290 if context is not None: 291 student = context.student 292 if not student: 293 student = getattr(context, 'stdnt', None) 294 if name in ('student_id', 'display_fullname', 'matric_number', 295 'certcode') and student is not None: 296 value = getattr(student, name, None) 297 return ExporterBase().mangle_value(value, name, context=context) -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py
r16617 r16859 12 12 CustomCourseTicketExporter, 13 13 LevelReportDataExporter, 14 CustomStudentStudyCourseExporter) 14 CustomStudentStudyCourseExporter, 15 OutstandingCourses2Exporter) 15 16 from waeup.aaue.testing import FunctionalLayer 16 17 … … 226 227 return 227 228 228 229 class OutstandingCourses2ExporterTest(StudentImportExportSetup): 230 231 layer = FunctionalLayer 232 233 def setUp(self): 234 super(OutstandingCourses2ExporterTest, self).setUp() 235 self.setup_for_export() 236 return 237 238 def test_export_all(self): 239 # we can really export all course tickets 240 # set values we can expect in export file 241 self.setup_student(self.student) 242 self.student['studycourse']['100']['CRS1'].course_category = 'C' 243 exporter = OutstandingCourses2Exporter() 244 exporter.export_all(self.app, self.outfile) 245 result = open(self.outfile, 'rb').read() 246 self.assertEqual( 247 result, 248 'student_id,matric_number,certcode,display_fullname,code,' 249 'course_category,remark\r\n' 250 'A111111,234,CERT1,"TESTER, Anna M.",CRS1,C,nottaken\r\n' 251 ) 252 return 253 254 -
main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
r16822 r16859 617 617 'trimmedpayments', 618 618 'trimmed', 619 'outstandingcourses_2' 619 620 ) 620 621
Note: See TracChangeset for help on using the changeset viewer.