[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 1771 2007-05-11 11:37:16Z henrik $ |
---|
| 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 |
---|
[1681] | 45 | reg_count = 0 |
---|
[1680] | 46 | nyl_count = 0 |
---|
| 47 | wrong_count = 0 |
---|
| 48 | cr_count = 0 |
---|
| 49 | res = scat() |
---|
| 50 | for sbrain in res: |
---|
[1771] | 51 | if not sbrain.matric_no: |
---|
| 52 | continue |
---|
[1680] | 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 |
---|
[1682] | 60 | #everdict = erg[0].Verdict |
---|
[1680] | 61 | level_cc = context.getLevelFromResultsCosCode(erg) |
---|
| 62 | #if level_cc == 0: |
---|
| 63 | #lc = "-" |
---|
| 64 | lc = "%s00" % level_cc |
---|
[1682] | 65 | |
---|
| 66 | #verdict,elegible = context.getVerdict(everdict) |
---|
| 67 | #if elegible: |
---|
| 68 | # continue |
---|
[1687] | 69 | |
---|
| 70 | verdict = sbrain.verdict |
---|
[1683] | 71 | if verdict in ('A','B','',): |
---|
[1680] | 72 | continue |
---|
[1687] | 73 | |
---|
[1680] | 74 | dict = context.getFormattedStudentEntry(sbrain) |
---|
[1682] | 75 | dict['level_res'] = lc |
---|
[1680] | 76 | count += 1 |
---|
| 77 | dict['count'] = count |
---|
| 78 | code = 'xxx' |
---|
| 79 | comment = "" |
---|
[1681] | 80 | dict['review_state'] = '' |
---|
| 81 | sres = context.portal_catalog(id = sbrain.id) |
---|
| 82 | if sres: |
---|
| 83 | dict['review_state'] = sres[0].review_state |
---|
[1683] | 84 | |
---|
| 85 | #if sbrain.level == '': |
---|
| 86 | # code = 'nyl' |
---|
| 87 | # nyl_count += 1 |
---|
| 88 | |
---|
| 89 | if sbrain.level != lc: |
---|
[1680] | 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) |
---|
[1682] | 95 | if level is not None: |
---|
[1680] | 96 | cr_count += 1 |
---|
[1683] | 97 | if dict['review_state'] in ('courses_registered', 'courses_validated'): |
---|
[1681] | 98 | code = 'nok_cr' |
---|
[1683] | 99 | reg_count += 1 |
---|
| 100 | else: |
---|
[1687] | 101 | comment = "level %(level)s deleted" % dict |
---|
[1683] | 102 | comment = comment + ", level in students_catalog modified to %s" % lc |
---|
[1681] | 103 | ##study_course.manage_delObjects((sbrain.level,)) |
---|
[1683] | 104 | ##context.students_catalog.modifyRecord(id = sbrain.id,level=lc,) |
---|
[1680] | 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 |
---|
[1681] | 111 | dict['reg_count'] = reg_count |
---|
[1680] | 112 | dict['wrong_count'] = wrong_count |
---|
| 113 | dict['code'] = code |
---|
| 114 | dict['comment'] = comment |
---|
[1687] | 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) |
---|
[1680] | 116 | |
---|
[1683] | 117 | rwrite("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 | |
---|