Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -95,7 +95,7 @@ def update_quiz_components(quiz_data):
|
|
| 95 |
radio_updates.append(radio_update)
|
| 96 |
return radio_updates + [gr.update(value="Please select answers and click 'Check Score'.", visible=True)]
|
| 97 |
|
| 98 |
-
def collect_answers_and_calculate(*radio_values, quiz_data):
|
| 99 |
print(f"Received radio_values: {radio_values}") # Debug print
|
| 100 |
print(f"Received quiz_data: {quiz_data}") # Debug print
|
| 101 |
user_answer_list = [answer for answer in radio_values if answer is not None]
|
|
@@ -158,13 +158,13 @@ with gr.Blocks(title="Quiz Maker", theme=colorful_theme) as QUIZBOT:
|
|
| 158 |
# Register the click event for Check Score with explicit unpacking
|
| 159 |
check_score_btn.click(
|
| 160 |
fn=collect_answers_and_calculate,
|
| 161 |
-
inputs=question_radios + [quiz_data_state], #
|
| 162 |
outputs=[score_output],
|
| 163 |
api_name="check_score"
|
| 164 |
)
|
| 165 |
|
| 166 |
if __name__ == "__main__":
|
| 167 |
-
QUIZBOT.queue().launch(server_name="0.0.0.0", server_port=7860)
|
| 168 |
# from pathlib import Path
|
| 169 |
# from sentence_transformers import CrossEncoder
|
| 170 |
# import numpy as np
|
|
|
|
| 95 |
radio_updates.append(radio_update)
|
| 96 |
return radio_updates + [gr.update(value="Please select answers and click 'Check Score'.", visible=True)]
|
| 97 |
|
| 98 |
+
def collect_answers_and_calculate(*radio_values, /, quiz_data): # / enforces quiz_data as positional-only after *radio_values
|
| 99 |
print(f"Received radio_values: {radio_values}") # Debug print
|
| 100 |
print(f"Received quiz_data: {quiz_data}") # Debug print
|
| 101 |
user_answer_list = [answer for answer in radio_values if answer is not None]
|
|
|
|
| 158 |
# Register the click event for Check Score with explicit unpacking
|
| 159 |
check_score_btn.click(
|
| 160 |
fn=collect_answers_and_calculate,
|
| 161 |
+
inputs=question_radios + [quiz_data_state], # 10 radio values + 1 quiz_data
|
| 162 |
outputs=[score_output],
|
| 163 |
api_name="check_score"
|
| 164 |
)
|
| 165 |
|
| 166 |
if __name__ == "__main__":
|
| 167 |
+
QUIZBOT.queue().launch(server_name="0.0.0.0", server_port=7860)
|
| 168 |
# from pathlib import Path
|
| 169 |
# from sentence_transformers import CrossEncoder
|
| 170 |
# import numpy as np
|