source: WAeUP_SRP/branches/regebro-noskins/skins/waeup_student/refresh_level.py @ 17367

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

M profiles/default/vocabularies/verdicts.xml
added "N/A"
M skins/waeup_student/getSessionResults.py
check vocabulary for key
M skins/waeup_student/study_level_view.pt
add "Refresh List" button
AM skins/waeup_student/refresh_level.py

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