Exemplo n.º 1
0
 def setUp(self):
     super().setUp()
     self.mock_user(save=True)
     self.course = add_course()
     exam = add_exam(self.course)
     # self.multiple = Question(exam_id=exam.id, type=Question.MULTIPLE, text="Test Question")
     self.boolean = Question(exam_id=exam.id, type=Question.BOOLEAN, text="Test Question", correct=True)
     db.session.add(self.boolean)
     db.session.commit()
Exemplo n.º 2
0
 def setUp(self):
     super().setUp()
     self.mock_user(save=True)
     self.course = add_course()
     self.exam = add_exam(self.course)
     self.boolean = add_question_boolean(self.exam, text="Test Question", correct=True)
     self.multiple = add_question_multiple(self.exam, text="Test Question", alternatives=[
         ('Alt 1', False),
         ('Alt 2', True),
         ('Alt 3', False),
     ])
Exemplo n.º 3
0
    def test_correct_multiple_one_answer_several_correct(self):
        exam = add_exam(self.course, multiple_correct=False)
        question = add_question_multiple(exam, text="Test Question", alternatives=[
            ('Alt 1', True),
            ('Alt 2', True),
            ('Alt 3', False),
        ])

        response = self.client.post(
            url_for('api.answer'),
            data={'question': question.id, 'alternative': [question.alternatives[1].id]}
        )

        self.assert200(response)
        self.assertTrue(response.json['correct'], 'Answer is correct')
Exemplo n.º 4
0
    def test_answer_multiple_correct_multiple_answer(self):
        exam = add_exam(self.course, name="TEST2", multiple_correct=True)
        question = add_question_multiple(exam, text="Test Question", alternatives=[
            ('Alt 1', True),
            ('Alt 2', True),
            ('Alt 3', False),
        ])
        stats_data = generate_stats(question.course.code, question.exam.name)
        url = url_for('quiz.question_course', course_code=question.course.code, id=question.id)

        response = self.post_answer(url, [question.alternatives[0].id, question.alternatives[1].id])

        stats_data_after = generate_stats(question.course.code, question.exam.name)
        self.assertEqual(stats_data['combo'] + 1, stats_data_after['combo'])
        self.assert200(response)