Skip to content

Commit

Permalink
feat: generate_assessment_data handler created
Browse files Browse the repository at this point in the history
  • Loading branch information
nandodev-net committed Oct 18, 2023
1 parent 12b1c6b commit 9e852d2
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
1 change: 1 addition & 0 deletions lms/djangoapps/ora_staff_grader/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Query params
PARAM_ORA_LOCATION = "oraLocation"
PARAM_SUBMISSION_ID = "submissionUUID"
PARAM_ASSESSMENT_TYPE = "assessmentType"

# Error codes
ERR_UNKNOWN = "ERR_UNKNOWN"
Expand Down
15 changes: 15 additions & 0 deletions lms/djangoapps/ora_staff_grader/ora_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ def get_submissions(request, usage_id):
return json.loads(response.content)


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

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

if response.status_code != 200:
raise XBlockInternalError(context={"handler": handler_name})

return json.loads(response.content)


def get_submission_info(request, usage_id, submission_uuid):
"""
Get submission content from ORA 'get_submission_info' XBlock.json_handler
Expand Down
53 changes: 53 additions & 0 deletions lms/djangoapps/ora_staff_grader/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,49 @@ class Meta:
read_only_fields = fields


class AssessmentScoresMetadataSerializer(serializers.Serializer):
"""
Assessment Score metadata for displaying assessment table in ESG
"""
type = serializers.CharField()
score = serializers.IntegerField()
score_type = serializers.CharField()

class Meta:
fields = [
"type",
"score",
"score_type",
]
read_only_fields = fields


class AssessmentMetadataSerializer(serializers.Serializer):
"""
Assessment metadata for displaying assessment table in ESG
"""
idAssessment = serializers.CharField()
grader_name = serializers.CharField(allow_null=True)
grader_username = serializers.CharField(allow_null=True)
grader_email = serializers.CharField(allow_null=True)
assesmentDate = serializers.DateTimeField()
assesmentScores = serializers.ListField(child=AssessmentScoresMetadataSerializer())
problemStep = serializers.CharField(allow_null=True)
feedback = serializers.CharField(allow_null=True)

class Meta:
fields = [
"idAssessment",
"grader_name",
"grader_username",
"grader_email",
"assesmentDate",
"assesmentScores",
"problemStep",
"feedback",
]
read_only_fields = fields

class InitializeSerializer(serializers.Serializer):
"""
Serialize info for the initialize call. Packages ORA, course, submission, and rubric data.
Expand All @@ -191,6 +234,16 @@ def get_isEnabled(self, obj):
"""
return obj['isEnabled'] and not obj['oraMetadata'].teams_enabled

class FeedbackSerializer(serializers.Serializer):
"""
Serialize info for the initialize call. Packages ORA, course, submission, and rubric data.
"""

assessments = serializers.ListField(child=AssessmentMetadataSerializer())

class Meta:
fields = ["assessments",]
read_only_fields = fields

class UploadedFileSerializer(serializers.Serializer):
"""Serializer for a file uploaded as a part of a response"""
Expand Down
2 changes: 2 additions & 0 deletions lms/djangoapps/ora_staff_grader/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SubmissionLockView,
SubmissionStatusFetchView,
UpdateGradeView,
FeedbackListView,
)


Expand All @@ -22,6 +23,7 @@
urlpatterns += [
path("mock/", include("lms.djangoapps.ora_staff_grader.mock.urls")),
path("initialize", InitializeView.as_view(), name="initialize"),
path("feedbacklist", FeedbackListView.as_view(), name="feedbacklist"),
path("submission/batch/unlock", SubmissionBatchUnlockView.as_view(), name="batch-unlock"),
path("submission/files", SubmissionFilesFetchView.as_view(), name="fetch-files"),
path(
Expand Down
46 changes: 46 additions & 0 deletions lms/djangoapps/ora_staff_grader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from lms.djangoapps.ora_staff_grader.constants import (
PARAM_ORA_LOCATION,
PARAM_SUBMISSION_ID,
PARAM_ASSESSMENT_TYPE,
)
from lms.djangoapps.ora_staff_grader.errors import (
BadOraLocationResponse,
Expand All @@ -43,11 +44,13 @@
get_assessment_info,
get_submission_info,
get_submissions,
get_assessments_grades,
submit_grade,
)
from lms.djangoapps.ora_staff_grader.serializers import (
FileListSerializer,
InitializeSerializer,
FeedbackSerializer,
LockStatusSerializer,
StaffAssessSerializer,
SubmissionFetchSerializer,
Expand Down Expand Up @@ -147,6 +150,49 @@ def get(self, request, ora_location, *args, **kwargs):
return UnknownErrorResponse()


class FeedbackListView(StaffGraderBaseView):
"""
GET course metadata
Response: {
courseMetadata
oraMetadata
submissions
isEnabled
}
Errors:
- MissingParamResponse (HTTP 400) for missing params
- BadOraLocationResponse (HTTP 400) for bad ORA location
- XBlockInternalError (HTTP 500) for an issue with ORA
- 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):

try:
init_data = {}

# Get list of submissions for this ORA
init_data["assessments"] = get_assessments_grades(request, ora_location, submission_uuid, assessment_type)
#init_data["assessments"] = TEST

response_data = FeedbackSerializer(init_data).data
log.info(response_data)
return Response(response_data)

# Issues with the XBlock handlers
except XBlockInternalError as ex:
log.error(ex)
return InternalErrorResponse(context=ex.context)

# Blanket exception handling in case something blows up
except Exception as ex:
log.exception(ex)
return UnknownErrorResponse()


class SubmissionFetchView(StaffGraderBaseView):
"""
GET submission contents and assessment info, if any
Expand Down

0 comments on commit 9e852d2

Please sign in to comment.