Spaces:
Sleeping
Sleeping
elibrowne commited on
Commit ·
8c58af0
1
Parent(s): e079737
Load data after login
Browse files
app.py
CHANGED
|
@@ -134,27 +134,22 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 134 |
with gr.Row(equal_height = False, visible = False) as evals:
|
| 135 |
# Passage text
|
| 136 |
with gr.Column(scale = 2) as passages:
|
| 137 |
-
selection = gr.HTML(
|
|
|
|
|
|
|
| 138 |
<h2> Retrieved Passage </h2>
|
| 139 |
-
<p> "
|
|
|
|
| 140 |
print(step)
|
| 141 |
print(user_data["modes"][user_data["current"]][mode])
|
| 142 |
line = gr.Markdown("---")
|
| 143 |
# New answers is able to render the Q and A with formatting. It doesn't change the contents of the answers.
|
| 144 |
-
new_answers = current_question["answers"].copy()
|
| 145 |
-
new_answers[current_question["correct_answer_index"]] = "**" + current_question["answers"][current_question["correct_answer_index"]] + "** ✅"
|
| 146 |
-
passage_display = gr.Markdown(
|
|
|
|
| 147 |
## Question and Answer
|
| 148 |
-
|
| 149 |
-
"""* \n
|
| 150 |
-
+ """ + new_answers[0] +
|
| 151 |
-
""" \n
|
| 152 |
-
+ """ + new_answers[1] +
|
| 153 |
-
""" \n
|
| 154 |
-
+ """ + new_answers[2] +
|
| 155 |
-
""" \n
|
| 156 |
-
+ """ + new_answers[3])
|
| 157 |
-
|
| 158 |
|
| 159 |
# Scoring box
|
| 160 |
with gr.Column(scale = 1) as scores_p:
|
|
@@ -349,12 +344,28 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 349 |
global user_id
|
| 350 |
user_id = email
|
| 351 |
load_user_data(user_id) # calls login, downloads data, initializes session
|
|
|
|
|
|
|
|
|
|
| 352 |
return {
|
| 353 |
question: gr.Row(visible = True),
|
| 354 |
-
login: gr.Row(visible = False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
}
|
| 356 |
-
|
| 357 |
-
s.click(fn = submit_email, inputs = [email], outputs = [question, login])
|
| 358 |
|
| 359 |
# Starts on question, switches to evaluation after the user answers
|
| 360 |
user_eval.launch()
|
|
|
|
| 134 |
with gr.Row(equal_height = False, visible = False) as evals:
|
| 135 |
# Passage text
|
| 136 |
with gr.Column(scale = 2) as passages:
|
| 137 |
+
selection = gr.HTML()
|
| 138 |
+
"""
|
| 139 |
+
selection = gr.HTML("
|
| 140 |
<h2> Retrieved Passage </h2>
|
| 141 |
+
<p> " + current_question["top10_" + user_data["modes"][user_data["current"]][mode]][0] + "</p>")
|
| 142 |
+
"""
|
| 143 |
print(step)
|
| 144 |
print(user_data["modes"][user_data["current"]][mode])
|
| 145 |
line = gr.Markdown("---")
|
| 146 |
# New answers is able to render the Q and A with formatting. It doesn't change the contents of the answers.
|
| 147 |
+
# new_answers = current_question["answers"].copy()
|
| 148 |
+
# new_answers[current_question["correct_answer_index"]] = "**" + current_question["answers"][current_question["correct_answer_index"]] + "** ✅"
|
| 149 |
+
passage_display = gr.Markdown()
|
| 150 |
+
temp = """
|
| 151 |
## Question and Answer
|
| 152 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
# Scoring box
|
| 155 |
with gr.Column(scale = 1) as scores_p:
|
|
|
|
| 344 |
global user_id
|
| 345 |
user_id = email
|
| 346 |
load_user_data(user_id) # calls login, downloads data, initializes session
|
| 347 |
+
# After loading user data, update with current question
|
| 348 |
+
new_answers = current_question["answers"].copy()
|
| 349 |
+
new_answers[current_question["correct_answer_index"]] = "**" + current_question["answers"][current_question["correct_answer_index"]] + "** ✅"
|
| 350 |
return {
|
| 351 |
question: gr.Row(visible = True),
|
| 352 |
+
login: gr.Row(visible = False),
|
| 353 |
+
selection: gr.HTML("""
|
| 354 |
+
<h2> Retrieved Passage </h2>
|
| 355 |
+
<p> """ + current_question["top10_" + user_data["modes"][user_data["current"]][mode]][0] + "</p>"),
|
| 356 |
+
passage_display: gr.Markdown("""
|
| 357 |
+
## Question and Answer
|
| 358 |
+
*""" + current_question["question"] +
|
| 359 |
+
"""* \n
|
| 360 |
+
+ """ + new_answers[0] +
|
| 361 |
+
""" \n
|
| 362 |
+
+ """ + new_answers[1] +
|
| 363 |
+
""" \n
|
| 364 |
+
+ """ + new_answers[2] +
|
| 365 |
+
""" \n
|
| 366 |
+
+ """ + new_answers[3])
|
| 367 |
}
|
| 368 |
+
s.click(fn = submit_email, inputs = [email], outputs = [question, login, selection, passage_display])
|
|
|
|
| 369 |
|
| 370 |
# Starts on question, switches to evaluation after the user answers
|
| 371 |
user_eval.launch()
|