Ignore:
Timestamp:
5 Jun 2013, 08:02:29 (12 years ago)
Author:
Henrik Bettermann
Message:

Remove gpa field. The GPA must not be an attribute of the level. It contains also information on carry over courses of following levels. Thus it can only be reliably calculated at the end of a study course, e.g. in transcripts.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r10028 r10276  
    519519        fields = super(StudentStudyLevelProcessor, self).available_fields
    520520        fields.remove('total_credits')
    521         fields.remove('gpa')
    522521        return  fields
    523522
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r10270 r10276  
    13371337    grok.template('studylevelmanagepage')
    13381338    form_fields = grok.AutoFields(IStudentStudyLevel).omit(
    1339         'validation_date', 'validated_by', 'total_credits', 'gpa')
     1339        'validation_date', 'validated_by', 'total_credits')
    13401340    pnav = 4
    13411341    taboneactions = [_('Save'),_('Cancel')]
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r10250 r10276  
    567567        )
    568568
    569     gpa = schema.Int(
    570         title = _(u'GPA'),
    571         required = False,
    572         readonly = True,
    573         )
     569    #gpa = schema.Int(
     570    #    title = _(u'GPA'),
     571    #    required = False,
     572    #    readonly = True,
     573    #    )
    574574
    575575    def addCourseTicket(ticket, course):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py

    r10260 r10276  
    133133            tickets_3 = []
    134134            tickets = sorted(level_val.values(), key=lambda ticket: ticket.code)
    135             sgpa = 0.0
    136             session_credits_counted = 0
    137135            for ticket in tickets:
    138136                if ticket.semester == 1:
     
    142140                elif ticket.semester == 3:
    143141                    tickets_3.append(ticket)
    144                 if ticket.score:
    145                     total_credits_counted += ticket.credits
    146                     session_credits_counted += ticket.credits
    147                     cgpa += ticket.credits * ticket.weight
    148                     sgpa += ticket.credits * ticket.weight
    149             if session_credits_counted:
    150                 sgpa = round(sgpa/session_credits_counted, 2)
     142            gpa_params = level_val.gpa_params
     143            sgpa = gpa_params[0]
     144            total_credits_counted += gpa_params[1]
     145            cgpa += gpa_params[2]
    151146            levels.append(
    152147                dict(level_key=level_key,
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r9925 r10276  
    2929from waeup.kofa.utils.helpers import attrs_to_fields
    3030from waeup.kofa.students.vocabularies import StudyLevelSource
     31
     32def find_carry_over(ticket):
     33    return None
    3134
    3235def getGradeWeightFromScore(score):
     
    8790
    8891    @property
    89     def gpa(self):
    90         gpa = 0.0
     92    def gpa_params(self):
     93        weighted_credits = 0.0
    9194        credits_counted = 0
     95        level_gpa = 0.0
    9296        for ticket in self.values():
    93             if ticket.score:
     97            if ticket.carry_over is False and ticket.score:
     98                if ticket.score < ticket.passmark:
     99                    co_ticket = find_carry_over(ticket)
     100                    if co_ticket is not None:
     101                        credits_counted += co_ticket.credits
     102                        weighted_credits += co_ticket.credits * co_ticket.weight
     103                    continue
    94104                credits_counted += ticket.credits
    95                 gpa += ticket.credits * ticket.weight
     105                weighted_credits += ticket.credits * ticket.weight
    96106        if credits_counted:
    97             gpa = round(gpa/credits_counted, 2)
    98         return gpa
     107            level_gpa = round(weighted_credits/credits_counted, 2)
     108        return level_gpa, credits_counted, weighted_credits
    99109
    100110    @property
     
    145155
    146156StudentStudyLevel = attrs_to_fields(
    147     StudentStudyLevel, omit=['total_credits', 'gpa'])
     157    StudentStudyLevel, omit=['total_credits'])
    148158
    149159class StudentStudyLevelFactory(grok.GlobalUtility):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r10267 r10276  
    785785        self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C')
    786786        self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3)
    787         # We add another ticket to check if GPA will be correctly calculated
     787        # We add another ticket to check if GPAwill be correctly calculated
    788788        # (and rounded)
    789789        courseticket = createObject('waeup.CourseTicket')
     
    797797        self.student['studycourse']['100']['COURSE2'] = courseticket
    798798        self.browser.open(self.student_path + '/studycourse/100')
    799         self.assertTrue('<div>3.57</div>' in self.browser.contents)
    800         self.assertEqual(self.student['studycourse']['100'].gpa, 3.57)
     799        # total credits
     800        self.assertEqual(self.student['studycourse']['100'].gpa_params[1], 23)
     801        # weigheted credits = 3 * 10 + 4 * 13
     802        self.assertEqual(self.student['studycourse']['100'].gpa_params[2], 82.0)
     803        # sgpa = 82 / 23
     804        self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.57)
    801805        # Carry-over courses will be collected when next level is created
    802806        self.browser.open(self.student_path + '/studycourse/manage')
     
    18361840        self.student['studycourse']['110']['COURSE2'] = courseticket
    18371841        self.student['studycourse']['100']['COURSE1'].score = 55
    1838         self.assertEqual(self.student['studycourse']['100'].gpa, 3.0)
    1839         self.assertEqual(self.student['studycourse']['110'].gpa, 4.0)
     1842        self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.0)
     1843        self.assertEqual(self.student['studycourse']['110'].gpa_params[0], 4.0)
    18401844        # Get transcript data
    18411845        td = self.student['studycourse'].getTranscriptData()
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r10245 r10276  
    402402        self.assertEqual(
    403403            result,
    404             'gpa,level,level_session,level_verdict,total_credits,'
     404            'level,level_session,level_verdict,total_credits,'
    405405            'validated_by,validation_date,'
    406406            'student_id,number_of_tickets,certcode\r\n'
    407             '0.0,,,0,0,,,,0,\r\n'
     407            ',,0,0,,,,0,\r\n'
    408408            )
    409409        return
     
    420420        self.assertEqual(
    421421            result,
    422             'gpa,level,level_session,level_verdict,total_credits,'
     422            'level,level_session,level_verdict,total_credits,'
    423423            'validated_by,validation_date,'
    424424            'student_id,number_of_tickets,certcode\r\n'
    425             '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
     425            '100,2012,A,100,,,A111111,1,CERT1\r\n'
    426426            )
    427427        return
     
    436436        self.assertEqual(
    437437            result,
    438             'gpa,level,level_session,level_verdict,total_credits,'
     438            'level,level_session,level_verdict,total_credits,'
    439439            'validated_by,validation_date,'
    440440            'student_id,number_of_tickets,certcode\r\n'
    441             '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
     441            '100,2012,A,100,,,A111111,1,CERT1\r\n'
    442442            )
    443443        return
     
    451451        self.assertEqual(
    452452            result,
    453             'gpa,level,level_session,level_verdict,total_credits,'
     453            'level,level_session,level_verdict,total_credits,'
    454454            'validated_by,validation_date,'
    455455            'student_id,number_of_tickets,certcode\r\n'
    456             '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
     456            '100,2012,A,100,,,A111111,1,CERT1\r\n'
    457457            )
    458458        return
     
    470470        self.assertEqual(
    471471            result,
    472             'gpa,level,level_session,level_verdict,total_credits,'
     472            'level,level_session,level_verdict,total_credits,'
    473473            'validated_by,validation_date,'
    474474            'student_id,number_of_tickets,certcode\r\n'
    475             '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
     475            '100,2012,A,100,,,A111111,1,CERT1\r\n'
    476476            )
    477477        return
Note: See TracChangeset for help on using the changeset viewer.