Spaces:
Runtime error
Runtime error
Greg Thompson
commited on
Commit
•
85a4243
1
Parent(s):
3363428
Update the MathQuizFSM class to be more modular
Browse files
mathtext_fastapi/math_quiz_fsm.py
CHANGED
@@ -16,21 +16,26 @@ class MathQuizFSM(object):
|
|
16 |
['exit', 'quiz_question', 'quiz_end'],
|
17 |
]
|
18 |
|
19 |
-
def __init__(
|
|
|
|
|
|
|
|
|
|
|
20 |
# Instantiate the FSM
|
21 |
self.machine = Machine(
|
22 |
-
model=self,
|
23 |
-
states=MathQuizFSM.states,
|
24 |
transitions=MathQuizFSM.transitions,
|
25 |
-
initial=
|
26 |
)
|
27 |
|
28 |
# Instantiate variables necessary for tracking activity
|
29 |
-
self.question_nums =
|
30 |
-
self.correct_answer =
|
31 |
-
self.student_answer =
|
32 |
self.is_correct_answer = False
|
33 |
-
self.response_text = "What is
|
34 |
|
35 |
# Define functions to run on transitions
|
36 |
self.machine.on_enter_quiz_question('generate_math_problem')
|
|
|
16 |
['exit', 'quiz_question', 'quiz_end'],
|
17 |
]
|
18 |
|
19 |
+
def __init__(
|
20 |
+
self,
|
21 |
+
initial_state='quiz_start',
|
22 |
+
question_nums=[2, 3],
|
23 |
+
initial_student_answer=0,
|
24 |
+
):
|
25 |
# Instantiate the FSM
|
26 |
self.machine = Machine(
|
27 |
+
model=self,
|
28 |
+
states=MathQuizFSM.states,
|
29 |
transitions=MathQuizFSM.transitions,
|
30 |
+
initial=initial_state
|
31 |
)
|
32 |
|
33 |
# Instantiate variables necessary for tracking activity
|
34 |
+
self.question_nums = question_nums
|
35 |
+
self.correct_answer = self.question_nums[0] + self.question_nums[1]
|
36 |
+
self.student_answer = initial_student_answer
|
37 |
self.is_correct_answer = False
|
38 |
+
self.response_text = f"What is {self.question_nums[0]} + {self.question_nums[1]}?"
|
39 |
|
40 |
# Define functions to run on transitions
|
41 |
self.machine.on_enter_quiz_question('generate_math_problem')
|