Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,21 +32,27 @@ def game_mode(topic):
|
|
32 |
question, choices = generate_question(topic)
|
33 |
|
34 |
st.write(question)
|
35 |
-
answer = st.radio("Select your answer:", choices)
|
36 |
|
37 |
-
#
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
st.write(f"Time left: {time_left} seconds")
|
42 |
|
43 |
-
if st.
|
44 |
-
st.
|
45 |
-
st.
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
def quiz_mode(topic):
|
52 |
st.write("Quiz Mode: Take your time!")
|
@@ -54,11 +60,21 @@ def quiz_mode(topic):
|
|
54 |
question, choices = generate_question(topic)
|
55 |
|
56 |
st.write(question)
|
57 |
-
answer = st.radio("Select your answer:", choices)
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
def main():
|
64 |
st.title("Grok-Powered Quiz App")
|
|
|
32 |
question, choices = generate_question(topic)
|
33 |
|
34 |
st.write(question)
|
|
|
35 |
|
36 |
+
# Use session state to track whether the answer has been submitted
|
37 |
+
if 'submitted' not in st.session_state:
|
38 |
+
st.session_state.submitted = False
|
|
|
|
|
39 |
|
40 |
+
if not st.session_state.submitted:
|
41 |
+
answer = st.radio("Select your answer:", choices)
|
42 |
+
submit_button = st.button("Submit")
|
43 |
+
|
44 |
+
if submit_button:
|
45 |
+
st.session_state.submitted = True
|
46 |
+
st.write("You selected:", answer)
|
47 |
+
time_elapsed = time.time() - start_time
|
48 |
+
st.write(f"Time taken: {int(time_elapsed)} seconds")
|
49 |
+
if time_elapsed >= 30:
|
50 |
+
st.warning("Time's up!")
|
51 |
+
else:
|
52 |
+
st.success("Good job!")
|
53 |
+
|
54 |
+
else:
|
55 |
+
st.write("You've already submitted your answer.")
|
56 |
|
57 |
def quiz_mode(topic):
|
58 |
st.write("Quiz Mode: Take your time!")
|
|
|
60 |
question, choices = generate_question(topic)
|
61 |
|
62 |
st.write(question)
|
|
|
63 |
|
64 |
+
# Use session state to track whether the answer has been submitted
|
65 |
+
if 'submitted' not in st.session_state:
|
66 |
+
st.session_state.submitted = False
|
67 |
+
|
68 |
+
if not st.session_state.submitted:
|
69 |
+
answer = st.radio("Select your answer:", choices)
|
70 |
+
submit_button = st.button("Submit")
|
71 |
+
|
72 |
+
if submit_button:
|
73 |
+
st.session_state.submitted = True
|
74 |
+
st.write("You selected:", answer)
|
75 |
+
st.success("Great! On to the next question!")
|
76 |
+
else:
|
77 |
+
st.write("You've already submitted your answer.")
|
78 |
|
79 |
def main():
|
80 |
st.title("Grok-Powered Quiz App")
|