def test_get_problem_module_size(self): xml = textwrap.dedent(""" <problem> <multiplechoiceresponse> <choicegroup type="MultipleChoice"> <choice correct="false">Apple</choice> <choice correct="false">Banana</choice> <choice correct="false">Chocolate</choice> <choice correct ="true">Donut</choice> </choicegroup> </multiplechoiceresponse> <p>HELLO </p> <multiplechoiceresponse> <choicegroup type="MultipleChoice"> <choice correct="false">Apple</choice> <choice correct="false">Banana</choice> <choice correct="false">Chocolate</choice> <choice correct ="true">Donut</choice> </choicegroup> </multiplechoiceresponse> </problem> """) problem_module = CapaFactory.create(xml=xml) self.assertEqual(2, tasks.get_problem_module_size(problem_module))
def test_rerandomize_true(self): module = CapaFactory.create(rerandomize='always') response = get_responses_data(module) self.assertEquals( response[0].message, 'The analytics cannot be displayed for this question as it uses randomization.' )
def test_multi_responses_name_mask(self): xml = textwrap.dedent("""\ <?xml version="1.0"?> <problem> <p>1st question</p> <choiceresponse> <checkboxgroup direction="vertical"> <choice correct="true">row 1</choice> <choice correct="true">row 2</choice> <choice correct="false">row 3</choice> </checkboxgroup> </choiceresponse> <p>2nd question in the same problem:</p> <multiplechoiceresponse> <choicegroup type="MultipleChoice"> <choice correct="false" name="Tom">1st choice text</choice> <choice correct="false" name="Dick">2nd choice text</choice> <choice correct="true" name="Harry">3rd choice text</choice> </choicegroup> </multiplechoiceresponse> </problem> """) module = CapaFactory.create(xml=xml) response = get_responses_data(module) self.assertEquals(response[0].correct_response, ['choice_0', 'choice_1']) self.assertEquals(response[1].correct_response, ['choice_Harry']) self.assertEquals(response[0].response_type, 'checkbox') self.assertEquals(response[1].response_type, 'radio') self.assertEquals(response[0].message, None) self.assertEquals(response[1].message, None) self.assertEquals(response[0].choice_name_list, '[]') self.assertEquals( response[1].choice_name_list, '["choice_Tom", "choice_Dick", "choice_Harry"]' )
def setUp(self): super(ResponseTest, self).setUp() self.module = CapaFactory.create()
def setUp(self): self.module = CapaFactory.create()