コード例 #1
0
    def test_get_staff_grading_data(self):
        # pylint: disable=no-member
        """
        Test fetch grading data for staff members.
        """
        block = self.make_one()
        barney = self.make_student(
            block, "barney",
            filename="foo.txt",
            score=10,
            annotated_filename="foo_corrected.txt",
            comment="Good work!")
        fred = self.make_student(
            block, "fred",
            filename="bar.txt")
        data = block.get_staff_grading_data(None).json_body  # lint-amnesty, pylint: disable=redefined-outer-name
        assignments = sorted(data['assignments'], key=lambda x: x['username'])

        barney_assignment, fred_assignment = assignments

        assert barney_assignment['module_id'] == barney['module'].id
        assert barney_assignment['username'] == 'barney'
        assert barney_assignment['fullname'] == 'barney'
        assert barney_assignment['filename'] == 'foo.txt'
        assert barney_assignment['score'] == 10
        assert barney_assignment['annotated'] == 'foo_corrected.txt'
        assert barney_assignment['comment'] == 'Good work!'
        assert barney_assignment['approved'] is True
        assert barney_assignment['finalized'] is True
        assert barney_assignment['may_grade'] is False
        assert barney_assignment['needs_approval'] is False
        assert barney_assignment['student_id'] == barney['item'].student_id
        assert barney_assignment['submission_id'] == barney['submission']['uuid']
        assert is_near_now(parse_timestamp(barney_assignment['timestamp']))

        assert fred_assignment['module_id'] == fred['module'].id
        assert fred_assignment['username'] == 'fred'
        assert fred_assignment['fullname'] == 'fred'
        assert fred_assignment['filename'] == 'bar.txt'
        assert fred_assignment['score'] is None
        assert fred_assignment['annotated'] == u''
        assert fred_assignment['comment'] == u''
        assert fred_assignment['approved'] is False
        assert fred_assignment['finalized'] is True
        assert fred_assignment['may_grade'] is True
        assert fred_assignment['needs_approval'] is False
        assert fred_assignment['student_id'] == fred['item'].student_id
        assert fred_assignment['submission_id'] == fred['submission']['uuid']
        assert is_near_now(parse_timestamp(fred_assignment['timestamp']))
コード例 #2
0
    def test_get_staff_grading_data(self):
        # pylint: disable=no-member
        """
        Test fetch grading data for staff members.
        """
        block = self.make_one()
        barney = self.make_student(
            block, "barney",
            filename="foo.txt",
            score=10,
            annotated_filename="foo_corrected.txt",
            comment="Good work!")
        fred = self.make_student(
            block, "fred",
            filename="bar.txt")
        data = block.get_staff_grading_data(None).json_body  # lint-amnesty, pylint: disable=redefined-outer-name
        assignments = sorted(data['assignments'], key=lambda x: x['username'])

        barney_assignment, fred_assignment = assignments

        assert barney_assignment['module_id'] == barney['module'].id
        assert barney_assignment['username'] == 'barney'
        assert barney_assignment['fullname'] == 'barney'
        assert barney_assignment['filename'] == 'foo.txt'
        assert barney_assignment['score'] == 10
        assert barney_assignment['annotated'] == 'foo_corrected.txt'
        assert barney_assignment['comment'] == 'Good work!'
        assert barney_assignment['approved'] is True
        assert barney_assignment['finalized'] is True
        assert barney_assignment['may_grade'] is False
        assert barney_assignment['needs_approval'] is False
        assert barney_assignment['student_id'] == barney['item'].student_id
        assert barney_assignment['submission_id'] == barney['submission']['uuid']
        assert is_near_now(parse_timestamp(barney_assignment['timestamp']))

        assert fred_assignment['module_id'] == fred['module'].id
        assert fred_assignment['username'] == 'fred'
        assert fred_assignment['fullname'] == 'fred'
        assert fred_assignment['filename'] == 'bar.txt'
        assert fred_assignment['score'] is None
        assert fred_assignment['annotated'] == u''
        assert fred_assignment['comment'] == u''
        assert fred_assignment['approved'] is False
        assert fred_assignment['finalized'] is True
        assert fred_assignment['may_grade'] is True
        assert fred_assignment['needs_approval'] is False
        assert fred_assignment['student_id'] == fred['item'].student_id
        assert fred_assignment['submission_id'] == fred['submission']['uuid']
        assert is_near_now(parse_timestamp(fred_assignment['timestamp']))
コード例 #3
0
    def test_staff_upload_annotated_state(self):
        # pylint: disable=no-member
        """
        Test state recorded in the module state when staff_upload_annotated is called
        """
        block = self.make_one()
        fred = self.make_student(block, "fred1")['module']

        with self.dummy_upload('testa.txt') as (upload, _):
            block.upload_assignment(mock.Mock(params={"assignment": upload}))
        block.finalize_uploaded_assignment(mock.Mock(method="POST"))

        with self.dummy_upload('testb.txt') as (upload, expected):
            request = mock.Mock(params={
                'annotated': upload,
                'module_id': fred.id
            })
            resp = block.staff_upload_annotated(request)
        assert resp.json == block.staff_grading_data()
        state = json.loads(block.get_student_module(fred.id).state)
        assert state['annotated_mimetype'] == 'text/plain'
        parsed_date = parse_timestamp(state['annotated_timestamp'])
        assert is_near_now(parsed_date)
        assert state['annotated_filename'].endswith('testb.txt')
        assert state['annotated_sha1'] == get_sha1(expected)
コード例 #4
0
    def test_staff_upload_annotated_state(self):
        # pylint: disable=no-member
        """
        Test state recorded in the module state when staff_upload_annotated is called
        """
        block = self.make_one()
        fred = self.make_student(block, "fred1")['module']

        with self.dummy_upload('testa.txt') as (upload, _):
            block.upload_assignment(mock.Mock(params={"assignment": upload}))
        block.finalize_uploaded_assignment(mock.Mock(method="POST"))

        with self.dummy_upload('testb.txt') as (upload, expected):
            request = mock.Mock(params={
                'annotated': upload,
                'module_id': fred.id
            })
            resp = block.staff_upload_annotated(request)
        assert resp.json == block.staff_grading_data()
        state = json.loads(block.get_student_module(fred.id).state)
        assert state['annotated_mimetype'] == 'text/plain'
        parsed_date = parse_timestamp(state['annotated_timestamp'])
        assert is_near_now(parsed_date)
        assert state['annotated_filename'].endswith('testb.txt')
        assert state['annotated_sha1'] == get_sha1(expected)