Changeset 2460
- Timestamp:
- 28 Oct 2007, 14:46:29 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPTables.py
r2454 r2460 1373 1373 else: 1374 1374 normal.append(d) 1375 normal.sort(cmp=lambda x,y: cmp(x['semester'], y['semester'])) 1376 carry_overs.sort(cmp=lambda x,y: cmp(x['semester'], y['semester'])) 1375 normal.sort(cmp=lambda x,y: cmp("%(semester)s%(code)s" % x, 1376 "%(semester)s%(code)s" % y)) 1377 carry_overs.sort(cmp=lambda x,y: cmp("%(semester)s%(code)s" % x, 1378 "%(semester)s%(code)s" % y)) 1377 1379 return credits,carry_overs,normal 1378 1380 ###) -
WAeUP_SRP/base/skins/waeup_student/add_course_result.py
r2451 r2460 33 33 member = mtool.getAuthenticatedMember() 34 34 35 36 35 d = context.getCourseInfo(course_id) 37 36 args = {} … … 44 43 if d['title'] == 'unknown': 45 44 err = "No such course!" 46 #logger.info('%s tried to add StudentCourseResult object %s for non-existing course' % (member,course_id))47 45 break 48 if context.hasObject(course_id): 46 d['course_id'] = course_id 47 d['student_id'] = student_id = context.getStudentId() 48 d['level_id'] = level_id = context.getId() 49 session_id = context.getLevelSession(context.getContent(),student_id,level_id) 50 d['session_id'] = session_id 51 d['key'] = "%s|%s|%s" % (student_id,level_id,course_id) 52 try: 53 context.course_results.addRecord(**d) 54 break 55 except ValueError: 49 56 err = "Course already exists!" 50 #logger.info('%s tried to add StudentCourseResult object %s which is already in course list' % (member,course_id))51 break52 if context.hasObject("%s_co" % course_id):53 err = "Course already exists as carryover course!"54 #logger.info('%s tried to add StudentCourseResult object %s which already exists as carryover course' % (member,course_id))55 57 break 56 58 break … … 58 60 if err: 59 61 args['course_id'] = course_id 60 #args['error'] = err61 62 args['portal_status_message'] = err 62 63 url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args) 63 64 return request.RESPONSE.redirect(url) 64 65 65 66 # cr_id = context.invokeFactory('StudentCourseResult',course_id)67 # cr = getattr(context,cr_id)68 # context.portal_workflow.doActionFor(cr,'open')69 # cr.getContent().edit(mapping=d)70 d['course_id'] = course_id71 d['student_id'] = student_id = context.getStudentId()72 d['level_id'] = level_id = context.getId()73 session_id = context.getLevelSession(context.getContent(),student_id,level_id)74 d['session_id'] = session_id75 d['key'] = "%s|%s|%s" % (student_id,level_id,course_id)76 77 context.course_results.addRecord(**d)78 #context.portal_workflow.doActionFor(cr,'close')79 #args['course_id'] = course_id80 66 81 67 logger.info('%s added StudentCourseResult object %s at level %s for %s' % (member, -
WAeUP_SRP/base/skins/waeup_student/refresh_level.py
r2451 r2460 42 42 student = context.students_catalog(id=context.getStudentId())[0] 43 43 cert_id = student.course 44 current_level = student.level 44 student_id = context.getStudentId() 45 45 level = context 46 #results = context.results_import(matric_no = student.matric_no) 47 # results = False #skip carry overs 48 # if results: 49 # #carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')] 50 # l = [] 51 # carry_overs = results 52 # for co in carry_overs: 53 # carry_over = False 54 # query = Eq('code',co.CosCode) 55 # c_res = aq_courses(query) 56 # if not c_res: 57 # logger.info('%s, course %s not found in courses_catalog' % (student.id,co.CosCode)) 58 # continue 59 # course_cat_entry = c_res[0] 60 # if not course_cat_entry.passmark: 61 # carry_over = co.GRADE in ('D','E','F') 62 # else: 63 # try: 64 # score = int(co.Score) 65 # except: 66 # logger.info('%s, course %s has invalid score %s' % (student.id, 67 # co.CosCode, 68 # co.Score)) 69 # continue 70 # if int(c_res[0].passmark) <= score: 71 # continue 72 # carry_over = True 73 # if not carry_over: 74 # continue 75 # d = context.getCourseInfo(co.CosCode) 76 # d['grade'] = co.GRADE 77 # d['carry_level'] = co.CarryLevel 78 # course_id = "%s_co" % co.CosCode 79 # if not context.hasObject(course_id): 80 # cr_id = level.invokeFactory('StudentCourseResult',course_id) 81 # course_result = getattr(level,cr_id) 82 # context.portal_workflow.doActionFor(course_result,'open') 83 # course_result.getContent().edit(mapping=d) 46 level_id = context.getId() 84 47 res = context.portal_catalog(portal_type="Certificate", id = cert_id) 48 query = Eq('student_id',student_id) & Eq('level_id', level_id) 49 existing_courses = [course.code for course in 50 context.course_results.evalAdvancedQuery(query)] 85 51 l = [] 52 records = [] 86 53 if res: 87 54 cert = res[0] … … 90 57 Eq('portal_type','CertificateCourse') 91 58 courses = aq_portal(query) 92 course_ids = [c.getId for c in courses if c.getId not in level.objectIds()]59 course_ids = [c.getId for c in courses if c.getId not in existing_courses] 93 60 for course_id in course_ids: 94 61 #set_trace() 62 if course_id in l: 63 # don't add twice 64 continue 65 l += course_id, 95 66 d = context.getCourseInfo(course_id) 96 # cr_id = level.invokeFactory('StudentCourseResult',c_id)97 # course_result = getattr(level,cr_id)98 # context.portal_workflow.doActionFor(course_result,'open')99 # course_result.getContent().edit(mapping=d)100 # context.waeup_tool.doCommit()101 67 d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') 102 #d['core_or_elective'] = True103 68 d['course_id'] = course_id 104 d['student_id'] = student_id = context.getStudentId()105 d['level_id'] = level_id = context.getId()69 d['student_id'] = student_id 70 d['level_id'] = level_id 106 71 d['key'] = "%s|%s|%s" % (student_id,level_id,course_id) 107 context.course_results.addRecord(**d) 72 records.append(d) 73 if records: 74 context.course_results.addMultipleRecords(records) 75 108 76 #session.set('in_progress','finished') 109 77 logger.info('%s updated course list' % member)
Note: See TracChangeset for help on using the changeset viewer.