Ignore:
Timestamp:
8 Mar 2016, 17:21:35 (9 years ago)
Author:
Henrik Bettermann
Message:

Customize ICourseTicket. Add field 'ca'.

Customize EditScoresPage?, CourseTicketManageFormPage?, CourseTicketDisplayFormPage? and editscorespage.pt accordingly.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r13755 r13770  
    2222import grok
    2323from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
     24from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2425from datetime import datetime, timedelta, date
    2526from mechanize import LinkNotFoundError
     
    3334from waeup.kofa.students.accommodation import BedTicket
    3435from waeup.kofa.testing import FunctionalTestCase
     36from waeup.kofa.authentication import LocalRoleSetEvent
    3537from waeup.kofa.browser.tests.test_pdf import samples_dir
    3638from waeup.aaue.testing import FunctionalLayer
     
    634636            in self.browser.contents)
    635637        return
     638
     639    def test_handle_courses_by_lecturer(self):
     640        self.app['users'].addUser('mrslecturer', 'mrslecturersecret')
     641        self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng'
     642        self.app['users']['mrslecturer'].title = u'Mercedes Benz'
     643        # Add course ticket
     644        studylevel = createObject(u'waeup.StudentStudyLevel')
     645        studylevel.level = 100
     646        studylevel.level_session = 2004
     647        self.student['studycourse'].addStudentStudyLevel(
     648            self.certificate, studylevel)
     649        # Assign local Lecturer role for a certificate.
     650        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
     651        prmlocal = IPrincipalRoleManager(course)
     652        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
     653        notify(LocalRoleSetEvent(
     654            course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
     655        # Login as lecturer.
     656        self.browser.open(self.login_path)
     657        self.browser.getControl(name="form.login").value = 'mrslecturer'
     658        self.browser.getControl(name="form.password").value = 'mrslecturersecret'
     659        self.browser.getControl("Login").click()
     660        self.browser.getLink("My Roles").click()
     661        self.browser.getLink(
     662            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1").click()
     663        # Course results can be batch edited via the edit_courses view.
     664        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
     665        self.app['configuration'].current_academic_session = 2004
     666        IWorkflowState(self.student).setState('courses validated')
     667        self.browser.open(
     668            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
     669        self.assertTrue(
     670            'input type="text" name="scores"'
     671            in self.browser.contents)
     672        self.browser.getControl(name="scores", index=0).value = '55'
     673        self.browser.getControl(name="cas", index=0).value = '66'
     674        self.browser.getControl("Update scores").click()
     675        # New score and ca has been set.
     676        self.assertEqual(
     677            self.student['studycourse']['100']['COURSE1'].score, 55)
     678        self.assertEqual(
     679            self.student['studycourse']['100']['COURSE1'].ca, 66)
     680        # Score editing has been logged.
     681        logfile = os.path.join(
     682            self.app['datacenter'].storage, 'logs', 'students.log')
     683        logcontent = open(logfile).read()
     684        self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - '
     685                        'E1000000 100/COURSE1 score updated (55)' in logcontent)
     686        self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - '
     687                        'E1000000 100/COURSE1 ca updated (66)' in logcontent)
     688        # Non-integer scores won't be accepted.
     689        self.browser.open(
     690            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
     691        self.assertTrue('value="55" />' in self.browser.contents)
     692        self.browser.getControl(name="scores", index=0).value = 'abc'
     693        self.browser.getControl("Update scores").click()
     694        self.assertTrue('Error: Score(s) and CA(s) of Anna Tester have not be updated.'
     695            in self.browser.contents)
     696        # Scores can be removed.
     697        self.browser.open(
     698            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
     699        self.browser.getControl(name="scores", index=0).value = ''
     700        self.browser.getControl("Update scores").click()
     701        self.assertEqual(
     702            self.student['studycourse']['100']['COURSE1'].score, None)
     703        logcontent = open(logfile).read()
     704        self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - '
     705                        'E1000000 100/COURSE1 score updated (None)' in logcontent)
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py

    r13715 r13770  
    162162        self.assertEqual(
    163163            result,
    164             'automatic,carry_over,code,credits,dcode,fcode,level,level_session,'
     164            'automatic,ca,carry_over,code,credits,dcode,fcode,level,level_session,'
    165165            'mandatory,passmark,score,semester,title,student_id,certcode,'
    166166            'display_fullname,matric_number\r\n'
    167             '1,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'
     167            '1,,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'
    168168            'Anna M. Tester,234\r\n'
    169169            )
Note: See TracChangeset for help on using the changeset viewer.