Spaces:
Running
Running
burtenshaw
commited on
Commit
·
1cb2d7e
1
Parent(s):
6c68b5b
add layout and styling
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ def on_user_logged_in(token: gr.OAuthToken | None):
|
|
19 |
Otherwise, keep the login button visible, hide Start.
|
20 |
"""
|
21 |
if token is not None:
|
22 |
-
return gr.update(visible=False), gr.update(visible=
|
23 |
else:
|
24 |
# Not logged in, keep the login visible, hide Start
|
25 |
return gr.update(visible=True), gr.update(visible=False)
|
@@ -81,7 +81,7 @@ def handle_quiz(question_idx, user_answers, selected_answer, is_start):
|
|
81 |
else:
|
82 |
# Otherwise, show the next question
|
83 |
q = quiz_data[question_idx]
|
84 |
-
updated_question = f"##
|
85 |
return (
|
86 |
updated_question,
|
87 |
gr.update(
|
@@ -109,32 +109,39 @@ def success_message(response):
|
|
109 |
|
110 |
with gr.Blocks() as demo:
|
111 |
demo.title = f"Dataset Quiz for {EXAM_DATASET_ID}"
|
112 |
-
|
113 |
-
# Header
|
114 |
-
gr.Markdown(f"## Welcome to the {EXAM_DATASET_ID} Quiz")
|
115 |
-
gr.Markdown(
|
116 |
-
"Log in first, then click 'Start' to begin. Answer each question, click 'Next', and finally click 'Submit' to publish your results to the Hugging Face Hub."
|
117 |
-
)
|
118 |
-
|
119 |
-
# Step 1: Login
|
120 |
-
login_btn = gr.LoginButton()
|
121 |
-
# We'll hide the Start button until user logs in
|
122 |
-
start_btn = gr.Button("Start", visible=False)
|
123 |
-
|
124 |
# State variables
|
125 |
question_idx = gr.State(value=0)
|
126 |
user_answers = gr.State(value=[])
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
# We display question text with Markdown
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
-
|
134 |
-
|
135 |
|
136 |
-
|
137 |
-
|
|
|
|
|
138 |
|
139 |
# Use click() instead of login()
|
140 |
login_btn.click(fn=on_user_logged_in, inputs=None, outputs=[login_btn, start_btn])
|
|
|
19 |
Otherwise, keep the login button visible, hide Start.
|
20 |
"""
|
21 |
if token is not None:
|
22 |
+
return gr.update(visible=False), gr.update(visible=False)
|
23 |
else:
|
24 |
# Not logged in, keep the login visible, hide Start
|
25 |
return gr.update(visible=True), gr.update(visible=False)
|
|
|
81 |
else:
|
82 |
# Otherwise, show the next question
|
83 |
q = quiz_data[question_idx]
|
84 |
+
updated_question = f"## Question {question_idx + 1} \n### {q['question']}"
|
85 |
return (
|
86 |
updated_question,
|
87 |
gr.update(
|
|
|
109 |
|
110 |
with gr.Blocks() as demo:
|
111 |
demo.title = f"Dataset Quiz for {EXAM_DATASET_ID}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
# State variables
|
113 |
question_idx = gr.State(value=0)
|
114 |
user_answers = gr.State(value=[])
|
115 |
|
116 |
+
with gr.Row(variant="compact"):
|
117 |
+
gr.Markdown(f"## Welcome to the {EXAM_DATASET_ID} Quiz")
|
118 |
+
with gr.Row(variant="compact"):
|
119 |
+
gr.Markdown(
|
120 |
+
"Log in first, then click 'Start' to begin. Answer each question, click 'Next', and finally click 'Submit' to publish your results to the Hugging Face Hub."
|
121 |
+
)
|
122 |
# We display question text with Markdown
|
123 |
+
with gr.Row(
|
124 |
+
variant="panel",
|
125 |
+
):
|
126 |
+
question_text = gr.Markdown("")
|
127 |
+
radio_choices = gr.Radio(
|
128 |
+
choices=[], visible=False, label="Your Answer", scale=1.5
|
129 |
+
)
|
130 |
+
|
131 |
+
with gr.Row(variant="compact"):
|
132 |
+
status_text = gr.Markdown("")
|
133 |
+
|
134 |
+
with gr.Row(variant="compact"):
|
135 |
+
# Final results after all questions are done
|
136 |
+
final_markdown = gr.Markdown("", visible=False)
|
137 |
|
138 |
+
next_btn = gr.Button("Next ⏭️")
|
139 |
+
submit_btn = gr.Button("Submit ✅")
|
140 |
|
141 |
+
with gr.Row(variant="compact"):
|
142 |
+
login_btn = gr.LoginButton()
|
143 |
+
# We'll hide the Start button until user logs in
|
144 |
+
start_btn = gr.Button("Start", visible=False)
|
145 |
|
146 |
# Use click() instead of login()
|
147 |
login_btn.click(fn=on_user_logged_in, inputs=None, outputs=[login_btn, start_btn])
|