## Script (Python) "student_index" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=batch=None ##title= ## # $Id: student_index.py 1380 2007-01-31 16:24:18Z joachim $ """ return the current student_index_html """ from Products.AdvancedQuery import Eq, Between, Le,In evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery request = context.REQUEST session = request.SESSION response = request.RESPONSE redirect = response.redirect pm = context.portal_membership member = pm.getAuthenticatedMember() #from Products.zdb import set_trace;set_trace() if context.isStaff(): if context.portal_type == 'StudentStudyCourse': return context.study_course_view() elif context.portal_type == 'StudentStudyLevel': return context.study_level_view() elif context.portal_type == 'StudentClearance': return context.clearance_view() elif context.portal_type == 'PaymentsFolder': return context.payments_view() elif context.portal_type == 'Student': return redirect("%s/student_view" % context.absolute_url()) elif context.portal_type == 'Payment': return context.payment_receipt() return redirect("%s/waeup_document_view" % context.absolute_url()) if context.isStudent(): if context.portal_type == 'PaymentsFolder': return context.payments_view() elif context.portal_type == 'Payment': return context.payment_receipt() elif context.portal_type == 'StudentStudyLevel': if context.objectIds(): return context.study_level_view() student = context.students_catalog(id=context.getStudentId())[0] cert_id = student.course in_progress = session.get('in_progress','finished') if in_progress == 'finished': session.set('in_progress','started') view = context.in_progress_view(refresh=3,page='study_level_view') response.setHeader('Content-type','text/html; charset=ISO-8859-15') response.setHeader('Content-length','%d' % (len(view))) response.setStatus('OK') response.write(view) response.write('') elif in_progress == 'started': return #from Products.zdb import set_trace;set_trace() results = context.results_import(matric_no = student.matric_no) carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')] l = [] for co in carry_overs: d = context.getCourseInfo(co.CosCode) d['grade'] = co.GRADE d['carry_level'] = co.CarryLevel cr_id = context.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode) getattr(context,cr_id).getContent().edit(mapping=d) res = context.portal_catalog(portal_type="Certificate", id = cert_id) l = [] if res: cert = res[0] path = cert.getPath() query = Eq("path",path) &\ Eq('portal_type','CertificateCourse') &\ Eq('SearchableText', "%s" % student.level) courses = evalAdvancedQuery(query) for c in courses: d = context.getCourseInfo(c.getId) cr_id = context.invokeFactory('StudentCourseResult',c.getId) d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') getattr(context,cr_id).getContent().edit(mapping=d) session.set('in_progress','finished') return "finished" students_url = "%s/campus/students" % (context.portal_url()) id = str(member) return redirect("%s/%s/student_view" % (students_url, id)) return redirect("%s/srp_anonymous_view" % context.portal_url())