Changeset 16907


Ignore:
Timestamp:
25 Mar 2022, 18:49:53 (3 years ago)
Author:
Henrik Bettermann
Message:

Add cert courses tickets only if no carry-over ticket has been found.

File:
1 edited

Legend:

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

    r14384 r16907  
    2222import grok
    2323from zope.interface import implementedBy
     24from zope.component import createObject
    2425from waeup.kofa.students.studycourse import StudentStudyCourseFactory
    2526from waeup.kofa.utils.helpers import attrs_to_fields
    26 from waeup.kofa.students.interfaces import IStudentNavigation
     27from waeup.kofa.students.interfaces import (
     28    IStudentNavigation, IStudentStudyLevel)
    2729from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID
    2830from kofacustom.nigeria.students.studycourse import NigeriaStudentStudyCourse
     
    4850        return self.is_postgrad
    4951
     52    def addStudentStudyLevel(self, cert, studylevel, course_category=None):
     53        """Add a study level object.
     54        """
     55        if not IStudentStudyLevel.providedBy(studylevel):
     56            raise TypeError(
     57                'StudentStudyCourses contain only IStudentStudyLevel instances')
     58        self[str(studylevel.level)] = studylevel
     59        #studylevel.addCertCourseTickets(cert)
     60        # Collect carry-over courses in base levels (not in repeating levels)
     61        try:
     62            co_enabled = grok.getSite()['configuration'].carry_over
     63        except TypeError:
     64            # In tests we might not have a site object
     65            co_enabled = True
     66        if not co_enabled or studylevel.level % 100 != 0:
     67            return
     68        levels = sorted(self.keys())
     69        index = levels.index(str(studylevel.level))
     70        co_ticket = None
     71        if index > 0:
     72            previous_level = self[levels[index-1]]
     73            for key, val in previous_level.items():
     74                if val.total_score >= val.passmark:
     75                    continue
     76                if course_category and val.course_category != course_category:
     77                    continue
     78                if key in self[str(studylevel.level)]:
     79                    # Carry-over ticket exists
     80                    continue
     81                co_ticket = createObject(u'waeup.CourseTicket')
     82                for name in ['code', 'title', 'credits', 'passmark',
     83                             'semester', 'mandatory', 'fcode', 'dcode',
     84                             'course_category']:
     85                    setattr(co_ticket, name, getattr(val, name))
     86                co_ticket.automatic = True
     87                co_ticket.carry_over = True
     88                self[str(studylevel.level)][co_ticket.code] = co_ticket
     89        # AAUE modifaction: Add cert courses tickets only if no carry-over
     90        # ticket has been found
     91        if not co_ticket:
     92            studylevel.addCertCourseTickets(cert)
     93        return
     94
     95
    5096CustomStudentStudyCourse = attrs_to_fields(CustomStudentStudyCourse)
    5197
Note: See TracChangeset for help on using the changeset viewer.