Ignore:
Timestamp:
2 Jan 2007, 21:29:17 (18 years ago)
Author:
Henrik Bettermann
Message:

GPA calculation
medical hostel allocation corrected
and beautifying

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_student/getSessionResults.py

    r1174 r1179  
    5858with_courses_cat = hasattr(context,'courses_catalog')
    5959fields = context.results_import.schema()
     60gpa = 0
     61course_count = 0
    6062for r in results:
    6163    result = {}
     
    6668    if with_courses_cat and res:
    6769        result['title'] = res[0].title
     70        result['credits'] = res[0].credits
     71        try:
     72            weight = int(result['WEIGHT'])
     73            credits = int(res[0].credits)
     74            gpa_course =  int(res[0].credits) * weight
     75            gpa += gpa_course
     76            course_count += credits
     77            result['gpa'] = 'ok'
     78        except:
     79            result['gpa'] = 'na'
    6880    else:
    69         result['title'] = "To Be Determined"
     81        result['title'] = "na"
     82        result['credits'] = "na"
     83        result['gpa'] = 'na'
    7084    if r.Semester == '2':
    7185        sem2.append(result)
    7286    else:
    7387        sem1.append(result)
     88
     89if course_count:
     90    gpa = float(gpa) / course_count
     91    gpa = "%4.2f" % gpa
     92info['gpa'] = gpa
    7493info['results'] = (sem1, sem2)
    7594info['student'] = student
    7695info['s_id'] = student_id
    7796return info
     97
Note: See TracChangeset for help on using the changeset viewer.