source: WAeUP_SRP/branches/uli/skins/waeup_student/getStudyLevelInfo.py @ 17946

Last change on this file since 17946 was 1653, checked in by uli, 18 years ago

Incorporated changeset 1593:1652 of trunk into uli-branch.

  • Property svn:keywords set to Id
File size: 3.4 KB
RevLine 
[1513]1## Script (Python) "getStudyLevelInfo"
[723]2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=student=None
8##title=
9##
[805]10# $Id: getStudyLevelInfo.py 1653 2007-03-28 02:35:25Z uli $
[723]11"""
12return Info about the Studylevel
13"""
[1494]14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
[1380]19from Products.AdvancedQuery import Eq, Between, Le,In
[1494]20aq_portal = context.portal_catalog.evalAdvancedQuery
[1380]21request = context.REQUEST
22session = request.SESSION
23response = request.RESPONSE
24
[723]25def calculateGPA():
26    """calculate the gpa"""
27    sum = 0
28    course_count = 0
29    for sc in context.objectValues():
30        result = sc.getContent()
31        if not result.grade:
32            continue
33        res = context.portal_catalog({'meta_type': 'Course',
34                                      'id': sc.aq_parent.id})
35        if len(res) < 1:
36            continue
37        course = res[0].getObject().getContent()
38    if course_count:
39        return sum/course_count
40    return 0.0
41
[1653]42def cmp_semester_id(a,b):
43    s1 = "%(semester)s%(id)s" % a
44    s2 = "%(semester)s%(id)s" % b
45    if s1 == s2:
[1380]46        return 0
[1653]47    if s1 > s2:
[1380]48        return 1
49    return -1
[723]50
[1380]51
[723]52wf = context.portal_workflow
53mtool = context.portal_membership
[1380]54student_id = context.getStudentId()
55
[1515]56
57
[723]58info = {}
[1515]59info['is_so'] = is_so = context.isSectionOfficer()
60info['is_student'] = is_student = context.isStudent()
61info['is_ca'] = is_ca = context.isCourseAdviser()
[1380]62info['student'] = student = context.students_catalog(id=student_id)[0]
[1513]63info['review_state'] = review_state = context.getStudentReviewState()
[1515]64info['view_only'] =  review_state != "school_fee_paid"
[1593]65info['show_check_boxes'] =  (is_ca and review_state in ('school_fee_paid',)) or\
[1515]66                            (is_student and context.getStudentReviewState() == "school_fee_paid") or\
67                            (is_so)
[723]68info['choosen_ids'] = request.get('ids',[])
[1513]69info['status_info'] = ""
70if is_student:
[1515]71    if review_state == 'courses_registered':
[1513]72        info['status_info'] = "Request for Course Validation pending"
[1515]73    elif review_state == 'courses_validated':
[1513]74        info['status_info'] = "Courses validated"
75elif is_ca:
[1515]76    if review_state == 'courses_registered':
[1513]77        info['status_info'] = "Please validate these Courses"
[1515]78    elif review_state == 'courses_validated':
[1513]79        info['status_info'] = "Courses validated"
[723]80info['doc'] = context.getContent()
[1380]81##study_course = context.aq_parent.getContent()
82##cert_id = study_course.study_course
83cert_id = student.course
[723]84info['cert_id'] = cert_id
[1380]85normal = []
86carry_overs = []
[1482]87credits_total = 0
[1380]88for id,obj in context.objectItems():
[1482]89    try:
90        credit = int(obj.getContent().credits)
91    except ValueError:
92        credit = 3
93    credits_total += credit
[1380]94    if id.endswith('_co'):
95        d = context.getCourseInfo(id[:-3])
[1494]96        d['id'] = id
[1380]97        d['grade'] = obj.getContent().grade
98        carry_overs.append(d)
99    else:
100        d = context.getCourseInfo(id)
[1494]101        d['id'] = id
[1380]102        coe = obj.getContent().core_or_elective
103        d['coe'] = 'Core'
104        if not coe:
105            d['coe'] = 'Elective'
106        normal.append(d)
[1482]107info['credits_total'] = credits_total
[1653]108carry_overs.sort(cmp_semester_id)
[1380]109info['carry_overs'] = carry_overs
[1653]110normal.sort(cmp_semester_id)
[1380]111info['normal'] = normal
[1593]112
113students_object = context.portal_url.getPortalObject().campus.students
114student = getattr(students_object, student_id)
115info['app'] = student.application
116info['app_doc'] = student.application.getContent()
117
[723]118return info
Note: See TracBrowser for help on using the repository browser.