source: WAeUP_SRP/base/skins/waeup_student/getStudentLevelsVoc.py @ 2782

Last change on this file since 2782 was 2716, checked in by Henrik Bettermann, 17 years ago

minor changes

  • Property svn:keywords set to Id
File size: 1.4 KB
RevLine 
[2632]1##parameters=key=None
2# $Id: getStudentLevelsVoc.py 2716 2007-11-20 16:41:16Z henrik $
3"""
4Return the levels as an vocabulary
5"""
[2641]6student_id = context.getStudentId()
[2650]7end_level = 700
[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:
[2641]16    levels = [l for l in range(100,end_level+200,10)
17               if l % 100 < 30 and l < end_level + 110]
[2682]18    voc = [('','')]
[2641]19    for l in levels:
20        level_nr,repeat = divmod(l, 100)
21        if level_nr > end_level/100:
22            voc += ("%s" % l,"%s (spillover)" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))),
23        elif repeat > 0:
[2649]24            voc += ("%s" % l,"%s (on %d. probation)" %
[2641]25                    (context.portal_vocabularies.levels.get("%d00" % (level_nr)),
26                                                            (repeat // 10))),
27        else:
[2649]28            voc += ("%s" % l,"%s" %
[2641]29                    (context.portal_vocabularies.levels.get("%d00" % (level_nr)))),
30    return voc
[2649]31
[2655]32if key and key.isdigit():
[2647]33    ikey = int(key)
[2650]34else:
[2647]35    return ''
[2716]36level_nr,repeat = divmod(ikey, 100)                               
[2632]37l = []
38
39level = context.portal_vocabularies.levels.get("%d00" % level_nr)
[2641]40if level_nr > end_level/100:
[2649]41    return "%s Spillover" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))
[2632]42
43if repeat > 0:
[2649]44    level += " on %d. Probation" % (repeat // 10)
[2632]45
46return level
47
Note: See TracBrowser for help on using the repository browser.