From 8b07077ef3c28710be2f9de54eb35e497b4b3be1 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Fri, 11 Oct 2024 14:04:18 +0200 Subject: [PATCH] Include autograding settings on editing audit event --- lms/validation/_lti_launch_params.py | 6 +++++- lms/views/lti/basic_launch.py | 3 +++ tests/unit/lms/views/lti/basic_launch_test.py | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lms/validation/_lti_launch_params.py b/lms/validation/_lti_launch_params.py index 37d423af08..de57f29055 100644 --- a/lms/validation/_lti_launch_params.py +++ b/lms/validation/_lti_launch_params.py @@ -187,7 +187,11 @@ class ConfigureAssignmentSchema(_CommonLTILaunchSchema): ) @pre_load - def _decode_auto_grading_config(self, data, **_kwargs): + def _load_auto_grading_config(self, data, **_kwargs): + """Load auto grading config. + + "form" location doesn't accept Nested fields we'll accept the value as json and deserilize it here. + """ auto_grading_config = data.get("auto_grading_config") if auto_grading_config and isinstance(auto_grading_config, str): diff --git a/lms/views/lti/basic_launch.py b/lms/views/lti/basic_launch.py index 0ab55b661f..e9fa00d22b 100644 --- a/lms/views/lti/basic_launch.py +++ b/lms/views/lti/basic_launch.py @@ -163,6 +163,9 @@ def edit_assignment_callback(self): data={ "old_url": assignment.document_url, "old_group_set_id": assignment.extra.get("group_set_id"), + "old_auto_grading_configuration": assignment.auto_grading_config.asdict() + if assignment.auto_grading_config + else None, }, ) ) diff --git a/tests/unit/lms/views/lti/basic_launch_test.py b/tests/unit/lms/views/lti/basic_launch_test.py index a378dec331..0af4901510 100644 --- a/tests/unit/lms/views/lti/basic_launch_test.py +++ b/tests/unit/lms/views/lti/basic_launch_test.py @@ -106,6 +106,7 @@ def test_edit_assignment_callback( data={ "old_url": assignment.document_url, "old_group_set_id": assignment.extra.get.return_value, + "old_auto_grading_configuration": assignment.auto_grading_config.asdict.return_value, }, ) pyramid_request.registry.notify.has_call_with(LTIEvent.return_value)