## Script (Python) "search_pins"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST
##title=
##
# $Id: fixLevelFromResults.py 1388 2007-02-04 08:48:18Z henrik $
"""
list Students for ClearanceOfficers
"""
request = REQUEST
request = context.REQUEST
session = request.SESSION
response = request.RESPONSE
def rwrite(s):
response.setHeader('Content-type','text/html; charset=ISO-8859-15')
#response.setHeader('Content-length','%d' % (len(s)))
#response.setStatus('OK')
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
lc = 1
#from Products.zdb import set_trace;set_trace()
res = scat()
for sbrain in res:
ec = "nor"
erg = context.results_import(matric_no=sbrain.matric_no)
if erg and erg[0].Level:
ec = "e"
level = erg[0].Level
for e in erg:
ec = "E"
if level != e.Level:
ec = "%s:%s!=%s
\n" % (sbrain.matric_no,level,e.Level)
level = "%d" % (int(level) + 100)
# würde ich an dieser Stelle nicht machen (siehe unten)
#context.students_catalog.modifyRecord(id = sbrain.id, level=level)
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})
#dies ist der richtige Platz
context.students_catalog.modifyRecord(id = sbrain.id, level=level)
ec = "reg"
break
if sbrain.level:
old_level = str(sbrain.level)
else:
old_level = 'non'
rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no +"--"+ old_level +"--"+ level +"
")
else:
rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no + "
")
# count += 1
# if count > 60:
# lc += 1
# rwrite("
\n%3d " % lc)
# count = 0
rwrite("
\n Done" )