Commit 714708d8 by Diana Huang

fixup! TNL-3714, adding backend support for staff scoring

parent 634d3b97
...@@ -21,7 +21,6 @@ from submissions import api as sub_api ...@@ -21,7 +21,6 @@ from submissions import api as sub_api
logger = logging.getLogger("openassessment.assessment.api.staff") logger = logging.getLogger("openassessment.assessment.api.staff")
STAFF_TYPE = "ST" STAFF_TYPE = "ST"
...@@ -55,7 +54,7 @@ def assessment_is_finished(submission_uuid, requirements): ...@@ -55,7 +54,7 @@ def assessment_is_finished(submission_uuid, requirements):
""" """
if requirements and requirements.get('staff', {}).get('required', False): if requirements and requirements.get('staff', {}).get('required', False):
return bool(get_latest_assessment(submission_uuid)) return bool(get_latest_staff_assessment(submission_uuid))
return True return True
...@@ -74,7 +73,7 @@ def get_score(submission_uuid, requirements): ...@@ -74,7 +73,7 @@ def get_score(submission_uuid, requirements):
contributing_assessments, and staff_id information. contributing_assessments, and staff_id information.
""" """
assessment = get_latest_assessment(submission_uuid) assessment = get_latest_staff_assessment(submission_uuid)
if not assessment: if not assessment:
return None return None
...@@ -86,7 +85,7 @@ def get_score(submission_uuid, requirements): ...@@ -86,7 +85,7 @@ def get_score(submission_uuid, requirements):
} }
def get_latest_assessment(submission_uuid): def get_latest_staff_assessment(submission_uuid):
""" """
Retrieve the latest staff assessment for a submission. Retrieve the latest staff assessment for a submission.
...@@ -102,7 +101,7 @@ def get_latest_assessment(submission_uuid): ...@@ -102,7 +101,7 @@ def get_latest_assessment(submission_uuid):
Example usage: Example usage:
>>> get_latest_assessment('10df7db776686822e501b05f452dc1e4b9141fe5') >>> get_latest_staff_assessment('10df7db776686822e501b05f452dc1e4b9141fe5')
{ {
'points_earned': 6, 'points_earned': 6,
'points_possible': 12, 'points_possible': 12,
...@@ -132,7 +131,7 @@ def get_latest_assessment(submission_uuid): ...@@ -132,7 +131,7 @@ def get_latest_assessment(submission_uuid):
def get_assessment_scores_by_criteria(submission_uuid): def get_assessment_scores_by_criteria(submission_uuid):
"""Get the score for each rubric criterion """Get the staff score for each rubric criterion
Args: Args:
submission_uuid (str): The submission uuid is used to get the submission_uuid (str): The submission uuid is used to get the
...@@ -221,13 +220,13 @@ def create_assessment( ...@@ -221,13 +220,13 @@ def create_assessment(
return full_assessment_dict(assessment) return full_assessment_dict(assessment)
except InvalidRubric: except InvalidRubric:
msg = u"Rubric definition was not valid" error_message = u"Rubric definition was not valid"
logger.exception(msg) logger.exception(error_message)
raise StaffAssessmentRequestError(msg) raise StaffAssessmentRequestError(error_message)
except InvalidRubricSelection: except InvalidRubricSelection:
msg = u"Invalid options selected in the rubric" error_message = u"Invalid options selected in the rubric"
logger.warning(msg, exc_info=True) logger.warning(error_message, exc_info=True)
raise StaffAssessmentRequestError(msg) raise StaffAssessmentRequestError(error_message)
except DatabaseError: except DatabaseError:
error_message = ( error_message = (
u"An error occurred while creating assessment by scorer with ID: {}" u"An error occurred while creating assessment by scorer with ID: {}"
...@@ -251,11 +250,10 @@ def _complete_assessment( ...@@ -251,11 +250,10 @@ def _complete_assessment(
in a single transaction. in a single transaction.
Args: Args:
rubric_dict (dict): The rubric model associated with this assessment
scorer_id (str): The user ID for the user giving this assessment. This
is required to create an assessment on a submission.
submission_uuid (str): The submission uuid for the submission being submission_uuid (str): The submission uuid for the submission being
assessed. assessed.
scorer_id (str): The user ID for the user giving this assessment. This
is required to create an assessment on a submission.
options_selected (dict): Dictionary mapping criterion names to the options_selected (dict): Dictionary mapping criterion names to the
option names the user selected for that criterion. option names the user selected for that criterion.
criterion_feedback (dict): Dictionary mapping criterion names to the criterion_feedback (dict): Dictionary mapping criterion names to the
...@@ -263,6 +261,7 @@ def _complete_assessment( ...@@ -263,6 +261,7 @@ def _complete_assessment(
Since criterion feedback is optional, some criteria may not appear Since criterion feedback is optional, some criteria may not appear
in the dictionary. in the dictionary.
overall_feedback (unicode): Free-form text feedback on the submission overall. overall_feedback (unicode): Free-form text feedback on the submission overall.
rubric_dict (dict): The rubric model associated with this assessment
scored_at (datetime): Optional argument to override the time in which scored_at (datetime): Optional argument to override the time in which
the assessment took place. If not specified, scored_at is set to the assessment took place. If not specified, scored_at is set to
now. now.
......
...@@ -260,7 +260,7 @@ class TestStaffOverwrite(CacheResetTest): ...@@ -260,7 +260,7 @@ class TestStaffOverwrite(CacheResetTest):
# Try to get the latest staff assessment, handle database errors # Try to get the latest staff assessment, handle database errors
with self.assertRaises(StaffAssessmentInternalError) as context_manager: with self.assertRaises(StaffAssessmentInternalError) as context_manager:
staff_api.get_latest_assessment(tim_sub["uuid"]) staff_api.get_latest_staff_assessment(tim_sub["uuid"])
self.assertEqual( self.assertEqual(
str(context_manager.exception), str(context_manager.exception),
( (
......
...@@ -377,7 +377,7 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel): ...@@ -377,7 +377,7 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
""" """
Set a staff score for the workflow. Set a staff score for the workflow.
Allows for staff scores to bet set on a submission, with annotations to provide an audit trail if needed. Allows for staff scores to be set on a submission, with annotations to provide an audit trail if needed.
This method can be used for both required staff grading, and staff overrides. This method can be used for both required staff grading, and staff overrides.
Args: Args:
......
...@@ -42,7 +42,7 @@ class TestStaffAssessment(StaffAssessmentTestBase): ...@@ -42,7 +42,7 @@ class TestStaffAssessment(StaffAssessmentTestBase):
self.assertTrue(resp['success']) self.assertTrue(resp['success'])
# Expect that a staff-assessment was created # Expect that a staff-assessment was created
assessment = staff_api.get_latest_assessment(submission['uuid']) assessment = staff_api.get_latest_staff_assessment(submission['uuid'])
self.assertEqual(assessment['submission_uuid'], submission['uuid']) self.assertEqual(assessment['submission_uuid'], submission['uuid'])
self.assertEqual(assessment['points_earned'], 5) self.assertEqual(assessment['points_earned'], 5)
self.assertEqual(assessment['points_possible'], 6) self.assertEqual(assessment['points_possible'], 6)
...@@ -67,7 +67,7 @@ class TestStaffAssessment(StaffAssessmentTestBase): ...@@ -67,7 +67,7 @@ class TestStaffAssessment(StaffAssessmentTestBase):
self.assertEqual(assessment['points_possible'], score['points_possible']) self.assertEqual(assessment['points_possible'], score['points_possible'])
@scenario('data/self_assessment_scenario.xml', user_id='Bob') @scenario('data/self_assessment_scenario.xml', user_id='Bob')
def test_staff_assess_permission_error(self, xblock): def test_permission_error(self, xblock):
# Create a submission for the student # Create a submission for the student
student_item = xblock.get_student_item_dict() student_item = xblock.get_student_item_dict()
xblock.create_submission(student_item, self.SUBMISSION) xblock.create_submission(student_item, self.SUBMISSION)
...@@ -75,7 +75,7 @@ class TestStaffAssessment(StaffAssessmentTestBase): ...@@ -75,7 +75,7 @@ class TestStaffAssessment(StaffAssessmentTestBase):
self.assertIn("You do not have permission", resp) self.assertIn("You do not have permission", resp)
@scenario('data/self_assessment_scenario.xml', user_id='Bob') @scenario('data/self_assessment_scenario.xml', user_id='Bob')
def test_staff_assess_invalid_options(self, xblock): def test_invalid_options(self, xblock):
student_item = xblock.get_student_item_dict() student_item = xblock.get_student_item_dict()
# Create a submission for the student # Create a submission for the student
...@@ -92,7 +92,7 @@ class TestStaffAssessment(StaffAssessmentTestBase): ...@@ -92,7 +92,7 @@ class TestStaffAssessment(StaffAssessmentTestBase):
self.assertIn('msg', resp) self.assertIn('msg', resp)
@scenario('data/self_assessment_scenario.xml', user_id='bob') @scenario('data/self_assessment_scenario.xml', user_id='bob')
def test_staff_assess_assessment_error(self, xblock): def test_assessment_error(self, xblock):
student_item = xblock.get_student_item_dict() student_item = xblock.get_student_item_dict()
# Create a submission for the student # Create a submission for the student
...@@ -115,7 +115,7 @@ class TestStaffAssessment(StaffAssessmentTestBase): ...@@ -115,7 +115,7 @@ class TestStaffAssessment(StaffAssessmentTestBase):
class TestStaffAssessmentRender(StaffAssessmentTestBase): class TestStaffAssessmentRender(StaffAssessmentTestBase):
#TODO: test success when staff assessment template exists # TODO: test success when staff assessment template exists
@scenario('data/self_assessment_scenario.xml', user_id='Bob') @scenario('data/self_assessment_scenario.xml', user_id='Bob')
def test_render_staff_assessment_permission_error(self, xblock): def test_render_staff_assessment_permission_error(self, xblock):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment