Ejemplo n.º 1
0
    def setUp(self):
        state = json.dumps({
            'student_answers': ["Answer 1", "answer 2", "answer 3"],
            'scores': [0, 1],
            'hints': ['o hai'],
            'state':
            SelfAssessmentModule.INITIAL,
            'attempts':
            2
        })

        self.static_data = {
            'max_attempts': 10,
            'rubric': etree.XML(self.rubric),
            'prompt': self.prompt,
            'max_score': 1,
            'display_name': "Name",
            'accept_file_upload': False,
            'close_date': None,
            's3_interface': test_util_open_ended.S3_INTERFACE,
            'open_ended_grading_interface':
            test_util_open_ended.OPEN_ENDED_GRADING_INTERFACE,
            'skip_basic_checks': False,
            'control': {
                'required_peer_grading': 1,
                'peer_grader_count': 1,
                'min_to_calibrate': 3,
                'max_to_calibrate': 6,
                'peer_grade_finished_submissions_when_none_pending': False,
            }
        }

        self.module = SelfAssessmentModule(get_test_system(), self.location,
                                           self.definition, self.descriptor,
                                           self.static_data)
Ejemplo n.º 2
0
    def setUp(self):
        self.static_data = {
            'max_attempts': 10,
            'rubric': etree.XML(self.rubric),
            'prompt': self.prompt,
            'max_score': 1,
            'display_name': "Name",
            'accept_file_upload': False,
            'close_date': None,
            's3_interface': test_util_open_ended.S3_INTERFACE,
            'open_ended_grading_interface':
            test_util_open_ended.OPEN_ENDED_GRADING_INTERFACE,
            'skip_basic_checks': False,
            'control': {
                'required_peer_grading': 1,
                'peer_grader_count': 1,
                'min_to_calibrate': 3,
                'max_to_calibrate': 6,
                'peer_grade_finished_submissions_when_none_pending': False,
            }
        }

        system = get_test_system()

        usage_key = system.course_id.make_usage_key('combinedopenended',
                                                    'test_loc')
        scope_ids = ScopeIds(1, 'combinedopenended', usage_key, usage_key)
        system.xmodule_instance = Mock(scope_ids=scope_ids)
        self.module = SelfAssessmentModule(system, self.location,
                                           self.definition, self.descriptor,
                                           self.static_data)
Ejemplo n.º 3
0
    def test_self_assessment_display(self):
        """
        Test storing an answer with the self assessment module.
        """

        # Create a module with no state yet.  Important that this start off as a blank slate.
        test_module = SelfAssessmentModule(get_test_system(), self.location,
                                           self.definition, self.descriptor,
                                           self.static_data)

        saved_response = "Saved response."
        submitted_response = "Submitted response."

        # Initially, there will be no stored answer.
        self.assertEqual(test_module.stored_answer, None)
        # And the initial answer to display will be an empty string.
        self.assertEqual(test_module.get_display_answer(), "")

        # Now, store an answer in the module.
        test_module.handle_ajax("store_answer",
                                {'student_answer': saved_response},
                                get_test_system())
        # The stored answer should now equal our response.
        self.assertEqual(test_module.stored_answer, saved_response)
        self.assertEqual(test_module.get_display_answer(), saved_response)

        # Submit a student response to the question.
        test_module.handle_ajax("save_answer",
                                {"student_answer": submitted_response},
                                get_test_system())
        # Submitting an answer should clear the stored answer.
        self.assertEqual(test_module.stored_answer, None)
        # Confirm that the answer is stored properly.
        self.assertEqual(test_module.latest_answer(), submitted_response)

        # Mock saving an assessment.
        assessment = [0]
        assessment_dict = MockQueryDict({
            'assessment': sum(assessment),
            'score_list[]': assessment
        })
        data = test_module.handle_ajax("save_assessment", assessment_dict,
                                       get_test_system())
        self.assertTrue(json.loads(data)['success'])

        # Reset the module so the student can try again.
        test_module.reset(get_test_system())

        # Confirm that the right response is loaded.
        self.assertEqual(test_module.get_display_answer(), submitted_response)