source: WAeUP_SRP/base/skins/waeup_student/getStudyLevelInfo.py @ 2448

Last change on this file since 2448 was 2448, checked in by Henrik Bettermann, 17 years ago

new course registration module

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