Changeset 14593 for main/waeup.aaue/trunk
- Timestamp:
- 27 Feb 2017, 06:11:10 (8 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
r14442 r14593 18 18 """Exporters for student related stuff. 19 19 """ 20 import grok 21 from zope.component import getUtility 20 22 from waeup.kofa.utils.batching import ExporterBase 21 23 from waeup.kofa.utils.helpers import iface_names 22 from waeup.kofa.students.export import DataForLecturerExporter 24 from waeup.kofa.interfaces import IKofaUtils 25 from waeup.kofa.students.export import (get_levels, 26 DataForLecturerExporter, StudentExporterBase,) 23 27 from waeup.aaue.students.interfaces import ( 24 28 ICustomStudent, ICustomStudentStudyCourse, … … 103 107 'level', 'code', 'level_session', 'ca', 'score') 104 108 109 class LevelReportDataExporter(grok.GlobalUtility, StudentExporterBase): 110 """ 111 """ 112 grok.name('levelreportdata') 113 114 fields = ('matric_number', 'display_fullname', 115 'credits_counted', 'credits_passed','level_gpa', 116 'failed_courses','not_taken_courses','cum_credits_taken', 117 'cum_credits_passed','cgpa','remark') 118 title = u'Summary of Result Data' 119 120 def filter_func(self, x, **kw): 121 return get_levels(x) 122 123 def mangle_value(self, value, name, context=None): 124 """The mangler determines the student id, nothing else. 125 """ 126 if context is not None: 127 student = context.student 128 format_float = getUtility(IKofaUtils).format_float 129 if name in ('matric_number', 130 'display_fullname',) and student is not None: 131 value = getattr(student, name, None) 132 elif name == 'credits_counted': 133 value = context.gpa_params[1] 134 elif name == 'credits_passed': 135 value = context.passed_params[2] 136 elif name == 'level_gpa': 137 value = format_float(context.gpa_params[0], 3) 138 elif name == 'failed_courses': 139 value = context.passed_params[4] 140 elif name == 'not_taken_courses': 141 value = context.passed_params[5] 142 elif name == 'cum_credits_taken': 143 value = context.cumulative_params[1] 144 elif name == 'cum_credits_passed': 145 value = context.cumulative_params[4] 146 elif name == 'cgpa': 147 value = format_float(context.cumulative_params[0], 3) 148 elif name == 'remark': 149 value = getattr(context, 'remark', '') 150 return super( 151 LevelReportDataExporter, self).mangle_value( 152 value, name, context=context) 153 -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py
r14576 r14593 10 10 CustomStudentExporter, CustomStudentPaymentExporter, 11 11 CustomStudentStudyLevelExporter, 12 CustomCourseTicketExporter) 12 CustomCourseTicketExporter, 13 LevelReportDataExporter) 13 14 from waeup.aaue.testing import FunctionalLayer 14 15 … … 174 175 return 175 176 177 class LevelReportDataExporterTest(StudentImportExportSetup): 178 179 layer = FunctionalLayer 180 181 def setUp(self): 182 super(LevelReportDataExporterTest, self).setUp() 183 self.setup_for_export() 184 return 185 186 def test_export_all(self): 187 # we can really export study levels 188 # set values we can expect in export file 189 self.setup_student(self.student) 190 exporter = LevelReportDataExporter() 191 exporter.export_all(self.app, self.outfile) 192 result = open(self.outfile, 'rb').read() 193 self.assertEqual( 194 result, 195 'matric_number,display_fullname,credits_counted,credits_passed,' 196 'level_gpa,failed_courses,not_taken_courses,cum_credits_taken,' 197 'cum_credits_passed,cgpa,remark\r\n' 198 '234,"TESTER, Anna M.",0,0,0.000,,CRS1 ,0,0,0.000,\r\n' 199 ) 200 return 201 202 -
main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
r14585 r14593 495 495 # AAUE prefix 496 496 STUDENT_ID_PREFIX = u'E' 497 498 STUDENT_EXPORTER_NAMES = ('students', 'studentstudycourses', 499 'studentstudylevels', 'coursetickets', 500 'studentpayments', 'studentunpaidpayments', 501 'bedtickets', 'paymentsoverview', 502 'studylevelsoverview', 'combocard', 'bursary', 503 'levelreportdata')
Note: See TracChangeset for help on using the changeset viewer.