## Script (Python) "search_pins"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# $Id: fixLevelFromResults.py 1459 2007-02-21 17:18:32Z joachim $
"""
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 = []
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 = 100*level_cc - int(level_res)
verdict,elegible = context.getVerdict(everdict)
if elegible:
level = "%d00" % (level_cc + 1)
context.students_catalog.modifyRecord(id = sbrain.id,
level="",
verdict = "")
while True:
ec = "nos"
if not students.hasObject(sbrain.id):
break
student = getattr(students,sbrain.id)
ec = "nyr"
if not student.hasObject("study_course"):
break
study_course = getattr(student,"study_course")
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
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:
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)