source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/studylevel.py @ 15068

Last change on this file since 15068 was 14988, checked in by Henrik Bettermann, 7 years ago

DSPG course grading system is different.

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1## $Id: studylevel.py 14988 2018-04-23 13:28:21Z henrik $
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"""
19Container which holds the data of a student study level
20and contains the course tickets.
21"""
22import grok
23from zope.component.interfaces import IFactory
24from zope.interface import implementedBy
25from waeup.kofa.utils.helpers import attrs_to_fields
26from waeup.kofa.students.studylevel import (
27    StudentStudyLevel, CourseTicket,
28    CourseTicketFactory, StudentStudyLevelFactory)
29from waeup.kofa.students.interfaces import IStudentNavigation
30from kofacustom.dspg.students.interfaces import (
31    ICustomStudentStudyLevel, ICustomCourseTicket)
32
33
34class CustomStudentStudyLevel(StudentStudyLevel):
35    """This is a container for course tickets.
36    """
37    grok.implements(ICustomStudentStudyLevel, IStudentNavigation)
38    grok.provides(ICustomStudentStudyLevel)
39
40CustomStudentStudyLevel = attrs_to_fields(
41    CustomStudentStudyLevel, omit=['total_credits', 'gpa'])
42
43class 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
53class CustomCourseTicket(CourseTicket):
54    """
55    """
56    grok.implements(ICustomCourseTicket, IStudentNavigation)
57    grok.provides(ICustomCourseTicket)
58
59
60    @property
61    def _getGradeWeightFromScore(self):
62        """DSPG Course Grading System
63        """
64        if self.total_score is None:
65            return (None, None)
66        if self.total_score >= 75:
67            return ('A',4)
68        if self.total_score >= 70:
69            return ('AB',3.5)
70        if self.total_score >= 65:
71            return ('B',3.25)
72        if self.total_score >= 60:
73            return ('BC',3.0)
74        if self.total_score >= 55:
75            return ('C',2.75)
76        if self.total_score >= 50:
77            return ('CD',2.5)
78        if self.total_score >= 45:
79            return ('D',2.25)
80        if self.total_score >= 40:
81            return ('E',2)
82        return ('F',0)
83
84
85CustomCourseTicket = attrs_to_fields(CustomCourseTicket)
86
87class CustomCourseTicketFactory(CourseTicketFactory):
88    """A factory for student study levels.
89    """
90
91    def __call__(self, *args, **kw):
92        return CustomCourseTicket()
93
94    def getInterfaces(self):
95        return implementedBy(CustomCourseTicket)
Note: See TracBrowser for help on using the repository browser.