## 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 2752 2007-11-24 06:06:14Z henrik $
"""
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:
        try:
            context.portal_workflow.doActionFor(level_doc.aq_parent,'open')
        except:
            pass
        level_doc.edit(mapping={'session': session_id})
        #context.portal_workflow.doActionFor(level_doc.aq_parent,'close_for_edit')
return session_id



