[16639] | 1 | ## $Id: studylevel.py 16917 2022-04-11 16:39:46Z henrik $ |
---|
[15614] | 2 | ## |
---|
| 3 | ## Copyright (C) 2012 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 | """ |
---|
| 19 | Container which holds the data of a student study level |
---|
| 20 | and contains the course tickets. |
---|
| 21 | """ |
---|
| 22 | import grok |
---|
| 23 | from zope.component.interfaces import IFactory |
---|
| 24 | from zope.interface import implementedBy |
---|
| 25 | from waeup.kofa.utils.helpers import attrs_to_fields |
---|
| 26 | from waeup.kofa.students.studylevel import ( |
---|
| 27 | StudentStudyLevel, CourseTicket, |
---|
| 28 | CourseTicketFactory, StudentStudyLevelFactory) |
---|
| 29 | from waeup.kofa.students.interfaces import IStudentNavigation |
---|
[16615] | 30 | from kofacustom.edocons.students.interfaces import ( |
---|
[15614] | 31 | ICustomStudentStudyLevel, ICustomCourseTicket) |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | class CustomStudentStudyLevel(StudentStudyLevel): |
---|
| 35 | """This is a container for course tickets. |
---|
| 36 | """ |
---|
| 37 | grok.implements(ICustomStudentStudyLevel, IStudentNavigation) |
---|
| 38 | grok.provides(ICustomStudentStudyLevel) |
---|
| 39 | |
---|
| 40 | CustomStudentStudyLevel = attrs_to_fields( |
---|
| 41 | CustomStudentStudyLevel, omit=['total_credits', 'gpa']) |
---|
| 42 | |
---|
| 43 | class CustomStudentStudyLevelFactory(StudentStudyLevelFactory): |
---|
| 44 | """A factory for student study levels. |
---|
| 45 | """ |
---|
| 46 | |
---|
| 47 | def __call__(self, *args, **kw): |
---|
| 48 | return CustomStudentStudyLevel() |
---|
| 49 | |
---|
| 50 | def getInterfaces(self): |
---|
| 51 | return implementedBy(CustomStudentStudyLevel) |
---|
| 52 | |
---|
| 53 | class CustomCourseTicket(CourseTicket): |
---|
| 54 | """This is a course ticket which allows the |
---|
| 55 | student to attend the course. Lecturers will enter scores and more at |
---|
| 56 | the end of the term. |
---|
| 57 | |
---|
| 58 | A course ticket contains a copy of the original course and |
---|
| 59 | course referrer data. If the courses and/or their referrers are removed, the |
---|
| 60 | corresponding tickets remain unchanged. So we do not need any event |
---|
| 61 | triggered actions on course tickets. |
---|
| 62 | """ |
---|
| 63 | grok.implements(ICustomCourseTicket, IStudentNavigation) |
---|
| 64 | grok.provides(ICustomCourseTicket) |
---|
| 65 | |
---|
[16917] | 66 | @property |
---|
| 67 | def _getGradeWeightFromScore(self): |
---|
| 68 | """ECNS Course Grading System |
---|
| 69 | """ |
---|
| 70 | if self.total_score is None: |
---|
| 71 | return (None, None) |
---|
| 72 | if self.total_score >= 80: |
---|
| 73 | return ('A',4) |
---|
| 74 | if self.total_score >= 70: |
---|
| 75 | return ('B+',3.5) |
---|
| 76 | if self.total_score >= 60: |
---|
| 77 | return ('B',3) |
---|
| 78 | if self.total_score >= 50: |
---|
| 79 | return ('C',2.5) |
---|
| 80 | return ('F',1) |
---|
[15614] | 81 | |
---|
[16917] | 82 | |
---|
[15614] | 83 | CustomCourseTicket = attrs_to_fields(CustomCourseTicket) |
---|
| 84 | |
---|
| 85 | class CustomCourseTicketFactory(CourseTicketFactory): |
---|
| 86 | """A factory for student study levels. |
---|
| 87 | """ |
---|
| 88 | |
---|
| 89 | def __call__(self, *args, **kw): |
---|
| 90 | return CustomCourseTicket() |
---|
| 91 | |
---|
| 92 | def getInterfaces(self): |
---|
| 93 | return implementedBy(CustomCourseTicket) |
---|