Changeset 7625 for main


Ignore:
Timestamp:
10 Feb 2012, 20:05:55 (13 years ago)
Author:
Henrik Bettermann
Message:

It's quite tedious to setup the correct StudyLevelSource?. Now we have 2 probation levels and 3 spill-over levels. Pre-studies level (=10) can't be repeated.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_vocabularies.py

    r7616 r7625  
    3636        values = studylevelsource.getValues(studycourse)
    3737        self.assertEqual(values, [100, 110, 120, 200, 210, 220, 300, 310, 320,
    38             400, 410, 420, 500, 510, 520, 600, 610])
    39         self.assertTrue(studylevelsource.getTitle(studycourse, 0),
     38            400, 410, 420, 500, 510, 520, 600, 610, 620])
     39        self.assertEqual(studylevelsource.getTitle(studycourse, None),
     40            'Error: level id None out of range')
     41        self.assertEqual(studylevelsource.getTitle(studycourse, 0),
    4042            'Error: level id 0 out of range')
    41         self.assertTrue(studylevelsource.getTitle(studycourse, 10),
     43        self.assertEqual(studylevelsource.getTitle(studycourse, 10),
    4244            'Error: level id 10 out of range')
    43         self.assertTrue(studylevelsource.getTitle(studycourse, 100),
     45        self.assertEqual(studylevelsource.getTitle(studycourse, 100),
    4446            '100 (Year 1)')
    45         self.assertTrue(studylevelsource.getTitle(studycourse, 110),
    46             '100 (Year 1) on 1. probation')
    47         self.assertTrue(studylevelsource.getTitle(studycourse, 120),
    48             '100 (Year 1) on 2. probation')
    49         self.assertTrue(studylevelsource.getTitle(studycourse, 500),
     47        self.assertEqual(studylevelsource.getTitle(studycourse, 110),
     48            '100 (Year 1) on 1st probation')
     49        self.assertEqual(studylevelsource.getTitle(studycourse, 120),
     50            '100 (Year 1) on 2nd probation')
     51        self.assertEqual(studylevelsource.getTitle(studycourse, 500),
    5052            '500 (Year 5)')
    51         self.assertTrue(studylevelsource.getTitle(studycourse, 600),
    52             '500 (Year 5) spillover')
    53         self.assertTrue(studylevelsource.getTitle(studycourse, 610),
     53        self.assertEqual(studylevelsource.getTitle(studycourse, 600),
     54            '500 (Year 5) 1st spillover')
     55        self.assertEqual(studylevelsource.getTitle(studycourse, 610),
    5456            '500 (Year 5) 2nd spillover')
    55         self.assertTrue(studylevelsource.getTitle(studycourse, 620),
    56             'Error: level id 620 out of range')
    57         self.assertTrue(studylevelsource.getTitle(studycourse, 900),
    58             'Error: level id 900 out of range')
    59         # Now we change the certificates start_level in order to include
    60         # pre-studies
     57        self.assertEqual(studylevelsource.getTitle(studycourse, 620),
     58            '500 (Year 5) 3rd spillover')
     59        self.assertEqual(studylevelsource.getTitle(studycourse, 630),
     60            'Error: level id 630 out of range')
     61        self.assertEqual(studylevelsource.getTitle(studycourse, 700),
     62            'Error: level id 700 out of range')
     63        # Now we change the certificates start_level to pre-studies
    6164        studycourse.certificate.start_level = 10
    62         self.assertTrue(studylevelsource.getTitle(studycourse, 10),
     65        self.assertEqual(studylevelsource.getTitle(studycourse, 10),
    6366            'Pre-Studies')
     67        # Repeating Pre-Studies level does not exist
     68        self.assertRaises(KeyError,studylevelsource.getTitle,studycourse,20)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/vocabularies.py

    r7620 r7625  
    4040        start_level = int(studycourse.certificate.start_level)
    4141        end_level = int(studycourse.certificate.end_level)
     42        if start_level == 10:
     43            levels = [10,] + [level for level in range(100,end_level+200,10)
     44                if level % 100 < 30]
     45        else:
     46            levels = [level for level in range(start_level,end_level+200,10)
     47                if level % 100 < 30]
    4248    else:
    43         start_level = 10
    44         end_level = 800
    45     levels = [level for level in range(start_level,end_level+200,10)
    46                if level % 100 < 30 and level < end_level + 120]
     49        # default level range
     50        levels = [level for level in range(100,800,10) if level % 100 < 30]
    4751    return levels
    4852
     
    6670            end_level = int(context.certificate.end_level)
    6771        else:
    68             start_level = 10
    69             end_level = 800
    70         if value < start_level or value > end_level + 110:
     72            # default level range
     73            start_level = 100
     74            end_level = 600
     75        if value < start_level or value > end_level + 120:
    7176            return "Error: level id %s out of range" % value
     77        # Special treatment for pre-studies level
    7278        if value == 10:
    7379            return course_levels.by_value[value].title
     
    7682        repeat = repeat//10
    7783        title = course_levels.by_value[level].title
    78         if level > end_level and repeat:
     84        if level > end_level and repeat == 1:
    7985            title = course_levels.by_value[level - 100].title
    8086            return "%s 2nd spillover" % title
     87        if level > end_level and repeat == 2:
     88            title = course_levels.by_value[level - 100].title
     89            return "%s 3rd spillover" % title
    8190        if level > end_level:
    8291            title = course_levels.by_value[level - 100].title
    83             return  "%s spillover" % title
    84         if repeat:
    85             return "%s on %d. probation" % (title, repeat)
     92            return  "%s 1st spillover" % title
     93        if repeat == 1:
     94            return "%s on 1st probation" % title
     95        if repeat == 2:
     96            return "%s on 2nd probation" % title
    8697        return title
    8798
Note: See TracChangeset for help on using the changeset viewer.