def test_answer(self): question = self.boolean 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) stats_data_after = generate_stats(question.course.code, question.exam.name) self.assertEqual(stats_data['combo'] + 1, stats_data_after['combo']) self.assert200(response)
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)
def stats(self): from memorizer.utils import generate_stats return generate_stats(course_code=self.course.code, exam_name=self.name)
def get(self, course_code, exam_name=None): return utils.generate_stats(course_code, exam_name)