source: WAeUP_SRP/uniben/waeup_custom/getStudyLevelInfo.py @ 3076

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

51 credits for spillovers

File size: 4.3 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 2760 2007-11-26 07:39:15Z 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
40info = {}
41
42student_id = context.getStudentId()
43level_id  =  context.getId()
44level_doc = info['doc'] = context.getContent()
45
46info['is_so'] = is_so = context.isSectionOfficer()
47info['is_student'] = is_student = context.isStudent()
48info['is_ca'] = is_ca = context.isCourseAdviser()
49info['student'] = student = context.students_catalog(id=student_id)[0]
50info['review_state'] = review_state = student.review_state
51is_current_level = level_id == student.level
52school_fee_paid =  review_state == 'school_fee_paid'
53info['is_current_level'] = is_current_level
54info['has_verdict'] = has_verdict = level_doc.verdict
55
56info['submission_allowed']= school_fee_paid and is_current_level and not has_verdict
57info['validation_allowed']= review_state == 'courses_registered' and is_current_level
58info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated',) and is_current_level
59info['validated'] = review_state == 'courses_validated' and is_current_level
60
61info['show_check_boxes'] =  (is_ca and school_fee_paid and is_current_level and not has_verdict) or\
62                            (is_student and school_fee_paid and is_current_level and not has_verdict) or\
63                            (is_so and is_current_level and not has_verdict)
64
65info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper()
66info['session'] = context.portal_vocabularies.sessions.get(level_doc.session)
67# info['level_str'] = context.portal_vocabularies.student_levels.get(level_id) # not used
68
69info['choosen_ids'] = request.get('ids',[])
70
71#info['status_info'] = ""
72#if is_student:
73#    if review_state == 'courses_registered':
74#        info['status_info'] = "Request for course validation pending"
75#    elif review_state == 'courses_validated':
76#        info['status_info'] = "Courses validated"
77#elif is_ca:
78#    if review_state == 'courses_registered':
79#        info['status_info'] = "Please validate these courses"
80#    elif review_state == 'courses_validated':
81#        info['status_info'] = "Courses validated"
82
83cert_id = student.course
84info['cert_id'] = cert_id
85if context.objectIds():
86    course_results.moveResultsHere(context,student_id)
87    logger.info("%s initiated moveResultsHere for %s in level %s" % (member_id,student_id,level_id))
88total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
89info['total_credits'] = total_credits
90max_credits = 50
91try:
92    if int(context.getId()) >=  int(student.end_level):
93        max_credits = 51
94except:
95    logger.info("%s has strange level id %s" % (student_id,level_id))
96info['max_credits'] = max_credits
97info['credits_exceeded'] = total_credits > max_credits
98current_session = student.session
99
100info['gpa'] = gpa
101if gpa and total_credits:
102    info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
103
104
105
106# carry_overs.sort(cmp_semester_id)
107info['carry_overs'] = carry_overs
108# normal.sort(cmp_semester_id)
109info['normal1'] = normal1
110info['normal2'] = normal2
111info['normal3'] = normal3
112
113info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
114info['spillover'] = student.level > student.end_level
115
116students_object = context.portal_url.getPortalObject().campus.students
117student = getattr(students_object, student_id)
118info['app'] = student.application
119info['app_doc'] = student.application.getContent()
120
121return info
Note: See TracBrowser for help on using the repository browser.