source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_115fc_resolve.py @ 8794

Last change on this file since 8794 was 3397, checked in by joachim, 17 years ago

first analysis for #115 okene

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1## Script (Python) "ti_115fc_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_115fc_resolve.py 3397 2008-03-31 10:07:17Z joachim $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18
19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
21if str(member) not in ('admin','joachim'):
22    return
23
24
25import logging
26import DateTime
27logger = logging.getLogger('Skins.ti_115fc_resolve')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_students = context.students_catalog.evalAdvancedQuery
30aq_portal = context.portal_catalog_real.evalAdvancedQuery
31course_results = context.course_results
32aq_course_results = course_results.evalAdvancedQuery
33students_folder = context.portal_url.getPortalObject().campus.students
34
35request = context.REQUEST
36session = request.SESSION
37response = request.RESPONSE
38setheader = request.RESPONSE.setHeader
39def rwrite(s):
40    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
41    response.write("%s<br>\n\r" % s)
42results = course_results()
43inconsistent = {}
44students = context.students_catalog()   
45total = len(students)
46logger.info('started for %d students' % total)
47wrong_count = 0
48count = 0
49commit_after = 10000
50#set_trace()
51for student in students:
52    count += 1
53    if not count % commit_after:
54        logger.info('found %d wrong of %d searched total %d' % (wrong_count,count,total))
55    levels = context.getLevelsFromCourseResults(student.id)
56    for level in levels:
57        if int(level) % 100:
58            logger.info('%s invalid level in course_results %s' % (student.id,','.join(levels)))
59    study_course = getattr(getattr(students_folder,student.id),'study_course',None)
60    if study_course is None:
61        wrong_count += 1
62        logger.info('%s no study_course object but %s levels' % (student.id,','.join(levels)))
63        continue
64    existing_levels = study_course.objectIds()
65    different = [l for l in levels if l not in existing_levels]
66    if different:
67        wrong_count += 1
68        logger.info("%s levels %s in course_results and %s existing levels %d of %d checked %d wrong" % (student.id,
69                                                                                                         ",".join(levels),
70                                                                                                         ",".join(existing_levels),
71                                                                                                         count,
72                                                                                                         total,
73                                                                                                         wrong_count,
74                                                                                                        ))
75        # if count > 10:
76        #     break
77        # set_trace()
78logger.info('found %d' % wrong_count)
79logger.info('finished')
Note: See TracBrowser for help on using the repository browser.