From c50466e0818df91ae9bc846446f93691e65abd5b Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Wed, 4 Sep 2024 17:58:49 +0200 Subject: [PATCH] Expose auto grading config on the assigment API --- lms/views/dashboard/api/assignment.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lms/views/dashboard/api/assignment.py b/lms/views/dashboard/api/assignment.py index f07415a72f..44c25a0def 100644 --- a/lms/views/dashboard/api/assignment.py +++ b/lms/views/dashboard/api/assignment.py @@ -6,6 +6,7 @@ APIAssignment, APIAssignments, APICourse, + AutoGradingConfig, ) from lms.models import Assignment, RoleScope, RoleType from lms.security import Permissions @@ -98,7 +99,7 @@ def assignments(self) -> APIAssignments: ) def assignment(self) -> APIAssignment: assignment = self.dashboard_service.get_request_assignment(self.request) - return APIAssignment( + api_assignment = APIAssignment( id=assignment.id, title=assignment.title, created=assignment.created.isoformat(), @@ -108,6 +109,16 @@ def assignment(self) -> APIAssignment: ), ) + if auto_grading_config := assignment.auto_grading_config: + api_assignment["auto_grading_config"] = AutoGradingConfig( + grading_type=auto_grading_config.grading_type, + activity_calculation=auto_grading_config.activity_calculation, + required_annotations=auto_grading_config.required_annotations, + required_replies=auto_grading_config.required_replies, + ) + + return api_assignment + @view_config( route_name="api.dashboard.course.assignments.metrics", request_method="GET",