##parameters= # $Id: create_level.py 1492 2007-02-25 16:24:11Z joachim $ """ process the Application Form return html renderer + psm """ request = context.REQUEST import DateTime,logging try: from Products.zdb import set_trace except: def set_trace(): pass current = DateTime.DateTime() request = context.REQUEST session = request.SESSION response = request.RESPONSE redirect = response.redirect logger = logging.getLogger('Student.create_level') students = context.portal_directories.students mtool = context.portal_membership member = mtool.getAuthenticatedMember() member_id = str(member) lt = context.portal_layouts wt = context.waeup_tool student = context.students_catalog(id=context.getStudentId())[0] cert_id = student.course in_progress = session.get('in_progress','finished') if in_progress == 'finished': session.set('in_progress','started') view = context.in_progress_view(refresh=3,page='study_level_view') response.setHeader('Content-type','text/html; charset=ISO-8859-15') response.setHeader('Content-length','%d' % (len(view))) response.setStatus('OK') response.write(view) response.write('') elif in_progress == 'started': return context.invokeFactory('StudentStudyLevel',"%s" % current_level) level = getattr(context,"%s" % current_level) session = context.getSessionString() level.getContent().edit(mapping={'session': session}) context.portal_workflow.doActionFor(level,'open') context.portal_workflow.doActionFor(level,'close_for_edit') results = context.results_import(matric_no = student.matric_no) carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')] l = [] for co in carry_overs: d = context.getCourseInfo(co.CosCode) d['grade'] = co.GRADE d['carry_level'] = co.CarryLevel cr_id = context.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode) getattr(context,cr_id).getContent().edit(mapping=d) res = context.portal_catalog(portal_type="Certificate", id = cert_id) l = [] if res: cert = res[0] path = cert.getPath() query = Eq("path",path) &\ Eq('portal_type','CertificateCourse') &\ Eq('SearchableText', "%s" % student.level) courses = evalAdvancedQuery(query) for c in courses: d = context.getCourseInfo(c.getId) cr_id = context.invokeFactory('StudentCourseResult',c.getId) d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') getattr(context,cr_id).getContent().edit(mapping=d) session.set('in_progress','finished') return "finished"