Ignore:
Timestamp:
13 Sep 2011, 07:28:26 (13 years ago)
Author:
Henrik Bettermann
Message:

Replace the static study_levels vocab by a StudyLevelSource?.

The StudyLevelSource? is based on and extends the
course_levels vocabulary defined in the university package.
Repeating study levels are denoted by increments of 10, the
first spillover level by the certificate's end level plus 100
and the second spillover level by the end level plus 110.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6724 r6725  
    77from waeup.sirp.students.vocabularies import (
    88  year_range, lgas_vocab, CertificateSource, GenderSource,
    9   entry_session_vocab, study_levels, verdicts,
     9  entry_session_vocab, verdicts, StudyLevelSource,
    1010  )
    1111
     
    137137    current_level = schema.Choice(
    138138        title = u'Current Level',
    139         source = study_levels,
     139        source = StudyLevelSource(),
    140140        default = None,
    141         required = True,
     141        required = False,
    142142        )
    143143
     
    146146        source = verdicts,
    147147        default = None,
    148         required = True,
     148        required = False,
    149149        )
    150150
     
    153153        source = verdicts,
    154154        default = None,
    155         required = True,
     155        required = False,
    156156        )
    157157
  • main/waeup.sirp/trunk/src/waeup/sirp/students/vocabularies.py

    r6724 r6725  
    88from waeup.sirp.interfaces import SimpleWAeUPVocabulary
    99from waeup.sirp.students.lgas import LGAS
     10from waeup.sirp.university.vocabularies import course_levels
    1011
    1112def year_range():
     
    2324    *sorted([(x[1],x[0]) for x in LGAS]))
    2425
    25 # This will become a source with probation and
    26 # splill-over levels too
    27 study_levels = SimpleWAeUPVocabulary(
    28     ('Pre-Studies',0),
    29     ('100 (Year 1)',100),
    30     ('200 (Year 2)',200),
    31     ('300 (Year 3)',300),
    32     ('400 (Year 4)',400),
    33     ('500 (Year 5)',500),
    34     ('600 (Year 6)',600),
    35     ('700 (Year 7)',700),
    36     ('800 (Year 8)',800),
    37     )
     26def study_levels(studycourse):
     27    try:
     28        start_level = int(studycourse.certificate.start_level)
     29        end_level = int(studycourse.certificate.end_level)
     30        levels = [level for level in range(start_level,end_level+200,10)
     31                   if level % 100 < 30 and level < end_level + 120]
     32        return levels
     33    except AttributeError:
     34        return []
     35   
     36class StudyLevelSource(BasicContextualSourceFactory):
     37    """The StudyLevelSource is based on and extends the
     38    course_levels vocabulary defined in the university package.
     39    Repeating study levels are denoted by increments of 10, the
     40    first spillover level by the certificate's end level plus 100
     41    and the second spillover level by the end level plus 110.
     42    """
     43    def getValues(self, context):
     44        return study_levels(context)
     45
     46    def getToken(self, context, value):
     47        return str(value)
     48
     49    def getTitle(self, context, value):
     50        end_level = int(context.certificate.end_level)
     51        level,repeat = divmod(value, 100)
     52        level = level * 100
     53        repeat = repeat//10
     54        title = course_levels.by_value[level].title
     55        if level > end_level and repeat:
     56            title = course_levels.by_value[level-100].title
     57            title = "%s 2nd spillover" % title
     58        elif level > end_level:
     59            title = course_levels.by_value[level-100].title
     60            title = "%s spillover" % title
     61        elif repeat:
     62            title = "%s on %d. probation" % (title, repeat)
     63        return title
    3864
    3965verdicts = SimpleWAeUPVocabulary(
Note: See TracChangeset for help on using the changeset viewer.