Exemple #1
0
    def _create_student_module_entry(self):
        cmap = self._build_correct_map('correct')
        student_answers = self._build_student_answers(OPTION_1, OPTION_2)

        StudentModuleFactory(course_id=self.course.id,
                             module_state_key=self.problem_module.location,
                             student=UserFactory(username=self.username,
                                                 profile__year_of_birth=1989,
                                                 profile__level_of_education=u'bac'),
                             state=json.dumps(self._build_student_module_state(cmap, student_answers)))
    def test_get_student_answers(self):
        first_question = RF.MultipleChoiceResponseXMLFactory().build_xml(
            choices=[True, False, False])

        second_question = RF.MultipleChoiceResponseXMLFactory().build_xml(
            choices=[False, True, False])

        self.problem_module.data = self._build_problem(first_question,
                                                       second_question)
        problem_monitor = ProblemMonitor(self.problem_module)

        cmap = self._build_correct_map('correct', 'incorrect')
        student_answers = self._build_student_answers('choice_0', 'choice_2')

        StudentModuleFactory(course_id=self.course.id,
                             state=self._build_student_module_state(
                                 cmap, student_answers))

        problem_monitor.get_student_answers()

        correctness_first_question = problem_monitor.question_monitors[
            self._build_question_id(0)].correctness
        student_answers_first_question = problem_monitor.question_monitors[
            self._build_question_id(1)].student_answers
        correctness_second_question = problem_monitor.question_monitors[
            self._build_question_id(1)].correctness
        student_answers_second_question = problem_monitor.question_monitors[
            self._build_question_id(1)].student_answers

        self.assertDictContainsSubset(correctness_first_question, {
            'correct': 1,
            'incorrect': 0
        })
        self.assertDictContainsSubset(student_answers_first_question,
                                      {'choice_0': 1})
        self.assertDictContainsSubset(correctness_second_question, {
            'correct': 0,
            'incorrect': 1
        })
        self.assertDictContainsSubset(student_answers_second_question,
                                      {'choice_2': 1})