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