From e5d386bd39a0ebb2f59ebcf76fdf0cc1b895b772 Mon Sep 17 00:00:00 2001 From: KarlLundengaard <106549720+KarlLundengaard@users.noreply.github.com> Date: Wed, 5 Oct 2022 13:54:21 +0100 Subject: [PATCH] Changed interaction logic for custom feedback and cases Previous behaviour was that if the evaluation function produced custom feedback this feedback was returned instead of the matched case feedback. The new behaviour is that the evaluation functions custom feedback is appended to the case feedback, unless the case has the parameter "override_eval_feedback" set to True in which case the evaluation functions custom feedback is ignored. --- handler.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/handler.py b/handler.py index 755d09a..2b02ad6 100755 --- a/handler.py +++ b/handler.py @@ -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: @@ -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: @@ -150,6 +147,7 @@ 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 @@ -157,6 +155,11 @@ def feedback_from_cases(response, params, cases): # 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]}]