source: WAeUP_SRP/trunk/skins/waeup_student/refresh_level.py @ 1589

Last change on this file since 1589 was 1571, checked in by Henrik Bettermann, 18 years ago

new logging format Part 4 (rest)

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