[3690] | 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 | 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
|
---|
| 50 | info['validation_allowed']= review_state == 'courses_registered' and is_current_level
|
---|
| 51 | info['rejection_allowed']= review_state in ('courses_registered', 'courses_validated',) and is_current_level
|
---|
| 52 | info['validated'] = review_state == 'courses_validated' and is_current_level
|
---|
| 53 |
|
---|
| 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 | (is_so and is_current_level and not has_verdict)
|
---|
| 57 |
|
---|
| 58 | info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper()
|
---|
| 59 | info['session'] = context.portal_vocabularies.sessions.get(level_doc.session)
|
---|
| 60 | info['level_str'] = context.portal_vocabularies.student_levels.get(level_id)
|
---|
| 61 |
|
---|
| 62 | info['choosen_ids'] = request.get('ids',[])
|
---|
| 63 |
|
---|
| 64 | #info['status_info'] = ""
|
---|
| 65 | #if is_student:
|
---|
| 66 | # if review_state == 'courses_registered':
|
---|
| 67 | # info['status_info'] = "Request for course validation pending"
|
---|
| 68 | # elif review_state == 'courses_validated':
|
---|
| 69 | # info['status_info'] = "Courses validated"
|
---|
| 70 | #elif is_ca:
|
---|
| 71 | # if review_state == 'courses_registered':
|
---|
| 72 | # info['status_info'] = "Please validate these courses"
|
---|
| 73 | # elif review_state == 'courses_validated':
|
---|
| 74 | # info['status_info'] = "Courses validated"
|
---|
| 75 |
|
---|
| 76 | cert_id = student.course
|
---|
| 77 | info['cert_id'] = cert_id
|
---|
| 78 | total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
|
---|
| 79 | info['total_credits'] = total_credits
|
---|
| 80 |
|
---|
| 81 | #start customization
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | max_credits = 58
|
---|
| 86 | info['without_score'] = False
|
---|
| 87 | info['without_cascore'] = False
|
---|
| 88 |
|
---|
| 89 | items = []
|
---|
| 90 | subobjects = context.objectValues()
|
---|
| 91 | for subobject in subobjects:
|
---|
| 92 | row = {}
|
---|
| 93 | row['id'] = subobject.getId()
|
---|
| 94 | row['title'] = '%s' % context.portal_vocabularies.terms.get(subobject.getId())
|
---|
| 95 | items.append(row)
|
---|
| 96 | info['items'] = items
|
---|
| 97 |
|
---|
[3811] | 98 | complete1 = 0
|
---|
[3902] | 99 | score_calc_average_1 = 0
|
---|
[3811] | 100 | for r in normal1:
|
---|
[3902] | 101 | if r['grade'] and r['atl']:
|
---|
| 102 | complete1 += 1
|
---|
| 103 | score_calc_average_1 += r['score_calc']
|
---|
[3811] | 104 | if len(normal1) == complete1:
|
---|
| 105 | complete1 = True
|
---|
| 106 | else:
|
---|
| 107 | complete1 = False
|
---|
[3902] | 108 | if len(normal1):
|
---|
| 109 | score_calc_average_1 /= len(normal1)
|
---|
[3811] | 110 | info['complete1'] = complete1
|
---|
[4035] | 111 | info['score_calc_average_1'] = '%.2f' % score_calc_average_1
|
---|
[3690] | 112 |
|
---|
[3811] | 113 | complete2 = 0
|
---|
[3902] | 114 | score_calc_average_2 = 0
|
---|
[4035] | 115 | for r in normal2:
|
---|
[3902] | 116 | if r['grade'] and r['atl']:
|
---|
| 117 | score_calc_average_2 += r['score_calc']
|
---|
| 118 | complete2 += 1
|
---|
[3811] | 119 | if len(normal2) == complete2:
|
---|
| 120 | complete2 = True
|
---|
| 121 | else:
|
---|
| 122 | complete2 = False
|
---|
[3902] | 123 | if len(normal2):
|
---|
| 124 | score_calc_average_2 /= len(normal2)
|
---|
[3811] | 125 | info['complete2'] = complete2
|
---|
[4035] | 126 | info['score_calc_average_2'] = '%.2f' % score_calc_average_2
|
---|
[3811] | 127 |
|
---|
| 128 | complete3 = 0
|
---|
[3902] | 129 | score_calc_average_3 = 0
|
---|
[4035] | 130 | for r in normal3:
|
---|
[3902] | 131 | if r['grade'] and r['atl']:
|
---|
| 132 | complete3 += 1
|
---|
| 133 | score_calc_average_3 += r['score_calc']
|
---|
[3811] | 134 | if len(normal3) == complete3:
|
---|
| 135 | complete3 = True
|
---|
| 136 | else:
|
---|
| 137 | complete3 = False
|
---|
[3902] | 138 | if len(normal3):
|
---|
| 139 | score_calc_average_3 /= len(normal3)
|
---|
[3811] | 140 | info['complete3'] = complete3
|
---|
[4035] | 141 | info['score_calc_average_3'] = '%.2f' % score_calc_average_3
|
---|
[3811] | 142 |
|
---|
[4036] | 143 | session_id = level_doc.session
|
---|
| 144 | yga1,yga2,yga3,counter1,counter2,counter3 = course_results.getYearGroupAverage(session_id,level_id)
|
---|
| 145 | info['yga1'] = yga1
|
---|
| 146 | info['yga2'] = yga2
|
---|
| 147 | info['yga3'] = yga3
|
---|
| 148 | info['counter1'] = counter1
|
---|
| 149 | info['counter2'] = counter2
|
---|
| 150 | info['counter3'] = counter3
|
---|
[3811] | 151 |
|
---|
[3690] | 152 | #end customization
|
---|
| 153 |
|
---|
| 154 | info['max_credits'] = max_credits
|
---|
| 155 | info['credits_exceeded'] = total_credits > max_credits
|
---|
| 156 | current_session = student.session
|
---|
| 157 |
|
---|
| 158 | info['gpa'] = gpa
|
---|
| 159 | if gpa and total_credits:
|
---|
| 160 | info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
|
---|
| 161 |
|
---|
| 162 | info['carry_overs'] = carry_overs
|
---|
[3819] | 163 | normal1.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
|
---|
| 164 | normal2.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
|
---|
| 165 | normal3.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
|
---|
| 166 |
|
---|
[3690] | 167 | info['normal1'] = normal1
|
---|
| 168 | info['normal2'] = normal2
|
---|
| 169 | info['normal3'] = normal3
|
---|
| 170 |
|
---|
| 171 | info['data_missing'] = not info['normal1'] and not info['normal2'] and not info['normal3']
|
---|
| 172 | info['spillover'] = student.level > student.end_level
|
---|
| 173 |
|
---|
| 174 | students_object = context.portal_url.getPortalObject().campus.students
|
---|
| 175 | student = getattr(students_object, student_id)
|
---|
| 176 | info['app'] = student.application
|
---|
| 177 | info['app_doc'] = student.application.getContent()
|
---|
| 178 |
|
---|
| 179 | return info |
---|