sviddo commited on
Commit
13381fa
·
1 Parent(s): b2e649c

update generators module

Browse files
Files changed (1) hide show
  1. scripts/quiz/generators.py +11 -24
scripts/quiz/generators.py CHANGED
@@ -1,33 +1,20 @@
 
1
  from .questions import generate_question_data
2
- from .utils import get_next_level
3
 
4
 
5
- def start_interactive_math(right_answers=0, wrong_answers=0, level="easy"):
6
- if wrong_answers > 2:
7
- wrong_answers = 0
8
- right_answers = 0
9
- level = get_next_level(level, False)
10
- elif right_answers > 2:
11
- right_answers = 0
12
- wrong_answers = 0
13
- level = get_next_level(level)
14
-
15
- question_data = generate_question_data(level)
16
  question = question_data['question']
17
- right_answer = question_data['answer']
18
- cur_num = question_data['current_number']
19
- ord_num = question_data['ordinal_number']
20
- times = question_data['times']
21
 
22
- numbers_group = [cur_num, ord_num, times]
23
  output = {
24
  "text": question,
25
- "question_numbers": numbers_group,
26
- "right_answer": right_answer,
27
- 'number_correct': right_answers,
28
- 'number_incorrect': wrong_answers,
29
- 'level': level,
30
- "hints_used": 0
31
  }
32
  return output
33
-
 
1
+ import random
2
  from .questions import generate_question_data
3
+ from .utils import get_next_difficulty, generate_start_step
4
 
5
 
6
+ def start_interactive_math(difficulty=0.01, do_increase: True | False = True):
7
+ next_difficulty = get_next_difficulty(difficulty, do_increase)
8
+ start, step = generate_start_step(difficulty)
9
+ question_data = generate_question_data(start, step, question_num=random.randint(0, 5))
10
+
 
 
 
 
 
 
11
  question = question_data['question']
12
+ start = question_data['start']
13
+ step = question_data['step']
 
 
14
 
 
15
  output = {
16
  "text": question,
17
+ "difficulty": next_difficulty,
18
+ "question_numbers": [start, step, start + step]
 
 
 
 
19
  }
20
  return output