source: WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py @ 1589

Last change on this file since 1589 was 1586, checked in by Henrik Bettermann, 18 years ago

fixed

  • 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 1586 2007-03-19 12:13:05Z henrik $
[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
[1380]42def cmp_semester(a,b):
43    if a['semester'] == b['semester']:
44        return 0
45    if a['semester'] > b['semester']:
46        return 1
47    return -1
[723]48
[1380]49
[723]50wf = context.portal_workflow
51mtool = context.portal_membership
[1380]52student_id = context.getStudentId()
53
[1515]54
55
[723]56info = {}
[1515]57info['is_so'] = is_so = context.isSectionOfficer()
58info['is_student'] = is_student = context.isStudent()
59info['is_ca'] = is_ca = context.isCourseAdviser()
[1380]60info['student'] = student = context.students_catalog(id=student_id)[0]
[1513]61info['review_state'] = review_state = context.getStudentReviewState()
[1515]62info['view_only'] =  review_state != "school_fee_paid"
[1586]63info['show_check_boxes'] =  (is_ca and review_state in ('school_fee_paid',)) or\
[1515]64                            (is_student and context.getStudentReviewState() == "school_fee_paid") or\
65                            (is_so)
[723]66info['choosen_ids'] = request.get('ids',[])
[1513]67info['status_info'] = ""
68if is_student:
[1515]69    if review_state == 'courses_registered':
[1513]70        info['status_info'] = "Request for Course Validation pending"
[1515]71    elif review_state == 'courses_validated':
[1513]72        info['status_info'] = "Courses validated"
73elif is_ca:
[1515]74    if review_state == 'courses_registered':
[1513]75        info['status_info'] = "Please validate these Courses"
[1515]76    elif review_state == 'courses_validated':
[1513]77        info['status_info'] = "Courses validated"
[723]78info['doc'] = context.getContent()
[1380]79##study_course = context.aq_parent.getContent()
80##cert_id = study_course.study_course
81cert_id = student.course
[723]82info['cert_id'] = cert_id
[1380]83normal = []
84carry_overs = []
[1482]85credits_total = 0
[1380]86for id,obj in context.objectItems():
[1482]87    try:
88        credit = int(obj.getContent().credits)
89    except ValueError:
90        credit = 3
91    credits_total += credit
[1380]92    if id.endswith('_co'):
93        d = context.getCourseInfo(id[:-3])
[1494]94        d['id'] = id
[1380]95        d['grade'] = obj.getContent().grade
96        carry_overs.append(d)
97    else:
98        d = context.getCourseInfo(id)
[1494]99        d['id'] = id
[1380]100        coe = obj.getContent().core_or_elective
101        d['coe'] = 'Core'
102        if not coe:
103            d['coe'] = 'Elective'
104        normal.append(d)
[1482]105info['credits_total'] = credits_total
[1380]106carry_overs.sort(cmp_semester)
107info['carry_overs'] = carry_overs
108normal.sort(cmp_semester)
109info['normal'] = normal
[1575]110
111students_object = context.portal_url.getPortalObject().campus.students
112student = getattr(students_object, student_id)
113info['app'] = student.application
114info['app_doc'] = student.application.getContent()
115
[723]116return info
Note: See TracBrowser for help on using the repository browser.