Changeset 2988 for WAeUP_SRP/base/skins


Ignore:
Timestamp:
7 Jan 2008, 18:57:27 (17 years ago)
Author:
joachim
Message:

this should work in all cases:

first the normal courses for a level are added, than the
carryover courses are added, which are not already in the level.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_student/create_level.py

    r2977 r2988  
    6464    #context.portal_workflow.doActionFor(level,'close_for_edit')
    6565level_id = level.getId()
    66 onprobation = context.getContent().previous_verdict in ('C',)
    6766session_id = context.getLevelSession(level.getContent(),student_id,level_id)
    6867results = []
     
    7271l = []
    7372
     73level_nr,dummy = divmod(int(current_level),100)
     74# fetch session courses from the certificate
     75res = context.portal_catalog(portal_type="Certificate", id = cert_id)
     76if res:
     77    cert = res[0]
     78    path = cert.getPath()
     79    academics_level = 100 * level_nr
     80    query = Eq("path","%s/%s" % (path,academics_level)) &\
     81            Eq('portal_type','CertificateCourse')
     82    courses = aq_portal(query)
     83    for c in courses:
     84        course_id = "%s" % c.getId
     85        if course_id in l:
     86            # don't add twice
     87            continue
     88        l += course_id,
     89        d = context.getCourseInfo(c.getId)
     90        d['carry_over'] = False
     91        d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
     92        d['course_id'] = course_id
     93        d['student_id'] = student_id = context.getStudentId()
     94        d['level_id'] = level_id
     95        d['session_id'] = session_id
     96        records.append(d)
    7497# fetch carry_over courses from results_import
    7598if student.session in ('6', '06') and results:
     
    77100    for co in carry_overs:
    78101        course_id = co.CosCode
    79         if level.hasObject(course_id):    #already created
     102        if course_id in l:
     103            # don't add twice
    80104            continue
     105        # if level.hasObject(course_id):    #already created
     106        #     continue
    81107        carry_over = False
    82108        query = Eq('code',co.CosCode)
     
    102128        if not carry_over:
    103129            continue
    104         if course_id in l:
    105             # don't add twice
    106             continue
    107130        l += course_id,
    108131        d = context.getCourseInfo(co.CosCode)
     
    115138        records.append(d)
    116139# fetch carry_over courses from the course_results catalog
    117 elif not onprobation:
     140else:
    118141    res = aq_results(Eq('student_id',student_id),
    119142                             sortSpecs=('level_id',))
    120     if res:
    121         last_level_id = res[-1].level_id
    122143    for result in res:
    123144        course_id = result.code
    124         if course_id in l or result.level_id != last_level_id:
     145        if course_id in l:
    125146            continue
    126147        query = Eq('code',course_id)
     
    150171        records.append(d)
    151172
    152 # fetch session courses from the certificate
    153 res = context.portal_catalog(portal_type="Certificate", id = cert_id)
    154 if res:
    155     cert = res[0]
    156     path = cert.getPath()
    157     academics_level = 100 * (int(current_level)/100)
    158     query = Eq("path","%s/%s" % (path,academics_level)) &\
    159             Eq('portal_type','CertificateCourse')
    160     courses = aq_portal(query)
    161     for c in courses:
    162         course_id = "%s" % c.getId
    163         if course_id in l:
    164             # don't add twice
    165             continue
    166         l += course_id,
    167         d = context.getCourseInfo(c.getId)
    168         d['carry_over'] = False
    169         d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
    170         d['course_id'] = course_id
    171         d['student_id'] = student_id = context.getStudentId()
    172         d['level_id'] = level_id
    173         d['session_id'] = session_id
    174         records.append(d)
    175173if records:
    176174    context.course_results.addMultipleRecords(records)
Note: See TracChangeset for help on using the changeset viewer.