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

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

rebuild getNextInfo.py completely
fetch session from portal properties.xml
change all scripts using getSessionId
remove StudentCourseResult? relevant code from event services
make pay_by_sc.py and interswitch_cb.py work (rebuild both)

  • 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 2454 2007-10-27 21:53:04Z 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
34response = request.RESPONSE
35import logging
36logger = logging.getLogger('Skins.getStudyLevelInfo')
37
38def calculateGPA():
39    """calculate the gpa"""
40    sum = 0
41    course_count = 0
42    for sc in context.objectValues():
43        result = sc.getContent()
44        if not result.grade:
45            continue
46        res = context.portal_catalog({'meta_type': 'Course',
47                                      'id': sc.aq_parent.id})
48        if len(res) < 1:
49            continue
50        course = res[0].getObject().getContent()
51    if course_count:
52        return sum/course_count
53    return 0.0
54
55def cmp_semester_id(a,b):
56    s1 = "%(semester)s%(id)s" % a
57    s2 = "%(semester)s%(id)s" % b
58    if s1 == s2:
59        return 0
60    if s1 > s2:
61        return 1
62    return -1
63
64student_id = context.getStudentId()
65level_id = context.getId()
66
67info = {}
68info['is_so'] = is_so = context.isSectionOfficer()
69info['is_student'] = is_student = context.isStudent()
70info['is_ca'] = is_ca = context.isCourseAdviser()
71info['student'] = student = context.students_catalog(id=student_id)[0]
72info['review_state'] = review_state = context.getStudentReviewState()
73info['view_only'] =  review_state != "school_fee_paid"
74info['show_check_boxes'] =  (is_ca and review_state in ('school_fee_paid',)) or\
75                            (is_student and context.getStudentReviewState() == "school_fee_paid") or\
76                            (is_so)
77info['choosen_ids'] = request.get('ids',[])
78info['status_info'] = ""
79if is_student:
80    if review_state == 'courses_registered':
81        info['status_info'] = "Request for Course Validation pending"
82    elif review_state == 'courses_validated':
83        info['status_info'] = "Courses validated"
84elif is_ca:
85    if review_state == 'courses_registered':
86        info['status_info'] = "Please validate these Courses"
87    elif review_state == 'courses_validated':
88        info['status_info'] = "Courses validated"
89info['doc'] = context.getContent()
90cert_id = student.course
91info['cert_id'] = cert_id
92if context.objectIds():
93    course_results.moveResultsHere(context,student_id)
94    logger.info("%s moved courseresults and deleted objects in level %s" % (student_id,level_id))
95credits_total,carry_overs,normal = course_results.getCourses(student_id,level_id)
96info['credits_total'] = credits_total
97info['credits_exceeded'] = credits_total > 51
98current_session = student.session
99info['submission_allowed']= not info['credits_exceeded'] and current_session == context.getSessionId()[0]
100# carry_overs.sort(cmp_semester_id)
101info['carry_overs'] = carry_overs
102# normal.sort(cmp_semester_id)
103info['normal'] = normal
104
105students_object = context.portal_url.getPortalObject().campus.students
106student = getattr(students_object, student_id)
107info['app'] = student.application
108info['app_doc'] = student.application.getContent()
109
110return info
Note: See TracBrowser for help on using the repository browser.