Changeset 1380 for WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py
- Timestamp:
- 31 Jan 2007, 16:24:18 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py
r913 r1380 12 12 return Info about the Studylevel 13 13 """ 14 from Products.AdvancedQuery import Eq, Between, Le,In 15 evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery 16 request = context.REQUEST 17 session = request.SESSION 18 response = request.RESPONSE 19 14 20 def calculateGPA(): 15 21 """calculate the gpa""" … … 29 35 return 0.0 30 36 31 request = context.REQUEST 37 def cmp_semester(a,b): 38 if a['semester'] == b['semester']: 39 return 0 40 if a['semester'] > b['semester']: 41 return 1 42 return -1 43 32 44 33 45 wf = context.portal_workflow 34 46 mtool = context.portal_membership 35 path_info = request.get('PATH_INFO').split('/') 36 try: 37 i = int(path_info[-1]) 38 p = 0 39 except: 40 p = 1 47 student_id = context.getStudentId() 48 41 49 info = {} 42 pt = request.get('PATH_TRANSLATED').split('/') 43 44 student_id = pt[-(3+p)] 45 level_id = pt[-(1+p)] 46 info['action'] = "%s" % context.absolute_url() 50 info['student'] = student = context.students_catalog(id=student_id)[0] 47 51 info['choosen_ids'] = request.get('ids',[]) 48 52 info['doc'] = context.getContent() 49 study_course = context.aq_parent.getContent() 50 cert_id = study_course.study_course 51 brain = context.portal_catalog(meta_type="Student",id = student_id)[-1] 52 cp = brain.getPath() 53 info['container_path'] = cp 53 ##study_course = context.aq_parent.getContent() 54 ##cert_id = study_course.study_course 55 cert_id = student.course 54 56 info['cert_id'] = cert_id 57 normal = [] 58 carry_overs = [] 59 for id,obj in context.objectItems(): 60 if id.endswith('_co'): 61 d = context.getCourseInfo(id[:-3]) 62 d['grade'] = obj.getContent().grade 63 carry_overs.append(d) 64 else: 65 d = context.getCourseInfo(id) 66 coe = obj.getContent().core_or_elective 67 d['coe'] = 'Core' 68 if not coe: 69 d['coe'] = 'Elective' 70 normal.append(d) 55 71 56 res = context.portal_catalog(meta_type="StudentCourseResult", 57 container_path="%s/study_course/%s" % (cp,level_id)) 58 first = [] 59 second = [] 60 sum = 0 61 course_count = 0 62 for r in res: 63 row = {} 64 ro = r.getObject() 65 rd = ro.getContent() 66 row['id'] = ro.getId() 67 row['credits'] = rd.credits 68 if row['credits'] and rd.grade: 69 credits = int(rd.credits) 70 sum += credits * ['F','E','D','C','B','A'].index(rd.grade) 71 course_count += credits 72 row['sum'] = sum 73 row['count'] = course_count 74 row['title'] = rd.title 75 #row['core'] = rd.core_or_elective 76 row['semester'] = rd.semester 77 row['score'] = rd.score 78 row['grade'] = rd.grade 79 row['weight'] = rd.weight 80 row['url'] = ro.absolute_url() 81 row['review_state'] = wf.getInfoFor(ro,'review_state','None') 82 row['is_editable'] = mtool.checkPermission('Modify portal content', ro) 83 if rd.semester == 1: 84 first.append(row) 85 else: 86 second.append(row) 87 first.sort() 88 second.sort() 89 gpaf = 0.0 90 if course_count: 91 gpaf = (float(sum)/course_count) 92 gpa = "%4.2f" % gpaf 93 info['doc'].edit(mapping={'gpa': gpaf}) 94 info['first'] = first 95 info['second'] = second 72 carry_overs.sort(cmp_semester) 73 info['carry_overs'] = carry_overs 74 normal.sort(cmp_semester) 75 info['normal'] = normal 96 76 return info
Note: See TracChangeset for help on using the changeset viewer.