source: WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py @ 1477

Last change on this file since 1477 was 1380, checked in by joachim, 18 years ago

course registration

M waeup_student/student_index.py
M waeup_student/study_level_view.pt
M waeup_student/getStudyLevelInfo.py
M waeup_student/study_course_view.pt
M waeup_student/getStudyCourseInfo.py
AM waeup_academics/getCourseInfo.py

reindex entry_mode

M waeup_utilities/getFromData_entry_mode.py
M waeup_utilities/reindex_entry_mode.py

  • Property svn:keywords set to Id
File size: 2.0 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 1380 2007-01-31 16:24:18Z joachim $
11"""
12return Info about the Studylevel
13"""
14from Products.AdvancedQuery import Eq, Between, Le,In
15evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
16request = context.REQUEST
17session = request.SESSION
18response = request.RESPONSE
19
20def calculateGPA():
21    """calculate the gpa"""
22    sum = 0
23    course_count = 0
24    for sc in context.objectValues():
25        result = sc.getContent()
26        if not result.grade:
27            continue
28        res = context.portal_catalog({'meta_type': 'Course',
29                                      'id': sc.aq_parent.id})
30        if len(res) < 1:
31            continue
32        course = res[0].getObject().getContent()
33    if course_count:
34        return sum/course_count
35    return 0.0
36
37def 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
44
45wf = context.portal_workflow
46mtool = context.portal_membership
47student_id = context.getStudentId()
48
49info = {}
50info['student'] = student = context.students_catalog(id=student_id)[0]
51info['choosen_ids'] = request.get('ids',[])
52info['doc'] = context.getContent()
53##study_course = context.aq_parent.getContent()
54##cert_id = study_course.study_course
55cert_id = student.course
56info['cert_id'] = cert_id
57normal = []
58carry_overs = []
59for 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)
71
72carry_overs.sort(cmp_semester)
73info['carry_overs'] = carry_overs
74normal.sort(cmp_semester)
75info['normal'] = normal
76return info
Note: See TracBrowser for help on using the repository browser.