source: WAeUP_SRP/trunk/skins/waeup_student/create_level.py @ 1493

Last change on this file since 1493 was 1492, checked in by joachim, 18 years ago

create level button, create_level function

  • Property svn:keywords set to Id
File size: 2.4 KB
RevLine 
[1492]1##parameters=
2# $Id: create_level.py 1492 2007-02-25 16:24:11Z joachim $
3"""
4process the Application Form
5return html renderer + psm
6"""
7request = context.REQUEST
8import DateTime,logging
9try:
10    from Products.zdb import set_trace
11except:
12    def set_trace():
13        pass
14
15current = DateTime.DateTime()
16request = context.REQUEST
17session = request.SESSION
18response = request.RESPONSE
19redirect = response.redirect
20logger = logging.getLogger('Student.create_level')
21students = context.portal_directories.students
22mtool = context.portal_membership
23member = mtool.getAuthenticatedMember()
24member_id = str(member)
25lt = context.portal_layouts
26wt = context.waeup_tool
27student = context.students_catalog(id=context.getStudentId())[0]
28cert_id = student.course
29in_progress =  session.get('in_progress','finished')
30if 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('')
38elif in_progress == 'started':
39    return
40context.invokeFactory('StudentStudyLevel',"%s" % current_level)
41level = getattr(context,"%s" % current_level)
42session = context.getSessionString()
43level.getContent().edit(mapping={'session': session})
44context.portal_workflow.doActionFor(level,'open')
45context.portal_workflow.doActionFor(level,'close_for_edit')
46results = context.results_import(matric_no = student.matric_no)
47carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')]
48l = []
49for 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)
55res = context.portal_catalog(portal_type="Certificate", id = cert_id)
56l = []
57if 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)
69session.set('in_progress','finished')
70return "finished"
Note: See TracBrowser for help on using the repository browser.