def setUp(self): problem_tree = RF.ChoiceResponseXMLFactory().build_xml( choice_type='checkbox', choices=[True, True, False], choice_names=['henri2', 'henri1', 'charles8']) question_tree = etree.fromstring(problem_tree).find('choiceresponse') self.question_monitor = ChoiceQuestionMonitor(1, question_tree, None)
class ChoiceQuestionMonitorTestCase(TestCase): def setUp(self): problem_tree = RF.ChoiceResponseXMLFactory().build_xml( choice_type='checkbox', choices=[True, True, False], choice_names=['henri2', 'henri1', 'charles8']) question_tree = etree.fromstring(problem_tree).find('choiceresponse') self.question_monitor = ChoiceQuestionMonitor(1, question_tree, None) def test_format_student_answers(self): self.question_monitor.student_answers = { "[u'choice_0',u'choice_2']": 10, "[u'choice_0',u'choice_1']": 42 } self.assertEqual(self.question_monitor.format_student_answers(), { (1, 3): 10, (1, 2): 42 }) def test_choice_with_large_value(self): self.question_monitor.student_answers = {"[u'choice_15']": 7} self.assertEqual(self.question_monitor.format_student_answers(), {(16, ): 7}) def test_multiple_choice_answer_to_problem(self): self.question_monitor.student_answers['choice_1'] = 1 self.assertEqual(self.question_monitor.format_student_answers(), {(2, ): 1}) def test_invalid_response_to_problem(self): self.question_monitor.student_answers['['] = 1 self.question_monitor.student_answers['pouac'] = 2 self.assertEqual(self.question_monitor.format_student_answers(), {(): 3})
class ChoiceQuestionMonitorTestCase(TestCase): def setUp(self): problem_tree = RF.ChoiceResponseXMLFactory().build_xml(choice_type='checkbox', choices=[True, True, False], choice_names=['henri2','henri1','charles8']) question_tree = etree.fromstring(problem_tree).find('choiceresponse') self.question_monitor = ChoiceQuestionMonitor(1, question_tree, None) self.question_monitor.student_answers = {"[u'choice_0',u'choice_2']": 10, "[u'choice_0',u'choice_1']": 42} def test_parse_student_answers(self): self.question_monitor._parse_student_answers() self.assertEqual(self.question_monitor.student_answers, {(1, 3) : 10, (1, 2) :42})
def setUp(self): problem_tree = RF.ChoiceResponseXMLFactory().build_xml(choice_type='checkbox', choices=[True, True, False], choice_names=['henri2','henri1','charles8']) question_tree = etree.fromstring(problem_tree).find('choiceresponse') self.question_monitor = ChoiceQuestionMonitor(1, question_tree, None) self.question_monitor.student_answers = {"[u'choice_0',u'choice_2']": 10, "[u'choice_0',u'choice_1']": 42}