Changeset 1649 for WAeUP_SRP/trunk


Ignore:
Timestamp:
27 Mar 2007, 12:11:17 (18 years ago)
Author:
joachim
Message:

add create_course_results

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r1616 r1649  
    1616from Products.CPSCore.CPSMembershipTool import CPSUnrestrictedUser
    1717from Products.WAeUP_SRP.Academics import makeCertificateCode
     18from Products.AdvancedQuery import Eq, Between, Le,In
    1819import logging
    1920import csv,re,os
     
    14281429        return "Level %s" % self.aq_parent.getId()
    14291430
    1430 ##    security.declarePublic("gpa")
    1431 ##    def gpa(self):
    1432 ##        """calculate the gpa"""
    1433 ##        sum = 0
    1434 ##        course_count = 0
    1435 ##        for sc in self.objectValues():
    1436 ##            result = sc.getContent()
    1437 ##            if not result.grade:
    1438 ##                continue
    1439 ##            res = self.portal_catalog({'meta_type': 'Course',
    1440 ##                                          'id': sc.aq_parent.id})
    1441 ##            if len(res) != 1:
    1442 ##                continue
    1443 ##            course = res[0].getObject().getContent()
    1444 ##            sum += course.credits * ['F','E','D','C','B','A'].index(result.grade)
    1445 ##            course_count += 1
    1446 ##        if course_count:
    1447 ##            return sum/course_count
    1448 ##        return 0.0
     1431    def create_course_results(self,cert_id,current_level):
     1432        "create all courses in a level"
     1433        aq_portal = self.portal_catalog.evalAdvancedQuery
     1434        res = self.portal_catalog(portal_type="Certificate", id = cert_id)
     1435        l = []
     1436        import transaction
     1437        if res:
     1438            cert = res[0]
     1439            path = cert.getPath()
     1440            query = Eq("path","%s/%s" % (path,current_level)) &\
     1441                    Eq('portal_type','CertificateCourse')
     1442            courses = aq_portal(query)
     1443            #from pdb import set_trace;set_trace()
     1444            self_proxy = self.aq_parent
     1445            for c in courses:
     1446                d = self.getCourseInfo(c.getId)
     1447                cr_id = self_proxy.invokeFactory('StudentCourseResult',c.getId)
     1448                course_result = getattr(self_proxy,cr_id)
     1449                self.portal_workflow.doActionFor(course_result,'open')
     1450                d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
     1451                course_result.getContent().edit(mapping=d)
     1452                transaction.commit()
    14491453
    14501454InitializeClass(StudentStudyLevel)
Note: See TracChangeset for help on using the changeset viewer.