Changeset 7661


Ignore:
Timestamp:
17 Feb 2012, 07:43:22 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement carry-over course collection. Collect carry-over courses in base levels (not in repeating levels).

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

Legend:

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

    r7641 r7661  
    378378        )
    379379
     380    carry_over = schema.Bool(
     381        title = u'Carry-over Course',
     382        default = False,
     383        required = False,
     384        readonly = False,
     385        )
     386
    380387    def getLevel():
    381388        """Returns the id of the level the ticket has been added to.
  • main/waeup.sirp/trunk/src/waeup/sirp/students/studycourse.py

    r7536 r7661  
    5959                ticket.core_or_elective = val.core_or_elective
    6060                ticket.title = val.course.title
    61                 ticket.faculty = val.course.__parent__.__parent__.__parent__.title
    62                 ticket.department = val.course.__parent__.__parent__.title
    6361                ticket.fcode = val.course.__parent__.__parent__.__parent__.code
    6462                ticket.dcode = val.course.__parent__.__parent__.code
     
    6664                ticket.passmark = val.course.passmark
    6765                ticket.semester = val.course.semester
    68                 self[str(studylevel.level)][val.getCourseCode()] = ticket
     66                self[str(studylevel.level)][ticket.code] = ticket
     67        # Collect carry-over courses in base levels (not in repeating levels)
     68        if studylevel.level % 100 == 0:
     69            levels = sorted(self.keys())
     70            index = levels.index(str(studylevel.level))
     71            if  index > 0:
     72                previous_level = self[levels[index-1]]
     73                for key, val in previous_level.items():
     74                    if val.score < val.passmark:
     75                        if key in self[str(studylevel.level)]:
     76                            # Carry-over ticket exists
     77                            continue
     78                        co_ticket = CourseTicket()
     79                        for name in ['code', 'title', 'credits', 'passmark',
     80                                     'semester', 'core_or_elective',
     81                                     'fcode', 'dcode']:
     82                            setattr(co_ticket, name, getattr(val, name))
     83                        co_ticket.automatic = True
     84                        co_ticket.carry_over = True
     85                        self[str(studylevel.level)][co_ticket.code] = co_ticket
    6986        return
    7087
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7650 r7661  
    640640        self.browser.getControl(name="addlevel").value = ['100']
    641641        self.browser.getControl("Add study level").click()
    642         self.browser.getControl(name="addlevel").value = ['100']
    643642
    644643        # Managers can view and manage course lists
     
    669668        self.browser.getControl("Save").click()
    670669        self.assertTrue('Form has been saved' in self.browser.contents)
     670        # Carry-over courses will be collected when next level is created
     671        self.browser.open(self.student_path + '/studycourse/manage')
     672        # Add next level
     673        self.browser.getControl(name="addlevel").value = ['200']
     674        self.browser.getControl("Add study level").click()
     675        self.browser.getLink("200").click()
     676        self.assertMatches(
     677            '...: Study Level 200 (Year 2)...', self.browser.contents)
     678        # COURSE1 has score 0 and thus will become a carry-over course
     679        # in level 200
     680        self.assertEqual(
     681            sorted(self.student['studycourse']['200'].keys()), [u'COURSE1'])
     682        self.assertTrue(
     683            self.student['studycourse']['200']['COURSE1'].carry_over)
    671684        return
    672685
     
    11741187        self.browser.getControl(name="form.course").value = ['COURSE1']
    11751188        self.browser.getControl("Add course ticket").click()
    1176         self.assertMatches('...Successfully added COURSE1...',
    1177                            self.browser.contents)
     1189        self.assertMatches('...The ticket exists...',
     1190                           self.browser.contents)
     1191        # Indeed the ticket exists as carry-over course from level 100
     1192        # since its score was 0
     1193        self.assertTrue(
     1194            self.student['studycourse']['200']['COURSE1'].carry_over is True)
    11781195        # Students can open the pdf course registration slip
    11791196        self.browser.open(self.student_path + '/studycourse/200')
     
    11851202        self.browser.getControl("Remove selected", index=0).click()
    11861203        self.assertTrue('No ticket selected' in self.browser.contents)
     1204        # No ticket can be selected since the carry-over course is a core course
     1205        self.assertRaises(
     1206            LookupError, self.browser.getControl, name='val_id')
     1207        self.student['studycourse']['200']['COURSE1'].core_or_elective = False
     1208        self.browser.open(self.student_path + '/studycourse/200/edit')
     1209        # Now the student can remove the ticket
    11871210        ctrl = self.browser.getControl(name='val_id')
    11881211        ctrl.getControl(value='COURSE1').selected = True
Note: See TracChangeset for help on using the changeset viewer.