Spaces:
Running
Running
burtenshaw
commited on
Commit
Β·
ad61a88
1
Parent(s):
dca750b
expand linkedin button messaging
Browse files
app.py
CHANGED
|
@@ -58,9 +58,9 @@ def on_user_logged_in(token: gr.OAuthToken | None):
|
|
| 58 |
gr.update(
|
| 59 |
visible=True,
|
| 60 |
value="""
|
| 61 |
-
<div style="text-align: center; padding: 20px; border: 2px dashed #ccc;
|
| 62 |
<h3>π― Complete the Quiz to Unlock</h3>
|
| 63 |
-
<p>
|
| 64 |
<img src="linkedin_logo.png" alt="LinkedIn Add to Profile" style="width: 200px; height: 53px; opacity: 0.5;">
|
| 65 |
</div>
|
| 66 |
""",
|
|
@@ -279,7 +279,15 @@ def handle_quiz(
|
|
| 279 |
gr.update(visible=False), # next button
|
| 280 |
gr.update(visible=False), # submit button
|
| 281 |
gr.update(visible=False), # certificate image
|
| 282 |
-
gr.update(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
]
|
| 284 |
|
| 285 |
if not is_start and question_idx < len(quiz_data):
|
|
@@ -301,12 +309,26 @@ def handle_quiz(
|
|
| 301 |
if question_idx >= len(quiz_data):
|
| 302 |
correct_count = sum(1 for answer in user_answers if answer["is_correct"])
|
| 303 |
grade = correct_count / len(user_answers)
|
| 304 |
-
results_text = (
|
| 305 |
-
f"**Quiz Complete!**\n\n"
|
| 306 |
-
f"Your score: {grade:.1%}\n"
|
| 307 |
-
f"Passing score: {float(EXAM_PASSING_SCORE):.1%}\n\n"
|
| 308 |
-
)
|
| 309 |
has_passed = grade >= float(EXAM_PASSING_SCORE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
return [
|
| 311 |
"", # question_text
|
| 312 |
gr.update(choices=[], visible=False), # radio choices
|
|
@@ -317,11 +339,11 @@ def handle_quiz(
|
|
| 317 |
gr.update(visible=False), # next button
|
| 318 |
gr.update(
|
| 319 |
visible=True,
|
| 320 |
-
value=
|
| 321 |
interactive=has_passed,
|
| 322 |
), # submit button
|
| 323 |
gr.update(visible=False), # certificate image
|
| 324 |
-
gr.update(visible=
|
| 325 |
]
|
| 326 |
|
| 327 |
# Show next question
|
|
@@ -340,7 +362,16 @@ def handle_quiz(
|
|
| 340 |
gr.update(visible=True), # next button
|
| 341 |
gr.update(visible=False), # submit button
|
| 342 |
gr.update(visible=False), # certificate image
|
| 343 |
-
gr.update(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
]
|
| 345 |
|
| 346 |
|
|
|
|
| 58 |
gr.update(
|
| 59 |
visible=True,
|
| 60 |
value="""
|
| 61 |
+
<div style="text-align: center; padding: 20px; border: 2px dashed #ccc;">
|
| 62 |
<h3>π― Complete the Quiz to Unlock</h3>
|
| 63 |
+
<p>Pass the quiz to add your certificate to LinkedIn!</p>
|
| 64 |
<img src="linkedin_logo.png" alt="LinkedIn Add to Profile" style="width: 200px; height: 53px; opacity: 0.5;">
|
| 65 |
</div>
|
| 66 |
""",
|
|
|
|
| 279 |
gr.update(visible=False), # next button
|
| 280 |
gr.update(visible=False), # submit button
|
| 281 |
gr.update(visible=False), # certificate image
|
| 282 |
+
gr.update(
|
| 283 |
+
visible=True,
|
| 284 |
+
value="""
|
| 285 |
+
<div style="text-align: center; padding: 20px; border: 2px dashed #ccc;">
|
| 286 |
+
<h3>π Login Required</h3>
|
| 287 |
+
<p>Please log in with your Hugging Face account to access the quiz and earn your LinkedIn certificate!</p>
|
| 288 |
+
</div>
|
| 289 |
+
""",
|
| 290 |
+
), # linkedin button with login prompt
|
| 291 |
]
|
| 292 |
|
| 293 |
if not is_start and question_idx < len(quiz_data):
|
|
|
|
| 309 |
if question_idx >= len(quiz_data):
|
| 310 |
correct_count = sum(1 for answer in user_answers if answer["is_correct"])
|
| 311 |
grade = correct_count / len(user_answers)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
has_passed = grade >= float(EXAM_PASSING_SCORE)
|
| 313 |
+
|
| 314 |
+
# LinkedIn button text for quiz completion
|
| 315 |
+
linkedin_completion_text = (
|
| 316 |
+
"""
|
| 317 |
+
<div style="text-align: center; padding: 20px; border: 2px dashed #4CAF50;">
|
| 318 |
+
<h3>π Ready for LinkedIn!</h3>
|
| 319 |
+
<p>Great! Click "Get your certificate" above to unlock the LinkedIn button.</p>
|
| 320 |
+
<img src="linkedin_logo.png" alt="LinkedIn Add to Profile" style="width: 200px; height: 53px; opacity: 0.7;">
|
| 321 |
+
</div>
|
| 322 |
+
"""
|
| 323 |
+
if has_passed
|
| 324 |
+
else """
|
| 325 |
+
<div style="text-align: center; padding: 20px; border: 2px dashed #ff6b6b;">
|
| 326 |
+
<h3>β Try Again</h3>
|
| 327 |
+
<p>You need a higher score to earn the LinkedIn certificate. Please retake the quiz!</p>
|
| 328 |
+
</div>
|
| 329 |
+
"""
|
| 330 |
+
)
|
| 331 |
+
|
| 332 |
return [
|
| 333 |
"", # question_text
|
| 334 |
gr.update(choices=[], visible=False), # radio choices
|
|
|
|
| 339 |
gr.update(visible=False), # next button
|
| 340 |
gr.update(
|
| 341 |
visible=True,
|
| 342 |
+
value="π Get your certificate" if has_passed else "β Did not pass",
|
| 343 |
interactive=has_passed,
|
| 344 |
), # submit button
|
| 345 |
gr.update(visible=False), # certificate image
|
| 346 |
+
gr.update(visible=True, value=linkedin_completion_text), # linkedin button
|
| 347 |
]
|
| 348 |
|
| 349 |
# Show next question
|
|
|
|
| 362 |
gr.update(visible=True), # next button
|
| 363 |
gr.update(visible=False), # submit button
|
| 364 |
gr.update(visible=False), # certificate image
|
| 365 |
+
gr.update(
|
| 366 |
+
visible=True,
|
| 367 |
+
value="""
|
| 368 |
+
<div style="text-align: center; padding: 20px; border: 2px dashed #ccc;">
|
| 369 |
+
<h3>π― Keep Going!</h3>
|
| 370 |
+
<p>Complete the quiz and pass to unlock your LinkedIn certificate!</p>
|
| 371 |
+
<img src="linkedin_logo.png" alt="LinkedIn Add to Profile" style="width: 200px; height: 53px; opacity: 0.5;">
|
| 372 |
+
</div>
|
| 373 |
+
""",
|
| 374 |
+
), # linkedin button with progress message
|
| 375 |
]
|
| 376 |
|
| 377 |
|