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

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

resolve #122

  • Property svn:keywords set to Id
File size: 3.8 KB
RevLine 
[2448]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 2606 2007-11-09 12:04:49Z henrik $
11"""
12return Info about the Studylevel
13"""
14
15wf = context.portal_workflow
16mtool = context.portal_membership
17if mtool.isAnonymousUser():
18    return None
[2466]19member = mtool.getAuthenticatedMember()
20member_id = str(member)
[2448]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
[2486]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
[2448]56
[2606]57#def 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
[2448]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)
[2466]96    logger.info("%s initiated moveResultsHere for %s in level %s" % (member_id,student_id,level_id))
[2606]97credits_total,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
[2448]98info['credits_total'] = credits_total
[2469]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
[2448]104current_session = student.session
[2469]105info['submission_allowed']= not info['credits_exceeded'] and\
106    current_session == context.getSessionId()[0]
[2448]107# carry_overs.sort(cmp_semester_id)
108info['carry_overs'] = carry_overs
109# normal.sort(cmp_semester_id)
[2606]110info['normal1'] = normal1
111info['normal2'] = normal2
112info['normal3'] = normal3
[2448]113
114students_object = context.portal_url.getPortalObject().campus.students
115student = getattr(students_object, student_id)
116info['app'] = student.application
117info['app_doc'] = student.application.getContent()
118
[2486]119return info
Note: See TracBrowser for help on using the repository browser.