diff --git a/openassessment/assessment/api/staff.py b/openassessment/assessment/api/staff.py index ab708c4cf6..291862dcdc 100644 --- a/openassessment/assessment/api/staff.py +++ b/openassessment/assessment/api/staff.py @@ -231,7 +231,7 @@ def get_assessment_scores_by_criteria(submission_uuid): raise StaffAssessmentInternalError(error_message) from ex -def get_submission_to_assess(course_id, item_id, scorer_id): +def get_submission_to_assess(course_id, item_id, scorer_id, filter_by_teams=False): """ Get a submission for staff evaluation. @@ -241,6 +241,7 @@ def get_submission_to_assess(course_id, item_id, scorer_id): course_id (str): The course that we would like to fetch submissions from. item_id (str): The student_item (problem) that we would like to retrieve submissions for. scorer_id (str): The user id of the staff member scoring this submission + filter_by_teams(boolean): True will retrieve only submissions from same teams as the staff Returns: dict: A student submission for assessment. This contains a 'student_item', @@ -262,7 +263,7 @@ def get_submission_to_assess(course_id, item_id, scorer_id): } """ - student_submission_uuid = StaffWorkflow.get_submission_for_review(course_id, item_id, scorer_id) + student_submission_uuid = StaffWorkflow.get_submission_for_review(course_id, item_id, scorer_id, filter_by_teams=False) if student_submission_uuid: try: submission_data = submissions_api.get_submission(student_submission_uuid) diff --git a/openassessment/assessment/models/staff.py b/openassessment/assessment/models/staff.py index 60c95c2965..ea4d81d415 100644 --- a/openassessment/assessment/models/staff.py +++ b/openassessment/assessment/models/staff.py @@ -93,7 +93,7 @@ def get_workflow_statistics(cls, course_id, item_id): return {'ungraded': ungraded, 'in-progress': in_progress, 'graded': graded} @classmethod - def get_submission_for_review(cls, course_id, item_id, scorer_id): + def get_submission_for_review(cls, course_id, item_id, scorer_id, filter_by_teams=False): """ Find a submission for staff assessment. This function will find the next submission that requires assessment, excluding any submission that has been @@ -101,8 +101,9 @@ def get_submission_for_review(cls, course_id, item_id, scorer_id): Args: course_id (str): The course that we would like to retrieve submissions for, - item_id (str): The student_item that we would like to retrieve submissions for. + item_id (str): The student_item (problem) that we would like to retrieve submissions for. scorer_id (str): The user id of the staff member scoring this submission + filter_by_teams(boolean): True will retrieve only submissions from same teams as the staff Returns: identifying_uuid (str): The identifying_uuid for the (team or individual) submission to review. @@ -133,6 +134,13 @@ def get_submission_for_review(cls, course_id, item_id, scorer_id): grading_completed_at=None, cancelled_at=None, ) + # if filter_by_teams, keep only staff_workflows from students in the same teams as staff + # this is just pseudo code (relations have not been investigated) + if filter_by_teams: + staff_teams = Teams.objects.filter(user_id=scorer_id) + staff_workflows = staff_workflows.filter( + submission__student__teams__intersect_with=staff_teams + ) if not staff_workflows: return None diff --git a/openassessment/xblock/staff_area_mixin.py b/openassessment/xblock/staff_area_mixin.py index fc8ad74c3f..7500cc4a49 100644 --- a/openassessment/xblock/staff_area_mixin.py +++ b/openassessment/xblock/staff_area_mixin.py @@ -324,7 +324,7 @@ def render_staff_grade_form(self, data, suffix=''): # pylint: disable=W0613 # Note that this will check out a submission for grading by the specified staff member. # If no submissions are available for grading, will return None. - submission_to_assess = staff_api.get_submission_to_assess(course_id, item_id, staff_id) + submission_to_assess = staff_api.get_submission_to_assess(course_id, item_id, staff_id, filter_by_teams=True) if submission_to_assess is not None: # This is posting a tracking event to the runtime.