Skip to content

Commit

Permalink
Match changes in H's API to allow filtering by multiple assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Jul 8, 2024
1 parent 29032a4 commit 5054805
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lms/services/h_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lms/views/dashboard/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/lms/services/h_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,28 @@ 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"],
},
},
),
(
{
"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"],
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lms/views/dashboard/api/user_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 5054805

Please sign in to comment.