Last change
on this file since 2647 was
2647,
checked in by Henrik Bettermann, 17 years ago
|
fixed
|
-
Property svn:keywords set to
Id
|
File size:
1.3 KB
|
Line | |
---|
1 | ##parameters=key=None |
---|
2 | # $Id: getStudentLevelsVoc.py 2647 2007-11-13 21:22:00Z henrik $ |
---|
3 | """ |
---|
4 | Return the levels as an vocabulary |
---|
5 | """ |
---|
6 | student_id = context.getStudentId() |
---|
7 | if student_id: |
---|
8 | end_level = int(context.students_catalog(id = student_id)[0].end_level) |
---|
9 | else: |
---|
10 | end_level = 600 |
---|
11 | |
---|
12 | if key is None: |
---|
13 | levels = [l for l in range(100,end_level+200,10) |
---|
14 | if l % 100 < 30 and l < end_level + 110] |
---|
15 | voc = [] |
---|
16 | for l in levels: |
---|
17 | level_nr,repeat = divmod(l, 100) |
---|
18 | if level_nr > end_level/100: |
---|
19 | voc += ("%s" % l,"%s (spillover)" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))), |
---|
20 | elif repeat > 0: |
---|
21 | voc += ("%s" % l,"%s (on %d. probation)" % |
---|
22 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)), |
---|
23 | (repeat // 10))), |
---|
24 | else: |
---|
25 | voc += ("%s" % l,"%s" % |
---|
26 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)))), |
---|
27 | return voc |
---|
28 | |
---|
29 | try: |
---|
30 | ikey = int(key) |
---|
31 | except ValueError: |
---|
32 | return '' |
---|
33 | level_nr,repeat = divmod(ikey, 100) |
---|
34 | l = [] |
---|
35 | |
---|
36 | level = context.portal_vocabularies.levels.get("%d00" % level_nr) |
---|
37 | if level_nr > end_level/100: |
---|
38 | return "%s spillover" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1)) |
---|
39 | |
---|
40 | if repeat > 0: |
---|
41 | level += " on %d. probation" % (repeat // 10) |
---|
42 | |
---|
43 | return level |
---|
44 | |
---|
45 | |
---|
Note: See
TracBrowser for help on using the repository browser.