Ignore:
Timestamp:
4 Feb 2020, 18:33:48 (5 years ago)
Author:
Henrik Bettermann
Message:

When adding course tickets, check if course has already been
passed at previous level.

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

Legend:

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

    r15972 r15986  
    155155        view.flash(warning, type="warning")
    156156        return False
     157    warning = students_utils.warnCourseAlreadyPassed(view.context, course)
     158    if warning:
     159        view.flash(warning, type="warning")
     160        return False
    157161    try:
    158162        view.context.addCourseTicket(ticket, course)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r15972 r15986  
    28342834        return
    28352835
     2836    def test_student_course_already_passed(self):
     2837        IWorkflowState(self.student).setState('school fee paid')
     2838        self.student['studycourse'].current_level = 100
     2839        self.browser.open(self.login_path)
     2840        self.browser.getControl(name="form.login").value = self.student_id
     2841        self.browser.getControl(name="form.password").value = 'spwd'
     2842        self.browser.getControl("Login").click()
     2843        # Now students can add the current study level
     2844        self.browser.getLink("Study Course").click()
     2845        self.browser.getLink("Add course list").click()
     2846        self.assertMatches('...Add current level 100 (Year 1)...',
     2847                           self.browser.contents)
     2848        self.browser.getControl("Create course list now").click()
     2849        # A level with one course ticket was created
     2850        self.assertEqual(self.student['studycourse']['100'].number_of_tickets, 1)
     2851        # We set the score above the passmark
     2852        self.student['studycourse']['100'][
     2853            'COURSE1'].score = self.student['studycourse']['100'][
     2854                'COURSE1'].passmark + 1
     2855        # We add a second level
     2856        self.student['studycourse'].current_level = 200
     2857        self.browser.getLink("Study Course").click()
     2858        self.browser.getLink("Add course list").click()
     2859        self.assertMatches('...Add current level 200 (Year 2)...',
     2860                           self.browser.contents)
     2861        self.browser.getControl("Create course list now").click()
     2862        self.browser.getLink("200").click()
     2863        self.browser.getLink("Edit course list").click()
     2864        self.browser.getLink("here").click()
     2865        self.browser.getControl(name="form.course").value = ['COURSE1']
     2866        self.browser.getControl("Add course ticket").click()
     2867        self.assertTrue(
     2868            'Course has already been passed at previous level'
     2869            in self.browser.contents)
     2870        self.assertEqual(self.student['studycourse']['200'].number_of_tickets, 0)
     2871        # We set the score below the passmark
     2872        self.student['studycourse']['100'][
     2873            'COURSE1'].score = self.student['studycourse']['100'][
     2874                'COURSE1'].passmark - 1
     2875        self.browser.getControl("Add course ticket").click()
     2876        self.assertTrue(
     2877            'Successfully added COURSE1' in self.browser.contents)
     2878        self.assertEqual(self.student['studycourse']['200'].number_of_tickets, 1)
     2879        return
     2880
    28362881    def test_student_course_registration_outstanding(self):
    28372882        self.course = createObject('waeup.Course')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r15984 r15986  
    732732        return
    733733
     734    def warnCourseAlreadyPassed(self, studylevel, course):
     735        """Return message if course has already been passed at
     736        previous levels.
     737        """
     738        for slevel in studylevel.__parent__.values():
     739            for cticket in slevel.values():
     740                if cticket.code == course.code \
     741                    and cticket.total_score >= cticket.passmark:
     742                    return _('Course has already been passed at previous level.')
     743        return False
     744
    734745    def getBedCoordinates(self, bedticket):
    735746        """Return descriptive bed coordinates.
Note: See TracChangeset for help on using the changeset viewer.