Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def handle_eval_command(event):
}
}

# Result already contains feedback generated inside the custom function
if "feedback" in result:
return {"command": "eval", "result": result}

# If a list of "cases" wasn't provided, we don't have any other way to get feedback
cases = params.get("cases", [])
if len(cases) == 0:
Expand Down Expand Up @@ -106,6 +102,7 @@ def feedback_from_cases(response, params, cases):
# A list of "cases" was provided, try matching to each of them
matches = []
warnings = []
eval_function_feedback = []
for i, case in enumerate(cases):
# Validate the case block has an answer and feedback
if 'answer' not in case:
Expand Down Expand Up @@ -150,13 +147,19 @@ def feedback_from_cases(response, params, cases):
# This case matches the response, add it's index to the list of matches
if res.get('is_correct') == True:
matches += [i]
eval_function_feedback += [res.get("feedback","")]

if len(matches) == 0:
return None, warnings

# Select the matched case
matched_case = cases[matches[0]]
matched_case['id'] = matches[0]
if not matched_case["params"].get("override_eval_feedback",False):
separator = "\n" if len(eval_function_feedback[0]) > 0 else ""
matched_case["feedback"] = matched_case.get("feedback","")\
+separator\
+eval_function_feedback[0]

if len(matches) == 1:
# warnings += [{"case": matches[0]}]
Expand Down