Last change
on this file since 2644 was
2641,
checked in by joachim, 17 years ago
|
belongs to previous fix for #207
|
-
Property svn:keywords set to
Id
|
File size:
1.4 KB
|
Line | |
---|
1 | ##parameters=key=None |
---|
2 | # $Id: getStudentLevelsVoc.py 2641 2007-11-13 14:07:36Z joachim $ |
---|
3 | """ |
---|
4 | Return the levels as an vocabulary |
---|
5 | # |
---|
6 | try: |
---|
7 | from Products.zdb import set_trace |
---|
8 | except: |
---|
9 | def set_trace(): |
---|
10 | pass |
---|
11 | """ |
---|
12 | student_id = context.getStudentId() |
---|
13 | if student_id: |
---|
14 | end_level = int(context.students_catalog(id = student_id)[0].end_level) |
---|
15 | else: |
---|
16 | end_level = 600 |
---|
17 | |
---|
18 | if key is None: |
---|
19 | levels = [l for l in range(100,end_level+200,10) |
---|
20 | if l % 100 < 30 and l < end_level + 110] |
---|
21 | voc = [] |
---|
22 | for l in levels: |
---|
23 | level_nr,repeat = divmod(l, 100) |
---|
24 | if level_nr > end_level/100: |
---|
25 | voc += ("%s" % l,"%s (spillover)" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))), |
---|
26 | elif repeat > 0: |
---|
27 | voc += ("%s" % l,"%s (on %d. probation)" % |
---|
28 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)), |
---|
29 | (repeat // 10))), |
---|
30 | else: |
---|
31 | voc += ("%s" % l,"%s" % |
---|
32 | (context.portal_vocabularies.levels.get("%d00" % (level_nr)))), |
---|
33 | return voc |
---|
34 | |
---|
35 | ikey = int(key) |
---|
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 | |
---|
Note: See
TracBrowser for help on using the repository browser.