Index: WAeUP_SRP/base/WAeUPTables.py
===================================================================
--- WAeUP_SRP/base/WAeUPTables.py	(revision 2631)
+++ WAeUP_SRP/base/WAeUPTables.py	(revision 2632)
@@ -90,5 +90,5 @@
 ###)
 
-    def record2dict(self,fields,record):
+    def record2dict(self,fields,record): ###(
         d = {}
         for key in fields:
@@ -109,4 +109,6 @@
                 d[key] = ''
         return d
+
+###)
 
     def addRecord(self, **data): ###(
@@ -602,10 +604,10 @@
     #               "course_admitted",
     #               )
+    ###)
+
     def __init__(self,name=None):
         if name ==  None:
             name = self.name
         WAeUPTable.__init__(self, name)
-
-
 
     security.declareProtected(ModifyPortalContent,"new_importCSV")###(
@@ -722,5 +724,5 @@
                     logger.info("invalid mode: %s" % mode)
         logger.info("%(mode)sed %(imported)d records, invalid written to %(not_imported_fn)s" % d)
-###)
+    ###)
 
 InitializeClass(ApplicantsCatalog)
Index: WAeUP_SRP/base/WAeUPTool.py
===================================================================
--- WAeUP_SRP/base/WAeUPTool.py	(revision 2631)
+++ WAeUP_SRP/base/WAeUPTool.py	(revision 2632)
@@ -304,5 +304,7 @@
         repository = getToolByName(self, 'portal_repository')
         pxtool = getToolByName(self, 'portal_proxies')
+        logger.info('start')
         pxtool_infos = pxtool.getRevisionsUsed()
+        logger.info('found  %d used revisions ' % (len(pxtool_infos)))
 
         nb_revs = 0
@@ -310,7 +312,9 @@
         unused_docids_d = {} # all docids that are unused
         ids_unused_revs_docids = [] # ids for revs of unused docids
-        ids_unused_revs = [] # ids for unused revs
+        unused_ids = [] # ids for unused revs
         total = 0
         idlist = repository.objectIds()
+        to_delete = 0
+        found = False
         for id in idlist:
             docid, rev = repository._splitId(id)
@@ -319,23 +323,23 @@
                 continue
             nb_revs += 1
-            docids_d[docid] = None
             if not pxtool_infos.has_key(docid):
-                unused_docids_d[docid] = None
-                ids_unused_revs_docids.append(id)
-                ids_unused_revs.append(id)
+                found = True
+                to_delete += 1
+                unused_ids.append(id)
             elif not pxtool_infos[docid].has_key(rev):
-                ids_unused_revs.append(id)
-            if len(ids_unused_revs) >= max:
-                repository.manage_delObjects(ids_unused_revs)
+                found = True
+                to_delete += 1
+                unused_ids.append(id)
+            if found and not to_delete % max:
+                found = False
                 #import pdb;pdb.set_trace()
+                repository.manage_delObjects(unused_ids)
                 transaction.commit()
-                total += max
-                logger.info('removed %d total %d unused docids ' % (max,total))
-        anz = len(ids_unused_revs)
-        if anz > 0:
-            repository.manage_delObjects(ids_unused_revs)
-            transaction.commit()
-            total += anz
-            logger.info('finished removing %d unused docids ' % (total))
+                logger.info('removed %d total %d unused docids ' % (max,to_delete))
+        else:
+            if unused_ids:
+                repository.manage_delObjects(unused_ids)
+                transaction.commit()
+        logger.info('finished removing %d unused docids ' % (to_delete))
 
 
Index: WAeUP_SRP/base/Widgets.py
===================================================================
--- WAeUP_SRP/base/Widgets.py	(revision 2631)
+++ WAeUP_SRP/base/Widgets.py	(revision 2632)
@@ -276,9 +276,11 @@
         if len(v) == 1:
             v = value = '0%c' % v
+        elif len(v) == 9:
+            v = value[2:4]
         elif not value:
             v = value = self.getSessionId()[0]
         #import pdb;pdb.set_trace()
         sessions = self._getSessions()
-        if not sessions.has_key(value):
+        if not sessions.has_key(v):
             datastructure.setError(widget_id, "'%s' not a valid session key" % v)
             return 0
Index: WAeUP_SRP/base/skins/waeup_student/get_student_levels.py
===================================================================
--- WAeUP_SRP/base/skins/waeup_student/get_student_levels.py	(revision 2632)
+++ WAeUP_SRP/base/skins/waeup_student/get_student_levels.py	(revision 2632)
@@ -0,0 +1,28 @@
+##parameters=key=None
+# $Id$
+"""
+Return the levels as an vocabulary
+#
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+"""
+
+if key is None:
+    return [("%s" % l,"Level %s" % l) for l in range(100,700,100)]
+ikey = int(key)
+level_nr,repeat = divmod(ikey, 100)
+l = []
+student = context.students_catalog(id = context.getStudentId())[0]
+
+level = context.portal_vocabularies.levels.get("%d00" % level_nr)
+if level_nr > int(student.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
+
Index: WAeUP_SRP/base/skins/waeup_student/study_course_view.pt
===================================================================
--- WAeUP_SRP/base/skins/waeup_student/study_course_view.pt	(revision 2631)
+++ WAeUP_SRP/base/skins/waeup_student/study_course_view.pt	(revision 2632)
@@ -31,5 +31,5 @@
       <tr>
         <td width="220px">Current Study Level:</td> 
-        <td><span tal:content="python:context.portal_vocabularies.levels.get(info['doc'].current_level)" /></td>
+        <td><span tal:content="python:context.portal_vocabularies.student_levels.get(info['doc'].current_level)" /></td>
       </tr>
       <tr>
Index: WAeUP_SRP/uniben/profiles/default/layouts/student_study_course.xml
===================================================================
--- WAeUP_SRP/uniben/profiles/default/layouts/student_study_course.xml	(revision 2631)
+++ WAeUP_SRP/uniben/profiles/default/layouts/student_study_course.xml	(revision 2632)
@@ -59,5 +59,5 @@
   <property name="hidden_layout_modes"/>
   <property name="hidden_readonly_layout_modes"/>
-  <property name="vocabulary">levels</property>
+  <property name="vocabulary">student_levels</property>
  </widget>
  <widget name="current_mode" meta_type="Select Widget">
Index: WAeUP_SRP/uniben/profiles/default/vocabularies.xml
===================================================================
--- WAeUP_SRP/uniben/profiles/default/vocabularies.xml	(revision 2631)
+++ WAeUP_SRP/uniben/profiles/default/vocabularies.xml	(revision 2632)
@@ -6,4 +6,5 @@
  <object name="acco_hall_reserved_rooms" meta_type="CPS Method Vocabulary"/>
  <object name="levels" meta_type="CPS Vocabulary"/>
+ <object name="student_levels" meta_type="CPS Method Vocabulary"/>
  <object name="csv_names" meta_type="CPS Method Vocabulary"/>
  <object name="entry_modes" meta_type="CPS Vocabulary"/>
Index: WAeUP_SRP/uniben/profiles/default/vocabularies/student_levels.xml
===================================================================
--- WAeUP_SRP/uniben/profiles/default/vocabularies/student_levels.xml	(revision 2632)
+++ WAeUP_SRP/uniben/profiles/default/vocabularies/student_levels.xml	(revision 2632)
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="vocabulary.xsl"?>
+<object name="student_levels" meta_type="CPS Method Vocabulary">
+ <property name="title"></property>
+ <property name="title_msgid"></property>
+ <property name="description"></property>
+ <property name="get_vocabulary_method">get_student_levels</property>
+ <property name="add_empty_key">False</property>
+ <property name="empty_key_pos">first</property>
+ <property name="empty_key_value"></property>
+ <property name="empty_key_value_i18n"></property>
+</object>
