[3818] | 1 | ## Script (Python) "getLecturerCourseResultsInfo" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=course_id |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: getCoursesInfo.py 3482 2008-05-01 05:54:53Z henrik $ |
---|
| 11 | """ |
---|
| 12 | return Info about the Courses |
---|
| 13 | """ |
---|
| 14 | |
---|
| 15 | mtool = context.portal_membership |
---|
| 16 | member = mtool.getAuthenticatedMember() |
---|
| 17 | lec_id = member_id = str(member) |
---|
| 18 | if mtool.isAnonymousUser(): |
---|
| 19 | return None |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | request = context.REQUEST |
---|
| 23 | |
---|
| 24 | path_info = request.get('PATH_INFO').split('/') |
---|
| 25 | |
---|
| 26 | info = {} |
---|
| 27 | info['lec_id'] = lec_id |
---|
| 28 | info['course_id'] = course_id |
---|
| 29 | |
---|
| 30 | res = context.course_results(code=course_id) |
---|
| 31 | items = [ brain for brain in res] |
---|
| 32 | rows = [] |
---|
| 33 | for r in items: |
---|
| 34 | row = {} |
---|
| 35 | if r['carry_over']: |
---|
| 36 | row['carry_over'] = 'CO' |
---|
| 37 | else: |
---|
| 38 | row['carry_over'] = '' |
---|
| 39 | row['credits'] = r['credits'] |
---|
| 40 | row['session_id'] = r['session_id'] |
---|
| 41 | row['level_id'] = level_id = r['level_id'] |
---|
[4033] | 42 | row['level_string'] = context.portal_vocabularies.student_levels.get(r['level_id']) |
---|
| 43 | row['session_string'] = context.portal_vocabularies.sessions.get(r['session_id']) |
---|
[3818] | 44 | #row['score'] = r['score'] |
---|
| 45 | row['student_id'] = student_id = r['student_id'] |
---|
| 46 | |
---|
| 47 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
| 48 | row['student_record'] = context.getFormattedStudentEntry(student_record) |
---|
| 49 | row['url'] = "%s/campus/students/%s/study_course/%s" % (context.portal_url(),student_id,level_id) |
---|
| 50 | |
---|
| 51 | row['editable'] = not (r['ca1'] and r['ca2'] and r['atl'] and r['exam']) and row['student_record']['review_state'] == 'courses_validated' |
---|
| 52 | row['sort_dummy'] = row['student_record']['review_state'] |
---|
| 53 | rows.append(row) |
---|
| 54 | |
---|
| 55 | rows.sort(cmp=lambda x,y: cmp("%(session_id)s%(sort_dummy)s" % x, |
---|
| 56 | "%(session_id)s%(sort_dummy)s" % y)) |
---|
| 57 | info['students'] = rows |
---|
| 58 | |
---|
| 59 | return context.lecturer_students_list(info = info,) |
---|
| 60 | |
---|
| 61 | #return info |
---|