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

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

remove "processing in progress" (in custom)

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1##parameters=
2# $Id: create_level.py 1639 2007-03-26 14:31:22Z 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
14from Products.AdvancedQuery import Eq, Between, Le,In
15aq_portal = context.portal_catalog.evalAdvancedQuery
16aq_courses = context.courses_catalog.evalAdvancedQuery
17
18current = DateTime.DateTime()
19request = context.REQUEST
20session = request.SESSION
21response = request.RESPONSE
22redirect = response.redirect
23logger = logging.getLogger('Skins.create_level')
24mtool = context.portal_membership
25member = mtool.getAuthenticatedMember()
26member_id = str(member)
27lt = context.portal_layouts
28wt = context.waeup_tool
29student = context.students_catalog(id=context.getStudentId())[0]
30cert_id = student.course
31current_level = student.level
32in_progress =  request.get('in_progress','not started')
33
34if context.hasObject(current_level):
35    logger.info('%s", level %s already exists' % (student.id,current_level))
36    response.redirect("%s/%s" % (context.absolute_url(),current_level))
37    return
38
39##if in_progress in ('not started','started'):
40##    session.set('in_progress','started')
41##    view = context.in_progress_view(refresh=20,page='create_level?in_progress=started')
42##    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
43##    response.setHeader('Content-length','%d' % (len(view)))
44##    response.setStatus('OK')
45##    response.write(view)
46##    response.write('')
47##    if in_progress == 'started':
48##        return
49   
50
51context.invokeFactory('StudentStudyLevel',"%s" % current_level)
52level = getattr(context,"%s" % current_level)
53context.portal_workflow.doActionFor(level,'open')
54study_session = context.getSessionString()
55level.getContent().edit(mapping={'session': study_session})
56context.portal_workflow.doActionFor(level,'close_for_edit')
57results = context.results_import(matric_no = student.matric_no)
58if results:
59    #carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')]
60    l = []
61    carry_overs = results
62    for co in carry_overs:
63        carry_over = False
64        query = Eq('code',co.CosCode)
65        c_res = aq_courses(query)
66        if not c_res:
67            logger.info('%s", course %s not found in courses_catalog' % (student.id,co.CosCode))
68            continue
69        course_cat_entry = c_res[0]
70        passmark = getattr(course_cat_entry,'passmark',None)
71        if not passmark:
72            carry_over = co.GRADE in ('D','E','F')
73        else:
74            try:
75                score = int(co.Score)
76            except:
77                logger.info('%s, course %s has invalid score %s"' % (student.id,
78                                                                    co.CosCode,
79                                                                    co.Score))
80                continue
81            if int(c_res[0].passmark) <= score:
82                continue
83            carry_over = True
84        if not carry_over:
85            continue
86        d = context.getCourseInfo(co.CosCode)
87        d['grade'] = co.GRADE
88        d['carry_level'] = co.CarryLevel
89        cr_id = level.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode)
90        course_result = getattr(level,cr_id)
91        context.portal_workflow.doActionFor(course_result,'open')
92        course_result.getContent().edit(mapping=d)
93res = context.portal_catalog(portal_type="Certificate", id = cert_id)
94l = []
95if res:
96    cert = res[0]
97    path = cert.getPath()
98    query = Eq("path",path) &\
99            Eq('portal_type','CertificateCourse') &\
100            Eq('SearchableText', "%s" % current_level)
101    courses = aq_portal(query)
102    for c in courses:
103        d = context.getCourseInfo(c.getId)
104        cr_id = level.invokeFactory('StudentCourseResult',c.getId)
105        course_result = getattr(level,cr_id)
106        context.portal_workflow.doActionFor(course_result,'open')
107        d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
108        course_result.getContent().edit(mapping=d)
109
110return response.redirect("%s/%s" % (context.absolute_url(),current_level))
111
Note: See TracBrowser for help on using the repository browser.