Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXAMPLE PR with pseudo code for filtering submissions based on teams #7

Draft
wants to merge 1 commit into
base: pedrovgp/master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions openassessment/assessment/api/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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',
Expand All @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions openassessment/assessment/models/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,17 @@ 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
completely graded, or is actively being reviewed by other staff members.

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.
Expand Down Expand Up @@ -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
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking the function render_staff_grade_form, this is where it all ends up, this is where we would need to implement the teams filtering.

if not staff_workflows:
return None

Expand Down
2 changes: 1 addition & 1 deletion openassessment/xblock/staff_area_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down