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