source: WAeUP_SRP/trunk/skins/waeup_student/getSessionResults.py @ 1316

Last change on this file since 1316 was 1315, checked in by joachim, 18 years ago

M skins/waeup_student/getFormattedStudentEntry.py
do the sex right.
M skins/waeup_student/getSessionResults.py
remove wrong getattr(student,'clearance')
M profiles/default/schemas/student_study_course.xml
removed redundant fields

File size: 2.6 KB
Line 
1## Script (Python) "getSessionResults"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: display_session_results.py 1166 2006-12-31 18:11:47Z henrik $
11"""
12process the Application Form
13return html renderer + psm
14"""
15import DateTime
16current = DateTime.DateTime()
17pr = context.portal_registration
18
19returning = context.returning_import
20results = context.results_import
21
22mtool = context.portal_membership
23member = mtool.getAuthenticatedMember()
24member_id = str(member)
25
26if mtool.isAnonymousUser():
27    return None
28info = {}
29#from Products.zdb import set_trace
30#set_trace()
31requested_id = context.getStudentId()
32if requested_id and not context.isStaff() and member_id != requested_id:
33    import logging
34    logger = logging.getLogger('Student.SessionResults.Info')
35    logger.info('"%s", "tried to access", "%s"' % (member_id,requested_id))
36    return None
37elif context.isStaff():
38    student_id = requested_id
39else:
40    student_id = member_id
41
42students_object = context.portal_url.getPortalObject().campus.students
43##student = getattr(students_object, student_id)
44##clear = getattr(student,'clearance',None)
45##if clear:
46##    value = clear.getContent().matric_no
47##else:
48##    return None
49
50res = returning(matric_no = value)
51student = res[0]
52res = results(matric_no = value)
53results = res
54
55
56sem1 = []
57sem2 = []
58with_courses_cat = hasattr(context,'courses_catalog')
59fields = context.results_import.schema()
60gpa = 0
61course_count = 0
62verdict = None
63session = None
64for r in results:
65    if verdict is None:
66        verdict = r.Verdict
67        session = r.Session
68    result = {}
69    for field in fields:
70        result[field] = getattr(r,field)
71    if with_courses_cat:
72        res = context.courses_catalog(code = r.CosCode)
73    if with_courses_cat and res:
74        result['title'] = res[0].title
75        result['credits'] = res[0].credits
76        try:
77            weight = int(result['WEIGHT'])
78            credits = int(res[0].credits)
79            gpa_course =  int(res[0].credits) * weight
80            gpa += gpa_course
81            course_count += credits
82            result['gpa'] = 'ok'
83        except:
84            result['gpa'] = 'na'
85    else:
86        result['title'] = "na"
87        result['credits'] = "na"
88        result['gpa'] = 'na'
89    if r.Semester == '2':
90        sem2.append(result)
91    else:
92        sem1.append(result)
93if course_count:
94    gpa = float(gpa) / course_count
95    gpa = "%4.2f" % gpa
96info['verdict'] = verdict
97info['session'] = session
98info['gpa'] = gpa
99info['results'] = (sem1, sem2)
100info['student'] = student
101info['s_id'] = student_id
102return info
103
Note: See TracBrowser for help on using the repository browser.