Spaces:
Running
Running
Jeff Myers II
commited on
Commit
·
19fd0c4
1
Parent(s):
751c24c
Completed Prototype
Browse files
app.py
CHANGED
@@ -237,27 +237,26 @@ 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 = 0
|
241 |
-
response = list(quiz)
|
242 |
-
evaluation = ""
|
243 |
|
244 |
-
if
|
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"
|
251 |
-
else: evaluation += f"
|
252 |
|
253 |
-
evaluation
|
254 |
|
255 |
-
if
|
256 |
-
elif 0.8 <= results < 0.9: evaluation
|
257 |
-
elif 0.7 <= results < 0.8: evaluation
|
258 |
-
elif 0.6 <= results < 0.7: evaluation
|
259 |
-
elif 0.5 <= results < 0.6: evaluation
|
260 |
-
else: evaluation
|
261 |
|
262 |
return show_eval(evaluation)
|
263 |
|
|
|
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, response, evaluation = 0, list(quiz), ""
|
|
|
|
|
241 |
|
242 |
+
if not answers: return "Answers are empty."
|
243 |
elif not quiz: return "Quiz is empty."
|
244 |
elif not isinstance(answers, list): return f"Answers is a {type(answers)} but should be {type(list())}."
|
245 |
+
|
246 |
for i, (ans, resp) in enumerate(zip(answers, response)):
|
247 |
if ans == resp:
|
248 |
results += 1
|
249 |
+
evaluation += f"\n\t{i + 1}: {resp} is correct!"
|
250 |
+
else: evaluation += f"\n\t{i + 1}: {resp} is incorrect."
|
251 |
|
252 |
+
evaluation = f"You got {results} out of {len(answers)} correct.\n" + evaluation
|
253 |
|
254 |
+
if 0.9 <= results <= 1.0: evaluation = f"Excellent! " + evaluation
|
255 |
+
elif 0.8 <= results < 0.9: evaluation = f"Great job! " + evaluation
|
256 |
+
elif 0.7 <= results < 0.8: evaluation = f"Good effort! " + evaluation
|
257 |
+
elif 0.6 <= results < 0.7: evaluation = f"Keep practicing! " + evaluation
|
258 |
+
elif 0.5 <= results < 0.6: evaluation = f"You can do better! " + evaluation
|
259 |
+
else: evaluation = f"Keep trying! " + evaluation
|
260 |
|
261 |
return show_eval(evaluation)
|
262 |
|