Skip to content

Commit

Permalink
Jkantor/flexible override (#1988)
Browse files Browse the repository at this point in the history
* feat: flexible peer grading course settings override

* fixup! feat: flexible peer grading course settings override

* test: add tests and fix a thing

* style: quality
  • Loading branch information
jansenk authored Jul 14, 2023
1 parent 1c79dee commit c2a59ee
Show file tree
Hide file tree
Showing 28 changed files with 328 additions and 127 deletions.
23 changes: 17 additions & 6 deletions openassessment/assessment/api/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@
FLEXIBLE_PEER_GRADING_GRADED_BY_PERCENTAGE = 30


def required_peer_grades(submission_uuid, peer_requirements):
def flexible_peer_grading_enabled(peer_requirements, course_settings):
"""
Is flexible peer grading turned on? Either at the course override
level or the block level?
"""
if course_settings.get('force_on_flexible_peer_openassessments'):
return True
return peer_requirements.get("enable_flexible_grading")


def required_peer_grades(submission_uuid, peer_requirements, course_settings):
"""
Given a submission id, finds how many peer assessment required.
Expand All @@ -45,7 +55,7 @@ def required_peer_grades(submission_uuid, peer_requirements):

must_grade = peer_requirements["must_be_graded_by"]

if peer_requirements.get("enable_flexible_grading"):
if flexible_peer_grading_enabled(peer_requirements, course_settings):

# find how many days elapsed since subimitted
days_elapsed = (timezone.now().date() - submission['submitted_at'].date()).days
Expand Down Expand Up @@ -125,7 +135,7 @@ def get_graded_by_count(submission_uuid):
return scored_items.count()


def assessment_is_finished(submission_uuid, peer_requirements):
def assessment_is_finished(submission_uuid, peer_requirements, course_settings):
"""
Check whether the submitter has received enough assessments
to get a score.
Expand All @@ -151,7 +161,7 @@ def assessment_is_finished(submission_uuid, peer_requirements):
if count is None:
return False

return count >= required_peer_grades(submission_uuid, peer_requirements)
return count >= required_peer_grades(submission_uuid, peer_requirements, course_settings)


def on_start(submission_uuid):
Expand Down Expand Up @@ -196,7 +206,7 @@ def on_start(submission_uuid):
raise PeerAssessmentInternalError(error_message) from ex


def get_score(submission_uuid, peer_requirements):
def get_score(submission_uuid, peer_requirements, course_settings):
"""
Retrieve a score for a submission if requirements have been satisfied.
Expand All @@ -205,6 +215,7 @@ def get_score(submission_uuid, peer_requirements):
requirements (dict): Dictionary with the key "must_be_graded_by"
indicating the required number of assessments the student
must receive to get a score.
course_settings (dict): Dictionary with course-level settings
Returns:
A dictionary with the points earned, points possible, and
Expand Down Expand Up @@ -232,7 +243,7 @@ def get_score(submission_uuid, peer_requirements):
).order_by('-assessment')

# Check if enough peers have graded this submission
num_required_peer_grades = required_peer_grades(submission_uuid, peer_requirements)
num_required_peer_grades = required_peer_grades(submission_uuid, peer_requirements, course_settings)
if items.count() < num_required_peer_grades:
return None

Expand Down
5 changes: 3 additions & 2 deletions openassessment/assessment/api/self.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def submitter_is_finished(submission_uuid, self_requirements): # pylint: disabl
).exists()


def assessment_is_finished(submission_uuid, self_requirements):
def assessment_is_finished(submission_uuid, self_requirements, _):
"""
Check whether a self-assessment has been completed. For self-assessment,
this function is synonymous with submitter_is_finished.
Expand All @@ -56,13 +56,14 @@ def assessment_is_finished(submission_uuid, self_requirements):
return submitter_is_finished(submission_uuid, self_requirements)


def get_score(submission_uuid, self_requirements): # pylint: disable=unused-argument
def get_score(submission_uuid, self_requirements, course_settings): # pylint: disable=unused-argument
"""
Get the score for this particular assessment.
Args:
submission_uuid (str): The unique identifier for the submission
self_requirements (dict): Not used.
course_settings (dict): Not used.
Returns:
A dictionary with the points earned, points possible, and
contributing_assessments information, along with a None staff_id.
Expand Down
5 changes: 3 additions & 2 deletions openassessment/assessment/api/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def submitter_is_finished(submission_uuid, staff_requirements): # pylint: disab
return True


def assessment_is_finished(submission_uuid, staff_requirements):
def assessment_is_finished(submission_uuid, staff_requirements, _):
"""
Determine if the staff assessment step of the given submission is completed.
This checks to see if staff have completed the assessment.
Expand Down Expand Up @@ -127,7 +127,7 @@ def on_cancel(submission_uuid):
raise StaffAssessmentInternalError(error_message) from ex


def get_score(submission_uuid, staff_requirements): # pylint: disable=unused-argument
def get_score(submission_uuid, staff_requirements, course_settings): # pylint: disable=unused-argument
"""
Generate a score based on a completed assessment for the given submission.
If no assessment has been completed for this submission, this will return
Expand All @@ -136,6 +136,7 @@ def get_score(submission_uuid, staff_requirements): # pylint: disable=unused-ar
Args:
submission_uuid (str): The UUID for the submission to get a score for.
staff_requirements (dict): Not used.
course_settings (dict): Not used.
Returns:
A dictionary with the points earned, points possible,
Expand Down
5 changes: 3 additions & 2 deletions openassessment/assessment/api/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def submitter_is_finished(team_submission_uuid, team_requirements): # pylint: d
return True


def assessment_is_finished(team_submission_uuid, staff_requirements):
def assessment_is_finished(team_submission_uuid, staff_requirements, _):
"""
Determine if the staff assessment step of the given team submission is completed.
This checks to see if staff have completed the assessment.
Expand Down Expand Up @@ -126,7 +126,7 @@ def on_cancel(team_submission_uuid):
raise StaffAssessmentInternalError(error_message) from ex


def get_score(team_submission_uuid, staff_requirements): # pylint: disable=unused-argument
def get_score(team_submission_uuid, staff_requirements, course_settings): # pylint: disable=unused-argument
"""
Generate a score based on a completed assessment for the given team submission.
If no assessment has been completed for this submission, this will return
Expand All @@ -135,6 +135,7 @@ def get_score(team_submission_uuid, staff_requirements): # pylint: disable=unus
Args:
team_submission_uuid (str): The UUID for the submission to get a score for.
staff_requirements (dict): Not used.
course_settings (dict): Not used.
Returns:
A dictionary with the points earned, points possible,
Expand Down
Loading

0 comments on commit c2a59ee

Please sign in to comment.