source: WAeUP_SRP/trunk/skins/waeup_utilities/fixLevelFromResults.py @ 1391

Last change on this file since 1391 was 1391, checked in by Henrik Bettermann, 18 years ago

siehe Emails

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1## Script (Python) "search_pins"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: fixLevelFromResults.py 1391 2007-02-05 09:17:07Z henrik $
11"""
12list Students for ClearanceOfficers
13"""
14
15request = context.REQUEST
16session = request.SESSION
17response = request.RESPONSE
18setheader = request.RESPONSE.setHeader
19
20#def rwrite(s):
21#    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
22#    response.write(s)
23   
24wftool = context.portal_workflow
25mtool = context.portal_membership
26member = mtool.getAuthenticatedMember()
27roles = member.getRolesInContext(context)
28retcat = context.returning_import
29rcat = context.results_import
30scat = context.students_catalog
31from Products.AdvancedQuery import Eq, Between, Le,In
32aq_students = context.students_catalog.evalAdvancedQuery
33students = context.portal_url.getPortalObject().campus.students
34
35
36
37
38if str(member) not in ('admin','joachim'):
39    return
40count = 0
41lc = 1
42lines = []
43#from Products.zdb import set_trace;set_trace()
44res = scat()
45for sbrain in res:
46    if str(sbrain.level) == '100':
47        ec = "new"
48    else:
49        ec = "nor"
50    erg = context.results_import(matric_no=sbrain.matric_no)
51    if erg and erg[0].Level:
52        ec = "e"
53        level = erg[0].Level
54        for e in erg:
55            ec = "E"
56            if level != e.Level:
57                ec = "%s:%s!=%s<br />\n" % (sbrain.matric_no,level,e.Level)
58        level = "%d" % (int(level) + 100)
59
60        # würde ich an dieser Stelle nicht machen (siehe unten)
61        #context.students_catalog.modifyRecord(id = sbrain.id, level=level)
62
63        while True:
64            student = getattr(students,sbrain.id,None)
65            ec = "nos"
66            if student is None:
67                break
68            ec = "nyr"
69            study_course = getattr(student,"study_course", None)
70            if study_course is None:
71                break
72            # zum Testen auskommentiert   
73            #study_course.getContent().edit(mapping = {'current_level':level})
74
75            #dies ist der richtige Platz
76            context.students_catalog.modifyRecord(id = sbrain.id, level=level)
77
78            ec = "reg"
79            break
80        if sbrain.level:
81            old_level = str(sbrain.level)
82        else:
83            old_level = 'non'
84#        rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no +"--"+ old_level +"--"+ level +"<br />")
85
86        lines.append('"%s","%s","%s","%s","%s"' % (ec,sbrain.id,sbrain.matric_no,old_level,level))
87       
88
89    else:
90#        rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no + "<br />")
91        lines.append('"%s","%s","%s","",""' % (ec,sbrain.id,sbrain.matric_no))
92       
93#    count += 1
94#    if count > 60:
95#        lc += 1
96#        rwrite("<br />\n%3d " % lc)
97#        count = 0
98
99#rwrite("<br />\n Done" )
100
101setheader('Content-type','text/semicolon-seperated-values')
102setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"')
103setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
104setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
105setheader('Cache-Control', 'post-check=0,pre-check=0')
106setheader('Pragma', 'no-cache') # HTTP/1.0
107return '\n'.join(lines)
108
Note: See TracBrowser for help on using the repository browser.