source: WAeUP_SRP/branches/uli/skins/waeup_student/getStudyLevelInfo.py @ 17727

Last change on this file since 17727 was 1653, checked in by uli, 18 years ago

Incorporated changeset 1593:1652 of trunk into uli-branch.

  • Property svn:keywords set to Id
File size: 3.4 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 1653 2007-03-28 02:35:25Z uli $
11"""
12return Info about the Studylevel
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19from Products.AdvancedQuery import Eq, Between, Le,In
20aq_portal = context.portal_catalog.evalAdvancedQuery
21request = context.REQUEST
22session = request.SESSION
23response = request.RESPONSE
24
25def calculateGPA():
26    """calculate the gpa"""
27    sum = 0
28    course_count = 0
29    for sc in context.objectValues():
30        result = sc.getContent()
31        if not result.grade:
32            continue
33        res = context.portal_catalog({'meta_type': 'Course',
34                                      'id': sc.aq_parent.id})
35        if len(res) < 1:
36            continue
37        course = res[0].getObject().getContent()
38    if course_count:
39        return sum/course_count
40    return 0.0
41
42def cmp_semester_id(a,b):
43    s1 = "%(semester)s%(id)s" % a
44    s2 = "%(semester)s%(id)s" % b
45    if s1 == s2:
46        return 0
47    if s1 > s2:
48        return 1
49    return -1
50
51
52wf = context.portal_workflow
53mtool = context.portal_membership
54student_id = context.getStudentId()
55
56
57
58info = {}
59info['is_so'] = is_so = context.isSectionOfficer()
60info['is_student'] = is_student = context.isStudent()
61info['is_ca'] = is_ca = context.isCourseAdviser()
62info['student'] = student = context.students_catalog(id=student_id)[0]
63info['review_state'] = review_state = context.getStudentReviewState()
64info['view_only'] =  review_state != "school_fee_paid"
65info['show_check_boxes'] =  (is_ca and review_state in ('school_fee_paid',)) or\
66                            (is_student and context.getStudentReviewState() == "school_fee_paid") or\
67                            (is_so)
68info['choosen_ids'] = request.get('ids',[])
69info['status_info'] = ""
70if is_student:
71    if review_state == 'courses_registered':
72        info['status_info'] = "Request for Course Validation pending"
73    elif review_state == 'courses_validated':
74        info['status_info'] = "Courses validated"
75elif is_ca:
76    if review_state == 'courses_registered':
77        info['status_info'] = "Please validate these Courses"
78    elif review_state == 'courses_validated':
79        info['status_info'] = "Courses validated"
80info['doc'] = context.getContent()
81##study_course = context.aq_parent.getContent()
82##cert_id = study_course.study_course
83cert_id = student.course
84info['cert_id'] = cert_id
85normal = []
86carry_overs = []
87credits_total = 0
88for id,obj in context.objectItems():
89    try:
90        credit = int(obj.getContent().credits)
91    except ValueError:
92        credit = 3
93    credits_total += credit
94    if id.endswith('_co'):
95        d = context.getCourseInfo(id[:-3])
96        d['id'] = id
97        d['grade'] = obj.getContent().grade
98        carry_overs.append(d)
99    else:
100        d = context.getCourseInfo(id)
101        d['id'] = id
102        coe = obj.getContent().core_or_elective
103        d['coe'] = 'Core'
104        if not coe:
105            d['coe'] = 'Elective'
106        normal.append(d)
107info['credits_total'] = credits_total
108carry_overs.sort(cmp_semester_id)
109info['carry_overs'] = carry_overs
110normal.sort(cmp_semester_id)
111info['normal'] = normal
112
113students_object = context.portal_url.getPortalObject().campus.students
114student = getattr(students_object, student_id)
115info['app'] = student.application
116info['app_doc'] = student.application.getContent()
117
118return info
Note: See TracBrowser for help on using the repository browser.