Ejemplo n.º 1
0
    def setUp(self):
        super(PeerReviewDashboardStudentTest, self).setUp()
        self.base = '/' + self.COURSE_NAME
        context = actions.simple_add_course(self.COURSE_NAME, '*****@*****.**',
                                            'Peer Back Button Child')
        self.course = courses.Course(None, context)

        self.assessment = self.course.add_assessment()
        self.assessment.title = 'Assessment'
        self.assessment.html_content = 'assessment content'
        self.assessment.workflow_yaml = (
            '{grader: human,'
            'matcher: peer,'
            'review_due_date: \'2034-07-01 12:00\','
            'review_min_count: 1,'
            'review_window_mins: 20,'
            'submission_due_date: \'2034-07-01 12:00\'}')
        self.assessment.now_available = True

        self.course.save()
        actions.login(self.STUDENT_EMAIL)
        actions.register(self, self.STUDENT_EMAIL)
        config.Registry.test_overrides[
            utils.CAN_PERSIST_ACTIVITY_EVENTS.name] = True

        actions.submit_assessment(
            self,
            self.assessment.unit_id, {
                'answers': '',
                'score': 0,
                'assessment_type': self.assessment.unit_id
            },
            presubmit_checks=False)
Ejemplo n.º 2
0
    def test_peer_graded(self):
        assessment = self.course.add_assessment()
        assessment.title = 'Assessment'
        assessment.html_content = 'assessment content'
        assessment.workflow_yaml = (
            '{grader: human,'
            'matcher: peer,'
            'review_due_date: \'2034-07-01 12:00\','
            'review_min_count: 1,'
            'review_window_mins: 20,'
            'submission_due_date: \'2034-07-01 12:00\'}')
        assessment.now_available = True
        self.course.save()

        self.certificate_criteria.append({'assessment_id': assessment.unit_id})

        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)

        actions.submit_assessment(self,
                                  assessment.unit_id, {
                                      'answers': '',
                                      'assessment_type': assessment.unit_id
                                  },
                                  presubmit_checks=False)

        # Submitting assessment without doing required reviews is not enough
        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)

        # Submitting assessment together with required reviews is enough
        self._submit_review(assessment)

        response = self.get('certificate')
        self.assertEquals(200, response.status_code)
    def setUp(self):
        super(PeerReviewDashboardStudentTest, self).setUp()
        self.base = '/' + self.COURSE_NAME
        context = actions.simple_add_course(
            self.COURSE_NAME, '*****@*****.**', 'Peer Back Button Child')
        self.course = courses.Course(None, context)

        self.assessment = self.course.add_assessment()
        self.assessment.title = 'Assessment'
        self.assessment.html_content = 'assessment content'
        self.assessment.workflow_yaml = (
            '{grader: human,'
            'matcher: peer,'
            'review_due_date: \'2034-07-01 12:00\','
            'review_min_count: 1,'
            'review_window_mins: 20,'
            'submission_due_date: \'2034-07-01 12:00\'}')
        self.assessment.now_available = True

        self.course.save()
        actions.login(self.STUDENT_EMAIL)
        actions.register(self, self.STUDENT_EMAIL)

        actions.submit_assessment(
            self,
            self.assessment.unit_id,
            {'answers': '', 'score': 0,
             'assessment_type': self.assessment.unit_id},
            presubmit_checks=False
        )
Ejemplo n.º 4
0
    def test_combination(self):
        # Add machine graded assessment
        machine_graded = self.course.add_assessment()
        machine_graded.title = 'Machine Graded'
        machine_graded.html_content = 'assessment content'
        machine_graded.now_available = True
        # Add peer graded assessment
        peer_graded = self.course.add_assessment()
        peer_graded.title = 'Peer Graded'
        peer_graded.html_content = 'assessment content'
        peer_graded.workflow_yaml = (
            '{grader: human,'
            'matcher: peer,'
            'review_due_date: \'2034-07-01 12:00\','
            'review_min_count: 1,'
            'review_window_mins: 20,'
            'submission_due_date: \'2034-07-01 12:00\'}')
        peer_graded.now_available = True
        self.course.save()

        self.certificate_criteria.extend([{
            'assessment_id': machine_graded.unit_id,
            'pass_percent': 30
        }, {
            'assessment_id': peer_graded.unit_id
        }])

        # Confirm that meeting one criterion is not sufficient
        actions.submit_assessment(self,
                                  machine_graded.unit_id, {
                                      'answers': '',
                                      'score': 40,
                                      'assessment_type': machine_graded.unit_id
                                  },
                                  presubmit_checks=False)

        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)

        # Confirm that meeting both criteria is sufficient
        actions.submit_assessment(self,
                                  peer_graded.unit_id, {
                                      'answers': '',
                                      'assessment_type': peer_graded.unit_id
                                  },
                                  presubmit_checks=False)

        self._submit_review(peer_graded)

        response = self.get('certificate')
        self.assertEquals(200, response.status_code)
    def test_combination(self):
        # Add machine graded assessment
        machine_graded = self.course.add_assessment()
        machine_graded.title = 'Machine Graded'
        machine_graded.html_content = 'assessment content'
        machine_graded.now_available = True
        # Add peer graded assessment
        peer_graded = self.course.add_assessment()
        peer_graded.title = 'Peer Graded'
        peer_graded.html_content = 'assessment content'
        peer_graded.workflow_yaml = (
            '{grader: human,'
            'matcher: peer,'
            'review_due_date: \'2034-07-01 12:00\','
            'review_min_count: 1,'
            'review_window_mins: 20,'
            'submission_due_date: \'2034-07-01 12:00\'}')
        peer_graded.now_available = True
        self.course.save()

        self.certificate_criteria.extend([
            {'assessment_id': machine_graded.unit_id, 'pass_percent': 30},
            {'assessment_id': peer_graded.unit_id}])

        # Confirm that meeting one criterion is not sufficient
        actions.submit_assessment(
            self,
            machine_graded.unit_id,
            {'answers': '', 'score': 40,
             'assessment_type': machine_graded.unit_id},
            presubmit_checks=False
        )

        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)

        # Confirm that meeting both criteria is sufficient
        actions.submit_assessment(
            self,
            peer_graded.unit_id,
            {'answers': '', 'assessment_type': peer_graded.unit_id},
            presubmit_checks=False
        )

        self._submit_review(peer_graded)

        response = self.get('certificate')
        self.assertEquals(200, response.status_code)
    def test_student_cannot_see_reviews_prematurely(self):
        """Test that students cannot see others' reviews prematurely."""

        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)

        # Student 1 cannot see the reviews for his assignment yet, because he
        # has not submitted the two required reviews.
        response = self.get("assessment?name=%s" % LEGACY_REVIEW_UNIT_ID)
        assert_equals(response.status_int, 200)
        assert_contains("Due date for this assignment", response.body)
        assert_contains("After you have completed the required number of peer reviews", response.body)

        actions.logout()
    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)
        assert_does_not_contain('Assignment to review', response.body)
        assert_contains('Sorry, there are no new submissions ', response.body)
        assert_contains('disabled="true"', response.body)

        actions.logout()
    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)
        assert_does_not_contain("Assignment to review", response.body)
        assert_contains("Sorry, there are no new submissions ", response.body)
        assert_contains('disabled="true"', response.body)

        actions.logout()
    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)
        assert_does_not_contain('Assignment to review', response.body)
        assert_contains('Sorry, there are no new submissions ', response.body)
        assert_contains('disabled="true"', response.body)

        actions.logout()
    def test_student_cannot_see_reviews_prematurely(self):
        """Test that students cannot see others' reviews prematurely."""

        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)

        # Student 1 cannot see the reviews for his assignment yet, because he
        # has not submitted the two required reviews.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        assert_equals(response.status_int, 200)
        assert_contains('Due date for this assignment', response.body)
        assert_contains(
            'After you have completed the required number of peer reviews',
            response.body)

        actions.logout()
    def test_student_cannot_see_reviews_prematurely(self):
        """Test that students cannot see others' reviews prematurely."""

        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)

        # Student 1 cannot see the reviews for his assignment yet, because he
        # has not submitted the two required reviews.
        response = self.get('assessment?name=%s' % LEGACY_REVIEW_UNIT_ID)
        assert_equals(response.status_int, 200)
        assert_contains('Due date for this assignment', response.body)
        assert_contains(
            'After you have completed the required number of peer reviews',
            response.body)

        actions.logout()
Ejemplo n.º 12
0
    def test_machine_graded(self):
        assessment = self.course.add_assessment()
        assessment.title = 'Assessment'
        assessment.html_content = 'assessment content'
        assessment.now_available = True
        self.course.save()

        self.certificate_criteria.append({
            'assessment_id': assessment.unit_id,
            'pass_percent': 70.0
        })

        # Student has not yet completed assessment, expect redirect to home page
        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)
        self._run_analytic_and_expect(1, 0, 0)  # 1 student, 0 active, no cert.

        # Submit assessment with low score
        actions.submit_assessment(self,
                                  assessment.unit_id, {
                                      'answers': '',
                                      'score': 50.0,
                                      'assessment_type': assessment.unit_id
                                  },
                                  presubmit_checks=False)

        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)
        self._run_analytic_and_expect(1, 1, 0)  # 1 student, 1 active, no cert

        # Submit assessment with expected score
        actions.submit_assessment(self,
                                  assessment.unit_id, {
                                      'answers': '',
                                      'score': 70,
                                      'assessment_type': assessment.unit_id
                                  },
                                  presubmit_checks=False)

        response = self.get('certificate')
        self.assertEquals(200, response.status_code)
        self._run_analytic_and_expect(1, 1, 1)  # 1 student, 1 active, 1 cert
    def test_handling_of_fake_review_step_key(self):
        """Test that bad keys result in the appropriate responses."""

        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)
        actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID, payload)

        actions.view_review(self, LEGACY_REVIEW_UNIT_ID, "Fake key", expected_status_code=404)

        actions.logout()
    def test_machine_graded(self):
        assessment = self.course.add_assessment()
        assessment.title = 'Assessment'
        assessment.html_content = 'assessment content'
        assessment.now_available = True
        self.course.save()

        self.certificate_criteria.append(
            {'assessment_id': assessment.unit_id, 'pass_percent': 70.0})

        # Student has not yet completed assessment, expect redirect to home page
        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)
        self._run_analytic_and_expect(1, 0, 0)  # 1 student, 0 active, no cert.

        # Submit assessment with low score
        actions.submit_assessment(
            self,
            assessment.unit_id,
            {'answers': '', 'score': 50.0,
             'assessment_type': assessment.unit_id},
            presubmit_checks=False
        )

        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)
        self._run_analytic_and_expect(1, 1, 0)  # 1 student, 1 active, no cert

        # Submit assessment with expected score
        actions.submit_assessment(
            self,
            assessment.unit_id,
            {'answers': '', 'score': 70,
             'assessment_type': assessment.unit_id},
            presubmit_checks=False
        )

        response = self.get('certificate')
        self.assertEquals(200, response.status_code)
        self._run_analytic_and_expect(1, 1, 1)  # 1 student, 1 active, 1 cert
Ejemplo n.º 15
0
    def test_handling_of_fake_review_step_key(self):
        """Test that bad keys result in the appropriate responses."""

        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)
        actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID, payload)

        actions.view_review(self,
                            LEGACY_REVIEW_UNIT_ID,
                            'Fake key',
                            expected_status_code=404)

        actions.logout()
    def test_handling_of_fake_review_step_key(self):
        """Test that bad keys result in the appropriate responses."""

        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)
        actions.submit_assessment(self, LEGACY_REVIEW_UNIT_ID, payload)

        actions.view_review(
            self, LEGACY_REVIEW_UNIT_ID, 'Fake key',
            expected_status_code=404)

        actions.logout()
    def test_peer_graded(self):
        assessment = self.course.add_assessment()
        assessment.title = 'Assessment'
        assessment.html_content = 'assessment content'
        assessment.workflow_yaml = (
            '{grader: human,'
            'matcher: peer,'
            'review_due_date: \'2034-07-01 12:00\','
            'review_min_count: 1,'
            'review_window_mins: 20,'
            'submission_due_date: \'2034-07-01 12:00\'}')
        assessment.now_available = True
        self.course.save()

        self.certificate_criteria.append(
            {'assessment_id': assessment.unit_id})

        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)

        actions.submit_assessment(
            self,
            assessment.unit_id,
            {'answers': '', 'assessment_type': assessment.unit_id},
            presubmit_checks=False
        )

        # Submitting assessment without doing required reviews is not enough
        response = self.get('certificate')
        self._assert_redirect_to_course_landing_page(response)

        # Submitting assessment together with required reviews is enough
        self._submit_review(assessment)

        response = self.get('certificate')
        self.assertEquals(200, response.status_code)
    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)
        assert_does_not_contain('Assignment to review', response.body)
        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)
        assert_equals(response.status_int, 302)
        response = self.get(response.location)
        assert_does_not_contain(
            'Error 412: The reviewer is already assigned', response.body)
        assert_contains('First answer to Q1', response.body)
        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)
        assert_equals(response.status_int, 302)
        response = self.get(response.location)
        assert_contains(
            'Error 412: The reviewer is already assigned', response.body)
    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)
        assert_does_not_contain('Assignment to review', response.body)
        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)
        assert_equals(response.status_int, 302)
        response = self.get(response.location)
        assert_does_not_contain(
            'Error 412: The reviewer is already assigned', response.body)
        assert_contains('First answer to Q1', response.body)
        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)
        assert_equals(response.status_int, 302)
        response = self.get(response.location)
        assert_contains(
            'Error 412: The reviewer is already assigned', response.body)
    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)
        assert_does_not_contain("Assignment to review", response.body)
        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)
        assert_equals(response.status_int, 302)
        response = self.get(response.location)
        assert_does_not_contain("Error 412: The reviewer is already assigned", response.body)
        assert_contains("First answer to Q1", response.body)
        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)
        assert_equals(response.status_int, 302)
        response = self.get(response.location)
        assert_contains("Error 412: The reviewer is already assigned", response.body)
Ejemplo n.º 21
0
    def test_peer_review_analytics(self):
        """Test analytics page on course dashboard."""

        student1 = '*****@*****.**'
        name1 = 'Test Student 1'
        student2 = '*****@*****.**'
        name2 = 'Test Student 2'

        peer = {'assessment_type': 'ReviewAssessmentExample'}

        # Student 1 submits a peer review assessment.
        actions.login(student1)
        actions.register(self, name1)
        actions.submit_assessment(self, 'ReviewAssessmentExample', peer)
        actions.logout()

        # Student 2 submits the same peer review assessment.
        actions.login(student2)
        actions.register(self, name2)
        actions.submit_assessment(self, 'ReviewAssessmentExample', peer)
        actions.logout()

        email = '*****@*****.**'

        # The admin looks at the analytics page on the dashboard.
        actions.login(email, is_admin=True)
        response = self.get('dashboard?action=analytics')
        assert_contains(
            'Google &gt;<a href="%s"> Dashboard </a>&gt; Analytics' %
                self.canonicalize('dashboard'),
            response.body)
        assert_contains('have not been calculated yet', response.body)

        compute_form = response.forms['gcb-compute-student-stats']
        response = self.submit(compute_form)
        assert_equals(response.status_int, 302)
        assert len(self.taskq.GetTasks('default')) == 5

        response = self.get('dashboard?action=analytics')
        assert_contains('is running', response.body)

        self.execute_all_deferred_tasks()

        response = self.get('dashboard?action=analytics')
        assert_contains('were last updated at', response.body)
        assert_contains('currently enrolled: 2', response.body)
        assert_contains('total: 2', response.body)

        assert_contains('Peer Review Statistics', response.body)
        assert_contains('Sample peer review assignment', response.body)
        # JSON code for the completion statistics.
        assert_contains('"[{\\"stats\\": [2]', response.body)
        actions.logout()

        # Student2 requests a review.
        actions.login(student2)
        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        review_step_key_2_for_1 = get_review_step_key(response)
        assert_contains('Assignment to review', response.body)

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

        actions.login(email, is_admin=True)
        response = self.get('dashboard?action=analytics')
        assert_contains(
            'Google &gt;<a href="%s"> Dashboard </a>&gt; Analytics' %
                self.canonicalize('dashboard'),
            response.body)

        compute_form = response.forms['gcb-compute-student-stats']
        response = self.submit(compute_form)
        self.execute_all_deferred_tasks()

        response = self.get('dashboard?action=analytics')
        assert_contains('Peer Review Statistics', response.body)
        # JSON code for the completion statistics.
        assert_contains('"[{\\"stats\\": [1, 1]', response.body)
        actions.logout()
Ejemplo n.º 22
0
    def test_independence_of_draft_reviews(self):
        """Test that draft reviews do not interfere with each other."""

        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)
        actions.logout()

        # Student 3 logs in and 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)
        assert_equals(response.status_int, 200)
        assert_contains('Assignment to review', response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains('Assignment to review', response.body)
        assert_contains('not-S1', response.body)

        review_step_key_1_for_someone_else = get_review_step_key(response)

        self.assertNotEqual(review_step_key_1_for_someone,
                            review_step_key_1_for_someone_else)

        # Student 1 submits two draft reviews.
        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone,
            get_review_payload('R1forFirst', is_draft=True))
        assert_contains('Your review has been saved.', response.body)

        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone_else,
            get_review_payload('R1forSecond', is_draft=True))
        assert_contains('Your review has been saved.', response.body)

        # The two draft reviews should still be different when subsequently
        # accessed.
        response = self.get(
            'review?unit=%s&key=%s' %
            (LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone))
        assert_contains('R1forFirst', response.body)

        response = self.get(
            'review?unit=%s&key=%s' %
            (LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone_else))
        assert_contains('R1forSecond', response.body)

        # Student 1 logs out.
        actions.logout()
Ejemplo n.º 23
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
            },
        ])

        # Check that the sample peer-review assignment shows up in the preview
        # page.
        response = actions.view_preview(self)
        assert_contains('Sample peer review assignment', response.body)
        assert_does_not_contain('Review peer assignments', response.body)

        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)
        assert_contains('Sample peer review assignment', response.body)
        assert_contains('Review peer assignments', response.body)
        assert_contains(
            '<a href="assessment?name=%s">' % LEGACY_REVIEW_UNIT_ID,
            response.body)
        assert_contains('<span> Review peer assignments </span>',
                        response.body,
                        collapse_whitespace=True)
        assert_does_not_contain('<a href="reviewdashboard',
                                response.body,
                                collapse_whitespace=True)

        # Check that the progress circle for this assignment is unfilled.
        assert_contains('progress-notstarted-%s' % LEGACY_REVIEW_UNIT_ID,
                        response.body)
        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)
        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)
        assert_does_not_contain('Submitted assignment', response.body)
        assert_contains('Due date for this assignment', response.body)
        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)
        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
            })
        assert_contains('Thank you for completing this assignment',
                        response.body)
        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)
        assert_contains('First answer to Q1', response.body)
        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)
        assert_contains('You have already submitted this assignment.',
                        response.body)
        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)
        assert_contains('First answer to Q1', response.body)
        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)
        assert_contains('progress-completed-%s' % LEGACY_REVIEW_UNIT_ID,
                        response.body)
        assert_does_not_contain('<span> Review peer assignments </span>',
                                response.body,
                                collapse_whitespace=True)
        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)
        assert_contains('Assignments for your review', response.body)
        assert_contains('Review a new assignment', response.body)

        actions.logout()

        # Clean up app_context.
        sites.ApplicationContext.get_environ = get_environ_old
    def test_independence_of_draft_reviews(self):
        """Test that draft reviews do not interfere with each other."""

        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)
        actions.logout()

        # Student 3 logs in and 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)
        assert_equals(response.status_int, 200)
        assert_contains('Assignment to review', response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains('Assignment to review', response.body)
        assert_contains('not-S1', response.body)

        review_step_key_1_for_someone_else = get_review_step_key(response)

        self.assertNotEqual(
            review_step_key_1_for_someone, review_step_key_1_for_someone_else)

        # Student 1 submits two draft reviews.
        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone,
            get_review_payload('R1forFirst', is_draft=True))
        assert_contains('Your review has been saved.', response.body)

        response = actions.submit_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone_else,
            get_review_payload('R1forSecond', is_draft=True))
        assert_contains('Your review has been saved.', response.body)

        # The two draft reviews should still be different when subsequently
        # accessed.
        response = self.get('review?unit=%s&key=%s' % (
            LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone))
        assert_contains('R1forFirst', response.body)

        response = self.get('review?unit=%s&key=%s' % (
            LEGACY_REVIEW_UNIT_ID, review_step_key_1_for_someone_else))
        assert_contains('R1forSecond', response.body)

        # Student 1 logs out.
        actions.logout()
Ejemplo n.º 25
0
    def test_peer_review_analytics(self):
        """Test analytics page on course dashboard."""

        student1 = '*****@*****.**'
        name1 = 'Test Student 1'
        student2 = '*****@*****.**'
        name2 = 'Test Student 2'

        peer = {'assessment_type': 'ReviewAssessmentExample'}

        # Student 1 submits a peer review assessment.
        actions.login(student1)
        actions.register(self, name1)
        actions.submit_assessment(self, 'ReviewAssessmentExample', peer)
        actions.logout()

        # Student 2 submits the same peer review assessment.
        actions.login(student2)
        actions.register(self, name2)
        actions.submit_assessment(self, 'ReviewAssessmentExample', peer)
        actions.logout()

        email = '*****@*****.**'

        # The admin looks at the analytics page on the dashboard.
        actions.login(email, is_admin=True)
        response = self.get('dashboard?action=analytics&tab=peer_review')
        assert_contains(
            'Google &gt; Dashboard &gt; Analytics &gt; Peer Review',
            response.body)
        assert_contains('have not been calculated yet', response.body)

        response = response.forms['gcb-generate-analytics-data'].submit(
        ).follow()
        assert len(self.taskq.GetTasks('default')) == 1

        assert_contains('is running', response.body)

        self.execute_all_deferred_tasks()

        response = self.get(response.request.url)
        assert_contains('were last updated at', response.body)
        assert_contains('Peer Review', response.body)
        assert_contains('Sample peer review assignment', response.body)
        # JSON code for the completion statistics.
        assert_contains('"[{\\"stats\\": [2]', response.body)
        actions.logout()

        # Student2 requests a review.
        actions.login(student2)
        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        review_step_key_2_for_1 = get_review_step_key(response)
        assert_contains('Assignment to review', response.body)

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

        actions.login(email, is_admin=True)
        response = self.get('dashboard?action=analytics&tab=peer_review')
        assert_contains(
            'Google &gt; Dashboard &gt; Analytics &gt; Peer Review',
            response.body)

        response = response.forms['gcb-generate-analytics-data'].submit(
        ).follow()
        self.execute_all_deferred_tasks()

        response = self.get(response.request.url)
        assert_contains('Peer Review', response.body)
        # JSON code for the completion statistics.
        assert_contains('"[{\\"stats\\": [1, 1]', response.body)
        actions.logout()
    def test_reviewer_cannot_impersonate_another_reviewer(self):
        """Test that one reviewer cannot use another's review step key."""

        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)
        assert_contains('S1-1', response.body)
        actions.logout()

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

        # Student 3 tries to view Student 1's assignment using Student 2's
        # review step key, but is not allowed to.
        response = actions.view_review(
            self, LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1,
            expected_status_code=404)

        # Student 3 logs out.
        actions.logout()
    def test_peer_review_analytics(self):
        """Test analytics page on course dashboard."""

        student1 = '*****@*****.**'
        name1 = 'Test Student 1'
        student2 = '*****@*****.**'
        name2 = 'Test Student 2'

        peer = {'assessment_type': 'ReviewAssessmentExample'}

        # Student 1 submits a peer review assessment.
        actions.login(student1)
        actions.register(self, name1)
        actions.submit_assessment(self, 'ReviewAssessmentExample', peer)
        actions.logout()

        # Student 2 submits the same peer review assessment.
        actions.login(student2)
        actions.register(self, name2)
        actions.submit_assessment(self, 'ReviewAssessmentExample', peer)
        actions.logout()

        email = '*****@*****.**'

        # The admin looks at the analytics page on the dashboard.
        actions.login(email, is_admin=True)
        response = self.get('dashboard?action=analytics&tab=peer_review')
        assert_contains(
            'Google &gt; Dashboard &gt; Analytics &gt; Peer Review',
            response.body)
        assert_contains('have not been calculated yet', response.body)

        response = response.forms[
            'gcb-generate-analytics-data'].submit().follow()
        assert len(self.taskq.GetTasks('default')) == 1

        assert_contains('is running', response.body)

        self.execute_all_deferred_tasks()

        response = self.get(response.request.url)
        assert_contains('were last updated at', response.body)
        assert_contains('Peer Review', response.body)
        assert_contains('Sample peer review assignment', response.body)
        # JSON code for the completion statistics.
        assert_contains('"[{\\"stats\\": [2]', response.body)
        actions.logout()

        # Student2 requests a review.
        actions.login(student2)
        response = actions.request_new_review(self, LEGACY_REVIEW_UNIT_ID)
        review_step_key_2_for_1 = get_review_step_key(response)
        assert_contains('Assignment to review', response.body)

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

        actions.login(email, is_admin=True)
        response = self.get('dashboard?action=analytics&tab=peer_review')
        assert_contains(
            'Google &gt; Dashboard &gt; Analytics &gt; Peer Review',
            response.body)

        response = response.forms[
            'gcb-generate-analytics-data'].submit().follow()
        self.execute_all_deferred_tasks()

        response = self.get(response.request.url)
        assert_contains('Peer Review', response.body)
        # JSON code for the completion statistics.
        assert_contains('"[{\\"stats\\": [1, 1]', response.body)
        actions.logout()
    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)
        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)
        assert_contains('Your review has been saved.', response.body)

        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        assert_equals(response.status_int, 200)
        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)
        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)
        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)
        assert_contains('Assignment to review', response.body)
        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)
        assert_contains('Assignment to review', response.body)
        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)
        assert_equals(response.status_int, 200)
        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)
        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)
        assert_contains(
            'Your review has been submitted successfully', response.body)

        response = self.get('/reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        assert_contains('(Completed)', response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains(
            'You have not received any peer reviews yet.', response.body)
        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))
        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'))
        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))
        assert_contains('Submitted review', response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains('R2for1', response.body)
    def test_reviewer_cannot_impersonate_another_reviewer(self):
        """Test that one reviewer cannot use another's review step key."""

        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)
        assert_contains("S1-1", response.body)
        actions.logout()

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

        # Student 3 tries to view Student 1's assignment using Student 2's
        # review step key, but is not allowed to.
        response = actions.view_review(self, LEGACY_REVIEW_UNIT_ID, review_step_key_2_for_1, expected_status_code=404)

        # Student 3 logs out.
        actions.logout()
    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},
        ])

        # Check that the sample peer-review assignment shows up in the preview
        # page.
        response = actions.view_preview(self)
        assert_contains('Sample peer review assignment', response.body)
        assert_does_not_contain('Review peer assignments', response.body)

        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)
        assert_contains('Sample peer review assignment', response.body)
        assert_contains('Review peer assignments', response.body)
        assert_contains(
            '<a href="assessment?name=%s">' % LEGACY_REVIEW_UNIT_ID,
            response.body)
        assert_contains('<span> Review peer assignments </span>', response.body,
                        collapse_whitespace=True)
        assert_does_not_contain('<a href="reviewdashboard', response.body,
                                collapse_whitespace=True)

        # Check that the progress circle for this assignment is unfilled.
        assert_contains(
            'progress-notstarted-%s' % LEGACY_REVIEW_UNIT_ID, response.body)
        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)
        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)
        assert_does_not_contain('Submitted assignment', response.body)
        assert_contains('Due date for this assignment', response.body)
        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)
        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}
        )
        assert_contains(
            'Thank you for completing this assignment', response.body)
        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)
        assert_contains('First answer to Q1', response.body)
        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
        )
        assert_contains(
            'You have already submitted this assignment.', response.body)
        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)
        assert_contains('First answer to Q1', response.body)
        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)
        assert_contains(
            'progress-completed-%s' % LEGACY_REVIEW_UNIT_ID, response.body)
        assert_does_not_contain(
            '<span> Review peer assignments </span>', response.body,
            collapse_whitespace=True)
        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)
        assert_contains('Assignments for your review', response.body)
        assert_contains('Review a new assignment', response.body)

        actions.logout()

        # Clean up app_context.
        sites.ApplicationContext.get_environ = get_environ_old
Ejemplo n.º 31
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)
        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)
        assert_contains('Your review has been saved.', response.body)

        response = self.get('reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        assert_equals(response.status_int, 200)
        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)
        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)
        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)
        assert_contains('Assignment to review', response.body)
        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)
        assert_contains('Assignment to review', response.body)
        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)
        assert_equals(response.status_int, 200)
        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)
        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)
        assert_contains('Your review has been submitted successfully',
                        response.body)

        response = self.get('/reviewdashboard?unit=%s' % LEGACY_REVIEW_UNIT_ID)
        assert_contains('(Completed)', response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains('You have not received any peer reviews yet.',
                        response.body)
        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))
        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'))
        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))
        assert_contains('Submitted review', response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains('R2for1', response.body)
Ejemplo n.º 32
0
    def test_reviewer_cannot_impersonate_another_reviewer(self):
        """Test that one reviewer cannot use another's review step key."""

        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)
        assert_contains('S1-1', response.body)
        actions.logout()

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

        # Student 3 tries to view Student 1's assignment using Student 2's
        # review step key, but is not allowed to.
        response = actions.view_review(self,
                                       LEGACY_REVIEW_UNIT_ID,
                                       review_step_key_2_for_1,
                                       expected_status_code=404)

        # Student 3 logs out.
        actions.logout()
    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)
        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)
        assert_contains("Your review has been saved.", response.body)

        response = self.get("reviewdashboard?unit=%s" % LEGACY_REVIEW_UNIT_ID)
        assert_equals(response.status_int, 200)
        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)
        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)
        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)
        assert_contains("Assignment to review", response.body)
        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)
        assert_contains("Assignment to review", response.body)
        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)
        assert_equals(response.status_int, 200)
        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
        )
        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
        )
        assert_contains("Your review has been submitted successfully", response.body)

        response = self.get("/reviewdashboard?unit=%s" % LEGACY_REVIEW_UNIT_ID)
        assert_contains("(Completed)", response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains("You have not received any peer reviews yet.", response.body)
        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))
        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")
        )
        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))
        assert_contains("Submitted review", response.body)
        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)
        assert_equals(response.status_int, 200)
        assert_contains("R2for1", response.body)