Ignore:
Timestamp:
26 Mar 2008, 10:11:44 (16 years ago)
Author:
joachim
Message:

add functionality to edit the current_mode in the study_course object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_utilities/ti_507_resolve.py

    r3368 r3376  
    2222    return
    2323
    24 
    2524import logging
    2625import DateTime
     
    3837count = 0
    3938found = 0
    40 commit_after = 100000
     39commit_after = 1000
    4140certificates = context.getCertificatesDict()
    4241students = context.students_catalog()
    43 wrong = []
     42wrong = {}
    4443missing_courses = []
    4544wrong_modes = {}
     
    6463            w_count += 1
    6564            wrong_modes[(current_mode,study_mode)] = w_count
    66             wrong += student.id,
    67     if wrong and not (len(wrong) % commit_after):
    68         logger.info('found %d wrong of %d' % (len(wrong),count))
     65            d = {}
     66            d['student_id'] = student.id
     67            d['current_mode'] = study_mode
     68            d['current_mode_old'] = current_mode
     69            wrong[student.id] = d
     70    # if wrong and not (len(wrong) % commit_after):
     71    #     logger.info('found %d wrong of %d' % (len(wrong),count))
    6972for k,v in wrong_modes.items():
    7073    logger.info('wrong mode %s counted %d' % (k,v))
    7174logger.info('missing courses %s (%d counted)' % (', '.join(missing_courses),len(students_with_missing_courses)))
    7275logger.info('found %d wrong of %d' % (len(wrong),count))
     76count = 0
     77for student_id,d in wrong.items():
     78    #set_trace()
     79    try:
     80        getattr(getattr(students_folder,student_id),'study_course').getContent().edit(mapping=d)
     81        failed = False
     82    except:
     83        failed = True
     84    if failed:
     85        logger.info("%(student_id)s change failed")
     86    else:
     87        logger.info("%(student_id)s changed current_mode from %(current_mode_old)s to %(current_mode)s" % d)
     88    if count and not count % commit_after:
     89        context.waeup_tool.doCommit()
     90        logger.info("committing %d of total %d" % (commit_after,count))
     91    count += 1
Note: See TracChangeset for help on using the changeset viewer.