Changeset 10598


Ignore:
Timestamp:
10 Sep 2013, 11:39:24 (11 years ago)
Author:
Henrik Bettermann
Message:

Determine cumulative sessional gpa and other cumulative parameters needed for level reports.

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

Legend:

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

    r10586 r10598  
    102102    @property
    103103    def gpa_params_rectified(self):
    104         weighted_credits = 0.0
     104        """Calculate corrected corrected level (sesional) gpa parameters.
     105
     106        The corrected gpa is displayed on transcripts only.
     107        """
     108        credits_weighted = 0.0
    105109        credits_counted = 0
    106110        level_gpa = 0.0
     
    111115                    if co_ticket is not None and co_ticket.weight is not None:
    112116                        credits_counted += co_ticket.credits
    113                         weighted_credits += co_ticket.credits * co_ticket.weight
     117                        credits_weighted += co_ticket.credits * co_ticket.weight
    114118                    continue
    115119                credits_counted += ticket.credits
    116                 weighted_credits += ticket.credits * ticket.weight
     120                credits_weighted += ticket.credits * ticket.weight
    117121        if credits_counted:
    118             level_gpa = round(weighted_credits/credits_counted, 3)
    119         return level_gpa, credits_counted, weighted_credits
     122            level_gpa = round(credits_weighted/credits_counted, 3)
     123        return level_gpa, credits_counted, credits_weighted
    120124
    121125    @property
    122126    def gpa_params(self):
    123         weighted_credits = 0.0
     127        """Calculate gpa parameters for this level.
     128        """
     129        credits_weighted = 0.0
    124130        credits_counted = 0
    125131        level_gpa = 0.0
     
    127133            if ticket.score is not None:
    128134                credits_counted += ticket.credits
    129                 weighted_credits += ticket.credits * ticket.weight
     135                credits_weighted += ticket.credits * ticket.weight
    130136        if credits_counted:
    131             level_gpa = round(weighted_credits/credits_counted, 3)
    132         return level_gpa, credits_counted, weighted_credits
     137            level_gpa = round(credits_weighted/credits_counted, 3)
     138        return level_gpa, credits_counted, credits_weighted
    133139
    134140    @property
     
    138144    @property
    139145    def passed_params(self):
     146        """Determine the number and credits of passed and failed courses.
     147
     148        This method is used for level reports.
     149        """
    140150        passed = failed = 0
    141151        failed_courses = []
     
    154164
    155165    @property
     166    def cumulative_params(self):
     167        """Calculate the cumulative gpa and other cumulative parameters
     168        for this level.
     169
     170        All levels below this level are taken under consideration
     171        (including repeating levels). This method is used for level reports.
     172        """
     173        passed_credits = 0
     174        total_credits = 0
     175        total_credits_counted = 0
     176        total_credits_weighted = 0
     177        cgpa = 0
     178        for level in self.__parent__.values():
     179            if level.level > self.level:
     180                continue
     181            passed_credits += level.passed_params[2]
     182            total_credits += level.total_credits
     183            gpa_params = level.gpa_params
     184            total_credits_counted += gpa_params[1]
     185            total_credits_weighted += gpa_params[2]
     186        if total_credits_counted:
     187            cgpa = round(total_credits_weighted / total_credits_counted, 3)
     188        return (cgpa, total_credits_counted, total_credits_weighted,
     189               total_credits, passed_credits)
     190
     191    @property
    156192    def is_current_level(self):
    157193        try:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r10586 r10598  
    814814        self.assertMatches(
    815815            '...: Study Level 200 (Year 2)...', self.browser.contents)
    816         # If COURSE1 has score 10 it becomes a carry-over course
     816        # Since COURSE1 has score 10 it becomes a carry-over course
    817817        # in level 200
    818818        self.assertEqual(
     
    827827            self.student['studycourse']['200'].passed_params,
    828828            (0, 0, 0, 0, []))
     829        # And also cumulative params can be calculated. Meanwhile we have the
     830        # following courses: COURSE1 and COURSE2 in level 100 and
     831        # COURSE1 as carry-over course in level 200.
     832        self.assertEqual(
     833            self.student['studycourse']['100'].cumulative_params,
     834            (2.261, 23, 52.0, 23, 13))
     835        # COURSE1 in level 200 is not taken into consideration
     836        # when calculating the gpa.
     837        self.assertEqual(
     838            self.student['studycourse']['200'].cumulative_params,
     839            (2.261, 23, 52.0, 33, 13))
    829840        return
    830841
Note: See TracChangeset for help on using the changeset viewer.