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 2664 2007-11-15 14:35:05Z henrik $
|
---|
11 | """
|
---|
12 | return Info about the Studylevel
|
---|
13 | """
|
---|
14 |
|
---|
15 | wf = context.portal_workflow
|
---|
16 | mtool = context.portal_membership
|
---|
17 | if mtool.isAnonymousUser():
|
---|
18 | return None
|
---|
19 | member = mtool.getAuthenticatedMember()
|
---|
20 | member_id = str(member)
|
---|
21 |
|
---|
22 | try:
|
---|
23 | from Products.zdb import set_trace
|
---|
24 | except:
|
---|
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
|
---|
34 | course_results = context.course_results
|
---|
35 | request = context.REQUEST
|
---|
36 | response = request.RESPONSE
|
---|
37 | import logging
|
---|
38 | logger = logging.getLogger('Skins.getStudyLevelInfo')
|
---|
39 |
|
---|
40 | student_id = context.getStudentId()
|
---|
41 | level_id = context.getId()
|
---|
42 |
|
---|
43 | info = {}
|
---|
44 | info['is_so'] = is_so = context.isSectionOfficer()
|
---|
45 | info['is_student'] = is_student = context.isStudent()
|
---|
46 | info['is_ca'] = is_ca = context.isCourseAdviser()
|
---|
47 | info['student'] = student = context.students_catalog(id=student_id)[0]
|
---|
48 | info['review_state'] = review_state = student.review_state
|
---|
49 | info['view_only'] = review_state != "school_fee_paid"
|
---|
50 |
|
---|
51 |
|
---|
52 | has_paid = review_state == 'school_fee_paid'
|
---|
53 |
|
---|
54 | info['show_check_boxes'] = (is_ca and has_paid) or\
|
---|
55 | (is_student and has_paid) or\
|
---|
56 | (is_so)
|
---|
57 |
|
---|
58 |
|
---|
59 | info['choosen_ids'] = request.get('ids',[])
|
---|
60 | info['status_info'] = ""
|
---|
61 | if is_student:
|
---|
62 | if review_state == 'courses_registered':
|
---|
63 | info['status_info'] = "Request for Course Validation pending"
|
---|
64 | elif review_state == 'courses_validated':
|
---|
65 | info['status_info'] = "Courses validated"
|
---|
66 | elif is_ca:
|
---|
67 | if review_state == 'courses_registered':
|
---|
68 | info['status_info'] = "Please validate these Courses"
|
---|
69 | elif review_state == 'courses_validated':
|
---|
70 | info['status_info'] = "Courses validated"
|
---|
71 | info['doc'] = context.getContent()
|
---|
72 | cert_id = student.course
|
---|
73 | info['cert_id'] = cert_id
|
---|
74 | if context.objectIds():
|
---|
75 | course_results.moveResultsHere(context,student_id)
|
---|
76 | logger.info("%s initiated moveResultsHere for %s in level %s" % (member_id,student_id,level_id))
|
---|
77 | credits_total,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
|
---|
78 | info['credits_total'] = credits_total
|
---|
79 | max_credits = 50
|
---|
80 | if context.getId() == student.end_level:
|
---|
81 | max_credits = 51
|
---|
82 | info['max_credits'] = max_credits
|
---|
83 | info['credits_exceeded'] = credits_total > max_credits
|
---|
84 | current_session = student.session
|
---|
85 |
|
---|
86 | info['submission_allowed']= review_state in ('school_fee_paid','returning') and has_paid
|
---|
87 | info['validation_allowed']= review_state == 'courses_registered'
|
---|
88 | info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated',)
|
---|
89 |
|
---|
90 |
|
---|
91 | # carry_overs.sort(cmp_semester_id)
|
---|
92 | info['carry_overs'] = carry_overs
|
---|
93 | # normal.sort(cmp_semester_id)
|
---|
94 | info['normal1'] = normal1
|
---|
95 | info['normal2'] = normal2
|
---|
96 | info['normal3'] = normal3
|
---|
97 |
|
---|
98 | info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
|
---|
99 | info['spillover'] = student.level > student.end_level
|
---|
100 |
|
---|
101 | students_object = context.portal_url.getPortalObject().campus.students
|
---|
102 | student = getattr(students_object, student_id)
|
---|
103 | info['app'] = student.application
|
---|
104 | info['app_doc'] = student.application.getContent()
|
---|
105 |
|
---|
106 | return info |
---|