source: WAeUP_SRP/trunk/skins/waeup_ois/getLecturerCourseResults.py @ 7869

Last change on this file since 7869 was 4033, checked in by Henrik Bettermann, 16 years ago

improve security level for lecturers

File size: 1.9 KB
Line 
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"""
12return Info about the Courses
13"""
14
15mtool = context.portal_membership
16member = mtool.getAuthenticatedMember()
17lec_id = member_id = str(member)
18if mtool.isAnonymousUser():
19    return None
20
21
22request = context.REQUEST
23
24path_info = request.get('PATH_INFO').split('/')
25
26info = {}
27info['lec_id'] = lec_id
28info['course_id'] = course_id
29
30res = context.course_results(code=course_id)
31items = [ brain for brain in res]
32rows = []
33for 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['level_string'] = context.portal_vocabularies.student_levels.get(r['level_id'])
43    row['session_string'] = context.portal_vocabularies.sessions.get(r['session_id'])
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   
55rows.sort(cmp=lambda x,y: cmp("%(session_id)s%(sort_dummy)s" % x,
56                              "%(session_id)s%(sort_dummy)s" % y))   
57info['students'] = rows
58
59return context.lecturer_students_list(info = info,)
60
61#return info
Note: See TracBrowser for help on using the repository browser.