Spaces:
Running
Running
Fix for Resolving Skipping Question 1 and Submission Errors in Quiz
#1
by
aovabo
- opened
app.py
CHANGED
@@ -168,7 +168,7 @@ with gr.Blocks() as demo:
|
|
168 |
):
|
169 |
question_text = gr.Markdown("")
|
170 |
radio_choices = gr.Radio(
|
171 |
-
choices=[], visible=False, label="Your Answer", scale=1.5
|
172 |
)
|
173 |
|
174 |
with gr.Row(variant="compact"):
|
@@ -187,7 +187,19 @@ with gr.Blocks() as demo:
|
|
187 |
start_btn = gr.Button("Start", visible=False)
|
188 |
|
189 |
# Use click() instead of login()
|
190 |
-
login_btn.click(fn=on_user_logged_in, inputs=None, outputs=[login_btn, start_btn])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
# Click "Start" => show first question, hide Start button
|
193 |
start_btn.click(
|
@@ -202,7 +214,7 @@ with gr.Blocks() as demo:
|
|
202 |
start_btn,
|
203 |
final_markdown,
|
204 |
],
|
205 |
-
)
|
206 |
|
207 |
# Click "Next" => store selection, move on
|
208 |
next_btn.click(
|
@@ -217,7 +229,7 @@ with gr.Blocks() as demo:
|
|
217 |
start_btn,
|
218 |
final_markdown,
|
219 |
],
|
220 |
-
)
|
221 |
|
222 |
submit_btn.click(fn=push_results_to_hub, inputs=[user_answers])
|
223 |
|
@@ -225,4 +237,4 @@ with gr.Blocks() as demo:
|
|
225 |
if __name__ == "__main__":
|
226 |
# Note: If testing locally, you'll need to run `huggingface-cli login` or set HF_TOKEN
|
227 |
# environment variable for the login to work locally.
|
228 |
-
demo.launch()
|
|
|
168 |
):
|
169 |
question_text = gr.Markdown("")
|
170 |
radio_choices = gr.Radio(
|
171 |
+
choices=["None"], value="None", visible=False, label="Your Answer", scale=1.5
|
172 |
)
|
173 |
|
174 |
with gr.Row(variant="compact"):
|
|
|
187 |
start_btn = gr.Button("Start", visible=False)
|
188 |
|
189 |
# Use click() instead of login()
|
190 |
+
login_btn.click(fn=on_user_logged_in, inputs=None, outputs=[login_btn, start_btn]).then(
|
191 |
+
fn=handle_quiz,
|
192 |
+
inputs=[question_idx, user_answers, radio_choices, gr.State(True)],
|
193 |
+
outputs=[
|
194 |
+
question_text,
|
195 |
+
radio_choices,
|
196 |
+
status_text,
|
197 |
+
question_idx,
|
198 |
+
user_answers,
|
199 |
+
start_btn,
|
200 |
+
final_markdown,
|
201 |
+
],
|
202 |
+
)
|
203 |
|
204 |
# Click "Start" => show first question, hide Start button
|
205 |
start_btn.click(
|
|
|
214 |
start_btn,
|
215 |
final_markdown,
|
216 |
],
|
217 |
+
).then(lambda x:x, user_answers)
|
218 |
|
219 |
# Click "Next" => store selection, move on
|
220 |
next_btn.click(
|
|
|
229 |
start_btn,
|
230 |
final_markdown,
|
231 |
],
|
232 |
+
).then(lambda x:x, user_answers)
|
233 |
|
234 |
submit_btn.click(fn=push_results_to_hub, inputs=[user_answers])
|
235 |
|
|
|
237 |
if __name__ == "__main__":
|
238 |
# Note: If testing locally, you'll need to run `huggingface-cli login` or set HF_TOKEN
|
239 |
# environment variable for the login to work locally.
|
240 |
+
demo.launch()
|