Spaces:
Running
Running
Jeff Myers II
commited on
Commit
·
751c24c
1
Parent(s):
61eeb8b
Completed Prototype
Browse files
app.py
CHANGED
@@ -237,22 +237,27 @@ with gr.Blocks() as demo:
|
|
237 |
heading, num_headlines, category, get, headline, description, show, summarize, content, ready, submit, answers, *quiz])
|
238 |
|
239 |
def get_evaluation(answers, *quiz): ################ Evaluate the user's responses to the quiz
|
240 |
-
results =
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
return show_eval(evaluation)
|
258 |
|
|
|
237 |
heading, num_headlines, category, get, headline, description, show, summarize, content, ready, submit, answers, *quiz])
|
238 |
|
239 |
def get_evaluation(answers, *quiz): ################ Evaluate the user's responses to the quiz
|
240 |
+
results = 0
|
241 |
+
response = list(quiz)
|
242 |
+
evaluation = ""
|
243 |
+
|
244 |
+
if not answers: return "Answers are empty."
|
245 |
+
elif not quiz: return "Quiz is empty."
|
246 |
+
elif not isinstance(answers, list): return f"Answers is a {type(answers)} but should be {type(list())}."
|
247 |
+
for i, (ans, resp) in enumerate(zip(answers, response)):
|
248 |
+
if ans == resp:
|
249 |
+
results += 1
|
250 |
+
evaluation += f"Question {i + 1}: Correct!\n"
|
251 |
+
else: evaluation += f"Question {i + 1}: Incorrect.\n"
|
252 |
+
|
253 |
+
evaluation += f"\nYou got {results} out of {len(answers)} correct. "
|
254 |
+
|
255 |
+
if 0.9 <= results <= 1.0: evaluation += f"Excellent!"
|
256 |
+
elif 0.8 <= results < 0.9: evaluation += f"Great job!"
|
257 |
+
elif 0.7 <= results < 0.8: evaluation += f"Good effort!"
|
258 |
+
elif 0.6 <= results < 0.7: evaluation += f"Keep practicing!"
|
259 |
+
elif 0.5 <= results < 0.6: evaluation += f"You can do better!"
|
260 |
+
else: evaluation += f"Keep trying!"
|
261 |
|
262 |
return show_eval(evaluation)
|
263 |
|