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

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

show also matric_no

  • Property svn:keywords set to Id
File size: 3.6 KB
RevLine 
[1683]1## Script (Python) "ti_188_resolve"
[1680]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 1687 2007-04-18 11:28:47Z 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
[1681]45reg_count = 0
[1680]46nyl_count = 0
47wrong_count = 0
48cr_count = 0
49res = scat()
50for sbrain in res:
51    if str(sbrain.level) == '100':
52        ec = "new"
53    else:
54        ec = "nor"
55    erg = context.results_import(matric_no=sbrain.matric_no)
56    if erg and erg[0].Level:
57        level_res = erg[0].Level
[1682]58        #everdict = erg[0].Verdict
[1680]59        level_cc = context.getLevelFromResultsCosCode(erg)
60        #if level_cc == 0:
61            #lc = "-"
62        lc = "%s00" % level_cc
[1682]63
64        #verdict,elegible = context.getVerdict(everdict)
65        #if elegible:
66        #    continue
[1687]67
68        verdict =  sbrain.verdict
[1683]69        if verdict in ('A','B','',):
[1680]70            continue
[1687]71
[1680]72        dict = context.getFormattedStudentEntry(sbrain)
[1682]73        dict['level_res'] = lc
[1680]74        count += 1
75        dict['count'] = count
76        code = 'xxx'
77        comment = ""
[1681]78        dict['review_state'] = ''
79        sres = context.portal_catalog(id = sbrain.id)
80        if sres:
81            dict['review_state'] = sres[0].review_state
[1683]82
83        #if sbrain.level == '':
84        #    code = 'nyl'
85        #    nyl_count += 1
86
87        if sbrain.level != lc:
[1680]88            code = 'nok'
89            wrong_count += 1
90            student = getObject(students,sbrain.id)
91            study_course = getObject(student,'study_course')
92            level = getObject(study_course,sbrain.level)
[1682]93            if level is not None:
[1680]94                cr_count += 1
[1683]95                if dict['review_state'] in ('courses_registered', 'courses_validated'):
[1681]96                    code = 'nok_cr'
[1683]97                    reg_count += 1
98                else:
[1687]99                    comment = "level %(level)s deleted" % dict
[1683]100                    comment = comment + ", level in students_catalog modified to %s" % lc
[1681]101                    ##study_course.manage_delObjects((sbrain.level,))
[1683]102                    ##context.students_catalog.modifyRecord(id = sbrain.id,level=lc,)
[1680]103        else:
104            ok_count += 1
105            code = 'ok'
106        dict['nyl_count'] = nyl_count
107        dict['ok_count'] = ok_count
108        dict['cr_count'] = cr_count
[1681]109        dict['reg_count'] = reg_count
[1680]110        dict['wrong_count'] = wrong_count
111        dict['code'] = code
112        dict['comment'] = comment
[1687]113        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)
[1680]114
[1683]115rwrite("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 )
116
117
Note: See TracBrowser for help on using the repository browser.