1 | ##parameters=key=None |
---|
2 | # $Id: getStudentLevelsVoc.py 2682 2007-11-16 21:45:32Z henrik $ |
---|
3 | """ |
---|
4 | Return the levels as an vocabulary |
---|
5 | """ |
---|
6 | student_id = context.getStudentId() |
---|
7 | end_level = 700 |
---|
8 | if student_id: |
---|
9 | end_level = context.students_catalog(id = student_id)[0].end_level |
---|
10 | if end_level and end_level.isdigit(): |
---|
11 | end_level = int(end_level) |
---|
12 | |
---|
13 | if key is None: |
---|
14 | levels = [l for l in range(100,end_level+200,10) |
---|
15 | if l % 100 < 30 and l < end_level + 110] |
---|
16 | voc = [('','')] |
---|
17 | for l in levels: |
---|
18 | level_nr,repeat = divmod(l, 100) |
---|
19 | if level_nr > end_level/100: |
---|
20 | voc += ("%s" % l,"%s (spillover)" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))), |
---|
21 | elif repeat > 0: |
---|
22 | voc += ("%s" % l,"%s (on %d. probation)" % |
---|
23 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)), |
---|
24 | (repeat // 10))), |
---|
25 | else: |
---|
26 | voc += ("%s" % l,"%s" % |
---|
27 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)))), |
---|
28 | return voc |
---|
29 | |
---|
30 | if key and key.isdigit(): |
---|
31 | ikey = int(key) |
---|
32 | else: |
---|
33 | return '' |
---|
34 | level_nr,repeat = divmod(ikey, 100) |
---|
35 | l = [] |
---|
36 | |
---|
37 | level = context.portal_vocabularies.levels.get("%d00" % level_nr) |
---|
38 | if level_nr > end_level/100: |
---|
39 | return "%s Spillover" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1)) |
---|
40 | |
---|
41 | if repeat > 0: |
---|
42 | level += " on %d. Probation" % (repeat // 10) |
---|
43 | |
---|
44 | return level |
---|
45 | |
---|