[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'] |
---|
| 42 | #row['score'] = r['score'] |
---|
| 43 | row['student_id'] = student_id = r['student_id'] |
---|
| 44 | |
---|
| 45 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
| 46 | row['student_record'] = context.getFormattedStudentEntry(student_record) |
---|
| 47 | row['url'] = "%s/campus/students/%s/study_course/%s" % (context.portal_url(),student_id,level_id) |
---|
| 48 | |
---|
| 49 | row['editable'] = not (r['ca1'] and r['ca2'] and r['atl'] and r['exam']) and row['student_record']['review_state'] == 'courses_validated' |
---|
| 50 | row['sort_dummy'] = row['student_record']['review_state'] |
---|
| 51 | rows.append(row) |
---|
| 52 | |
---|
| 53 | rows.sort(cmp=lambda x,y: cmp("%(session_id)s%(sort_dummy)s" % x, |
---|
| 54 | "%(session_id)s%(sort_dummy)s" % y)) |
---|
| 55 | info['students'] = rows |
---|
| 56 | |
---|
| 57 | return context.lecturer_students_list(info = info,) |
---|
| 58 | |
---|
| 59 | #return info |
---|