[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 | """
|
---|
| 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
|
---|
[2466] | 19 | member = mtool.getAuthenticatedMember()
|
---|
| 20 | member_id = str(member)
|
---|
[2448] | 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 |
|
---|
[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 |
|
---|
| 66 | student_id = context.getStudentId()
|
---|
| 67 | level_id = context.getId()
|
---|
| 68 |
|
---|
| 69 | info = {}
|
---|
| 70 | info['is_so'] = is_so = context.isSectionOfficer()
|
---|
| 71 | info['is_student'] = is_student = context.isStudent()
|
---|
| 72 | info['is_ca'] = is_ca = context.isCourseAdviser()
|
---|
| 73 | info['student'] = student = context.students_catalog(id=student_id)[0]
|
---|
| 74 | info['review_state'] = review_state = context.getStudentReviewState()
|
---|
| 75 | info['view_only'] = review_state != "school_fee_paid"
|
---|
| 76 | info['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)
|
---|
| 79 | info['choosen_ids'] = request.get('ids',[])
|
---|
| 80 | info['status_info'] = ""
|
---|
| 81 | if 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"
|
---|
| 86 | elif 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"
|
---|
| 91 | info['doc'] = context.getContent()
|
---|
| 92 | cert_id = student.course
|
---|
| 93 | info['cert_id'] = cert_id
|
---|
| 94 | if 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] | 97 | credits_total,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
|
---|
[2448] | 98 | info['credits_total'] = credits_total
|
---|
[2469] | 99 | max_credits = 50
|
---|
| 100 | if context.getId() == student.end_level:
|
---|
| 101 | max_credits = 51
|
---|
| 102 | info['max_credits'] = max_credits
|
---|
| 103 | info['credits_exceeded'] = credits_total > max_credits
|
---|
[2448] | 104 | current_session = student.session
|
---|
[2469] | 105 | info['submission_allowed']= not info['credits_exceeded'] and\
|
---|
| 106 | current_session == context.getSessionId()[0]
|
---|
[2448] | 107 | # carry_overs.sort(cmp_semester_id)
|
---|
| 108 | info['carry_overs'] = carry_overs
|
---|
| 109 | # normal.sort(cmp_semester_id)
|
---|
[2606] | 110 | info['normal1'] = normal1
|
---|
| 111 | info['normal2'] = normal2
|
---|
| 112 | info['normal3'] = normal3
|
---|
[2448] | 113 |
|
---|
| 114 | students_object = context.portal_url.getPortalObject().campus.students
|
---|
| 115 | student = getattr(students_object, student_id)
|
---|
| 116 | info['app'] = student.application
|
---|
| 117 | info['app_doc'] = student.application.getContent()
|
---|
| 118 |
|
---|
[2486] | 119 | return info |
---|