lms.djangoapps.ora_staff_grader package

Contents

lms.djangoapps.ora_staff_grader package#

Subpackages#

Submodules#

lms.djangoapps.ora_staff_grader.constants module#

Constants used throughout ESG

lms.djangoapps.ora_staff_grader.errors module#

Error codes and exceptions for ESG

class lms.djangoapps.ora_staff_grader.errors.BadOraLocationResponse(context=None)#

Bases: StaffGraderErrorResponse

Error response for when the requested ORA_LOCATION could not be found in a course. Returns an HTTP 400 with error code.

err_code = 'ERR_BAD_ORA_LOCATION'#
status = 400#
class lms.djangoapps.ora_staff_grader.errors.ErrorSerializer(*args, **kwargs)#

Bases: Serializer

Returns error code and unpacks additional context, returns unknown error code if not supplied

to_representation(instance)#

Override to unpack context alongside error code

exception lms.djangoapps.ora_staff_grader.errors.ExceptionWithContext(context=None)#

Bases: Exception

An exception with optional context dict to be supplied in serialized result

class lms.djangoapps.ora_staff_grader.errors.GradeContestedResponse(context=None)#

Bases: StaffGraderErrorResponse

Error response for when a user tries to operate on a submission that they do not have a lock for. Returns an HTTP 409 with error code and updated submission status.

err_code = 'ERR_GRADE_CONTESTED'#
status = 409#
class lms.djangoapps.ora_staff_grader.errors.InternalErrorResponse(context=None)#

Bases: StaffGraderErrorResponse

Generic error response for an issue in an XBlock handler. Returns an HTTP 500 with internal error code.

err_code = 'ERR_INTERNAL'#
status = 500#
exception lms.djangoapps.ora_staff_grader.errors.LockContestedError(context=None)#

Bases: ExceptionWithContext

Signal for trying to operate on a lock owned by someone else

class lms.djangoapps.ora_staff_grader.errors.LockContestedResponse(context=None)#

Bases: StaffGraderErrorResponse

Error response for when a user tries to operate on a submission that they do not have a lock for. Returns an HTTP 409 with error code and updated lock status.

err_code = 'ERR_LOCK_CONTESTED'#
status = 409#
class lms.djangoapps.ora_staff_grader.errors.MissingParamResponse(context=None)#

Bases: StaffGraderErrorResponse

Error response for when a request is missing a required param/body. Returns an HTTP 400 with error code.

err_code = 'ERR_MISSING_PARAM'#
status = 400#
class lms.djangoapps.ora_staff_grader.errors.StaffGraderErrorResponse(context=None)#

Bases: Response

An HTTP error response that returns serialized error data with additional provided context

err_code = 'ERR_UNKNOWN'#
status = 500#
class lms.djangoapps.ora_staff_grader.errors.UnknownErrorResponse(context=None)#

Bases: StaffGraderErrorResponse

Blanket exception for when something strange breaks Returns an HTTP 500 with generic error code.

err_code = 'ERR_UNKNOWN'#
status = 500#
exception lms.djangoapps.ora_staff_grader.errors.XBlockInternalError(context=None)#

Bases: ExceptionWithContext

Errors from XBlock handlers

lms.djangoapps.ora_staff_grader.ora_api module#

Functions used for interacting with ORA

All XBlock handlers are wrapped to return: - Data, on success - Exception, on failure

Some XBlock handlers natively return error codes for errors. These are caught by status code and raise XBlockInternalError by convention.

Other handlers return status OK even for an error, but contain error info in the returned payload. These are checked (usually by checking for a {“success”:false} response) and raise errors, possibly with extra context.

lms.djangoapps.ora_staff_grader.ora_api.batch_delete_submission_locks(request, usage_id, submission_uuids)#

Batch delete a list of submission locks. Limited only to those in the list the user owns.

Returns: none

lms.djangoapps.ora_staff_grader.ora_api.check_submission_lock(request, usage_id, submission_uuid)#

Look up lock info for the given submission by calling the ORA’s ‘check_submission_lock’ XBlock.json_handler

lms.djangoapps.ora_staff_grader.ora_api.claim_submission_lock(request, usage_id, submission_uuid)#

Attempt to claim a submission lock for grading.

Returns: - lockStatus (string) - One of [‘not-locked’, ‘locked’, ‘in-progress’]

lms.djangoapps.ora_staff_grader.ora_api.delete_submission_lock(request, usage_id, submission_uuid)#

Attempt to claim a submission lock for grading.

Returns: - lockStatus (string) - One of [‘not-locked’, ‘locked’, ‘in-progress’]

lms.djangoapps.ora_staff_grader.ora_api.get_assessment_info(request, usage_id, submission_uuid)#

Get assessment data from ORA ‘get_assessment_info’ XBlock.json_handler

lms.djangoapps.ora_staff_grader.ora_api.get_assessments(request: Request, usage_id: str, handler_name: str, submission_uuid: str)#

Get a list of assessments according to the handler name from ORA XBlock.json_handler

  • list_assessments_to handler

    Lists all assessments given by a user (according to their submissionUUID) in an ORA assignment. Assessments can be Self, Peer and Staff.

  • list_assessments_from handler

    Lists all assessments received by a user (according to their submissionUUID) in an ORA assignment. Assessments can be Self, Peer and Staff.

Parameters:
  • request (Request) – The request object.

  • usage_id (str) – Usage ID of the XBlock for running the handler

  • handler_name (str) – The name of the handler to call

  • submission_uuid (str) – The ORA submission UUID

lms.djangoapps.ora_staff_grader.ora_api.get_submission_info(request, usage_id, submission_uuid)#

Get submission content from ORA ‘get_submission_info’ XBlock.json_handler

lms.djangoapps.ora_staff_grader.ora_api.get_submissions(request, usage_id)#

Get a list of submissions from the ORA’s ‘list_staff_workflows’ XBlock.json_handler

lms.djangoapps.ora_staff_grader.ora_api.submit_grade(request, usage_id, grade_data)#

Submit a grade for an assessment.

Returns: {‘success’: True/False, ‘msg’: err_msg}

lms.djangoapps.ora_staff_grader.serializers module#

Serializers for Enhanced Staff Grader (ESG)

class lms.djangoapps.ora_staff_grader.serializers.AssessmentCriteriaSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for information about a criterion, in the context of a completed assessment

class lms.djangoapps.ora_staff_grader.serializers.AssessmentFeedbackSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a list of assessments for the response from the assessments feedback endpoints (from/to) in Enhanced Staff Grader (ESG)

class Meta#

Bases: object

fields = ['assessments']#
read_only_fields = ['assessments']#
class lms.djangoapps.ora_staff_grader.serializers.AssessmentScoresSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for score information associated with a specific assessment.

This serializer is included in the AssessmentSerializer as a ListField

class Meta#

Bases: object

fields = ['criterion_name', 'score_earned', 'score_type']#
read_only_fields = ['criterion_name', 'score_earned', 'score_type']#
class lms.djangoapps.ora_staff_grader.serializers.AssessmentSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for the each assessment metadata in the response from the assessments feedback endpoints (from/to) in Enhanced Staff Grader (ESG)

This serializer is included in the AssessmentFeedbackSerializer as a ListField

class Meta#

Bases: object

fields = ['assessment_id', 'scorer_name', 'scorer_username', 'scorer_email', 'assessment_date', 'assessment_scores', 'problem_step', 'feedback']#
read_only_fields = ['assessment_id', 'scorer_name', 'scorer_username', 'scorer_email', 'assessment_date', 'assessment_scores', 'problem_step', 'feedback']#
class lms.djangoapps.ora_staff_grader.serializers.CourseMetadataSerializer(*args, **kwargs)#

Bases: Serializer

Serialize top-level info about a course, used for creating header in ESG

class Meta#

Bases: object

fields = ['title', 'org', 'number', 'courseId']#
model#

alias of CourseOverview

read_only_fields = ['title', 'org', 'number', 'courseId']#
class lms.djangoapps.ora_staff_grader.serializers.FileListSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a list of files in a submission

class lms.djangoapps.ora_staff_grader.serializers.GradeDataSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for the gradeData api construct, which represents a completed staff assessment

class lms.djangoapps.ora_staff_grader.serializers.GradeStatusField(*args, **kwargs)#

Bases: ChoiceField

Field that can have the values [‘graded’ ‘ungraded’]

class lms.djangoapps.ora_staff_grader.serializers.InitializeSerializer(*args, **kwargs)#

Bases: Serializer

Serialize info for the initialize call. Packages ORA, course, submission, and rubric data.

class Meta#

Bases: object

fields = ['courseMetadata', 'oraMetadata', 'submissions', 'isEnabled']#
read_only_fields = ['courseMetadata', 'oraMetadata', 'submissions', 'isEnabled']#
get_isEnabled(obj)#

Only enable ESG if the flag is enabled and also this is not a Team ORA Revert back to BooleanField in AU-617 when ESG officially supports team ORAs

class lms.djangoapps.ora_staff_grader.serializers.LockStatusField(*args, **kwargs)#

Bases: ChoiceField

Field that can have the values [‘unlocked’, ‘locked’, ‘in-progress’]

class lms.djangoapps.ora_staff_grader.serializers.LockStatusSerializer(*args, **kwargs)#

Bases: Serializer

Info about the status of a submission lock, with extra metadata stripped out.

class Meta#

Bases: object

fields = ['lockStatus']#
read_only_fields = ['lockStatus']#
class lms.djangoapps.ora_staff_grader.serializers.OpenResponseMetadataSerializer(*args, **kwargs)#

Bases: Serializer

Serialize ORA metadata, used for setting up views in ESG

class Meta#

Bases: object

fields = ['name', 'prompts', 'type', 'textResponseConfig', 'textResponseEditor', 'fileUploadResponseConfig', 'rubricConfig']#
read_only_fields = ['name', 'prompts', 'type', 'textResponseConfig', 'textResponseEditor', 'fileUploadResponseConfig', 'rubricConfig']#
get_fileUploadResponseConfig(instance)#
get_textResponseConfig(instance)#
get_type(instance)#
class lms.djangoapps.ora_staff_grader.serializers.ResponseSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for the responseData api construct, which represents the contents of a submitted learner response

class lms.djangoapps.ora_staff_grader.serializers.RubricConfigSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for rubric config

class lms.djangoapps.ora_staff_grader.serializers.RubricCriterionOptionsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for selectable options in a rubric criterion

class lms.djangoapps.ora_staff_grader.serializers.RubricCriterionSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for individual criteria in a rubric

class lms.djangoapps.ora_staff_grader.serializers.ScoreField(*args, **kwargs)#

Bases: Field

Returns None if score is not given for a submission

to_representation(value)#

Transform the outgoing native value into primitive data.

class lms.djangoapps.ora_staff_grader.serializers.ScoreSerializer(*args, **kwargs)#

Bases: Serializer

Score (points earned/possible) for use in SubmissionMetadataSerializer

class lms.djangoapps.ora_staff_grader.serializers.StaffAssessSerializer(*args, **kwargs)#

Bases: Serializer

Converts grade data to the format used for doing staff assessments

From: {

“overallFeedback”: “was pretty good”, “criteria”: [

{

“name”: “<criterion_name_1>”, “feedback”: (string), “selectedOption”: <selected_option_name>

}

]

}

To: {
‘options_selected’: {

‘<criterion_name_1>’: <selected_option_name>, ‘<criterion_name_2>’: <selected_option_name>,

}, ‘criterion_feedback’: {

‘<criterion_label_1>’: (string)

}, ‘overall_feedback’: (string) ‘submission_uuid’: (string) ‘assess_type’: (string) one of [‘regrade’, full-grade’]

}

get_criterion_feedback(instance)#
get_options_selected(instance)#
get_submission_uuid(instance)#
requires_context = True#
class lms.djangoapps.ora_staff_grader.serializers.SubmissionFetchSerializer(*args, **kwargs)#

Bases: SubmissionStatusFetchSerializer

Serializer for the response from the submission fetch endpoint Same as the SubmissionStatusFetchSerializer with an added submission_info field

class lms.djangoapps.ora_staff_grader.serializers.SubmissionMetadataSerializer(*args, **kwargs)#

Bases: Serializer

Submission metadata for displaying submissions table in Enhanced Staff Grader (ESG)

class Meta#

Bases: object

fields = ['submissionUUID', 'username', 'teamName', 'dateSubmitted', 'dateGraded', 'gradedBy', 'gradeStatus', 'lockStatus', 'score', 'email', 'fullname']#
read_only_fields = ['submissionUUID', 'username', 'teamName', 'dateSubmitted', 'dateGraded', 'gradedBy', 'gradeStatus', 'lockStatus', 'score', 'email', 'fullname']#
class lms.djangoapps.ora_staff_grader.serializers.SubmissionStatusFetchSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for the response from the submission status fetch endpoint

get_gradeStatus(obj)#
class lms.djangoapps.ora_staff_grader.serializers.UploadedFileSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a file uploaded as a part of a response

get_download_url(obj)#

Get the representation for SerializerMethodField downloadUrl

lms.djangoapps.ora_staff_grader.urls module#

URLs for Enhanced Staff Grader (ESG) backend-for-frontend (BFF)

lms.djangoapps.ora_staff_grader.utils module#

Various helpful utilities for ESG

lms.djangoapps.ora_staff_grader.utils.call_xblock_json_handler(request, usage_id, handler_name, data, auth=False)#

WARN: Tested only for use in ESG. Consult before use outside of ESG.

Create an internally-routed XBlock.json_handler request. The internal auth code/param unpacking requires a POST request with payload in the body. Ideally, we would be able to call functions on XBlocks without this sort of hacky request proxying but this is what we have to work with right now.

params:

request (HttpRequest): Originating web request, we’re going to borrow auth headers/cookies from this usage_id (str): Usage ID of the XBlock for running the handler handler_name (str): the name of the XBlock handler method data (dict): Data to be encoded and sent as the body of the POST request

Returns:

get response data with json.loads(response.content)

Return type:

response (HttpResponse)

lms.djangoapps.ora_staff_grader.utils.is_json(input_string)#

Quick True/False check to see if a value is JSON

lms.djangoapps.ora_staff_grader.utils.require_params(param_names)#

Adds the required query params to the view function. Returns 404 if param(s) missing.

Params: - param_name (string): the query param to unpack

Raises: - MissingParamResponse (HTTP 400)

lms.djangoapps.ora_staff_grader.views module#

Views for Enhanced Staff Grader

class lms.djangoapps.ora_staff_grader.views.AssessmentFeedbackView(**kwargs)#

Bases: StaffGraderBaseView, ViewSet

View for fetching assessment feedback for a submission.

Methods

  • (GET) api/ora_staff_grader/assessments/feedback/from

    List all assessments received by a user (according to their submissionUUID) in an ORA assignment.

  • (GET) api/ora_staff_grader/assessments/feedback/to

    List all assessments given by a user (according to their submissionUUID) in an ORA assignment.

Query Params:

  • oraLocation (str): ORA location for XBlock handling

  • submissionUUID (str): The ORA submission UUID

Response:

{
assessments (List[dict]): [
{

“assessment_id: (str) Assessment id “scorer_name: (str) Scorer name “scorer_username: (str) Scorer username “scorer_email: (str) Scorer email “assessment_date: (str) Assessment date “assessment_scores (List[dict]) [

{

“criterion_name: (str) Criterion name “score_earned: (int) Score earned “score_type: (str) Score type

}

] “problem_step (str) Problem step (Self, Peer, or Staff) “feedback: (str) Feedback of the assessment

}

]

}

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

basename = None#
description = None#
detail = None#
get_from(request: Request, ora_location: str, submission_uuid: str, *args, **kwargs)#
get_to(request: Request, ora_location: str, submission_uuid: str, *args, **kwargs)#
name = None#
suffix = None#
class lms.djangoapps.ora_staff_grader.views.InitializeView(**kwargs)#

Bases: 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

get(request, ora_location, *args, **kwargs)#
class lms.djangoapps.ora_staff_grader.views.StaffGraderBaseView(**kwargs)#

Bases: RetrieveAPIView

Base view for common auth/permission setup used across ESG views.

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
class lms.djangoapps.ora_staff_grader.views.SubmissionBatchUnlockView(**kwargs)#

Bases: StaffGraderBaseView

POST delete a group of submission locks, limited to just those in the list that the user owns.

Params: - ora_location (str/UsageID): ORA location for XBlock handling

Body: - submissionUUIDs (UUID): A list of submission/team submission UUIDS to lock/unlock

Response: None

Errors: - MissingParamResponse (HTTP 400) for missing params - XBlockInternalError (HTTP 500) for an issue within ORA

post(request, ora_location, *args, **kwargs)#

Batch delete submission locks

class lms.djangoapps.ora_staff_grader.views.SubmissionFetchView(**kwargs)#

Bases: StaffGraderBaseView

GET submission contents and assessment info, if any

Response: {
gradeData: {
score: (dict or None) {

pointsEarned: (int) earned points pointsPossible: (int) possible points

} overallFeedback: (string) overall feedback criteria: (list of dict) [{

name: (str) name of criterion feedback: (str) feedback for criterion points: (int) points of selected option or None if feedback-only criterion selectedOption: (str) name of selected option or None if feedback-only criterion

}]

} response: {

text: (list of string), [the html content of text responses] files: (list of dict) [{

downloadUrl: (string) file download url description: (string) file description name: (string) filename

}]

}

}

Errors: - MissingParamResponse (HTTP 400) for missing params - XBlockInternalError (HTTP 500) for an issue with ORA - UnknownError (HTTP 500) for other errors

get(request, ora_location, submission_uuid, *args, **kwargs)#
class lms.djangoapps.ora_staff_grader.views.SubmissionFilesFetchView(**kwargs)#

Bases: StaffGraderBaseView

GET file metadata for a submission.

Used to get updated file download links to avoid signed download link expiration issues.

Response: {
files: [

downloadUrl (url), description (string), name (string), size (bytes),

]

}

Errors: - MissingParamResponse (HTTP 400) for missing params - XBlockInternalError (HTTP 500) for an issue with ORA - UnknownError (HTTP 500) for other errors

get(request, ora_location, submission_uuid, *args, **kwargs)#
class lms.djangoapps.ora_staff_grader.views.SubmissionLockView(**kwargs)#

Bases: StaffGraderBaseView

POST claim a submission lock for grading DELETE release a submission lock

Params: - ora_location (str/UsageID): ORA location for XBlock handling - submissionUUID (UUID): A submission to lock/unlock

Response: {

lockStatus

}

Errors: - MissingParamResponse (HTTP 400) for missing params - LockContestedResponse (HTTP 409) for contested lock - XBlockInternalError (HTTP 500) for an issue with ORA - UnknownError (HTTP 500) for other errors

delete(request, ora_location, submission_uuid, *args, **kwargs)#

Clear a submission lock

post(request, ora_location, submission_uuid, *args, **kwargs)#

Claim a submission lock

class lms.djangoapps.ora_staff_grader.views.SubmissionStatusFetchView(**kwargs)#

Bases: StaffGraderBaseView

GET submission grade status, lock status, and grade data

Response: {

gradeStatus: (str) one of [graded, ungraded] lockStatus: (str) one of [locked, unlocked, in-progress] gradeData: {

score: (dict or None) {

pointsEarned: (int) earned points pointsPossible: (int) possible points

} overallFeedback: (string) overall feedback criteria: (list of dict) [{

name: (str) name of criterion feedback: (str) feedback for criterion points: (int) points of selected option or None if feedback-only criterion selectedOption: (str) name of selected option or None if feedback-only criterion

}]

}

}

Errors: - MissingParamResponse (HTTP 400) for missing params - XBlockInternalError (HTTP 500) for an issue with ORA - UnknownError (HTTP 500) for other errors

get(request, ora_location, submission_uuid, *args, **kwargs)#
class lms.djangoapps.ora_staff_grader.views.UpdateGradeView(**kwargs)#

Bases: StaffGraderBaseView

POST submit a grade for a submission

Body: {

overallFeedback: (string) overall feedback criteria: [

{

name: (string) name of criterion feedback: (string, optional) feedback for criterion selectedOption: (string) name of selected option or None if feedback-only criterion

}, … (one per criteria)

]

}

Response: {

gradeStatus: (string) - One of [‘graded’, ‘ungraded’] lockStatus: (string) - One of [‘unlocked’, ‘locked’, ‘in-progress’] gradeData: {

score: (dict or None) {

pointsEarned: (int) earned points pointsPossible: (int) possible points

} overallFeedback: (string) overall feedback criteria: (list of dict) [{

name: (str) name of criterion feedback: (str) feedback for criterion selectedOption: (str) name of selected option or None if feedback-only criterion

}]

}

}

Errors: - MissingParamResponse (HTTP 400) for missing params - GradeContestedResponse (HTTP 409) for trying to submit a grade for a submission you don’t have an active lock for - XBlockInternalError (HTTP 500) for an issue with ORA - UnknownError (HTTP 500) for other errors

post(request, ora_location, submission_uuid, *args, **kwargs)#

Update a grade

Module contents#

App for Enhanced Staff Grader (ESG) backend-for-frontend (BFF)