Changeset 3612


Ignore:
Timestamp:
7 Aug 2008, 10:10:29 (16 years ago)
Author:
Henrik Bettermann
Message:

transcript for demo purposes

Location:
WAeUP_SRP/unilorin/waeup_custom
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/unilorin/waeup_custom/getTranscriptInfo.py

    r3602 r3612  
    1818"""
    1919
     20request = context.REQUEST
     21response = request.RESPONSE
     22import logging
     23logger = logging.getLogger('Skins.getTranscriptInfo')
    2024info = context.waeup_tool.getAccessInfo(context)
    2125student_id = info['student_id']
    2226if student_id is None:
    2327    return None
     28   
     29mtool = context.portal_membership   
     30if mtool.isAnonymousUser() or not context.isSectionOfficer():
     31    return None   
    2432
    2533mtool = context.portal_membership
     
    2836
    2937course_results = context.course_results
    30 request = context.REQUEST
    31 response = request.RESPONSE
    32 import logging
    33 logger = logging.getLogger('Skins.getTranscriptInfo')
    3438
    3539
    36 info['is_so'] = is_so = info['is_sectionofficer']
    37 info['student'] = student = context.students_catalog.getRecordByKey(student_id)
    38 info['review_state'] = review_state = student.review_state
    39 school_fee_paid =  review_state == 'school_fee_paid'
    40 info['has_verdict'] = has_verdict = level_doc.verdict
    41 
    42 info['verdict'] = context.portal_vocabularies.verdicts.get(level_doc.verdict).upper()
    43 info['session'] = context.portal_vocabularies.sessions.get(level_doc.session)
    44 
    45 cert_id = student.course
    46 info['cert_id'] = cert_id
    47 total_credits,gpa,carry_overs,normal1,normal2,normal3 = course_results.getCourses(student_id,level_id)
    48 info['total_credits'] = total_credits
    49 
    50 current_session = student.session
    51 info['gpa'] = gpa
    52 
    53 if gpa and total_credits:
    54     info['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
    55 
    56 info['carry_overs'] = carry_overs
     40student_record = context.students_catalog.getRecordByKey(student_id)
     41info['student_record'] = context.getFormattedStudentEntry(student_record)
    5742
    5843
     44year_courses = [[],[],[],[],[],[],[],[],[]]
     45year_details = [{'year':0},{'year':1},{'year':2},{'year':3},{'year':4},{'year':5},{'year':6},{'year':7},{'year':8}]
     46
     47courses = course_results.getAllCourses(student_id)
     48
     49for course in courses:
     50    year = divmod(int(course['level_id']),100)[0]
     51    year_courses[year].append(course)
     52    if not getattr(year_details[year],'session',None):
     53        year_details[year]['session'] = context.portal_vocabularies.sessions.get(course['session_id'])
     54
     55year_counter = 0
     56for year in year_courses:
     57    gpa = 0
     58    total_credits = 0
     59    for course in year:
     60        gpa += int(course['weight']) * int(course['credits'])
     61        total_credits += int(course['credits'])   
     62    if gpa and total_credits:
     63        year_details[year_counter]['total_credits'] = total_credits   
     64        year_details[year_counter]['gpa'] = "%4.2f" % (float(gpa)/int(total_credits))
     65    year.sort(cmp=lambda x,y: cmp("%(semester)s%(code)s" % x,
     66                                         "%(semester)s%(code)s" % y))
     67    year_counter += 1
     68   
     69info['year_details'] = year_details
     70info['year_courses'] = year_courses
     71
    5972return info
     73
     74
Note: See TracChangeset for help on using the changeset viewer.