Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
burtenshaw
commited on
Commit
·
2ec763a
1
Parent(s):
359570c
resolve user_logged_in outputs
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ DATASET_REPO_URL = "https://huggingface.co/datasets/agents-course/certificates"
|
|
| 31 |
|
| 32 |
# Convert dataset to a list of dicts and randomly sort
|
| 33 |
quiz_data = ds.to_pandas().to_dict("records")
|
| 34 |
-
|
| 35 |
|
| 36 |
# Limit to max questions if specified
|
| 37 |
if EXAM_MAX_QUESTIONS:
|
|
@@ -45,31 +45,33 @@ def on_user_logged_in(token: gr.OAuthToken | None):
|
|
| 45 |
"""
|
| 46 |
if token is not None:
|
| 47 |
return [
|
| 48 |
-
gr.update(visible=False), #
|
| 49 |
-
gr.update(visible=True),
|
| 50 |
-
gr.update(visible=False), #
|
| 51 |
-
gr.update(visible=False), #
|
| 52 |
-
"",
|
| 53 |
-
[], #
|
| 54 |
-
"Click 'Start' to begin the quiz", #
|
| 55 |
-
0,
|
| 56 |
-
[],
|
| 57 |
-
|
| 58 |
-
|
|
|
|
| 59 |
]
|
| 60 |
else:
|
| 61 |
return [
|
| 62 |
-
gr.update(visible=True),
|
| 63 |
-
gr.update(visible=False), #
|
| 64 |
-
gr.update(visible=False), #
|
| 65 |
-
gr.update(visible=False), #
|
| 66 |
-
"",
|
| 67 |
-
[], #
|
| 68 |
-
"",
|
| 69 |
-
0,
|
| 70 |
-
[],
|
| 71 |
-
|
| 72 |
-
|
|
|
|
| 73 |
]
|
| 74 |
|
| 75 |
|
|
@@ -290,7 +292,11 @@ def handle_quiz(
|
|
| 290 |
user_answers, # user_answers
|
| 291 |
gr.update(visible=False), # start button
|
| 292 |
gr.update(visible=False), # next button
|
| 293 |
-
gr.update(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
gr.update(visible=False), # certificate image
|
| 295 |
gr.update(visible=False), # linkedin button
|
| 296 |
]
|
|
|
|
| 31 |
|
| 32 |
# Convert dataset to a list of dicts and randomly sort
|
| 33 |
quiz_data = ds.to_pandas().to_dict("records")
|
| 34 |
+
random.shuffle(quiz_data)
|
| 35 |
|
| 36 |
# Limit to max questions if specified
|
| 37 |
if EXAM_MAX_QUESTIONS:
|
|
|
|
| 45 |
"""
|
| 46 |
if token is not None:
|
| 47 |
return [
|
| 48 |
+
gr.update(visible=False), # login_btn
|
| 49 |
+
gr.update(visible=True), # start_btn
|
| 50 |
+
gr.update(visible=False), # next_btn
|
| 51 |
+
gr.update(visible=False), # submit_btn
|
| 52 |
+
"", # question_text
|
| 53 |
+
gr.update(choices=[], visible=False), # radio_choices
|
| 54 |
+
"Click 'Start' to begin the quiz", # status_text
|
| 55 |
+
0, # question_idx
|
| 56 |
+
[], # user_answers
|
| 57 |
+
gr.update(visible=False), # certificate_img
|
| 58 |
+
gr.update(visible=False), # linkedin_btn
|
| 59 |
+
token, # user_token
|
| 60 |
]
|
| 61 |
else:
|
| 62 |
return [
|
| 63 |
+
gr.update(visible=True), # login_btn
|
| 64 |
+
gr.update(visible=False), # start_btn
|
| 65 |
+
gr.update(visible=False), # next_btn
|
| 66 |
+
gr.update(visible=False), # submit_btn
|
| 67 |
+
"", # question_text
|
| 68 |
+
gr.update(choices=[], visible=False), # radio_choices
|
| 69 |
+
"", # status_text
|
| 70 |
+
0, # question_idx
|
| 71 |
+
[], # user_answers
|
| 72 |
+
gr.update(visible=False), # certificate_img
|
| 73 |
+
gr.update(visible=False), # linkedin_btn
|
| 74 |
+
None, # user_token
|
| 75 |
]
|
| 76 |
|
| 77 |
|
|
|
|
| 292 |
user_answers, # user_answers
|
| 293 |
gr.update(visible=False), # start button
|
| 294 |
gr.update(visible=False), # next button
|
| 295 |
+
gr.update(
|
| 296 |
+
visible=True,
|
| 297 |
+
value=f"🎓 Get your certificate" if has_passed else "❌ Did not pass",
|
| 298 |
+
interactive=has_passed,
|
| 299 |
+
), # submit button
|
| 300 |
gr.update(visible=False), # certificate image
|
| 301 |
gr.update(visible=False), # linkedin button
|
| 302 |
]
|