[1492] | 1 | ##parameters= |
---|
| 2 | # $Id: create_level.py 1492 2007-02-25 16:24:11Z joachim $ |
---|
| 3 | """ |
---|
| 4 | process the Application Form |
---|
| 5 | return html renderer + psm |
---|
| 6 | """ |
---|
| 7 | request = context.REQUEST |
---|
| 8 | import DateTime,logging |
---|
| 9 | try: |
---|
| 10 | from Products.zdb import set_trace |
---|
| 11 | except: |
---|
| 12 | def set_trace(): |
---|
| 13 | pass |
---|
| 14 | |
---|
| 15 | current = DateTime.DateTime() |
---|
| 16 | request = context.REQUEST |
---|
| 17 | session = request.SESSION |
---|
| 18 | response = request.RESPONSE |
---|
| 19 | redirect = response.redirect |
---|
| 20 | logger = logging.getLogger('Student.create_level') |
---|
| 21 | students = context.portal_directories.students |
---|
| 22 | mtool = context.portal_membership |
---|
| 23 | member = mtool.getAuthenticatedMember() |
---|
| 24 | member_id = str(member) |
---|
| 25 | lt = context.portal_layouts |
---|
| 26 | wt = context.waeup_tool |
---|
| 27 | student = context.students_catalog(id=context.getStudentId())[0] |
---|
| 28 | cert_id = student.course |
---|
| 29 | in_progress = session.get('in_progress','finished') |
---|
| 30 | if in_progress == 'finished': |
---|
| 31 | session.set('in_progress','started') |
---|
| 32 | view = context.in_progress_view(refresh=3,page='study_level_view') |
---|
| 33 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
| 34 | response.setHeader('Content-length','%d' % (len(view))) |
---|
| 35 | response.setStatus('OK') |
---|
| 36 | response.write(view) |
---|
| 37 | response.write('') |
---|
| 38 | elif in_progress == 'started': |
---|
| 39 | return |
---|
| 40 | context.invokeFactory('StudentStudyLevel',"%s" % current_level) |
---|
| 41 | level = getattr(context,"%s" % current_level) |
---|
| 42 | session = context.getSessionString() |
---|
| 43 | level.getContent().edit(mapping={'session': session}) |
---|
| 44 | context.portal_workflow.doActionFor(level,'open') |
---|
| 45 | context.portal_workflow.doActionFor(level,'close_for_edit') |
---|
| 46 | results = context.results_import(matric_no = student.matric_no) |
---|
| 47 | carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')] |
---|
| 48 | l = [] |
---|
| 49 | for co in carry_overs: |
---|
| 50 | d = context.getCourseInfo(co.CosCode) |
---|
| 51 | d['grade'] = co.GRADE |
---|
| 52 | d['carry_level'] = co.CarryLevel |
---|
| 53 | cr_id = context.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode) |
---|
| 54 | getattr(context,cr_id).getContent().edit(mapping=d) |
---|
| 55 | res = context.portal_catalog(portal_type="Certificate", id = cert_id) |
---|
| 56 | l = [] |
---|
| 57 | if res: |
---|
| 58 | cert = res[0] |
---|
| 59 | path = cert.getPath() |
---|
| 60 | query = Eq("path",path) &\ |
---|
| 61 | Eq('portal_type','CertificateCourse') &\ |
---|
| 62 | Eq('SearchableText', "%s" % student.level) |
---|
| 63 | courses = evalAdvancedQuery(query) |
---|
| 64 | for c in courses: |
---|
| 65 | d = context.getCourseInfo(c.getId) |
---|
| 66 | cr_id = context.invokeFactory('StudentCourseResult',c.getId) |
---|
| 67 | d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') |
---|
| 68 | getattr(context,cr_id).getContent().edit(mapping=d) |
---|
| 69 | session.set('in_progress','finished') |
---|
| 70 | return "finished" |
---|