##parameters=key=None # $Id: getStudentLevelsVoc.py 3041 2008-01-24 08:44:19Z joachim $ """ Return the levels as an vocabulary """ student_id = context.getStudentId() end_level = 700 if student_id: end_level = context.students_catalog(id = student_id)[0].end_level if end_level and end_level.isdigit(): end_level = int(end_level) else: end_level = 700 if key is None: levels = [l for l in range(0,end_level+200,10) if l % 100 < 30 and l < end_level + 110] voc = [('','')] for l in levels: level_nr,repeat = divmod(l, 100) if level_nr > end_level/100: voc += ("%s" % l,"%s (spillover)" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1))), elif repeat > 0: voc += ("%s" % l,"%s (on %d. probation)" % (context.portal_vocabularies.levels.get("%d00" % (level_nr)), (repeat // 10))), else: voc += ("%03d" % l,"%s" % (context.portal_vocabularies.levels.get("%d00" % (level_nr)))), return voc if key and key.isdigit(): ikey = int(key) else: return '' level_nr,repeat = divmod(ikey, 100) l = [] level = context.portal_vocabularies.levels.get("%d00" % level_nr) if level_nr > end_level/100: return "%s Spillover" % context.portal_vocabularies.levels.get("%d00" % (level_nr - 1)) if repeat > 0: level += " on %d. Probation" % (repeat // 10) return level