source: WAeUP_SRP/trunk/skins/waeup_ois/getStudyLevelInfo.py @ 3946

Last change on this file since 3946 was 3902, checked in by Henrik Bettermann, 16 years ago

resolve 2 and 3 of ticket Schools #7

File size: 5.5 KB
Line 
1## Script (Python) "getStudyLevelInfo"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=student=None
8##title=
9##
10# $Id: getStudyLevelInfo.py 2760 2007-11-26 07:39:15Z henrik $
11"""
12return Info about the Studylevel
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18"""
19
20info = context.waeup_tool.getAccessInfo(context)
21student_id = info['student_id']
22if student_id is None:
23    return None
24
25mtool = context.portal_membership
26member = mtool.getAuthenticatedMember()
27member_id = str(member)
28
29course_results = context.course_results
30request = context.REQUEST
31response = request.RESPONSE
32import logging
33logger = logging.getLogger('Skins.getStudyLevelInfo')
34
35level_id  =  context.getId()
36level_doc = info['doc'] = context.getContent()
37
38info['is_so'] = is_so = info['is_sectionofficer']
39#info['is_student'] = is_student = context.isStudent()
40info['is_ca'] = is_ca = context.isCourseAdviser()
41#info['student'] = student = context.students_catalog(id=student_id)[0]
42info['student'] = student = context.students_catalog.getRecordByKey(student_id)
43info['review_state'] = review_state = student.review_state
44is_current_level = level_id == student.level
45school_fee_paid =  review_state == 'school_fee_paid'
46info['is_current_level'] = is_current_level
47info['has_verdict'] = has_verdict = level_doc.verdict
48
49info['submission_allowed']= school_fee_paid and is_current_level and not has_verdict
50info['validation_allowed']= review_state == 'courses_registered' and is_current_level
51info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated',) and is_current_level
52info['validated'] = review_state == 'courses_validated' and is_current_level
53
54info['show_check_boxes'] =  (is_ca and school_fee_paid and is_current_level and not has_verdict) or\
55                            (info['is_student'] and school_fee_paid and is_current_level and not has_verdict) or\
56                            (is_so and is_current_level and not has_verdict)
57
58info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper()
59info['session'] = context.portal_vocabularies.sessions.get(level_doc.session)
60info['level_str'] = context.portal_vocabularies.student_levels.get(level_id)
61
62info['choosen_ids'] = request.get('ids',[])
63
64#info['status_info'] = ""
65#if is_student:
66#    if review_state == 'courses_registered':
67#        info['status_info'] = "Request for course validation pending"
68#    elif review_state == 'courses_validated':
69#        info['status_info'] = "Courses validated"
70#elif is_ca:
71#    if review_state == 'courses_registered':
72#        info['status_info'] = "Please validate these courses"
73#    elif review_state == 'courses_validated':
74#        info['status_info'] = "Courses validated"
75
76cert_id = student.course
77info['cert_id'] = cert_id
78total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
79info['total_credits'] = total_credits
80
81#start customization
82
83
84
85max_credits = 58
86info['without_score'] = False
87info['without_cascore'] = False
88
89items = []
90subobjects = context.objectValues()
91for subobject in subobjects:
92    row = {}
93    row['id'] = subobject.getId()
94    row['title'] = '%s' % context.portal_vocabularies.terms.get(subobject.getId())
95    items.append(row)
96info['items'] = items
97
98complete1 = 0
99score_calc_average_1 = 0
100for r in normal1:
101    if r['grade'] and r['atl']:
102        complete1 += 1
103        score_calc_average_1 += r['score_calc']
104if len(normal1) == complete1:
105    complete1 =  True
106else:
107    complete1 = False
108if len(normal1):
109    score_calc_average_1 /= len(normal1)   
110info['complete1'] = complete1     
111info['score_calc_average_1'] = score_calc_average_1 
112
113complete2 = 0
114score_calc_average_2 = 0
115for r in normal1:
116    if r['grade'] and r['atl']:
117        score_calc_average_2 += r['score_calc']
118        complete2 += 1
119if len(normal2) == complete2:
120    complete2 =  True
121else:
122    complete2 = False
123if len(normal2):
124    score_calc_average_2 /= len(normal2)
125info['complete2'] = complete2
126info['score_calc_average_2'] = score_calc_average_2 
127
128complete3 = 0
129score_calc_average_3 = 0
130for r in normal1:
131    if r['grade'] and r['atl']:
132        complete3 += 1
133        score_calc_average_3 += r['score_calc']
134if len(normal3) == complete3:
135    complete3 =  True
136else:
137    complete3 = False
138if len(normal3):
139    score_calc_average_3 /= len(normal3)   
140info['complete3'] = complete3
141info['score_calc_average_3'] = score_calc_average_3 
142
143
144#end customization
145
146info['max_credits'] = max_credits
147info['credits_exceeded'] = total_credits > max_credits
148current_session = student.session
149
150info['gpa'] = gpa
151if gpa and total_credits:
152    info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
153
154info['carry_overs'] = carry_overs
155normal1.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
156normal2.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
157normal3.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
158
159info['normal1'] = normal1
160info['normal2'] = normal2
161info['normal3'] = normal3
162
163info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
164info['spillover'] = student.level > student.end_level
165
166students_object = context.portal_url.getPortalObject().campus.students
167student = getattr(students_object, student_id)
168info['app'] = student.application
169info['app_doc'] = student.application.getContent()
170
171return info
Note: See TracBrowser for help on using the repository browser.