[7191] | 1 | ## $Id: studylevel.py 7549 2012-02-01 11:24:35Z henrik $ |
---|
| 2 | ## |
---|
[6775] | 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 | """ |
---|
| 19 | Container which holds the data of a student study level |
---|
| 20 | and contains the course tickets. |
---|
| 21 | """ |
---|
| 22 | import grok |
---|
[7536] | 23 | from zope.component.interfaces import IFactory |
---|
[6775] | 24 | from waeup.sirp.students.interfaces import ( |
---|
[6781] | 25 | IStudentStudyLevel, IStudentNavigation, ICourseTicket) |
---|
[6775] | 26 | from waeup.sirp.utils.helpers import attrs_to_fields |
---|
| 27 | from waeup.sirp.students.vocabularies import StudyLevelSource |
---|
| 28 | |
---|
| 29 | class StudentStudyLevel(grok.Container): |
---|
| 30 | """This is a container for course tickets. |
---|
| 31 | """ |
---|
| 32 | grok.implements(IStudentStudyLevel, IStudentNavigation) |
---|
| 33 | grok.provides(IStudentStudyLevel) |
---|
| 34 | |
---|
| 35 | def __init__(self): |
---|
| 36 | super(StudentStudyLevel, self).__init__() |
---|
| 37 | self.level = None |
---|
[6795] | 38 | self.validation_date = None |
---|
| 39 | self.validated_by = None |
---|
[6775] | 40 | return |
---|
| 41 | |
---|
| 42 | def getStudent(self): |
---|
| 43 | return self.__parent__.__parent__ |
---|
| 44 | |
---|
| 45 | @property |
---|
| 46 | def level_title(self): |
---|
| 47 | studylevelsource = StudyLevelSource() |
---|
| 48 | return studylevelsource.factory.getTitle(self.__parent__, self.level) |
---|
| 49 | |
---|
[6781] | 50 | def addCourseTicket(self, courseticket): |
---|
| 51 | """Add a course ticket object. |
---|
| 52 | """ |
---|
| 53 | if not ICourseTicket.providedBy(courseticket): |
---|
| 54 | raise TypeError( |
---|
| 55 | 'StudentStudyLeves contain only ICourseTicket instances') |
---|
[6782] | 56 | self[courseticket.code] = courseticket |
---|
[6781] | 57 | return |
---|
| 58 | |
---|
| 59 | StudentStudyLevel = attrs_to_fields(StudentStudyLevel) |
---|
| 60 | |
---|
[7536] | 61 | class StudentStudyLevelFactory(grok.GlobalUtility): |
---|
| 62 | """A factory for student study levels. |
---|
| 63 | """ |
---|
| 64 | grok.implements(IFactory) |
---|
| 65 | grok.name(u'waeup.StudentStudyLevel') |
---|
| 66 | title = u"Create a new student study level.", |
---|
| 67 | description = u"This factory instantiates new student study level instances." |
---|
| 68 | |
---|
| 69 | def __call__(self, *args, **kw): |
---|
| 70 | return StudentStudyLevel() |
---|
| 71 | |
---|
| 72 | def getInterfaces(self): |
---|
| 73 | return implementedBy(StudentStudyLevel) |
---|
| 74 | |
---|
[6781] | 75 | class CourseTicket(grok.Model): |
---|
| 76 | """This is a course ticket which allows the |
---|
| 77 | student to attend the course. Lecturers will enter scores and more at |
---|
| 78 | the end of the term. |
---|
[6783] | 79 | |
---|
| 80 | A course ticket contains a copy of the original course and |
---|
| 81 | course referrer data. If the courses and/or their referrers are removed, the |
---|
| 82 | corresponding tickets remain unchanged. So we do not need any event |
---|
| 83 | triggered actions on course tickets. |
---|
[6781] | 84 | """ |
---|
| 85 | grok.implements(ICourseTicket, IStudentNavigation) |
---|
| 86 | grok.provides(ICourseTicket) |
---|
| 87 | |
---|
[6795] | 88 | def __init__(self): |
---|
[6781] | 89 | super(CourseTicket, self).__init__() |
---|
[6795] | 90 | self.code = None |
---|
| 91 | self.title = None |
---|
[7304] | 92 | self.fcode = None |
---|
| 93 | self.dcode = None |
---|
[6795] | 94 | self.credits = None |
---|
| 95 | self.passmark = None |
---|
| 96 | self.semester = None |
---|
[6781] | 97 | return |
---|
| 98 | |
---|
| 99 | def getStudent(self): |
---|
| 100 | return self.__parent__.__parent__.__parent__ |
---|
| 101 | |
---|
[6782] | 102 | CourseTicket = attrs_to_fields(CourseTicket) |
---|
[7548] | 103 | |
---|
| 104 | class CourseTicketFactory(grok.GlobalUtility): |
---|
| 105 | """A factory for student study levels. |
---|
| 106 | """ |
---|
| 107 | grok.implements(IFactory) |
---|
| 108 | grok.name(u'waeup.CourseTicket') |
---|
| 109 | title = u"Create a new course ticket.", |
---|
| 110 | description = u"This factory instantiates new course ticket instances." |
---|
| 111 | |
---|
| 112 | def __call__(self, *args, **kw): |
---|
| 113 | return CourseTicket() |
---|
| 114 | |
---|
| 115 | def getInterfaces(self): |
---|
| 116 | return implementedBy(CourseTicket) |
---|