theodotus commited on
Commit
2526b2b
·
1 Parent(s): cd85390

Use Test class

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
 
 
3
 
4
 
5
 
@@ -10,24 +11,24 @@ info = "Пройдіть тест до кінця"
10
 
11
 
12
  # Define your list of questions and answers
13
- questions = ["Question 1", "Question 2", "Question 3"]
14
- answers = ["Answer 1", "Answer 2", "Answer 3"]
15
 
16
  def question_interface(question_state, answer):
17
  question_state["value"] += 1
18
  current_question_index = question_state["value"]
19
 
20
  # Check if all questions have been answered
21
- if current_question_index == len(questions):
22
  # Show all responses
23
  response_text = "\n".join(f"Question: {q}\nAnswer: {a}\n" for q, a in zip(questions, question_state["responses"]))
24
  return response_text
25
 
26
  # Display the current question
27
- question = questions[current_question_index]
28
 
29
  # Create an input component for the answer
30
- radio = gr.Radio.update(choices = ["1","2","3"])
31
 
32
  return question_state, question, radio, "Click 'Answer' to submit"
33
 
 
1
  import gradio as gr
2
 
3
+ from utils import Test
4
 
5
 
6
 
 
11
 
12
 
13
  # Define your list of questions and answers
14
+ test = Test()
15
+
16
 
17
  def question_interface(question_state, answer):
18
  question_state["value"] += 1
19
  current_question_index = question_state["value"]
20
 
21
  # Check if all questions have been answered
22
+ if current_question_index == len(test):
23
  # Show all responses
24
  response_text = "\n".join(f"Question: {q}\nAnswer: {a}\n" for q, a in zip(questions, question_state["responses"]))
25
  return response_text
26
 
27
  # Display the current question
28
+ question = test.get_question(current_question_index)
29
 
30
  # Create an input component for the answer
31
+ radio = gr.Radio.update(choices = test.get_answers(current_question_index))
32
 
33
  return question_state, question, radio, "Click 'Answer' to submit"
34