def step_impl(context: Context): for row in context.table: answer, expected = row['answer'], row.get('expected', 'right') question = current_question(context) recent_answer: StudyController.RecordedAnswer = \ context.study_controller.record_answer_and_get_status( question_number=question.question_number, quiz=question.quiz, selection=answer, session_id=None ) if expected in 'wrong': assert_that(recent_answer.correct, is_(False)) else: assert_that(recent_answer.correct, is_(True)) context.recent_answer = recent_answer more_questions = recent_answer.next_question_number if more_questions: new_question = context.study_controller.prepare_quiz_question_document( recent_answer.quiz, recent_answer.next_question_number ) context.current_question = new_question
def step_impl(context: Context, quiz_name: str): study_controller: StudyController = context.study_controller quiz = study_controller.get_quiz_by_name(quiz_name) context.current_question = study_controller.begin_quiz(quiz) assert_that(context.current_question.quiz, equal_to(quiz))