Ignore:
Timestamp:
19 Nov 2012, 18:08:39 (12 years ago)
Author:
Henrik Bettermann
Message:

Remove total_credits method from view. This is already done in the content class.

Calculate momentary gpa and show on level page.

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

Legend:

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

    r9685 r9687  
    10371037            'b':level_title})
    10381038
    1039     @property
    1040     def total_credits(self):
    1041         total_credits = 0
    1042         for key, val in self.context.items():
    1043             total_credits += val.credits
    1044         return total_credits
    1045 
    10461039class ExportPDFCourseRegistrationSlipPage(UtilityView, grok.View):
    10471040    """Deliver a PDF slip of the context.
     
    22132206
    22142207    @property
    2215     def total_credits(self):
    2216         total_credits = 0
    2217         for key, val in self.context.items():
    2218             total_credits += val.credits
    2219         return total_credits
    2220 
    2221     @property
    22222208    def translated_values(self):
    22232209        return translated_values(self)
     
    22632249            self.redirect(self.url(self.context))
    22642250            return
    2265         if self.total_credits > self.max_credits:
     2251        if self.context.total_credits > self.max_credits:
    22662252            self.flash(_('Maximum credits of ${a} exceeded.',
    22672253                mapping = {'a':self.max_credits}))
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/studyleveleditpage.pt

    r8921 r9687  
    55    Course Tickets
    66    (Total Credits:
    7     <span i18n:name="total_credits" tal:replace="view/total_credits">TOTAL</span>)
     7    <span i18n:name="total_credits"
     8      tal:replace="view/context/total_credits">TOTAL</span>)
    89  </h3>
    910  <table class="display dataTableManage">
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/studylevelpage.pt

    r9320 r9687  
    2020      </td>
    2121      <td>
    22         <span tal:replace="view/total_credits">TOTAL</span>
     22        <span tal:replace="view/context/total_credits">26</span>
     23      </td>
     24    </tr>
     25    <tr>
     26      <td i18n:translate="">
     27        Momentary GPA:
     28      </td>
     29      <td>
     30        <span tal:replace="python: '%4.2f' % view.context.gpa">2.33</span>
    2331      </td>
    2432    </tr>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9684 r9687  
    481481    is_current_level = Attribute('Is this level the current level of the student?')
    482482    total_credits = Attribute('Total of all ticket credits in this study level.')
     483    gpa = Attribute('Grade point average in this study level.')
    483484
    484485    level_session = schema.Choice(
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r9684 r9687  
    8181
    8282    @property
     83    def gpa(self):
     84        gpa = 0
     85        credits_counted = 0
     86        for ticket in self.values():
     87            if ticket.score:
     88                credits_counted += ticket.credits
     89                gpa += ticket.credits * ticket.weight
     90        if credits_counted:
     91            gpa = float(gpa)/credits_counted
     92        return gpa
     93
     94    @property
    8395    def is_current_level(self):
    8496        try:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9684 r9687  
    765765        self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C')
    766766        self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3)
     767        # GPA has been properly calculated and is shown on the page
     768        self.browser.open(self.student_path + '/studycourse/100')
     769        self.assertTrue('3.00' in self.browser.contents)
     770        self.assertEqual(self.student['studycourse']['100'].gpa, 3.0)
    767771        # Carry-over courses will be collected when next level is created
    768772        self.browser.open(self.student_path + '/studycourse/manage')
Note: See TracChangeset for help on using the changeset viewer.