def setUp(self): super().setUp() self.user = self.mock_user(save=True) db.session.add(self.user) db.session.commit() # Add 5 courses with 3 exams each with stats for course_n in range(5): course = Course("TEST%d" % course_n, "Test Course") db.session.add(course) db.session.commit() for exam_n in range(3): exam = Exam("V%d" % exam_n, course.id) db.session.add(exam) db.session.commit() question = Question(exam_id=exam.id, type=Question.BOOLEAN, text="Test Question", correct=True) db.session.add(question) db.session.commit() for stats_n in range(2): stats = Stats(self.user, question, random.choice([True, False])) db.session.add(stats) db.session.commit()
def test_exam(self, random_patch): course = Course(code='TEST1', name='Course') db.session.add(course) db.session.commit() exam = Exam("H1", course.id) db.session.add(exam) db.session.commit() response = self.client.get('/%s/%s/' % (course.code, exam.name)) self.assert_redirects( response, url_for('quiz.question_exam', course_code=course.code, exam_name=exam.name, id=1) )
def add_exam(course, name="T16"): exam = Exam(name, course.id) db.session.add(exam) db.session.commit() return exam