source: WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py @ 8794

Last change on this file since 8794 was 5455, checked in by Henrik Bettermann, 14 years ago

resolve #702 (in custom)

File size: 4.5 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
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18"""
19
20info = context.waeup_tool.getAccessInfo(context)
21student_id = info['student_id']
22if student_id is None:
23    return None
24
25mtool = context.portal_membership
26member = mtool.getAuthenticatedMember()
27member_id = str(member)
28
29course_results = context.course_results
30request = context.REQUEST
31response = request.RESPONSE
32import logging
33logger = logging.getLogger('Skins.getStudyLevelInfo')
34
35level_id  =  context.getId()
36level_doc = info['doc'] = context.getContent()
37
38info['is_so'] = is_so = info['is_sectionofficer']
39#info['is_student'] = is_student = context.isStudent()
40info['is_ca'] = is_ca = context.isCourseAdviser()
41#info['student'] = student = context.students_catalog(id=student_id)[0]
42info['student'] = student = context.students_catalog.getRecordByKey(student_id)
43info['review_state'] = review_state = student.review_state
44is_current_level = level_id == student.level
45school_fee_paid =  review_state == 'school_fee_paid'
46info['is_current_level'] = is_current_level
47info['has_verdict'] = has_verdict = level_doc.verdict
48
49info['submission_allowed']= school_fee_paid and is_current_level and not has_verdict
50info['validation_allowed']= review_state == 'courses_registered' and is_current_level
51info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated','returning',) and is_current_level
52info['validated'] = level_doc.validated_by and not (is_current_level and review_state in ('courses_registered',))
53info['show_check_boxes'] =  (is_ca and school_fee_paid and is_current_level and not has_verdict) or\
54                            (info['is_student'] and school_fee_paid and is_current_level and not has_verdict) or\
55                            (is_so) # and is_current_level and not has_verdict)
56
57info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper()
58info['session'] = context.portal_vocabularies.sessions.get(level_doc.session)
59info['level_str'] = context.portal_vocabularies.student_levels.get(level_id)
60
61info['choosen_ids'] = request.get('ids',[])
62
63#info['status_info'] = ""
64#if is_student:
65#    if review_state == 'courses_registered':
66#        info['status_info'] = "Request for course validation pending"
67#    elif review_state == 'courses_validated':
68#        info['status_info'] = "Courses validated"
69#elif is_ca:
70#    if review_state == 'courses_registered':
71#        info['status_info'] = "Please validate these courses"
72#    elif review_state == 'courses_validated':
73#        info['status_info'] = "Courses validated"
74
75cert_id = student.course
76info['cert_id'] = cert_id
77total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
78info['total_credits'] = total_credits
79
80#start customization
81
82if context.objectIds():
83    course_results.moveResultsHere(context,student_id)
84    logger.info("%s initiated moveResultsHere for %s in level %s" % (member_id,student_id,level_id))
85
86max_credits = 50
87try:
88    if int(context.getId()) >=  int(student.end_level):
89        max_credits = 51
90except:
91    logger.info("%s has strange level id %s" % (student_id,level_id))
92info['without_score'] = without_score = True
93if without_score:
94    for rows in (normal1,normal2,normal3):
95        for row in rows:
96            row['score'] = 0
97info['without_cascore'] = True
98#end customization
99
100info['max_credits'] = max_credits
101info['credits_exceeded'] = total_credits > max_credits
102current_session = student.session
103
104info['gpa'] = gpa
105if gpa and total_credits:
106    info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
107
108# carry_overs.sort(cmp_semester_id)
109info['carry_overs'] = carry_overs
110# normal.sort(cmp_semester_id)
111
112info['normal1'] = normal1
113info['normal2'] = normal2
114info['normal3'] = normal3
115
116info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
117info['spillover'] = student.level > student.end_level
118
119students_object = context.portal_url.getPortalObject().campus.students
120student = getattr(students_object, student_id)
121info['app'] = student.application
122info['app_doc'] = student.application.getContent()
123return info
Note: See TracBrowser for help on using the repository browser.