1 | ## Script (Python) "student_index" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=batch=None |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: student_index.py 1380 2007-01-31 16:24:18Z joachim $ |
---|
11 | """ |
---|
12 | return the current student_index_html |
---|
13 | """ |
---|
14 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
15 | evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery |
---|
16 | |
---|
17 | request = context.REQUEST |
---|
18 | session = request.SESSION |
---|
19 | response = request.RESPONSE |
---|
20 | redirect = response.redirect |
---|
21 | pm = context.portal_membership |
---|
22 | member = pm.getAuthenticatedMember() |
---|
23 | |
---|
24 | #from Products.zdb import set_trace;set_trace() |
---|
25 | if context.isStaff(): |
---|
26 | if context.portal_type == 'StudentStudyCourse': |
---|
27 | return context.study_course_view() |
---|
28 | elif context.portal_type == 'StudentStudyLevel': |
---|
29 | return context.study_level_view() |
---|
30 | elif context.portal_type == 'StudentClearance': |
---|
31 | return context.clearance_view() |
---|
32 | elif context.portal_type == 'PaymentsFolder': |
---|
33 | return context.payments_view() |
---|
34 | elif context.portal_type == 'Student': |
---|
35 | return redirect("%s/student_view" % context.absolute_url()) |
---|
36 | elif context.portal_type == 'Payment': |
---|
37 | return context.payment_receipt() |
---|
38 | return redirect("%s/waeup_document_view" % context.absolute_url()) |
---|
39 | if context.isStudent(): |
---|
40 | if context.portal_type == 'PaymentsFolder': |
---|
41 | return context.payments_view() |
---|
42 | elif context.portal_type == 'Payment': |
---|
43 | return context.payment_receipt() |
---|
44 | elif context.portal_type == 'StudentStudyLevel': |
---|
45 | if context.objectIds(): |
---|
46 | return context.study_level_view() |
---|
47 | student = context.students_catalog(id=context.getStudentId())[0] |
---|
48 | cert_id = student.course |
---|
49 | in_progress = session.get('in_progress','finished') |
---|
50 | if in_progress == 'finished': |
---|
51 | session.set('in_progress','started') |
---|
52 | view = context.in_progress_view(refresh=3,page='study_level_view') |
---|
53 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
54 | response.setHeader('Content-length','%d' % (len(view))) |
---|
55 | response.setStatus('OK') |
---|
56 | response.write(view) |
---|
57 | response.write('') |
---|
58 | elif in_progress == 'started': |
---|
59 | return |
---|
60 | #from Products.zdb import set_trace;set_trace() |
---|
61 | results = context.results_import(matric_no = student.matric_no) |
---|
62 | carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')] |
---|
63 | l = [] |
---|
64 | for co in carry_overs: |
---|
65 | d = context.getCourseInfo(co.CosCode) |
---|
66 | d['grade'] = co.GRADE |
---|
67 | d['carry_level'] = co.CarryLevel |
---|
68 | cr_id = context.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode) |
---|
69 | getattr(context,cr_id).getContent().edit(mapping=d) |
---|
70 | res = context.portal_catalog(portal_type="Certificate", id = cert_id) |
---|
71 | l = [] |
---|
72 | if res: |
---|
73 | cert = res[0] |
---|
74 | path = cert.getPath() |
---|
75 | query = Eq("path",path) &\ |
---|
76 | Eq('portal_type','CertificateCourse') &\ |
---|
77 | Eq('SearchableText', "%s" % student.level) |
---|
78 | courses = evalAdvancedQuery(query) |
---|
79 | for c in courses: |
---|
80 | d = context.getCourseInfo(c.getId) |
---|
81 | cr_id = context.invokeFactory('StudentCourseResult',c.getId) |
---|
82 | d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') |
---|
83 | getattr(context,cr_id).getContent().edit(mapping=d) |
---|
84 | session.set('in_progress','finished') |
---|
85 | return "finished" |
---|
86 | students_url = "%s/campus/students" % (context.portal_url()) |
---|
87 | id = str(member) |
---|
88 | return redirect("%s/%s/student_view" % (students_url, id)) |
---|
89 | |
---|
90 | return redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
91 | |
---|