[16717] | 1 | ## $Id: export.py 17997 2025-01-29 16:10:23Z henrik $ |
---|
[15614] | 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | """Exporters for student related stuff. |
---|
| 19 | """ |
---|
[17997] | 20 | from waeup.kofa.students.export import DataForLecturerExporter |
---|
[16721] | 21 | from kofacustom.unidel.students.interfaces import ( |
---|
[15614] | 22 | ICustomStudent, |
---|
| 23 | ICustomStudentStudyCourse, |
---|
| 24 | ICustomStudentStudyLevel, |
---|
| 25 | ICustomCourseTicket, |
---|
| 26 | ICustomStudentOnlinePayment) |
---|
| 27 | from kofacustom.nigeria.students.export import ( |
---|
| 28 | NigeriaStudentExporter, |
---|
| 29 | NigeriaStudentStudyCourseExporter, |
---|
| 30 | NigeriaStudentStudyLevelExporter, |
---|
| 31 | NigeriaCourseTicketExporter, |
---|
| 32 | NigeriaStudentPaymentExporter) |
---|
| 33 | from waeup.kofa.utils.helpers import iface_names |
---|
| 34 | |
---|
| 35 | class CustomStudentExporter(NigeriaStudentExporter): |
---|
| 36 | """Exporter for Students. |
---|
| 37 | """ |
---|
| 38 | |
---|
| 39 | fields = tuple(sorted(iface_names( |
---|
| 40 | ICustomStudent, omit=['loggerInfo']))) + ( |
---|
| 41 | 'password', 'state', 'history', 'certcode', 'is_postgrad', |
---|
| 42 | 'current_level', 'current_session') |
---|
| 43 | |
---|
| 44 | class CustomStudentStudyCourseExporter(NigeriaStudentStudyCourseExporter): |
---|
| 45 | """Exporter for StudentStudyCourses. |
---|
| 46 | """ |
---|
| 47 | |
---|
| 48 | fields = tuple( |
---|
| 49 | sorted(iface_names(ICustomStudentStudyCourse))) + ('student_id',) |
---|
| 50 | |
---|
| 51 | class CustomStudentStudyLevelExporter(NigeriaStudentStudyLevelExporter): |
---|
| 52 | """Exporter for StudentStudyLevels. |
---|
| 53 | """ |
---|
| 54 | #: Fieldnames considered by this exporter |
---|
| 55 | fields = tuple(sorted(iface_names( |
---|
| 56 | ICustomStudentStudyLevel))) + ( |
---|
| 57 | 'student_id', 'number_of_tickets','certcode') |
---|
| 58 | |
---|
| 59 | class CustomCourseTicketExporter(NigeriaCourseTicketExporter): |
---|
| 60 | """Exporter for CourseTickets. |
---|
| 61 | """ |
---|
| 62 | |
---|
| 63 | fields = tuple(sorted(iface_names(ICustomCourseTicket) + |
---|
| 64 | ['level', 'code', 'level_session'])) + ('student_id', |
---|
| 65 | 'certcode', 'display_fullname') |
---|
| 66 | |
---|
| 67 | class CustomStudentPaymentExporter(NigeriaStudentPaymentExporter): |
---|
| 68 | """Exporter for OnlinePayment instances. |
---|
| 69 | """ |
---|
| 70 | |
---|
| 71 | fields = tuple( |
---|
| 72 | sorted(iface_names( |
---|
| 73 | ICustomStudentOnlinePayment, exclude_attribs=False, |
---|
| 74 | omit=['display_item']))) + ( |
---|
| 75 | 'student_id','state','current_session') |
---|
| 76 | |
---|
[17997] | 77 | class CustomDataForLecturerExporter(DataForLecturerExporter): |
---|
| 78 | """The Data for Lecturer Exporter searches for students in the course |
---|
| 79 | tickets catalog and exports those course tickets which belong to the |
---|
| 80 | given course code, meet level and session passed through at the |
---|
| 81 | same time, and which are editable by lecturers (disabled on 10/03/21). |
---|
| 82 | This exporter can only be called at course level in the academic section. |
---|
| 83 | """ |
---|
| 84 | |
---|
| 85 | fields = ('matric_number', 'student_id', 'display_fullname', |
---|
| 86 | 'faccode', 'certcode', 'state', |
---|
| 87 | 'level', 'code', 'level_session', 'score') |
---|
| 88 | |
---|
| 89 | def mangle_value(self, value, name, context=None): |
---|
| 90 | """The mangler determines the student's id and fullname. |
---|
| 91 | """ |
---|
| 92 | if context is not None: |
---|
| 93 | student = context.student |
---|
| 94 | if name in ('matric_number', |
---|
| 95 | 'reg_number', |
---|
| 96 | 'student_id', |
---|
| 97 | 'display_fullname', |
---|
| 98 | 'faccode', |
---|
| 99 | 'certcode', |
---|
| 100 | 'state',) and student is not None: |
---|
| 101 | value = getattr(student, name, None) |
---|
| 102 | return super( |
---|
| 103 | DataForLecturerExporter, self).mangle_value( |
---|
| 104 | value, name, context=context) |
---|
| 105 | |
---|