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

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

show session_results_view even if results are missing

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