source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_188_resolve.py @ 2224

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

import LGA as string
and other fixes

  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1## Script (Python) "ti_188_resolve"
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: ti_188_resolve.py 1771 2007-05-11 11:37:16Z henrik $
11"""
12resolve ticket #188
13"""
14
15request = context.REQUEST
16session = request.SESSION
17response = request.RESPONSE
18setheader = request.RESPONSE.setHeader
19
20def getObject(outer,object):
21    if outer and outer.hasObject(object):
22        return getattr(outer,object)
23    return None
24
25def rwrite(s):
26    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
27    response.write("%s<br>\n\r" % s)
28
29wftool = context.portal_workflow
30mtool = context.portal_membership
31member = mtool.getAuthenticatedMember()
32roles = member.getRolesInContext(context)
33retcat = context.returning_import
34rcat = context.results_import
35scat = context.students_catalog
36from Products.AdvancedQuery import Eq, Between, Le,In
37aq_students = context.students_catalog.evalAdvancedQuery
38students = context.portal_url.getPortalObject().campus.students
39
40
41if str(member) not in ('admin','joachim'):
42    return
43count = 0
44ok_count = 0
45reg_count = 0
46nyl_count = 0
47wrong_count = 0
48cr_count = 0
49res = scat()
50for sbrain in res:
51    if not sbrain.matric_no:
52        continue
53    if str(sbrain.level) == '100':
54        ec = "new"
55    else:
56        ec = "nor"
57    erg = context.results_import(matric_no=sbrain.matric_no)
58    if erg and erg[0].Level:
59        level_res = erg[0].Level
60        #everdict = erg[0].Verdict
61        level_cc = context.getLevelFromResultsCosCode(erg)
62        #if level_cc == 0:
63            #lc = "-"
64        lc = "%s00" % level_cc
65
66        #verdict,elegible = context.getVerdict(everdict)
67        #if elegible:
68        #    continue
69
70        verdict =  sbrain.verdict
71        if verdict in ('A','B','',):
72            continue
73
74        dict = context.getFormattedStudentEntry(sbrain)
75        dict['level_res'] = lc
76        count += 1
77        dict['count'] = count
78        code = 'xxx'
79        comment = ""
80        dict['review_state'] = ''
81        sres = context.portal_catalog(id = sbrain.id)
82        if sres:
83            dict['review_state'] = sres[0].review_state
84
85        #if sbrain.level == '':
86        #    code = 'nyl'
87        #    nyl_count += 1
88
89        if sbrain.level != lc:
90            code = 'nok'
91            wrong_count += 1
92            student = getObject(students,sbrain.id)
93            study_course = getObject(student,'study_course')
94            level = getObject(study_course,sbrain.level)
95            if level is not None:
96                cr_count += 1
97                if dict['review_state'] in ('courses_registered', 'courses_validated'):
98                    code = 'nok_cr'
99                    reg_count += 1
100                else:
101                    comment = "level %(level)s deleted" % dict
102                    comment = comment + ", level in students_catalog modified to %s" % lc
103                    ##study_course.manage_delObjects((sbrain.level,))
104                    ##context.students_catalog.modifyRecord(id = sbrain.id,level=lc,)
105        else:
106            ok_count += 1
107            code = 'ok'
108        dict['nyl_count'] = nyl_count
109        dict['ok_count'] = ok_count
110        dict['cr_count'] = cr_count
111        dict['reg_count'] = reg_count
112        dict['wrong_count'] = wrong_count
113        dict['code'] = code
114        dict['comment'] = comment
115        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)
116
117rwrite("total: %(count)d<br> correct: %(ok_count)d<br> wrong: %(wrong_count)d<br> level created: %(cr_count)d<br> courses registered: %(reg_count)d" % dict )
118
119
Note: See TracBrowser for help on using the repository browser.