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

Last change on this file since 5083 was 4487, checked in by Henrik Bettermann, 15 years ago

resolve email of Issoufou from 30/07/09

File size: 7.1 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
20import DateTime
21
22info = context.waeup_tool.getAccessInfo(context)
23student_id = info['student_id']
24if student_id is None:
25    return None
26
27mtool = context.portal_membership
28pprops = context.portal_properties
29member = mtool.getAuthenticatedMember()
30member_id = str(member)
31
32course_results = context.course_results
33request = context.REQUEST
34response = request.RESPONSE
35import logging
36logger = logging.getLogger('Skins.getStudyLevelInfo')
37
38level_id  =  context.getId()
39level_doc = info['doc'] = context.getContent()
40
41info['is_so'] = is_so = info['is_sectionofficer']
42#info['is_student'] = is_student = context.isStudent()
43info['is_ca'] = is_ca = context.isCourseAdviser()
44#info['student'] = student = context.students_catalog(id=student_id)[0]
45info['student'] = student = context.students_catalog.getRecordByKey(student_id)
46info['review_state'] = review_state = student.review_state
47is_current_level = level_id == student.level
48school_fee_paid =  review_state == 'school_fee_paid'
49info['is_current_level'] = is_current_level
50info['has_verdict'] = has_verdict = level_doc.verdict
51
52info['submission_allowed']= school_fee_paid and is_current_level and not has_verdict
53info['validation_allowed']= review_state == 'courses_registered' and is_current_level
54info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated',) and is_current_level
55info['validated'] = review_state == 'courses_validated' and is_current_level
56
57info['show_check_boxes'] =  (is_ca and school_fee_paid and is_current_level and not has_verdict) or\
58                            (info['is_student'] and school_fee_paid and is_current_level and not has_verdict) or\
59                            (is_so and is_current_level and not has_verdict)
60
61info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper()
62info['session'] = context.portal_vocabularies.sessions.get(level_doc.session)
63info['level_str'] = context.portal_vocabularies.student_levels.get(level_id)
64
65info['choosen_ids'] = request.get('ids',[])
66
67#info['status_info'] = ""
68#if is_student:
69#    if review_state == 'courses_registered':
70#        info['status_info'] = "Request for course validation pending"
71#    elif review_state == 'courses_validated':
72#        info['status_info'] = "Courses validated"
73#elif is_ca:
74#    if review_state == 'courses_registered':
75#        info['status_info'] = "Please validate these courses"
76#    elif review_state == 'courses_validated':
77#        info['status_info'] = "Courses validated"
78
79cert_id = student.course
80info['cert_id'] = cert_id
81total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
82info['total_credits'] = total_credits
83
84#start customization
85
86
87
88max_credits = 58
89info['without_score'] = False
90info['without_cascore'] = False
91
92items = []
93subobjects = context.objectValues()
94for subobject in subobjects:
95    row = {}
96    row['id'] = subobject.getId()
97    row['title'] = '%s' % context.portal_vocabularies.terms.get(subobject.getId())
98    items.append(row)
99info['items'] = items
100
101complete1 = 0
102score_calc_average_1 = 0
103for r in normal1:
104    if r['grade'] and r['atl']:
105        complete1 += 1
106        score_calc_average_1 += r['score_calc']
107if len(normal1) == complete1:
108    complete1 =  True
109else:
110    complete1 = False
111if len(normal1):
112    score_calc_average_1 /= len(normal1)   
113info['complete1'] = complete1     
114info['score_calc_average_1'] = '%.2f' % score_calc_average_1 
115
116complete2 = 0
117score_calc_average_2 = 0
118for r in normal2:
119    if r['grade'] and r['atl']:
120        score_calc_average_2 += r['score_calc']
121        complete2 += 1
122if len(normal2) == complete2:
123    complete2 =  True
124else:
125    complete2 = False
126if len(normal2):
127    score_calc_average_2 /= len(normal2)
128info['complete2'] = complete2
129info['score_calc_average_2'] = '%.2f' % score_calc_average_2 
130
131complete3 = 0
132score_calc_average_3 = 0
133for r in normal3:
134    if r['grade'] and r['atl']:
135        complete3 += 1
136        score_calc_average_3 += r['score_calc']
137if len(normal3) == complete3:
138    complete3 =  True
139else:
140    complete3 = False
141if len(normal3):
142    score_calc_average_3 /= len(normal3)   
143info['complete3'] = complete3
144info['score_calc_average_3'] =  '%.2f' % score_calc_average_3 
145
146score_calc_average_cum = (score_calc_average_1 + score_calc_average_2 + score_calc_average_3)/3
147
148info['score_calc_average_cum'] = '%.2f' % score_calc_average_cum
149
150session_id = level_doc.session
151yga1,yga2,yga3,counter1,counter2,counter3,yg1,yg2,yg3 = course_results.getYearGroupAverage(session_id,level_id)
152info['yga1'] = yga1
153info['yga2'] = yga2
154info['yga3'] = yga3
155info['counter1'] = counter1
156info['counter2'] = counter2
157info['counter3'] = counter3
158
159
160#yg1.sort(reverse=True)
161#if not len(yg1):
162#    pos1 = 'no result'
163#for pos1 in range(len(yg1)):
164#    if yg1[pos1] <= float(score_calc_average_1):
165#        break
166#info['pos1'] = '%d of %d' % (pos1+1,len(yg1))
167
168#end customization
169
170info['max_credits'] = max_credits
171info['credits_exceeded'] = total_credits > max_credits
172current_session = student.session
173
174info['gpa'] = gpa
175if gpa and total_credits:
176    info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
177
178info['carry_overs'] = carry_overs
179normal1.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
180normal2.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
181normal3.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
182
183info['normal1'] = normal1
184info['normal2'] = normal2
185info['normal3'] = normal3
186
187info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
188info['spillover'] = student.level > student.end_level
189
190students_object = context.portal_url.getPortalObject().campus.students
191student = getattr(students_object, student_id)
192info['app'] = student.application
193info['app_doc'] = student.application.getContent()
194
195if pprops.session == info['session']:
196    info['date1'] = DateTime.DateTime(pprops.date1).strftime('%d/%m/%Y')
197    info['date2'] = DateTime.DateTime(pprops.date2).strftime('%d/%m/%Y')
198    info['date3'] = DateTime.DateTime(pprops.date3).strftime('%d/%m/%Y')
199else:
200    info['date1'] = 'n/a'
201    info['date2'] = 'n/a'
202    info['date3'] = 'n/a'
203
204info['over_pos_term1'] = getattr(level_doc, 'over_pos_term1','n/a')
205info['no_stud_term1'] = getattr(level_doc, 'no_stud_term1','n/a')
206info['over_pos_term2'] = getattr(level_doc, 'over_pos_term2','n/a')
207info['no_stud_term2'] = getattr(level_doc, 'no_stud_term2','n/a')
208info['over_pos_term3'] = getattr(level_doc, 'over_pos_term3','n/a')
209info['no_stud_term3'] = getattr(level_doc, 'no_stud_term3','n/a')
210info['over_pos_cum'] = getattr(level_doc, 'over_pos_cum','n/a')
211info['no_stud_cum'] = getattr(level_doc, 'no_stud_cum','n/a')
212
213return info
Note: See TracBrowser for help on using the repository browser.