source: WAeUP_SRP/trunk/skins/waeup_student/getStudentLevelsVoc.py @ 6645

Last change on this file since 6645 was 5033, checked in by Henrik Bettermann, 15 years ago

increase level range

  • Property svn:keywords set to Id
File size: 1.8 KB
RevLine 
[2632]1##parameters=key=None
2# $Id: getStudentLevelsVoc.py 5033 2010-02-23 08:36:45Z henrik $
3"""
4Return the levels as an vocabulary
5"""
[2641]6student_id = context.getStudentId()
[5033]7end_level = 800
[2641]8if student_id:
[2650]9    end_level = context.students_catalog(id = student_id)[0].end_level
[2655]10    if end_level and end_level.isdigit():
[2650]11        end_level = int(end_level)
[2716]12    else:
13        end_level = 700
[2655]14
[2632]15if key is None:
[3040]16    levels = [l for l in range(0,end_level+200,10)
[3869]17               if l % 100 < 30 and l < end_level + 120]
[2682]18    voc = [('','')]
[2641]19    for l in levels:
20        level_nr,repeat = divmod(l, 100)
[3869]21        if level_nr > end_level/100 and repeat:
22            voc += ("%s" % l,"%s (2nd spillover)" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))),
23        elif level_nr > end_level/100:
[2641]24            voc += ("%s" % l,"%s (spillover)" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))),
25        elif repeat > 0:
[2649]26            voc += ("%s" % l,"%s (on %d. probation)" %
[2641]27                    (context.portal_vocabularies.levels.get("%d00" % (level_nr)),
28                                                            (repeat // 10))),
29        else:
[3041]30            voc += ("%03d" % l,"%s" %
[2641]31                    (context.portal_vocabularies.levels.get("%d00" % (level_nr)))),
32    return voc
[2649]33
[2655]34if key and key.isdigit():
[2647]35    ikey = int(key)
[2650]36else:
[3254]37    raise KeyError
[3040]38level_nr,repeat = divmod(ikey, 100)
[2632]39l = []
40
[3254]41level = context.portal_vocabularies.levels.get("%d00" % level_nr,None)
42if level is None:
43    raise KeyError
44   
[3869]45if level_nr > end_level/100 and repeat:   
46    return "%s 2nd Spillover" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))
47elif level_nr > end_level/100:
[2649]48    return "%s Spillover" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))
[2632]49
50if repeat > 0:
[2649]51    level += " on %d. Probation" % (repeat // 10)
[2632]52
53return level
54
Note: See TracBrowser for help on using the repository browser.