elibrowne commited on
Commit
46a842f
1 Parent(s): 95069fa
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -191,16 +191,16 @@ with gr.Blocks(theme = theme) as user_eval:
191
  }
192
 
193
  # Loads the user's current question — this is the first question that the user has not made any progress on.
194
- def load_current_question(user_data):
195
  q_index = user_data["current"]
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")
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])
204
  return all_questions[qid]
205
 
206
 
@@ -370,7 +370,7 @@ with gr.Blocks(theme = theme) as user_eval:
370
  user_data["current"] += 1
371
  user_data["responses"].append(current_response) # 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(user_data)
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
@@ -497,7 +497,7 @@ with gr.Blocks(theme = theme) as user_eval:
497
  user_id = email
498
  user_data = load_user_data(user_id) # calls login, downloads data, initializes session
499
  # After loading user data, update with current question
500
- current_question = load_current_question(user_data)
501
  new_answers = current_question["answers"].copy()
502
  new_answers[current_question["correct_answer_index"]] = "**" + current_question["answers"][current_question["correct_answer_index"]] + "** ✅"
503
  return {
 
191
  }
192
 
193
  # Loads the user's current question — this is the first question that the user has not made any progress on.
194
+ def load_current_question(user_data, user_id):
195
  q_index = user_data["current"]
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
 
 
370
  user_data["current"] += 1
371
  user_data["responses"].append(current_response) # 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(user_data, 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
 
497
  user_id = email
498
  user_data = load_user_data(user_id) # calls login, downloads data, initializes session
499
  # After loading user data, update with current question
500
+ current_question = load_current_question(user_data, user_id)
501
  new_answers = current_question["answers"].copy()
502
  new_answers[current_question["correct_answer_index"]] = "**" + current_question["answers"][current_question["correct_answer_index"]] + "** ✅"
503
  return {