source: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_165_resolve.py @ 17952

Last change on this file since 17952 was 1669, checked in by joachim, 18 years ago

merged up to 1664

  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1## Script (Python) "ti_151_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_165_resolve.py 1669 2007-04-04 06:31:52Z joachim $
11"""
12resolve ticket #151
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19import logging
20#>>>>>>>>>>>>>>>><
21logger = logging.getLogger('Skins.ti_165_resolve')
22#logger.info('already done on 26.3.07 by joachim')
23#return
24#<<<<<<<<<<<<<<<<<
25request = context.REQUEST
26session = request.SESSION
27response = request.RESPONSE
28setheader = request.RESPONSE.setHeader
29students = context.portal_url.getPortalObject().campus.students
30#from string import Template
31def rwrite(s):
32    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
33    response.write("%s<br>\n\r" % s)
34def getObject(outer,object):
35    if outer.hasObject(object):
36        return getattr(outer,object)
37    return None
38
39try:
40    from Products.AdvancedQuery import Eq, Between, Le,In
41    aq_students = context.students_catalog.evalAdvancedQuery
42except:
43    evalAdvancedQuery = None
44
45students_cat = context.students_catalog
46pumeresults = context.portal_pumeresults
47de_students = students_cat(entry_mode = 'DE')
48found = 0
49not_found = 0
50for des in de_students:
51    if not des.jamb_reg_no.startswith('6'):
52        continue
53    pres = pumeresults(jamb_reg_no = des.jamb_reg_no)
54    if not pres:
55        student_obj = getObject(students,des.id)
56        if student_obj is None:
57            rwrite('%s with jamb_reg_no %s %s/%s/%s student object not found' % (des.id,
58                                                                            des.jamb_reg_no,
59                                                                            des.faculty,
60                                                                            des.department,
61                                                                            des.course,
62                                                                            ))
63            continue
64        pume_obj = getObject(student_obj,'pume')
65        if pume_obj is None:
66            rwrite('%s with jamb_reg_no %s %s/%s/%s pume object not found' % (des.id,
67                                                                            des.jamb_reg_no,
68                                                                            des.faculty,
69                                                                            des.department,
70                                                                            des.course,
71                                                                            ))
72            continue
73        pume_doc = pume_obj.getContent()
74        score = pume_doc.pume_tot_score
75        dict = {}
76        dict['student_id'] = des.id
77        dict['jamb_reg_no'] = des.jamb_reg_no
78        dict['course_code'] = des.course
79        dict['department'] = des.department
80        dict['faculty'] = des.faculty
81        dict['name'] = des.name
82        dict['score'] = score
83        dict['result_type'] = 'DE'
84        dict['sex'] = 'M'
85        if des.sex:
86            dict['sex'] = 'F'
87        s = '%(jamb_reg_no)s with student_id %(student_id)s not in pumeresults should be recreatet<br>\r\n'
88        s += 'Sex:%(sex)s,Name: %(name)s,Type:%(result_type)s<br>\n\r'
89        s += 'Studycourse: %(course_code)s,Faculty: %(faculty)s,Department: %(department)s,Score: %(score)s'
90        rwrite(s % (dict))
91           
92        not_found += 1
93        continue
94    found += 1
95    #rwrite('%s with jamb_reg_no %s found in pumeresults' % (des.id,des.jamb_reg_no))
96rwrite('%d found in pumeresults <br>%d not found in pumeresults<br>total in portal_pumeresults %d <br>'
97        % (found,not_found,len(pumeresults())))
98   
Note: See TracBrowser for help on using the repository browser.