burtenshaw commited on
Commit
2ec763a
·
1 Parent(s): 359570c

resolve user_logged_in outputs

Browse files
Files changed (1) hide show
  1. app.py +30 -24
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
- # random.shuffle(quiz_data)
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), # login button visibility
49
- gr.update(visible=True), # start button visibility
50
- gr.update(visible=False), # next button visibility
51
- gr.update(visible=False), # submit button visibility
52
- "", # question text
53
- [], # radio choices (empty list = no choices)
54
- "Click 'Start' to begin the quiz", # status message
55
- 0, # question_idx
56
- [], # user_answers
57
- "", # final_markdown content
58
- token, # user token
 
59
  ]
60
  else:
61
  return [
62
- gr.update(visible=True), # login button visibility
63
- gr.update(visible=False), # start button visibility
64
- gr.update(visible=False), # next button visibility
65
- gr.update(visible=False), # submit button visibility
66
- "", # question text
67
- [], # radio choices
68
- "", # status message
69
- 0, # question_idx
70
- [], # user_answers
71
- "", # final_markdown content
72
- None, # no token
 
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(visible=True, value=f"🎓 Get your certificate" if has_passed else "❌ Did not pass", interactive=has_passed), # submit button
 
 
 
 
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
  ]