Ignore:
Timestamp:
13 Aug 2016, 03:23:04 (8 years ago)
Author:
Henrik Bettermann
Message:

Implement entry_session-dependent grading system.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py

    r13834 r14075  
    3131    StudentStudyLevel, CourseTicket,
    3232    CourseTicketFactory, StudentStudyLevelFactory)
    33 from waeup.kofa.students.interfaces import IStudentNavigation
     33from waeup.kofa.students.interfaces import IStudentNavigation, ICourseTicket
    3434from waeup.aaue.students.interfaces import (
    3535    ICustomStudentStudyLevel, ICustomCourseTicket)
    3636
    3737
    38 def getGradeWeightFromScore(score, ca):
     38def getGradeWeightFromScore(score, ca, student):
    3939    if None in (score, ca):
    4040        return (None, None)
     
    4848    if total >= 45:
    4949        return ('D',2)
    50     if total >= 40:
     50    if total >= 40 and student.entry_session < 2013:
    5151        return ('E',1)
    5252    return ('F',0)
     
    116116        return False
    117117
     118    def addCourseTicket(self, ticket, course):
     119        """Add a course ticket object.
     120        """
     121        if not ICourseTicket.providedBy(ticket):
     122            raise TypeError(
     123                'StudentStudyLeves contain only ICourseTicket instances')
     124        ticket.code = course.code
     125        ticket.title = course.title
     126        ticket.fcode = course.__parent__.__parent__.__parent__.code
     127        ticket.dcode = course.__parent__.__parent__.code
     128        ticket.credits = course.credits
     129        if self.student.entry_session < 2013:
     130            ticket.passmark = course.passmark - 5
     131        else:
     132            ticket.passmark = course.passmark
     133        ticket.semester = course.semester
     134        self[ticket.code] = ticket
     135        return
     136
    118137CustomStudentStudyLevel = attrs_to_fields(
    119138    CustomStudentStudyLevel, omit=[
     
    147166        """Returns the grade calculated from score.
    148167        """
    149         return getGradeWeightFromScore(self.score, self.ca)[0]
     168        return getGradeWeightFromScore(self.score, self.ca, self.student)[0]
    150169
    151170    @property
     
    153172        """Returns the weight calculated from score.
    154173        """
    155         return getGradeWeightFromScore(self.score, self.ca)[1]
     174        return getGradeWeightFromScore(self.score, self.ca, self.student)[1]
    156175
    157176CustomCourseTicket = attrs_to_fields(CustomCourseTicket)
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r14000 r14075  
    145145        # sgpa = 82 / 23
    146146        self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.565)
     147        return
     148
     149    def test_grade_weight(self):
     150        studylevel = createObject(u'waeup.StudentStudyLevel')
     151        studylevel.level = 100
     152        studylevel.level_session = 2005
     153        self.student['studycourse'].entry_mode = 'ug_ft'
     154        self.student['studycourse'].addStudentStudyLevel(
     155            self.certificate, studylevel)
     156        studylevel['COURSE1'].score = 42
     157        studylevel['COURSE1'].ca = 0
     158        courseticket = createObject('waeup.CourseTicket')
     159        self.assertEqual(studylevel['COURSE1'].weight, 1)
     160        self.assertEqual(studylevel['COURSE1'].grade, 'E')
     161        self.student['studycourse'].entry_session = 2015
     162        self.assertEqual(studylevel['COURSE1'].weight, 0)
     163        self.assertEqual(studylevel['COURSE1'].grade, 'F')
     164        studylevel['COURSE1'].score = 45
     165        self.assertEqual(studylevel['COURSE1'].weight, 2)
     166        self.assertEqual(studylevel['COURSE1'].grade, 'D')
    147167        return
    148168
Note: See TracChangeset for help on using the changeset viewer.