Пример #1
0
    def test_collect_ora2_submission_files(self):
        submission = sub_api._get_submission_model(self.submission['uuid'])  # pylint: disable=protected-access
        submission.answer = self.answer
        submission.save()

        # older submission formats
        pre_filesize_uuid = self.pre_file_size_submission['uuid']
        pre_file_size_submission = sub_api._get_submission_model(
            pre_filesize_uuid)  # pylint: disable=protected-access
        pre_file_size_submission.answer = self.pre_file_size_answer
        pre_file_size_submission.save()

        pre_filename_uuid = self.pre_file_name_submission['uuid']
        pre_file_name_submission = sub_api._get_submission_model(
            pre_filename_uuid)  # pylint: disable=protected-access
        pre_file_name_submission.answer = self.pre_file_name_answer
        pre_file_name_submission.save()

        # answer for scorer submission is just a string, and `collect_ora2_submission_files`
        # raises exception because of it, so we change it to empty dict
        scorer_submission = sub_api._get_submission_model(  # pylint: disable=protected-access
            self.scorer_submission['uuid'])
        scorer_submission.answer = {}
        scorer_submission.save()

        collected_ora_files_data = list(
            OraDownloadData.collect_ora2_submission_files(COURSE_ID))
        assert collected_ora_files_data == self.submission_files_data
Пример #2
0
    def test_collect_ora2_submission_files(self):
        submission = sub_api._get_submission_model(self.submission['uuid'])  # pylint: disable=protected-access
        submission.answer = self.answer
        submission.save()

        # answer for scorer submission is just a string, and `collect_ora2_submission_files`
        # raises exception because of it, so we change it to empty dict
        scorer_submission = sub_api._get_submission_model(  # pylint: disable=protected-access
            self.scorer_submission['uuid'])
        scorer_submission.answer = {}
        scorer_submission.save()

        assert list(OraDownloadData.collect_ora2_submission_files(
            COURSE_ID)) == self.submission_files_data
Пример #3
0
    def test_collect_ora2_data_with_special_characters(self, answer):
        """
        Scenario: Verify the data collection for ORA2 works with special or non-ascii characters.

        Given the submission object
        Then update its answer with a non-ascii value
        And the submission is saved
        When the ORA2 data for the submissions is obtained
        Then the data's answer will be same as json dumped answer
        """
        submission = sub_api._get_submission_model(self.submission['uuid'])  # pylint: disable=protected-access
        submission.answer = answer
        submission.save()
        _, rows = OraAggregateData.collect_ora2_data(COURSE_ID)
        self.assertEqual(json.dumps(answer, ensure_ascii=False), rows[1][4])
Пример #4
0
    def test_collect_ora2_data_with_special_characters(self, answer):
        """
        Scenario: Verify the data collection for ORA2 works with special or non-ascii characters.

        Given the submission object
        Then update its answer with a non-ascii value
        And the submission is saved
        When the ORA2 data for the submissions is obtained
        Then the data's answer will be same as json dumped answer
        """
        submission = sub_api._get_submission_model(self.submission['uuid'])  # pylint: disable=protected-access
        submission.answer = answer
        submission.save()
        with patch(
                'openassessment.data.OraAggregateData._map_anonymized_ids_to_usernames'
        ) as map_mock:
            map_mock.return_value = USERNAME_MAPPING
            _, rows = OraAggregateData.collect_ora2_data(COURSE_ID)
        self.assertEqual(json.dumps(answer, ensure_ascii=False), rows[1][7])