Skip to content

Commit

Permalink
fix: style and some test and docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nandodev-net committed Oct 25, 2023
1 parent b347841 commit 57e41da
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lms/djangoapps/ora_staff_grader/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Query params
PARAM_ORA_LOCATION = "oraLocation"
PARAM_SUBMISSION_ID = "submissionUUID"
PARAM_ASSESSMENT_TYPE = "assessmentType"
PARAM_ASSESSMENT_FILTER = "assessmentFilter"

# Error codes
ERR_UNKNOWN = "ERR_UNKNOWN"
Expand Down
7 changes: 4 additions & 3 deletions lms/djangoapps/ora_staff_grader/ora_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
These are checked (usually by checking for a {"success":false} response) and raise errors, possibly with extra context.
"""
import json
from http import HTTPStatus
from lms.djangoapps.ora_staff_grader.errors import (
LockContestedError,
XBlockInternalError,
Expand All @@ -33,12 +34,12 @@ def get_submissions(request, usage_id):
return json.loads(response.content)


def get_assessments(request, usage_id, submission_uuid, assessment_type):
def get_assessments(request, usage_id, submission_uuid, assessment_filter):
"""
Get a list of assessments from the ORA's 'list_assessments_grades' XBlock.json_handler
"""
handler_name = "list_assessments"
body = {"item_id": usage_id, "submission_uuid": submission_uuid, "assessment_type": assessment_type}
body = {"item_id": usage_id, "submission_uuid": submission_uuid, "assessment_filter": assessment_filter}

response = call_xblock_json_handler(request, usage_id, handler_name, body)

Expand Down Expand Up @@ -183,5 +184,5 @@ def batch_delete_submission_locks(request, usage_id, submission_uuids):
response = call_xblock_json_handler(request, usage_id, handler_name, body)

# Errors should raise a blanket exception. Otherwise body is empty, 200 is implicit success
if response.status_code != 200:
if response.status_code != HTTPStatus.OK:
raise XBlockInternalError(context={"handler": handler_name})
12 changes: 7 additions & 5 deletions lms/djangoapps/ora_staff_grader/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ class Meta:

class AssessmentScoresSerializer(serializers.Serializer):
"""
Assessment Score for displaying assessment table in Enhanced Staff Grader (ESG)
Score information associated with a specific assessment.
This serializer was intended for displaying assessment information in the Enhanced Staff Grader (ESG).
"""
criterion_name = serializers.CharField()
score_earned = serializers.IntegerField()
Expand All @@ -184,9 +186,9 @@ class Meta:

class AssessmentSerializer(serializers.Serializer):
"""
Assessment metadata for displaying assessment table in Enhanced Staff Grader (ESG)
Data for displaying Assessment objects in a table in Enhanced Staff Grader (ESG)
"""
id_assessment = serializers.CharField()
assessment_id = serializers.CharField()
scorer_name = serializers.CharField(allow_null=True)
scorer_username = serializers.CharField(allow_null=True)
scorer_email = serializers.CharField(allow_null=True)
Expand All @@ -197,7 +199,7 @@ class AssessmentSerializer(serializers.Serializer):

class Meta:
fields = [
"id_assessment",
"assessment_id",
"scorer_name",
"scorer_username",
"scorer_email",
Expand Down Expand Up @@ -236,7 +238,7 @@ def get_isEnabled(self, obj):

class AssessmentFeedbackSerializer(serializers.Serializer):
"""
Serialize info for the initialize call. Packages ORA, course, submission, and rubric data.
Serialize info for every assessment for a table in Enhanced Staff Grader (ESG)
"""

assessments = serializers.ListField(child=AssessmentSerializer())
Expand Down
20 changes: 10 additions & 10 deletions lms/djangoapps/ora_staff_grader/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ class TestSubmissionMetadataSerializer(TestCase):
"submissionUuid": "a",
"username": "foo",
"teamName": "",
'email': None,
'fullname': None,
'email': "[email protected]",
'fullname': "",
"dateSubmitted": "1969-07-16 13:32:00",
"dateGraded": "None",
"gradedBy": "",
Expand All @@ -251,8 +251,8 @@ class TestSubmissionMetadataSerializer(TestCase):
"b": {
"submissionUuid": "b",
"username": "",
'email': None,
'fullname': None,
'email': "[email protected]",
'fullname': "Jhon Does",
"teamName": "bar",
"dateSubmitted": "1969-07-20 20:17:40",
"dateGraded": "None",
Expand All @@ -264,8 +264,8 @@ class TestSubmissionMetadataSerializer(TestCase):
"c": {
"submissionUuid": "c",
"username": "baz",
'email': None,
'fullname': None,
'email': "[email protected]",
'fullname': "Jhon Does",
"teamName": "",
"dateSubmitted": "1969-07-21 21:35:00",
"dateGraded": "1969-07-24 16:44:00",
Expand Down Expand Up @@ -297,8 +297,8 @@ def test_empty_score(self):
submission = {
"submissionUuid": "empty-score",
"username": "WOPR",
'email': None,
'fullname': None,
'email': "[email protected]",
'fullname': "",
"dateSubmitted": "1983-06-03 00:00:00",
"dateGraded": None,
"gradedBy": None,
Expand All @@ -310,8 +310,8 @@ def test_empty_score(self):
expected_output = {
"submissionUUID": "empty-score",
"username": "WOPR",
'email': None,
'fullname': None,
'email': "[email protected]",
'fullname': "",
"teamName": None,
"dateSubmitted": "1983-06-03 00:00:00",
"dateGraded": None,
Expand Down
22 changes: 11 additions & 11 deletions lms/djangoapps/ora_staff_grader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from lms.djangoapps.ora_staff_grader.constants import (
PARAM_ORA_LOCATION,
PARAM_SUBMISSION_ID,
PARAM_ASSESSMENT_TYPE,
PARAM_ASSESSMENT_FILTER,
)
from lms.djangoapps.ora_staff_grader.errors import (
BadOraLocationResponse,
Expand Down Expand Up @@ -152,13 +152,10 @@ def get(self, request, ora_location, *args, **kwargs):

class AssessmentFeedbackView(StaffGraderBaseView):
"""
GET course metadata
GET data about Assessments by submission_uuid and ora_location
Response: {
courseMetadata
oraMetadata
submissions
isEnabled
assessments
}
Errors:
Expand All @@ -168,19 +165,22 @@ class AssessmentFeedbackView(StaffGraderBaseView):
- UnknownError (HTTP 500) for other errors
"""

@require_params([PARAM_ORA_LOCATION, PARAM_SUBMISSION_ID, PARAM_ASSESSMENT_TYPE])
def get(self, request, ora_location, submission_uuid, assessment_type=None, *args, **kwargs):
@require_params([PARAM_ORA_LOCATION, PARAM_SUBMISSION_ID, PARAM_ASSESSMENT_FILTER])
def get(self, request, ora_location, submission_uuid, assessment_filter=None, *args, **kwargs):

try:
assessments_data = {}

# Get list of submissions for this ORA
assessments_data["assessments"] = get_assessments(request, ora_location, submission_uuid, assessment_type)
assessments_data["assessments"] = get_assessments(request, ora_location, submission_uuid, assessment_filter)

response_data = AssessmentFeedbackSerializer(assessments_data).data
log.info(response_data)
return Response(response_data)

# Catch bad ORA location
except (InvalidKeyError, ItemNotFoundError):
log.error(f"Bad ORA location provided: {ora_location}")
return BadOraLocationResponse()

# Issues with the XBlock handlers
except XBlockInternalError as ex:
log.error(ex)
Expand Down

0 comments on commit 57e41da

Please sign in to comment.