[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 2760 2007-11-26 07:39:15Z 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 |
|
---|
[2758] | 40 | info = {}
|
---|
| 41 |
|
---|
[2448] | 42 | student_id = context.getStudentId()
|
---|
[2758] | 43 | level_id = context.getId()
|
---|
[2760] | 44 | level_doc = info['doc'] = context.getContent()
|
---|
[2448] | 45 |
|
---|
| 46 | info['is_so'] = is_so = context.isSectionOfficer()
|
---|
| 47 | info['is_student'] = is_student = context.isStudent()
|
---|
| 48 | info['is_ca'] = is_ca = context.isCourseAdviser()
|
---|
| 49 | info['student'] = student = context.students_catalog(id=student_id)[0]
|
---|
[2664] | 50 | info['review_state'] = review_state = student.review_state
|
---|
[2760] | 51 | is_current_level = level_id == student.level
|
---|
[2757] | 52 | school_fee_paid = review_state == 'school_fee_paid'
|
---|
[2760] | 53 | info['is_current_level'] = is_current_level
|
---|
| 54 | info['has_verdict'] = has_verdict = level_doc.verdict
|
---|
[2664] | 55 |
|
---|
[2760] | 56 | info['submission_allowed']= school_fee_paid and is_current_level and not has_verdict
|
---|
| 57 | info['validation_allowed']= review_state == 'courses_registered' and is_current_level
|
---|
| 58 | info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated',) and is_current_level
|
---|
| 59 | info['validated'] = review_state == 'courses_validated' and is_current_level
|
---|
[2664] | 60 |
|
---|
[2760] | 61 | info['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)
|
---|
[2758] | 64 |
|
---|
[2760] | 65 | info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper()
|
---|
| 66 | info['session'] = context.portal_vocabularies.sessions.get(level_doc.session)
|
---|
| 67 | info['level_str'] = context.portal_vocabularies.levels.get(level_id)
|
---|
[2758] | 68 |
|
---|
[2448] | 69 | info['choosen_ids'] = request.get('ids',[])
|
---|
[2758] | 70 |
|
---|
[2760] | 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 |
|
---|
[2448] | 83 | cert_id = student.course
|
---|
| 84 | info['cert_id'] = cert_id
|
---|
| 85 | if context.objectIds():
|
---|
| 86 | course_results.moveResultsHere(context,student_id)
|
---|
[2466] | 87 | logger.info("%s initiated moveResultsHere for %s in level %s" % (member_id,student_id,level_id))
|
---|
[2757] | 88 | total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
|
---|
| 89 | info['total_credits'] = total_credits
|
---|
[2469] | 90 | max_credits = 50
|
---|
| 91 | if context.getId() == student.end_level:
|
---|
| 92 | max_credits = 51
|
---|
| 93 | info['max_credits'] = max_credits
|
---|
[2757] | 94 | info['credits_exceeded'] = total_credits > max_credits
|
---|
[2448] | 95 | current_session = student.session
|
---|
[2664] | 96 |
|
---|
[2757] | 97 | info['gpa'] = gpa
|
---|
| 98 | if gpa and total_credits:
|
---|
| 99 | info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
|
---|
[2758] | 100 |
|
---|
[2664] | 101 |
|
---|
| 102 |
|
---|
[2448] | 103 | # carry_overs.sort(cmp_semester_id)
|
---|
| 104 | info['carry_overs'] = carry_overs
|
---|
| 105 | # normal.sort(cmp_semester_id)
|
---|
[2606] | 106 | info['normal1'] = normal1
|
---|
| 107 | info['normal2'] = normal2
|
---|
| 108 | info['normal3'] = normal3
|
---|
[2448] | 109 |
|
---|
[2664] | 110 | info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
|
---|
[2649] | 111 | info['spillover'] = student.level > student.end_level
|
---|
| 112 |
|
---|
[2448] | 113 | students_object = context.portal_url.getPortalObject().campus.students
|
---|
| 114 | student = getattr(students_object, student_id)
|
---|
| 115 | info['app'] = student.application
|
---|
| 116 | info['app_doc'] = student.application.getContent()
|
---|
| 117 |
|
---|
[2486] | 118 | return info |
---|