## Script (Python) "search_pins" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: fixLevelFromResults.py 1409 2007-02-12 08:50:49Z henrik $ """ list Students for ClearanceOfficers """ request = context.REQUEST session = request.SESSION response = request.RESPONSE setheader = request.RESPONSE.setHeader def rwrite(s): response.setHeader('Content-type','text/html; charset=ISO-8859-15') response.write(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 line_count = 0 lines = [] #from Products.zdb import set_trace;set_trace() 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: #lc = "N" level_res = erg[0].Level everdict = erg[0].Verdict level_cc = context.getLevelFromResultsCosCode(erg) #if level_cc == 0: #lc = "-" #if "%d00" % level_cc != level_res: lc = 100*level_cc - int(level_res) verdict,elegible = context.getVerdict(everdict) if elegible: #lc = "S" level = "%d00" % (level_cc + 1) #context.students_catalog.modifyRecord(id = sbrain.id, # level="", # verdict = "") while True: student = getattr(students,sbrain.id,None) ec = "nos" if student is None: break ec = "nyr" study_course = getattr(student,"study_course", None) if study_course is None: break #study_course.getContent().edit(mapping = {'current_level':level, # 'current_verdict':verdict}) #context.students_catalog.modifyRecord(id = sbrain.id, # level=level, # verdict=verdict) ec = "reg" break #rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no +"--"+ old_level +"--"+ level +"
") s = '"%s","%s","%s","%s","%s","%s","%s","%s"' % (str(lc),ec, sbrain.id, sbrain.matric_no, level_res, level_cc, everdict, verdict) #lines.append(s) else: #rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no + "
") s = '"","%s","%s","%s","",""' % (ec,sbrain.id,sbrain.matric_no) #lines.append(s) rwrite("%s
" %s) # count += 1 # if count > 60: # line_count += 1 # rwrite("
\n%3d " % line_count) # count = 0 rwrite("
\n Done" ) ##setheader('Content-type','text/semicolon-seperated-values') ##setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"') ##setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past ##setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 ##setheader('Cache-Control', 'post-check=0,pre-check=0') ##setheader('Pragma', 'no-cache') # HTTP/1.0 ##return '\n'.join(lines)