## Script (Python) "getLevelSession" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=level_doc,student_id,level_id ##title= ## # $Id: getLevelSession.py 2470 2007-10-29 09:05:08Z joachim $ """ return fixed session_id from level """ try: from Products.zdb import set_trace except: def set_trace(): pass import logging logger = logging.getLogger('Skins.getLevelSession') session_id = level_doc.session changed = False if len(session_id) == 2: pass elif len(session_id) == 9: changed = True session_id = session_id[2:4] if len(session_id) != 2: logger.info("invalid session %s in level %s for student %s" % (session_id,level_id,student_id)) else: if changed: context.portal_workflow.doActionFor(level_doc.aq_parent,'open') level_doc.edit(mapping={'session': session_id}) context.portal_workflow.doActionFor(level_doc.aq_parent,'close_for_edit') return session_id