source: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/create_level.py @ 14074

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

merged changes from trunk to joachim-event-branch

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