From 50548051b8b59f29c39da1b137d2cce92077f6b8 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Fri, 5 Jul 2024 11:44:24 +0200 Subject: [PATCH] Match changes in H's API to allow filtering by multiple assignments --- lms/services/h_api.py | 4 ++-- lms/views/dashboard/api/user.py | 2 +- tests/unit/lms/services/h_api_test.py | 8 ++++---- tests/unit/lms/views/dashboard/api/user_test.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lms/services/h_api.py b/lms/services/h_api.py index a847659b75..369bd89e66 100644 --- a/lms/services/h_api.py +++ b/lms/services/h_api.py @@ -174,11 +174,11 @@ def get_annotation_counts( group_authority_ids: list[str], group_by: str, h_userids: list[str] | None = None, - resource_link_id: str | None = None, + resource_link_ids: list[str] | None = None, ): filters = { "groups": group_authority_ids, - "assignment_id": resource_link_id, + "assignment_ids": resource_link_ids, } if h_userids: filters["h_userids"] = h_userids diff --git a/lms/views/dashboard/api/user.py b/lms/views/dashboard/api/user.py index c3d5f0417c..d5bafcdd48 100644 --- a/lms/views/dashboard/api/user.py +++ b/lms/views/dashboard/api/user.py @@ -89,7 +89,7 @@ def students_metrics(self) -> APIStudents: stats = self.h_api.get_annotation_counts( [g.authority_provided_id for g in assignment.groupings], group_by="user", - resource_link_id=assignment.resource_link_id, + resource_link_ids=[assignment.resource_link_id], h_userids=request_h_userids, ) # Organize the H stats by userid for quick access diff --git a/tests/unit/lms/services/h_api_test.py b/tests/unit/lms/services/h_api_test.py index ff370d01f7..b2ac7886f3 100644 --- a/tests/unit/lms/services/h_api_test.py +++ b/tests/unit/lms/services/h_api_test.py @@ -138,13 +138,13 @@ def test_get_annotations( { "group_authority_ids": ["group_1", "group_2"], "group_by": "user", - "resource_link_id": "assignment_id", + "resource_link_ids": ["assignment_id"], }, { "group_by": "user", "filter": { "groups": ["group_1", "group_2"], - "assignment_id": "assignment_id", + "assignment_ids": ["assignment_id"], }, }, ), @@ -152,14 +152,14 @@ def test_get_annotations( { "group_authority_ids": ["group_1", "group_2"], "group_by": "user", - "resource_link_id": "assignment_id", + "resource_link_ids": ["assignment_id"], "h_userids": ["user_1", "user_2"], }, { "group_by": "user", "filter": { "groups": ["group_1", "group_2"], - "assignment_id": "assignment_id", + "assignment_ids": ["assignment_id"], "h_userids": ["user_1", "user_2"], }, }, diff --git a/tests/unit/lms/views/dashboard/api/user_test.py b/tests/unit/lms/views/dashboard/api/user_test.py index 3bbd620285..fd81324aa8 100644 --- a/tests/unit/lms/views/dashboard/api/user_test.py +++ b/tests/unit/lms/views/dashboard/api/user_test.py @@ -99,7 +99,7 @@ def test_students_metrics( h_api.get_annotation_counts.assert_called_once_with( [g.authority_provided_id for g in assignment.groupings], group_by="user", - resource_link_id=assignment.resource_link_id, + resource_link_ids=[assignment.resource_link_id], h_userids=sentinel.h_userids, ) expected = {