File size: 1,145 Bytes
790a22c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3dc9376
790a22c
 
 
3dc9376
790a22c
 
 
 
 
 
 
3dc9376
790a22c
 
3dc9376
790a22c
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from .questions import generate_question_answer_pair
from .utils import get_next_level


def start_interactive_math(successful_answers=0, wrong_answers=0, level="easy"):
    if wrong_answers > 2:
        wrong_answers = 0
        successful_answers = 0
        level = get_next_level(level, False)
    elif successful_answers > 2:
        successful_answers = 0
        wrong_answers = 0
        level = get_next_level(level)
        
    question_data = generate_question_answer_pair(level)
    question = question_data['question']
    right_answer = question_data['answer']
    current_number = question_data['current_number']
    ordinal_number = question_data['ordinal_number']

    numbers_group = [current_number, ordinal_number]
    if "times" in question_data:
        times = question_data['times']
        numbers_group.append(times)

    data_to_return = {
        "text": question,
        "question_numbers": numbers_group,
        "right_answer": right_answer,
        'number_correct': successful_answers,
        'number_incorrect': wrong_answers,
        'level': level,
        "hints_used": 0
    }
    return data_to_return