コード例 #1
0
    def test_single_completed_course(self):
        """Tests when a single completed course is present."""
        name = 'Test Assessments'

        # Register.
        user = actions.login('*****@*****.**')
        actions.register(self, name)

        response = self.get('/explorer')
        # Before a course is not completed,
        # explorer page should not show 'view score' button.
        actions.assert_does_not_contain('View score', response.body)

        # Assign a grade to the course enrolled to mark it complete.
        profile = PersonalProfile.get_by_key_name(user.user_id())
        info = {'final_grade': 'A'}
        course_info_dict = {'': info}
        profile.course_info = transforms.dumps(course_info_dict)
        profile.put()

        # Check if 'View score' text is visible on profile page.
        response = self.get('/explorer/profile')
        actions.assert_contains('View score', response.body)

        # Check if 'Go to course' button is not visible on explorer page.
        response = self.get('/explorer')
        actions.assert_does_not_contain('Go to course', response.body)

        # Check if 'View score' button is visible on explorer page.
        response = self.get('/explorer')
        actions.assert_contains('View score', response.body)
コード例 #2
0
    def test_not_enough_assignments_to_allocate(self):
        """Test for the case when there are too few assignments in the pool."""

        email = '*****@*****.**'
        name = 'Student 1'
        submission = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'S1-1', 'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'is-S1', 'correct': True},
        ])
        payload = {
            'answers': submission, 'assessment_type': LEGACY_REVIEW_UNIT_ID}

        actions.login(email)
        actions.register(self, name)
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, payload)

        # The student goes to the review dashboard and requests an assignment
        # to review -- but there is nothing to review.
        response = actions.request_new_review(
            self, LEGACY_REVIEW_UNIT_ID, expected_status_code=200)
        actions.assert_does_not_contain('Assignment to review', response.body)
        actions.assert_contains(
            'Sorry, there are no new submissions ', response.body)
        actions.assert_contains('disabled="true"', response.body)

        actions.logout()
コード例 #3
0
    def test_single_completed_course(self):
        """Tests when a single completed course is present."""
        name = 'Test Assessments'

        # Register.
        user = actions.login('*****@*****.**')
        actions.register(self, name)

        response = self.get('/explorer')
        # Before a course is not completed,
        # explorer page should not show 'view score' button.
        actions.assert_does_not_contain('View score', response.body)

        # Assign a grade to the course enrolled to mark it complete.
        profile = PersonalProfile.get_by_key_name(user.user_id())
        info = {'final_grade': 'A'}
        course_info_dict = {'': info}
        profile.course_info = transforms.dumps(course_info_dict)
        profile.put()

        # Check if 'View score' text is visible on profile page.
        response = self.get('/explorer/profile')
        actions.assert_contains('View score', response.body)

        # Check if 'Go to course' button is not visible on explorer page.
        response = self.get('/explorer')
        actions.assert_does_not_contain('Go to course', response.body)

        # Check if 'View score' button is visible on explorer page.
        response = self.get('/explorer')
        actions.assert_contains('View score', response.body)
コード例 #4
0
 def test_explore_sample_course(self):
     actions.login(ADMIN_EMAIL, is_admin=True)
     response = self.post(
         '/admin/welcome?action=explore_sample',
         params={'xsrf_token': crypto.XsrfTokenManager.create_xsrf_token(
             'explore_sample')})
     self.assertEqual(response.status_int, 302)
     assert_contains('/dashboard', response.headers['location'])
     response = self.get(response.headers['location'])
     assert_contains('Power Searching with Google', response.body)
     assert_does_not_contain('explore_sample', response.body)
コード例 #5
0
 def test_explore_sample_course(self):
     actions.login(ADMIN_EMAIL, is_admin=True)
     response = self.post(
         '/admin/welcome?action=explore_sample',
         params={
             'xsrf_token':
             crypto.XsrfTokenManager.create_xsrf_token('explore_sample')
         })
     self.assertEqual(response.status_int, 302)
     assert_contains('/dashboard', response.headers['location'])
     response = self.get(response.headers['location'])
     assert_contains('Power Searching with Google', response.body)
     assert_does_not_contain('explore_sample', response.body)
コード例 #6
0
 def test_create_new_course(self):
     actions.login(ADMIN_EMAIL, is_admin=True)
     response = self.post(
         '/admin/welcome?action=add_first_course',
         params={'xsrf_token': crypto.XsrfTokenManager.create_xsrf_token(
             'add_first_course')})
     self.assertEqual(response.status_int, 302)
     self.assertEqual(
         response.headers['location'],
         'http://localhost/first/dashboard')
     response = self.get('/first/dashboard')
     assert_contains('My First Course', response.body)
     response = self.get('/admin/welcome?action=welcome')
     assert_does_not_contain('Create Empty Course', response.body)
コード例 #7
0
 def test_create_new_course(self):
     actions.login(ADMIN_EMAIL, is_admin=True)
     response = self.post(
         '/admin/welcome?action=add_first_course',
         params={
             'xsrf_token':
             crypto.XsrfTokenManager.create_xsrf_token('add_first_course')
         })
     self.assertEqual(response.status_int, 302)
     self.assertEqual(response.headers['location'],
                      'http://localhost/first/dashboard')
     response = self.get('/first/dashboard')
     assert_contains('My First Course', response.body)
     response = self.get('/admin/welcome?action=welcome')
     assert_does_not_contain('Create Empty Course', response.body)
コード例 #8
0
    def test_add_reviewer(self):
        """Test that admin can add a reviewer, and cannot re-add reviewers."""

        email = '*****@*****.**'
        name = 'Test Add Reviewer'
        submission = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'First answer to Q1',
             'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'First answer to Q3',
             'correct': True},
        ])
        payload = {
            'answers': submission, 'assessment_type': LEGACY_REVIEW_UNIT_ID}

        actions.login(email)
        actions.register(self, name)
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, payload)

        # There is nothing to review on the review dashboard.
        response = actions.request_new_review(
            self, LEGACY_REVIEW_UNIT_ID, expected_status_code=200)
        actions.assert_does_not_contain('Assignment to review', response.body)
        actions.assert_contains(
            'Sorry, there are no new submissions ', response.body)
        actions.logout()

        # The admin assigns the student to review his own work.
        actions.login(email, is_admin=True)
        response = actions.add_reviewer(
            self, LEGACY_REVIEW_UNIT_ID, email, email)
        actions.assert_equals(response.status_int, 302)
        response = self.get(response.location)
        actions.assert_does_not_contain(
            'Error 412: The reviewer is already assigned', response.body)
        actions.assert_contains('First answer to Q1', response.body)
        actions.assert_contains(
            'Review 1 from [email protected]', response.body)

        # The admin repeats the 'add reviewer' action. This should fail.
        response = actions.add_reviewer(
            self, LEGACY_REVIEW_UNIT_ID, email, email)
        actions.assert_equals(response.status_int, 302)
        response = self.get(response.location)
        actions.assert_contains(
            'Error 412: The reviewer is already assigned', response.body)
コード例 #9
0
    def test_not_enough_assignments_to_allocate(self):
        """Test for the case when there are too few assignments in the pool."""

        email = '*****@*****.**'
        name = 'Student 1'
        submission = transforms.dumps([
            {
                'index': 0,
                'type': 'regex',
                'value': 'S1-1',
                'correct': True
            },
            {
                'index': 1,
                'type': 'choices',
                'value': 3,
                'correct': False
            },
            {
                'index': 2,
                'type': 'regex',
                'value': 'is-S1',
                'correct': True
            },
        ])
        payload = {
            'answers': submission,
            'assessment_type': LEGACY_REVIEW_UNIT_ID
        }

        actions.login(email)
        actions.register(self, name)
        response = actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID,
                                             payload)

        # The student goes to the review dashboard and requests an assignment
        # to review -- but there is nothing to review.
        response = actions.request_new_review(self,
                                              LEGACY_REVIEW_UNIT_ID,
                                              expected_status_code=200)
        actions.assert_does_not_contain('Assignment to review', response.body)
        actions.assert_contains('Sorry, there are no new submissions ',
                                response.body)
        actions.assert_contains('disabled="true"', response.body)

        actions.logout()
コード例 #10
0
    def test_single_uncompleted_course(self):
        """Tests for a single available course."""
        # This call should redirect to explorer page.
        response = self.get('/')
        actions.assert_contains('/explorer', response.location)

        name = 'Test student courses page'
        email = 'Student'

        actions.login(email)

        # Test the explorer page.
        response = self.get('/explorer')
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('Register', response.body)

        # Navbar should not contain profile tab.
        actions.assert_does_not_contain(
            '<a href="/explorer/profile">Profile</a>', response.body)

        # Test 'my courses' page when a student is not enrolled in any course.
        response = self.get('/explorer/courses')
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('You are not currently enrolled in any course',
                        response.body)

        # Test 'my courses' page when a student is enrolled in all courses.
        actions.register(self, name)
        response = self.get('/explorer/courses')
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('Go to course', response.body)
        actions.assert_does_not_contain(
            'You are not currently enrolled in any course', response.body)

        # After the student registers for a course,
        # profile tab should be visible in navbar.
        actions.assert_contains(
            '<a href="/explorer/profile">Profile</a>', response.body)

        # Test profile page.
        response = self.get('/explorer/profile')
        actions.assert_contains('<td>%s</td>' % email, response.body)
        actions.assert_contains('<td>%s</td>' % name, response.body)
        actions.assert_contains('Progress', response.body)
        actions.assert_does_not_contain('View score', response.body)
コード例 #11
0
    def test_single_uncompleted_course(self):
        """Tests for a single available course."""
        # This call should redirect to explorer page.
        response = self.get('/')
        actions.assert_contains('/explorer', response.location)

        name = 'Test student courses page'
        email = 'Student'

        actions.login(email)

        # Test the explorer page.
        response = self.get('/explorer')
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('Register', response.body)

        # Navbar should not contain profile tab.
        actions.assert_does_not_contain(
            '<a href="/explorer/profile">Profile</a>', response.body)

        # Test 'my courses' page when a student is not enrolled in any course.
        response = self.get('/explorer/courses')
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('You are not currently enrolled in any course',
                                response.body)

        # Test 'my courses' page when a student is enrolled in all courses.
        actions.register(self, name)
        response = self.get('/explorer/courses')
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('Go to course', response.body)
        actions.assert_does_not_contain(
            'You are not currently enrolled in any course', response.body)

        # After the student registers for a course,
        # profile tab should be visible in navbar.
        actions.assert_contains('<a href="/explorer/profile">Profile</a>',
                                response.body)

        # Test profile page.
        response = self.get('/explorer/profile')
        actions.assert_contains('<td>%s</td>' % email, response.body)
        actions.assert_contains('<td>%s</td>' % name, response.body)
        actions.assert_contains('Progress', response.body)
        actions.assert_does_not_contain('View score', response.body)
コード例 #12
0
    def test_student_access(self):
        # enable course explorer
        config.Registry.test_overrides[
            course_explorer.GCB_ENABLE_COURSE_EXPLORER_PAGE.name] = True
        self.assertTrue(course_explorer.GCB_ENABLE_COURSE_EXPLORER_PAGE.value)

        # check not being logged in
        response = self.get('/explorer')
        actions.assert_contains('Explore Courses', response.body)
        actions.assert_does_not_contain('My Courses', response.body)
        actions.assert_does_not_contain('Dashboard', response.body)

        # login and check logged in student perspective
        config.Registry.test_overrides[
            sites.GCB_COURSES_CONFIG.name] = 'course:/:/'

        email = 'student'
        actions.login(email)
        response = self.get('/explorer')
        actions.assert_contains('Explore Courses', response.body)
        actions.assert_contains('My Courses', response.body)
        actions.assert_does_not_contain('Dashboard', response.body)
コード例 #13
0
    def test_student_access(self):
        # enable course explorer
        config.Registry.test_overrides[
            course_explorer.GCB_ENABLE_COURSE_EXPLORER_PAGE.name] = True
        self.assertTrue(course_explorer.GCB_ENABLE_COURSE_EXPLORER_PAGE.value)

        # check not being logged in
        response = self.get('/explorer')
        actions.assert_contains('Explore Courses', response.body)
        actions.assert_does_not_contain('My Courses', response.body)
        actions.assert_does_not_contain('Dashboard', response.body)

        # login and check logged in student perspective
        config.Registry.test_overrides[
            sites.GCB_COURSES_CONFIG.name] = 'course:/:/'

        email = 'student'
        actions.login(email)
        response = self.get('/explorer')
        actions.assert_contains('Explore Courses', response.body)
        actions.assert_contains('My Courses', response.body)
        actions.assert_does_not_contain('Dashboard', response.body)
コード例 #14
0
    def test_submit_assignment(self):
        """Test submission of peer-reviewed assignments."""

        # Override course.yaml settings by patching app_context.
        get_environ_old = sites.ApplicationContext.get_environ

        def get_environ_new(self):
            environ = get_environ_old(self)
            environ['course']['browsable'] = False
            return environ

        sites.ApplicationContext.get_environ = get_environ_new

        email = '*****@*****.**'
        name = 'Test Peer Reviewed Assignment Submission'
        submission = transforms.dumps([
            {
                'index': 0,
                'type': 'regex',
                'value': 'First answer to Q1',
                'correct': True
            },
            {
                'index': 1,
                'type': 'choices',
                'value': 3,
                'correct': False
            },
            {
                'index': 2,
                'type': 'regex',
                'value': 'First answer to Q3',
                'correct': True
            },
        ])
        second_submission = transforms.dumps([
            {
                'index': 0,
                'type': 'regex',
                'value': 'Second answer to Q1',
                'correct': True
            },
            {
                'index': 1,
                'type': 'choices',
                'value': 3,
                'correct': False
            },
            {
                'index': 2,
                'type': 'regex',
                'value': 'Second answer to Q3',
                'correct': True
            },
        ])

        actions.login(email)
        actions.register(self, name)

        # Check that the sample peer-review assignment shows up in the course
        # page and that it can be visited.
        response = actions.view_course(self)
        actions.assert_contains('Sample peer review assignment', response.body)
        actions.assert_contains('Review peer assignments', response.body)
        actions.assert_contains(
            '<a href="assessment?name=%s">' % LEGACY_REVIEW_UNIT_ID,
            response.body)
        actions.assert_contains('Review peer assignments </p>',
                                response.body,
                                collapse_whitespace=True)
        actions.assert_does_not_contain('<a href="reviewdashboard',
                                        response.body,
                                        collapse_whitespace=True)

        # Check that the progress circle for this assignment is unfilled.
        actions.assert_contains(
            'progress-notstarted-%s' % LEGACY_REVIEW_UNIT_ID, response.body)
        actions.assert_does_not_contain(
            'progress-completed-%s' % LEGACY_REVIEW_UNIT_ID, response.body)

        # Try to access an invalid assignment.
        response = self.get('assessment?name=FakeAssessment',
                            expect_errors=True)
        actions.assert_equals(response.status_int, 404)

        # The student should not be able to see others' reviews because he/she
        # has not submitted an assignment yet.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_does_not_contain('Submitted assignment', response.body)
        actions.assert_contains('Due date for this assignment', response.body)
        actions.assert_does_not_contain('Reviews received', response.body)

        # The student should not be able to access the review dashboard because
        # he/she has not submitted the assignment yet.
        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID,
                            expect_errors=True)
        actions.assert_contains('You must submit the assignment for',
                                response.body)

        # The student submits the assignment.
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, {
                'answers': submission,
                'assessment_type': LEGACY_REVIEW_UNIT_ID
            })
        actions.assert_contains('Thank you for completing this assignment',
                                response.body)
        actions.assert_contains('Review peer assignments', response.body)

        # The student views the submitted assignment, which has become readonly.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('First answer to Q1', response.body)
        actions.assert_contains('Submitted assignment', response.body)

        # The student tries to re-submit the same assignment. This should fail.
        response = actions.submit_assessment(
            self,
            LEGACY_REVIEW_UNIT_ID, {
                'answers': second_submission,
                'assessment_type': LEGACY_REVIEW_UNIT_ID
            },
            presubmit_checks=False)
        actions.assert_contains('You have already submitted this assignment.',
                                response.body)
        actions.assert_contains('Review peer assignments', response.body)

        # The student views the submitted assignment. The new answers have not
        # been saved.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('First answer to Q1', response.body)
        actions.assert_does_not_contain('Second answer to Q1', response.body)

        # The student checks the course page and sees that the progress
        # circle for this assignment has been filled, and that the 'Review
        # peer assignments' link is now available.
        response = actions.view_course(self)
        actions.assert_contains(
            'progress-completed-%s' % LEGACY_REVIEW_UNIT_ID, response.body)
        actions.assert_does_not_contain(
            '<span> Review peer assignments </span>',
            response.body,
            collapse_whitespace=True)
        actions.assert_contains('<a href="reviewdashboard?unit=%s">' %
                                LEGACY_REVIEW_UNIT_ID,
                                response.body,
                                collapse_whitespace=True)

        # The student should also be able to now view the review dashboard.
        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('Assignments for your review', response.body)
        actions.assert_contains('Review a new assignment', response.body)

        actions.logout()

        # Clean up app_context.
        sites.ApplicationContext.get_environ = get_environ_old
コード例 #15
0
    def test_add_reviewer(self):
        """Test that admin can add a reviewer, and cannot re-add reviewers."""

        email = '*****@*****.**'
        name = 'Test Add Reviewer'
        submission = transforms.dumps([
            {
                'index': 0,
                'type': 'regex',
                'value': 'First answer to Q1',
                'correct': True
            },
            {
                'index': 1,
                'type': 'choices',
                'value': 3,
                'correct': False
            },
            {
                'index': 2,
                'type': 'regex',
                'value': 'First answer to Q3',
                'correct': True
            },
        ])
        payload = {
            'answers': submission,
            'assessment_type': LEGACY_REVIEW_UNIT_ID
        }

        actions.login(email)
        actions.register(self, name)
        response = actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID,
                                             payload)

        # There is nothing to review on the review dashboard.
        response = actions.request_new_review(self,
                                              LEGACY_REVIEW_UNIT_ID,
                                              expected_status_code=200)
        actions.assert_does_not_contain('Assignment to review', response.body)
        actions.assert_contains('Sorry, there are no new submissions ',
                                response.body)
        actions.logout()

        # The admin assigns the student to review his own work.
        actions.login(email, is_admin=True)
        response = actions.add_reviewer(self, LEGACY_REVIEW_UNIT_ID, email,
                                        email)
        actions.assert_equals(response.status_int, 302)
        response = self.get(response.location)
        actions.assert_does_not_contain(
            'Error 412: The reviewer is already assigned', response.body)
        actions.assert_contains('First answer to Q1', response.body)
        actions.assert_contains('Review 1 from [email protected]',
                                response.body)

        # The admin repeats the 'add reviewer' action. This should fail.
        response = actions.add_reviewer(self, LEGACY_REVIEW_UNIT_ID, email,
                                        email)
        actions.assert_equals(response.status_int, 302)
        response = self.get(response.location)
        actions.assert_contains('Error 412: The reviewer is already assigned',
                                response.body)
コード例 #16
0
    def test_draft_review_behaviour(self):
        """Test correctness of draft review visibility."""

        email1 = '*****@*****.**'
        name1 = 'Student 1'
        submission1 = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'S1-1', 'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'is-S1', 'correct': True},
        ])
        payload1 = {
            'answers': submission1, 'assessment_type': LEGACY_REVIEW_UNIT_ID}

        email2 = '*****@*****.**'
        name2 = 'Student 2'
        submission2 = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'S2-1', 'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'not-S1', 'correct': True},
        ])
        payload2 = {
            'answers': submission2, 'assessment_type': LEGACY_REVIEW_UNIT_ID}

        email3 = '*****@*****.**'
        name3 = 'Student 3'
        submission3 = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'S3-1', 'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'not-S1', 'correct': True},
        ])
        payload3 = {
            'answers': submission3, 'assessment_type': LEGACY_REVIEW_UNIT_ID}

        # Student 1 submits the assignment.
        actions.login(email1)
        actions.register(self, name1)
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, payload1)
        actions.logout()

        # Student 2 logs in and submits the assignment.
        actions.login(email2)
        actions.register(self, name2)
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, payload2)

        # Student 2 requests a review, and is given Student 1's assignment.
        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        review_step_key_2_for_1 = get_review_step_key(response)
        actions.assert_contains('S1-1', response.body)

        # Student 2 saves her review as a draft.
        review_2_for_1_payload = get_review_payload(
            'R2for1', is_draft=True)

        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1,
            review_2_for_1_payload)
        actions.assert_contains('Your review has been saved.', response.body)

        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('(Draft)', response.body)

        # Student 2's draft is still changeable.
        response = actions.view_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1)
        actions.assert_contains('Submit Review', response.body)
        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1,
            review_2_for_1_payload)
        actions.assert_contains('Your review has been saved.', response.body)

        # Student 2 logs out.
        actions.logout()

        # Student 3 submits the assignment.
        actions.login(email3)
        actions.register(self, name3)
        response = actions.submit_assessment(
            self, LEGACY_REVIEW_UNIT_ID, payload3)
        actions.logout()

        # Student 1 logs in and requests two assignments to review.
        actions.login(email1)
        response = self.get('/reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)

        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('Assignment to review', response.body)
        actions.assert_contains('not-S1', response.body)

        review_step_key_1_for_someone = get_review_step_key(response)

        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('Assignment to review', response.body)
        actions.assert_contains('not-S1', response.body)

        review_step_key_1_for_someone_else = get_review_step_key(response)

        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('disabled="true"', response.body)

        # Student 1 submits both reviews, fulfilling his quota.
        review_1_for_other_payload = get_review_payload('R1for')

        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone,
            review_1_for_other_payload)
        actions.assert_contains(
            'Your review has been submitted successfully', response.body)

        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone_else,
            review_1_for_other_payload)
        actions.assert_contains(
            'Your review has been submitted successfully', response.body)

        response = self.get('/reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('(Completed)', response.body)
        actions.assert_does_not_contain('(Draft)', response.body)

        # Although Student 1 has submitted 2 reviews, he cannot view Student
        # 2's review because it is still in Draft status.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains(
            'You have not received any peer reviews yet.', response.body)
        actions.assert_does_not_contain('R2for1', response.body)

        # Student 1 logs out.
        actions.logout()

        # Student 2 submits her review for Student 1's assignment.
        actions.login(email2)

        response = self.get('review?unit=%s&key=%s' % (
            LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1))
        actions.assert_does_not_contain('Submitted review', response.body)

        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1,
            get_review_payload('R2for1'))
        actions.assert_contains(
            'Your review has been submitted successfully', response.body)

        # Her review is now read-only.
        response = self.get('review?unit=%s&key=%s' % (
            LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1))
        actions.assert_contains('Submitted review', response.body)
        actions.assert_contains('R2for1', response.body)

        # Student 2 logs out.
        actions.logout()

        # Now Student 1 can see the review he has received from Student 2.
        actions.login(email1)
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('R2for1', response.body)
コード例 #17
0
    def test_draft_review_behaviour(self):
        """Test correctness of draft review visibility."""

        email1 = '*****@*****.**'
        name1 = 'Student 1'
        submission1 = transforms.dumps([
            {
                'index': 0,
                'type': 'regex',
                'value': 'S1-1',
                'correct': True
            },
            {
                'index': 1,
                'type': 'choices',
                'value': 3,
                'correct': False
            },
            {
                'index': 2,
                'type': 'regex',
                'value': 'is-S1',
                'correct': True
            },
        ])
        payload1 = {
            'answers': submission1,
            'assessment_type': LEGACY_REVIEW_UNIT_ID
        }

        email2 = '*****@*****.**'
        name2 = 'Student 2'
        submission2 = transforms.dumps([
            {
                'index': 0,
                'type': 'regex',
                'value': 'S2-1',
                'correct': True
            },
            {
                'index': 1,
                'type': 'choices',
                'value': 3,
                'correct': False
            },
            {
                'index': 2,
                'type': 'regex',
                'value': 'not-S1',
                'correct': True
            },
        ])
        payload2 = {
            'answers': submission2,
            'assessment_type': LEGACY_REVIEW_UNIT_ID
        }

        email3 = '*****@*****.**'
        name3 = 'Student 3'
        submission3 = transforms.dumps([
            {
                'index': 0,
                'type': 'regex',
                'value': 'S3-1',
                'correct': True
            },
            {
                'index': 1,
                'type': 'choices',
                'value': 3,
                'correct': False
            },
            {
                'index': 2,
                'type': 'regex',
                'value': 'not-S1',
                'correct': True
            },
        ])
        payload3 = {
            'answers': submission3,
            'assessment_type': LEGACY_REVIEW_UNIT_ID
        }

        # Student 1 submits the assignment.
        actions.login(email1)
        actions.register(self, name1)
        response = actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID,
                                             payload1)
        actions.logout()

        # Student 2 logs in and submits the assignment.
        actions.login(email2)
        actions.register(self, name2)
        response = actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID,
                                             payload2)

        # Student 2 requests a review, and is given Student 1's assignment.
        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        review_step_key_2_for_1 = get_review_step_key(response)
        actions.assert_contains('S1-1', response.body)

        # Student 2 saves her review as a draft.
        review_2_for_1_payload = get_review_payload('R2for1', is_draft=True)

        response = actions.submit_review(self, LEGACY_REVIEW_UNIT_ID,
                                         review_step_key_2_for_1,
                                         review_2_for_1_payload)
        actions.assert_contains('Your review has been saved.', response.body)

        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('(Draft)', response.body)

        # Student 2's draft is still changeable.
        response = actions.view_review(self, LEGACY_REVIEW_UNIT_ID,
                                       review_step_key_2_for_1)
        actions.assert_contains('Submit Review', response.body)
        response = actions.submit_review(self, LEGACY_REVIEW_UNIT_ID,
                                         review_step_key_2_for_1,
                                         review_2_for_1_payload)
        actions.assert_contains('Your review has been saved.', response.body)

        # Student 2 logs out.
        actions.logout()

        # Student 3 submits the assignment.
        actions.login(email3)
        actions.register(self, name3)
        response = actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID,
                                             payload3)
        actions.logout()

        # Student 1 logs in and requests two assignments to review.
        actions.login(email1)
        response = self.get('/reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)

        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('Assignment to review', response.body)
        actions.assert_contains('not-S1', response.body)

        review_step_key_1_for_someone = get_review_step_key(response)

        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('Assignment to review', response.body)
        actions.assert_contains('not-S1', response.body)

        review_step_key_1_for_someone_else = get_review_step_key(response)

        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('disabled="true"', response.body)

        # Student 1 submits both reviews, fulfilling his quota.
        review_1_for_other_payload = get_review_payload('R1for')

        response = actions.submit_review(self, LEGACY_REVIEW_UNIT_ID,
                                         review_step_key_1_for_someone,
                                         review_1_for_other_payload)
        actions.assert_contains('Your review has been submitted successfully',
                                response.body)

        response = actions.submit_review(self, LEGACY_REVIEW_UNIT_ID,
                                         review_step_key_1_for_someone_else,
                                         review_1_for_other_payload)
        actions.assert_contains('Your review has been submitted successfully',
                                response.body)

        response = self.get('/reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('(Completed)', response.body)
        actions.assert_does_not_contain('(Draft)', response.body)

        # Although Student 1 has submitted 2 reviews, he cannot view Student
        # 2's review because it is still in Draft status.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('You have not received any peer reviews yet.',
                                response.body)
        actions.assert_does_not_contain('R2for1', response.body)

        # Student 1 logs out.
        actions.logout()

        # Student 2 submits her review for Student 1's assignment.
        actions.login(email2)

        response = self.get('review?unit=%s&key=%s' %
                            (LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1))
        actions.assert_does_not_contain('Submitted review', response.body)

        response = actions.submit_review(self, LEGACY_REVIEW_UNIT_ID,
                                         review_step_key_2_for_1,
                                         get_review_payload('R2for1'))
        actions.assert_contains('Your review has been submitted successfully',
                                response.body)

        # Her review is now read-only.
        response = self.get('review?unit=%s&key=%s' %
                            (LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1))
        actions.assert_contains('Submitted review', response.body)
        actions.assert_contains('R2for1', response.body)

        # Student 2 logs out.
        actions.logout()

        # Now Student 1 can see the review he has received from Student 2.
        actions.login(email1)
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_equals(response.status_int, 200)
        actions.assert_contains('R2for1', response.body)
コード例 #18
0
    def test_submit_assignment(self):
        """Test submission of peer-reviewed assignments."""

        # Override course.yaml settings by patching app_context.
        get_environ_old = sites.ApplicationContext.get_environ

        def get_environ_new(self):
            environ = get_environ_old(self)
            environ['course']['browsable'] = False
            return environ

        sites.ApplicationContext.get_environ = get_environ_new

        email = '*****@*****.**'
        name = 'Test Peer Reviewed Assignment Submission'
        submission = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'First answer to Q1',
             'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'First answer to Q3',
             'correct': True},
        ])
        second_submission = transforms.dumps([
            {'index': 0, 'type': 'regex', 'value': 'Second answer to Q1',
             'correct': True},
            {'index': 1, 'type': 'choices', 'value': 3, 'correct': False},
            {'index': 2, 'type': 'regex', 'value': 'Second answer to Q3',
             'correct': True},
        ])

        actions.login(email)
        actions.register(self, name)

        # Check that the sample peer-review assignment shows up in the course
        # page and that it can be visited.
        response = actions.view_course(self)
        actions.assert_contains('Sample peer review assignment', response.body)
        actions.assert_contains('Review peer assignments', response.body)
        actions.assert_contains(
            '<a href="assessment?name=%s">' % LEGACY_REVIEW_UNIT_ID,
            response.body)
        actions.assert_contains('Review peer assignments </p>', response.body,
                        collapse_whitespace=True)
        actions.assert_does_not_contain(
            '<a href="reviewdashboard', response.body, collapse_whitespace=True)

        # Check that the progress circle for this assignment is unfilled.
        actions.assert_contains(
            'progress-notstarted-%s' % LEGACY_REVIEW_UNIT_ID, response.body)
        actions.assert_does_not_contain(
            'progress-completed-%s' % LEGACY_REVIEW_UNIT_ID, response.body)

        # Try to access an invalid assignment.
        response = self.get(
            'assessment?name=FakeAssessment', expect_errors=True)
        actions.assert_equals(response.status_int, 404)

        # The student should not be able to see others' reviews because he/she
        # has not submitted an assignment yet.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_does_not_contain('Submitted assignment', response.body)
        actions.assert_contains('Due date for this assignment', response.body)
        actions.assert_does_not_contain('Reviews received', response.body)

        # The student should not be able to access the review dashboard because
        # he/she has not submitted the assignment yet.
        response = self.get(
            'reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID,
            expect_errors=True)
        actions.assert_contains(
            'You must submit the assignment for', response.body)

        # The student submits the assignment.
        response = actions.submit_assessment(
            self,
            LEGACY_REVIEW_UNIT_ID,
            {'answers': submission, 'assessment_type': LEGACY_REVIEW_UNIT_ID}
        )
        actions.assert_contains(
            'Thank you for completing this assignment', response.body)
        actions.assert_contains('Review peer assignments', response.body)

        # The student views the submitted assignment, which has become readonly.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('First answer to Q1', response.body)
        actions.assert_contains('Submitted assignment', response.body)

        # The student tries to re-submit the same assignment. This should fail.
        response = actions.submit_assessment(
            self,
            LEGACY_REVIEW_UNIT_ID,
            {'answers': second_submission,
             'assessment_type': LEGACY_REVIEW_UNIT_ID},
            presubmit_checks=False
        )
        actions.assert_contains(
            'You have already submitted this assignment.', response.body)
        actions.assert_contains('Review peer assignments', response.body)

        # The student views the submitted assignment. The new answers have not
        # been saved.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('First answer to Q1', response.body)
        actions.assert_does_not_contain('Second answer to Q1', response.body)

        # The student checks the course page and sees that the progress
        # circle for this assignment has been filled, and that the 'Review
        # peer assignments' link is now available.
        response = actions.view_course(self)
        actions.assert_contains(
            'progress-completed-%s' % LEGACY_REVIEW_UNIT_ID, response.body)
        actions.assert_does_not_contain(
            '<span> Review peer assignments </span>', response.body,
            collapse_whitespace=True)
        actions.assert_contains(
            '<a href="reviewdashboard?unit=%s">' % LEGACY_REVIEW_UNIT_ID,
            response.body, collapse_whitespace=True)

        # The student should also be able to now view the review dashboard.
        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        actions.assert_contains('Assignments for your review', response.body)
        actions.assert_contains('Review a new assignment', response.body)

        actions.logout()

        # Clean up app_context.
        sites.ApplicationContext.get_environ = get_environ_old