Changeset 15873 for main/waeup.kofa/trunk
- Timestamp:
- 9 Dec 2019, 10:44:57 (5 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r15865 r15873 4 4 1.6.1.dev0 (unreleased) 5 5 ======================= 6 7 * Add `StudentOutstandingCoursesExporter`. 6 8 7 9 * Sort lecturers on scores slip. -
main/waeup.kofa/trunk/docs/source/userdocs/datacenter/export.rst
r15277 r15873 221 221 .. automethod:: waeup.kofa.students.export.CourseTicketExporter.mangle_value() 222 222 223 Student Outstanding Courses Exporter 224 ---------------------- 225 226 .. autoclass:: waeup.kofa.students.export.StudentOutstandingCoursesExporter() 227 228 .. autoattribute:: waeup.kofa.students.export.StudentOutstandingCoursesExporter.fields 229 .. autoattribute:: waeup.kofa.students.export.StudentOutstandingCoursesExporter.title 230 .. automethod:: waeup.kofa.students.export.StudentOutstandingCoursesExporter.mangle_value() 231 223 232 Student Payment Exporter 224 233 ------------------------ -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r15792 r15873 25 25 IExtFileStore, IFileStoreNameChooser, IKofaUtils) 26 26 from waeup.kofa.interfaces import MessageFactory as _ 27 from waeup.kofa.university.interfaces import ICertificateCourse, ICourse 27 28 from waeup.kofa.students.catalog import StudentsQuery, CourseTicketsQuery 28 29 from waeup.kofa.students.interfaces import ( … … 133 134 return tickets 134 135 136 def get_outstanding(students, **kw): 137 """Get students with outstanding certificate courses. 138 """ 139 students_wo = [] 140 for student in students: 141 certificate = getattr( 142 student.get('studycourse', None), 'certificate', None) 143 if certificate: 144 allticketcodes = [] 145 failedticketcodes = '' # taken but failed 146 nottakenticketcodes = '' # registered but not taken 147 missedticketcodes = '' # not registered 148 for level in student['studycourse'].values(): 149 failedticketcodes += level.passed_params[4] 150 nottakenticketcodes += level.passed_params[5] 151 for ticket in level.values(): 152 allticketcodes.append(ticket.code) 153 for certcourse in certificate.values(): 154 if certcourse.getCourseCode() not in allticketcodes: 155 missedticketcodes += '%s ' % certcourse.__name__ 156 student_wo = (student, missedticketcodes, 157 failedticketcodes, nottakenticketcodes) 158 students_wo.append(student_wo) 159 return students_wo 160 135 161 def get_payments(students, p_states=None, **kw): 136 162 """Get all payments of `students` within given payment_date period. … … 430 456 value, name, context=context) 431 457 458 class StudentOutstandingCoursesExporter(grok.GlobalUtility, StudentExporterBase): 459 """The Student Outstanding Courses Exporter first filters the set of 460 students by searching the students catalog. Then it exports students with 461 lists of outstanding courses, i.e. courses which the student has 462 missed (not registered at all), failed (registered but not passed) 463 or nottaken (registered but not taken). 464 """ 465 grok.name('studentoutstandingcourses') 466 467 fields = ('student_id', 'certcode', 'display_fullname','missed', 468 'failed', 'nottaken') 469 title = _(u'Student Outstanding Courses') 470 471 def filter_func(self, x, **kw): 472 return get_outstanding(x, **kw) 473 474 def mangle_value(self, value, name, context=None): 475 """The mangler determines the student's id, fullname and certcode, 476 and it collects the lists of outstanding courses. 477 """ 478 if context is not None: 479 if name in ('student_id', 'display_fullname', 'certcode'): 480 value = getattr(context[0], name, None) 481 elif name == 'missed': 482 value = context[1] 483 elif name == 'failed': 484 value = context[2] 485 elif name == 'nottaken': 486 value = context[3] 487 return super( 488 StudentOutstandingCoursesExporter, self).mangle_value( 489 value, name, context=context) 490 432 491 class StudentPaymentExporter(grok.GlobalUtility, StudentExporterBase): 433 492 """The Student Payment Exporter first filters the set of students -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r15664 r15873 27 27 ICSVExporter, IExtFileStore, IFileStoreNameChooser) 28 28 from waeup.kofa.students.catalog import StudentsQuery 29 from waeup.kofa.university.course import Course 30 from waeup.kofa.university.certificate import CertificateCourse 29 31 from waeup.kofa.students.export import ( 30 32 StudentExporter, StudentStudyCourseExporter, StudentStudyLevelExporter, … … 33 35 ComboCardDataExporter, DataForBursaryExporter, 34 36 StudentUnpaidPaymentExporter, SessionPaymentsOverviewExporter, 37 StudentOutstandingCoursesExporter, 35 38 AccommodationPaymentsExporter, get_students,) 36 39 from waeup.kofa.students.accommodation import BedTicket … … 789 792 '1,1,CRS1,,100,DEP1,FAC1,110,2012,0,0,100,,2,,Course 1,A111111,CERT1,' 790 793 'Anna M. Tester\r\n' 794 ) 795 return 796 797 class StudentOutstandingCoursesExporterTest(StudentImportExportSetup): 798 799 layer = FunctionalLayer 800 801 def setUp(self): 802 super(StudentOutstandingCoursesExporterTest, self).setUp() 803 self.setup_for_export() 804 return 805 806 def test_ifaces(self): 807 # make sure we fullfill interface contracts 808 obj = StudentOutstandingCoursesExporter() 809 verifyObject(ICSVStudentExporter, obj) 810 verifyClass(ICSVStudentExporter, StudentOutstandingCoursesExporter) 811 return 812 813 def test_get_as_utility(self): 814 # we can get an student exporter as utility 815 result = queryUtility(ICSVExporter, name="studentoutstandingcourses") 816 self.assertTrue(result is not None) 817 return 818 819 def test_export_all(self): 820 course1 = Course(u'Cheese Basics', 'C1') 821 course2 = Course(u'Advanced Cheese Making', 'C2') 822 course3 = Course(u'Selling Cheese', 'C3') 823 self.app['faculties']['fac1']['dep1'].courses.addCourse(course1) 824 self.app['faculties']['fac1']['dep1'].courses.addCourse(course2) 825 self.app['faculties']['fac1']['dep1'].courses.addCourse(course3) 826 self.certificate.addCertCourse(course1, 100, True) 827 self.certificate.addCertCourse(course2, 400, False) 828 self.certificate.addCertCourse(course3, 100, False) 829 self.setup_student(self.student) 830 self.student['studycourse']['100']['C3'].score = 25 831 exporter = StudentOutstandingCoursesExporter() 832 exporter.export_all(self.app, self.outfile) 833 result = open(self.outfile, 'rb').read() 834 # The only student has registered C1, C3 and CRS1 835 # She missed C2, has failed C3 and did not 836 # take C1 and CRS1 837 self.assertEqual( 838 result, 839 'student_id,certcode,display_fullname,missed,failed,nottaken\r\n' 840 'A111111,CERT1,Anna M. Tester,C2_400 ,C3 ,C1 CRS1 \r\n' 791 841 ) 792 842 return -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r15823 r15873 1142 1142 #: subobjects thereof. 1143 1143 STUDENT_EXPORTER_NAMES = ('students', 'studentstudycourses', 1144 'studentstudylevels', 'coursetickets', 1144 'studentstudylevels', 'coursetickets','studentoutstandingcourses', 1145 1145 'studentpayments', 'studentunpaidpayments', 1146 'bedtickets', 'sfpaymentsoverview', 'sessionpaymentsoverview', 1147 'studylevelsoverview', 'combocard', 'bursary', 1148 'accommodationpayments') 1146 'sfpaymentsoverview', 'sessionpaymentsoverview', 1147 'studylevelsoverview','bedtickets', 1148 'combocard', 'bursary', 1149 'accommodationpayments',) 1149 1150 1150 1151 #: A tuple containing all exporter names needed for backing
Note: See TracChangeset for help on using the changeset viewer.