Skip to content

Commit e8d7407

Browse files
Merge pull request #1 from lambda-feedback/tr158-demonstrate-responses-per-student-per-response-area
If parameter "display_submission_count" is set to True, the number of…
2 parents 6e3e67e + 7072caa commit e8d7407

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

app/evaluation.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,13 @@ def evaluation_function(response, answer, params) -> dict:
5050
raise EvaluationException(
5151
f"Could not cast `answer` parameter to {req_type}")
5252

53+
result = {"is_correct": res == ans}
54+
55+
if "submission_context" in params.keys():
56+
if "submissions_per_student_per_response_area" in params["submission_context"].keys():
57+
nbr_of_responses = params["submission_context"]["submissions_per_student_per_response_area"]
58+
if params.get("display_submission_count", False):
59+
result.update({"feedback": f"You have submitted {nbr_of_responses} responses."})
60+
5361
# Are they equal?
54-
return {"is_correct": res == ans}
62+
return result

app/evaluation_tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,16 @@ def test_evaluate_as_dict(self):
121121
self.assertFalse(response.get("error", False))
122122

123123

124+
def test_display_submission_count(self):
125+
params = {
126+
"type": "int",
127+
"submission_context": {"submissions_per_student_per_response_area": 3},
128+
"display_submission_count": True
129+
}
130+
response = 1
131+
answer = 1
132+
result = evaluation_function(response, answer, params)
133+
self.assertTrue("You have submitted 3 responses." in result["feedback"])
134+
124135
if __name__ == "__main__":
125136
unittest.main()

0 commit comments

Comments
 (0)