Ignore:
Timestamp:
20 Nov 2012, 06:17:36 (12 years ago)
Author:
Henrik Bettermann
Message:

Use new attrs_to_fields function to display gpa and total_credits on level pages.

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

    r9631 r9690  
    476476    additional_headers = ['level']
    477477
     478    @property
     479    def available_fields(self):
     480        fields = super(StudentStudyLevelProcessor, self).available_fields
     481        fields.remove('total_credits')
     482        fields.remove('gpa')
     483        return  fields
     484
    478485    def getParent(self, row, site):
    479486        student = self._getStudent(row, site)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9687 r9690  
    11071107    grok.template('studylevelmanagepage')
    11081108    form_fields = grok.AutoFields(IStudentStudyLevel).omit(
    1109         'validation_date', 'validated_by')
     1109        'validation_date', 'validated_by', 'total_credits', 'gpa')
    11101110    pnav = 4
    11111111    taboneactions = [_('Save'),_('Cancel')]
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/studylevelpage.pt

    r9687 r9690  
    1515      </tr>
    1616    </tal:block>
    17     <tr>
    18       <td i18n:translate="">
    19         Total Credits:
    20       </td>
    21       <td>
    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>
    31       </td>
    32     </tr>
    3317  </tbody>
    3418</table>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9687 r9690  
    480480    certcode = Attribute('The certificate code of the study course')
    481481    is_current_level = Attribute('Is this level the current level of the student?')
    482     total_credits = Attribute('Total of all ticket credits in this study level.')
    483     gpa = Attribute('Grade point average in this study level.')
    484482
    485483    level_session = schema.Choice(
     
    508506        )
    509507
     508    total_credits = schema.Int(
     509        title = _(u'Total Credits'),
     510        required = False,
     511        readonly = True,
     512        )
     513
     514    gpa = schema.Int(
     515        title = _(u'GPA'),
     516        required = False,
     517        readonly = True,
     518        )
     519
    510520    def addCourseTicket(ticket, course):
    511521        """Add a course ticket object.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r9687 r9690  
    8989                gpa += ticket.credits * ticket.weight
    9090        if credits_counted:
    91             gpa = float(gpa)/credits_counted
    92         return gpa
     91            gpa = 100*gpa/credits_counted
     92        return float(gpa)/100
    9393
    9494    @property
     
    138138        return
    139139
    140 StudentStudyLevel = attrs_to_fields(StudentStudyLevel)
     140StudentStudyLevel = attrs_to_fields(
     141    StudentStudyLevel, omit=['total_credits', 'gpa'])
    141142
    142143class StudentStudyLevelFactory(grok.GlobalUtility):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9687 r9690  
    767767        # GPA has been properly calculated and is shown on the page
    768768        self.browser.open(self.student_path + '/studycourse/100')
    769         self.assertTrue('3.00' in self.browser.contents)
     769        self.assertTrue('3.0' in self.browser.contents)
    770770        self.assertEqual(self.student['studycourse']['100'].gpa, 3.0)
    771771        # Carry-over courses will be collected when next level is created
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r9684 r9690  
    219219        self.assertEqual(
    220220            result,
    221             'level,level_session,level_verdict,validated_by,validation_date,'
     221            'gpa,level,level_session,level_verdict,total_credits,'
     222            'validated_by,validation_date,'
    222223            'student_id,number_of_tickets,certcode\r\n'
    223             ',,0,,,,0,\r\n'
     224            '0.0,,,0,0,,,,0,\r\n'
    224225            )
    225226        return
     
    236237        self.assertEqual(
    237238            result,
    238             'level,level_session,level_verdict,validated_by,validation_date,'
     239            'gpa,level,level_session,level_verdict,total_credits,'
     240            'validated_by,validation_date,'
    239241            'student_id,number_of_tickets,certcode\r\n'
    240             '100,2012,A,,,A111111,1,CERT1\r\n'
     242            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
    241243            )
    242244        return
     
    251253        self.assertEqual(
    252254            result,
    253             'level,level_session,level_verdict,validated_by,validation_date,'
     255            'gpa,level,level_session,level_verdict,total_credits,'
     256            'validated_by,validation_date,'
    254257            'student_id,number_of_tickets,certcode\r\n'
    255             '100,2012,A,,,A111111,1,CERT1\r\n'
     258            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
    256259            )
    257260        return
     
    265268        self.assertEqual(
    266269            result,
    267             'level,level_session,level_verdict,validated_by,validation_date,'
     270            'gpa,level,level_session,level_verdict,total_credits,'
     271            'validated_by,validation_date,'
    268272            'student_id,number_of_tickets,certcode\r\n'
    269             '100,2012,A,,,A111111,1,CERT1\r\n'
     273            '0.0,100,2012,A,100,,,A111111,1,CERT1\r\n'
    270274            )
    271275        return
Note: See TracChangeset for help on using the changeset viewer.