1 | ##parameters=key=None |
---|
2 | # $Id: getStudentLevelsVoc.py 3041 2008-01-24 08:44:19Z joachim $ |
---|
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 | else: |
---|
13 | end_level = 700 |
---|
14 | |
---|
15 | if key is None: |
---|
16 | levels = [l for l in range(0,end_level+200,10) |
---|
17 | if l % 100 < 30 and l < end_level + 110] |
---|
18 | voc = [('','')] |
---|
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: |
---|
24 | voc += ("%s" % l,"%s (on %d. probation)" % |
---|
25 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)), |
---|
26 | (repeat // 10))), |
---|
27 | else: |
---|
28 | voc += ("%03d" % l,"%s" % |
---|
29 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)))), |
---|
30 | return voc |
---|
31 | |
---|
32 | if key and key.isdigit(): |
---|
33 | ikey = int(key) |
---|
34 | else: |
---|
35 | return '' |
---|
36 | level_nr,repeat = divmod(ikey, 100) |
---|
37 | l = [] |
---|
38 | |
---|
39 | level = context.portal_vocabularies.levels.get("%d00" % level_nr) |
---|
40 | if level_nr > end_level/100: |
---|
41 | return "%s Spillover" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1)) |
---|
42 | |
---|
43 | if repeat > 0: |
---|
44 | level += " on %d. Probation" % (repeat // 10) |
---|
45 | |
---|
46 | return level |
---|
47 | |
---|