elibrowne commited on
Commit
30363c9
1 Parent(s): ec65889
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -196,12 +196,12 @@ with gr.Blocks(theme = theme) as user_eval:
196
  if q_index >= len(all_questions):
197
  print("Done")
198
  gr.Info("You've finished — thank you so much! There are no more questions. :)")
199
- reset_current_response("USER FINISHED", user_id)
200
- return {"question": "You're done! Thanks so much for your help.", "answers": ["I want to log out now.", "I want to keep answering questions.","I want to keep answering questions.", "I want to keep answering questions."], "correct_answer_index": 0, "top10_e5": ["You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!"], "generation_e5": "I don't know how to exit this code right now, so you're in an endless loop of this question until you quit.", "top10_colbert": ["You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!"], "generation_colbert": "I don't know how to exit this code right now, so you're in an endless loop of this question until you quit.", "top10_contains_gold_passage": False, "gold_passage": "GOLD PASSAGE: LOG OFF!", "gold_passage_generation": "what do you gain"}
201
  else:
202
  qid = user_data["order"][q_index]
203
- reset_current_response(user_data["order"][q_index], user_id)
204
- return all_questions[qid]
205
 
206
 
207
  # Title text introducing study
@@ -370,7 +370,7 @@ with gr.Blocks(theme = theme) as user_eval:
370
  ud["current"] += 1
371
  ud["responses"].append(cr) # adds new answers to current list of responses
372
  update_huggingface(user_id) # persistence — update progress online, save answers
373
- current_question = load_current_question(ud, user_id)
374
  return {
375
  selection: gr.Markdown("Advancing to the next question..."),
376
  forward_btn: gr.Textbox("changed" + str(user_data["current"])), # current forces event to trigger always
@@ -500,7 +500,7 @@ with gr.Blocks(theme = theme) as user_eval:
500
  def submit_email(email):
501
  loaded_data = load_user_data(email) # calls login, downloads data, initializes session
502
  # After loading user data, update with current question
503
- new_q = load_current_question(loaded_data, email)
504
  new_answers = new_q["answers"].copy()
505
  new_answers[new_q["correct_answer_index"]] = "**" + new_q["answers"][new_q["correct_answer_index"]] + "** ✅"
506
  return {
@@ -528,9 +528,10 @@ with gr.Blocks(theme = theme) as user_eval:
528
  d: gr.Button(new_q["answers"][3]),
529
  user_id: email,
530
  user_data: loaded_data,
531
- current_question: new_q
 
532
  }
533
- s.click(fn = submit_email, inputs = [email], outputs = [question, login, selection, passage_display, q_text, a, b, c, d, user_id, user_data, current_question])
534
 
535
  # Starts on question, switches to evaluation after the user answers
536
  user_eval.launch()
 
196
  if q_index >= len(all_questions):
197
  print("Done")
198
  gr.Info("You've finished — thank you so much! There are no more questions. :)")
199
+ new_response = reset_current_response("USER FINISHED", user_id)
200
+ return {"question": "You're done! Thanks so much for your help.", "answers": ["I want to log out now.", "I want to keep answering questions.","I want to keep answering questions.", "I want to keep answering questions."], "correct_answer_index": 0, "top10_e5": ["You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!"], "generation_e5": "I don't know how to exit this code right now, so you're in an endless loop of this question until you quit.", "top10_colbert": ["You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!"], "generation_colbert": "I don't know how to exit this code right now, so you're in an endless loop of this question until you quit.", "top10_contains_gold_passage": False, "gold_passage": "GOLD PASSAGE: LOG OFF!", "gold_passage_generation": "what do you gain"}, new_response
201
  else:
202
  qid = user_data["order"][q_index]
203
+ new_response = reset_current_response(user_data["order"][q_index], user_id)
204
+ return all_questions[qid], new_response
205
 
206
 
207
  # Title text introducing study
 
370
  ud["current"] += 1
371
  ud["responses"].append(cr) # adds new answers to current list of responses
372
  update_huggingface(user_id) # persistence — update progress online, save answers
373
+ current_question, current_response = load_current_question(ud, user_id)
374
  return {
375
  selection: gr.Markdown("Advancing to the next question..."),
376
  forward_btn: gr.Textbox("changed" + str(user_data["current"])), # current forces event to trigger always
 
500
  def submit_email(email):
501
  loaded_data = load_user_data(email) # calls login, downloads data, initializes session
502
  # After loading user data, update with current question
503
+ new_q, new_r = load_current_question(loaded_data, email)
504
  new_answers = new_q["answers"].copy()
505
  new_answers[new_q["correct_answer_index"]] = "**" + new_q["answers"][new_q["correct_answer_index"]] + "** ✅"
506
  return {
 
528
  d: gr.Button(new_q["answers"][3]),
529
  user_id: email,
530
  user_data: loaded_data,
531
+ current_question: new_q,
532
+ current_response: new_r
533
  }
534
+ s.click(fn = submit_email, inputs = [email], outputs = [question, login, selection, passage_display, q_text, a, b, c, d, user_id, user_data, current_question, current_response])
535
 
536
  # Starts on question, switches to evaluation after the user answers
537
  user_eval.launch()