## Script (Python) "ti_188_resolve" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: ti_188_resolve.py 1687 2007-04-18 11:28:47Z henrik $ """ resolve ticket #188 """ request = context.REQUEST session = request.SESSION response = request.RESPONSE setheader = request.RESPONSE.setHeader def getObject(outer,object): if outer and outer.hasObject(object): return getattr(outer,object) return None def rwrite(s): response.setHeader('Content-type','text/html; charset=ISO-8859-15') response.write("%s
\n\r" % s) wftool = context.portal_workflow mtool = context.portal_membership member = mtool.getAuthenticatedMember() roles = member.getRolesInContext(context) retcat = context.returning_import rcat = context.results_import scat = context.students_catalog from Products.AdvancedQuery import Eq, Between, Le,In aq_students = context.students_catalog.evalAdvancedQuery students = context.portal_url.getPortalObject().campus.students if str(member) not in ('admin','joachim'): return count = 0 ok_count = 0 reg_count = 0 nyl_count = 0 wrong_count = 0 cr_count = 0 res = scat() for sbrain in res: if str(sbrain.level) == '100': ec = "new" else: ec = "nor" erg = context.results_import(matric_no=sbrain.matric_no) if erg and erg[0].Level: level_res = erg[0].Level #everdict = erg[0].Verdict level_cc = context.getLevelFromResultsCosCode(erg) #if level_cc == 0: #lc = "-" lc = "%s00" % level_cc #verdict,elegible = context.getVerdict(everdict) #if elegible: # continue verdict = sbrain.verdict if verdict in ('A','B','',): continue dict = context.getFormattedStudentEntry(sbrain) dict['level_res'] = lc count += 1 dict['count'] = count code = 'xxx' comment = "" dict['review_state'] = '' sres = context.portal_catalog(id = sbrain.id) if sres: dict['review_state'] = sres[0].review_state #if sbrain.level == '': # code = 'nyl' # nyl_count += 1 if sbrain.level != lc: code = 'nok' wrong_count += 1 student = getObject(students,sbrain.id) study_course = getObject(student,'study_course') level = getObject(study_course,sbrain.level) if level is not None: cr_count += 1 if dict['review_state'] in ('courses_registered', 'courses_validated'): code = 'nok_cr' reg_count += 1 else: comment = "level %(level)s deleted" % dict comment = comment + ", level in students_catalog modified to %s" % lc ##study_course.manage_delObjects((sbrain.level,)) ##context.students_catalog.modifyRecord(id = sbrain.id,level=lc,) else: ok_count += 1 code = 'ok' dict['nyl_count'] = nyl_count dict['ok_count'] = ok_count dict['cr_count'] = cr_count dict['reg_count'] = reg_count dict['wrong_count'] = wrong_count dict['code'] = code dict['comment'] = comment rwrite('"%(count)d:%(ok_count)d:%(nyl_count)d:%(wrong_count)d:%(cr_count)d:%(reg_count)d","%(code)s","%(id)s","%(matric_no)s","%(name)s","%(level)s","%(level_res)s","%(review_state)s","%(comment)s"' % dict) rwrite("total: %(count)d
correct: %(ok_count)d
wrong: %(wrong_count)d
level created: %(cr_count)d
courses registered: %(reg_count)d" % dict )