Changeset 9684 for main


Ignore:
Timestamp:
19 Nov 2012, 11:16:54 (12 years ago)
Author:
Henrik Bettermann
Message:

Calculate grade and weight from score and show on courseticketpage only if score attribute is set.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
1 added
5 edited

Legend:

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

    r9683 r9684  
    12861286    grok.require('waeup.viewStudent')
    12871287    form_fields = grok.AutoFields(ICourseTicket)
     1288    grok.template('courseticketpage')
    12881289    pnav = 4
    12891290
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9563 r9684  
    522522    code = Attribute('code of the original course')
    523523    certcode = Attribute('certificate code of the study course')
     524    grade = Attribute('grade calculated from score')
     525    weight = Attribute('weight calculated from score')
    524526
    525527    title = schema.TextLine(
     
    562564    score = schema.Int(
    563565        title = _(u'Score'),
    564         default = 0,
     566        default = None,
    565567        required = False,
    566568        )
     
    578580        )
    579581
    580 
    581582    def getLevel():
    582583        """Returns the id of the level the ticket has been added to.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r9532 r9684  
    2929from waeup.kofa.students.vocabularies import StudyLevelSource
    3030
     31def getGradeWeightFromScore(score):
     32    if score is None:
     33        return (None, None)
     34    if score >= 70:
     35        return ('A',5)
     36    if score >= 60:
     37        return ('B',4)
     38    if score >= 50:
     39        return ('C',3)
     40    if score >= 45:
     41        return ('D',2)
     42    if score >= 40:
     43        return ('E',1)
     44    return ('F',0)
     45
    3146class StudentStudyLevel(grok.Container):
    3247    """This is a container for course tickets.
     
    183198            return None
    184199
     200    @property
     201    def grade(self):
     202        """Returns the grade calculated from score.
     203        """
     204        return getGradeWeightFromScore(self.score)[0]
     205
     206    @property
     207    def weight(self):
     208        """Returns the weight calculated from score.
     209        """
     210        return getGradeWeightFromScore(self.score)[1]
    185211
    186212CourseTicket = attrs_to_fields(CourseTicket)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9641 r9684  
    752752        self.browser.getLink("COURSE1").click()
    753753        self.browser.getLink("Manage").click()
    754         self.browser.getControl(name="form.score").value = '10'
     754        #self.browser.getControl(name="form.score").value = '10'
    755755        self.browser.getControl("Save").click()
    756756        self.assertTrue('Form has been saved' in self.browser.contents)
     757        # Grade and weight have been determined
     758        self.browser.open(self.studycourse_path + '/100/COURSE1')
     759        self.assertFalse('Grade' in self.browser.contents)
     760        self.assertFalse('Weight' in self.browser.contents)
     761        self.student['studycourse']['100']['COURSE1'].score = 55
     762        self.browser.open(self.studycourse_path + '/100/COURSE1')
     763        self.assertTrue('Grade' in self.browser.contents)
     764        self.assertTrue('Weight' in self.browser.contents)
     765        self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C')
     766        self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3)
    757767        # Carry-over courses will be collected when next level is created
    758768        self.browser.open(self.student_path + '/studycourse/manage')
    759769        # Add next level
     770        self.student['studycourse']['100']['COURSE1'].score = 10
    760771        self.browser.getControl(name="addlevel").value = ['200']
    761772        self.browser.getControl(name="level_session").value = ['2005']
     
    764775        self.assertMatches(
    765776            '...: Study Level 200 (Year 2)...', self.browser.contents)
    766         # COURSE1 has score 0 and thus will become a carry-over course
     777        # If COURSE1 has score 10 it becomes a carry-over course
    767778        # in level 200
    768779        self.assertEqual(
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r9574 r9684  
    303303            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
    304304            'passmark,score,semester,title,student_id,certcode\r\n'
    305             '0,0,,,,,,0,,0,,,,\r\n'
     305            '0,0,,,,,,0,,,,,,\r\n'
    306306            )
    307307        return
     
    321321            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
    322322            'passmark,score,semester,title,student_id,certcode\r\n'
    323             '1,1,CRS1,100,DEP1,FAC1,100,0,100,0,2,Course 1,A111111,CERT1\r\n'
     323            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
    324324            )
    325325        return
     
    336336            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
    337337            'passmark,score,semester,title,student_id,certcode\r\n'
    338             '1,1,CRS1,100,DEP1,FAC1,100,0,100,0,2,Course 1,A111111,CERT1\r\n'
     338            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
    339339            )
    340340        return
     
    350350            'automatic,carry_over,code,credits,dcode,fcode,level,mandatory,'
    351351            'passmark,score,semester,title,student_id,certcode\r\n'
    352             '1,1,CRS1,100,DEP1,FAC1,100,0,100,0,2,Course 1,A111111,CERT1\r\n'
     352            '1,1,CRS1,100,DEP1,FAC1,100,0,100,,2,Course 1,A111111,CERT1\r\n'
    353353            )
    354354        return
Note: See TracChangeset for help on using the changeset viewer.