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

Last change on this file since 11102 was 5597, checked in by isouaba, 14 years ago

expend the credit limite in ois

File size: 7.3 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 = 100
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
146terms_completed = bool(score_calc_average_1) + bool(score_calc_average_2) + bool(score_calc_average_3)
147
148if terms_completed:
149    score_calc_average_cum = (score_calc_average_1 + score_calc_average_2 + score_calc_average_3)/terms_completed
150else:
151    score_calc_average_cum = 0
152
153info['score_calc_average_cum'] = '%.2f' % score_calc_average_cum
154
155session_id = level_doc.session
156yga1,yga2,yga3,counter1,counter2,counter3,yg1,yg2,yg3 = course_results.getYearGroupAverage(session_id,level_id)
157info['yga1'] = yga1
158info['yga2'] = yga2
159info['yga3'] = yga3
160info['counter1'] = counter1
161info['counter2'] = counter2
162info['counter3'] = counter3
163
164
165#yg1.sort(reverse=True)
166#if not len(yg1):
167#    pos1 = 'no result'
168#for pos1 in range(len(yg1)):
169#    if yg1[pos1] <= float(score_calc_average_1):
170#        break
171#info['pos1'] = '%d of %d' % (pos1+1,len(yg1))
172
173#end customization
174
175info['max_credits'] = max_credits
176info['credits_exceeded'] = total_credits > max_credits
177current_session = student.session
178
179info['gpa'] = gpa
180if gpa and total_credits:
181    info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
182
183info['carry_overs'] = carry_overs
184normal1.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
185normal2.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
186normal3.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
187
188info['normal1'] = normal1
189info['normal2'] = normal2
190info['normal3'] = normal3
191
192info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
193info['spillover'] = student.level > student.end_level
194
195students_object = context.portal_url.getPortalObject().campus.students
196student = getattr(students_object, student_id)
197info['app'] = student.application
198info['app_doc'] = student.application.getContent()
199
200if pprops.session == info['session']:
201    info['date1'] = DateTime.DateTime(pprops.date1).strftime('%d/%m/%Y')
202    info['date2'] = DateTime.DateTime(pprops.date2).strftime('%d/%m/%Y')
203    info['date3'] = DateTime.DateTime(pprops.date3).strftime('%d/%m/%Y')
204else:
205    info['date1'] = 'n/a'
206    info['date2'] = 'n/a'
207    info['date3'] = 'n/a'
208
209info['over_pos_term1'] = getattr(level_doc, 'over_pos_term1','n/a')
210info['no_stud_term1'] = getattr(level_doc, 'no_stud_term1','n/a')
211info['over_pos_term2'] = getattr(level_doc, 'over_pos_term2','n/a')
212info['no_stud_term2'] = getattr(level_doc, 'no_stud_term2','n/a')
213info['over_pos_term3'] = getattr(level_doc, 'over_pos_term3','n/a')
214info['no_stud_term3'] = getattr(level_doc, 'no_stud_term3','n/a')
215info['over_pos_cum'] = getattr(level_doc, 'over_pos_cum','n/a')
216info['no_stud_cum'] = getattr(level_doc, 'no_stud_cum','n/a')
217
218return info
Note: See TracBrowser for help on using the repository browser.