diff --git a/submissions/__init__.py b/submissions/__init__.py index 7ed47d3..f0dd367 100644 --- a/submissions/__init__.py +++ b/submissions/__init__.py @@ -1,2 +1,2 @@ """ API for creating submissions and scores. """ -__version__ = '3.4.1' +__version__ = '3.4.2' diff --git a/submissions/team_api.py b/submissions/team_api.py index 4465f16..0170bde 100644 --- a/submissions/team_api.py +++ b/submissions/team_api.py @@ -302,13 +302,12 @@ def get_team_submission_student_ids(team_submission_uuid): if not team_submission_uuid: raise TeamSubmissionNotFoundError() try: - student_ids = StudentItem.objects.filter( - submission__team_submission__uuid=team_submission_uuid - ).order_by( - 'student_id' - ).distinct().values_list( - 'student_id', flat=True + student_ids = TeamSubmission.objects.filter( + uuid=team_submission_uuid + ).values_list( + 'submissions__student_item__student_id', flat=True ) + except DatabaseError as exc: err_msg = "Attempt to get student ids for team submission {team_submission_uuid} caused error: {exc}".format( team_submission_uuid=team_submission_uuid, diff --git a/submissions/tests/test_team_api.py b/submissions/tests/test_team_api.py index af8e441..4a8e13d 100644 --- a/submissions/tests/test_team_api.py +++ b/submissions/tests/test_team_api.py @@ -613,15 +613,14 @@ def test_get_team_submission_student_ids(self): for student_id in submission_2_student_ids: self._make_individual_submission(student_id, team_submission=team_submission_2) + with self.assertNumQueries(1): + team_1_ids = team_api.get_team_submission_student_ids(str(team_submission.uuid)) + + team_2_ids = team_api.get_team_submission_student_ids(str(team_submission_2.uuid)) + # Assert that each team submission's uuid returns the correct student_ids - self.assertEqual( - team_api.get_team_submission_student_ids(str(team_submission.uuid)), - self.student_ids - ) - self.assertEqual( - team_api.get_team_submission_student_ids(str(team_submission_2.uuid)), - submission_2_student_ids - ) + self.assertEqual(team_1_ids, self.student_ids) + self.assertEqual(team_2_ids, submission_2_student_ids) def test_get_team_submission_student_ids__no_team_submission(self): with self.assertRaises(TeamSubmissionNotFoundError):