Ejemplo n.º 1
0
    def post(self, request, ora_location, *args, **kwargs):
        """Batch delete submission locks"""
        try:
            # Validate ORA location
            UsageKey.from_string(ora_location)

            # Pull submission UUIDs list from request body
            submission_uuids = request.data.get('submissionUUIDs')
            if not isinstance(submission_uuids, list):
                return MissingParamResponse()
            batch_delete_submission_locks(request, ora_location, submission_uuids)

            # Return empty response
            return Response({})

        # 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)
            return InternalErrorResponse(context=ex.context)

        # Blanket exception handling
        except Exception as ex:
            log.exception(ex)
            return UnknownErrorResponse()
Ejemplo n.º 2
0
    def delete(self, request, ora_location, submission_uuid, *args, **kwargs):
        """Clear a submission lock"""
        try:
            # Validate ORA location
            UsageKey.from_string(ora_location)
            lock_info = delete_submission_lock(request, ora_location, submission_uuid)

            response_data = LockStatusSerializer(lock_info).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()

        # Return updated lock info on error
        except LockContestedError:
            lock_info = check_submission_lock(request, ora_location, submission_uuid)
            lock_status = LockStatusSerializer(lock_info).data
            return LockContestedResponse(context=lock_status)

        # 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()
Ejemplo n.º 3
0
    def get(self, request, ora_location, submission_uuid, *args, **kwargs):
        try:
            assessment_info = get_assessment_info(
                request, ora_location, submission_uuid
            )
            lock_info = check_submission_lock(request, ora_location, submission_uuid)

            response_data = SubmissionStatusFetchSerializer(
                {
                    "assessment_info": assessment_info,
                    "lock_info": lock_info,
                }
            ).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()
Ejemplo n.º 4
0
    def get(self, request, ora_location, *args, **kwargs):
        try:
            init_data = {}

            # Get ORA block and config (incl. rubric)
            ora_usage_key = UsageKey.from_string(ora_location)
            init_data["oraMetadata"] = modulestore().get_item(ora_usage_key)

            # Get course metadata
            course_id = str(ora_usage_key.course_key)
            init_data["courseMetadata"] = get_course_overview_or_none(
                course_id)

            # Get list of submissions for this ORA
            init_data["submissions"] = get_submissions(request, ora_location)

            response_data = InitializeSerializer(init_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)
            return InternalErrorResponse(context=ex.context)

        # Blanket exception handling in case something blows up
        except Exception as ex:
            log.exception(ex)
            return UnknownErrorResponse()
Ejemplo n.º 5
0
    def post(self, request, ora_location, submission_uuid, *args, **kwargs):
        """Update a grade"""
        try:
            # Reassert that we have ownership of the submission lock
            lock_info = check_submission_lock(request, ora_location,
                                              submission_uuid)
            if not lock_info.get("lock_status") == "in-progress":
                assessment_info = get_assessment_info(request, ora_location,
                                                      submission_uuid)
                submission_status = SubmissionStatusFetchSerializer({
                    "assessment_info":
                    assessment_info,
                    "lock_info":
                    lock_info,
                }).data
                log.error(f"Grade contested for submission: {submission_uuid}")
                return GradeContestedResponse(context=submission_status)

            # Transform grade data and submit assessment, rasies on failure
            context = {"submission_uuid": submission_uuid}
            grade_data = StaffAssessSerializer(request.data,
                                               context=context).data
            submit_grade(request, ora_location, grade_data)

            # Clear the lock on the graded submission
            delete_submission_lock(request, ora_location, submission_uuid)

            # Return submission status info to frontend
            assessment_info = get_assessment_info(request, ora_location,
                                                  submission_uuid)
            lock_info = check_submission_lock(request, ora_location,
                                              submission_uuid)
            response_data = SubmissionStatusFetchSerializer({
                "assessment_info":
                assessment_info,
                "lock_info":
                lock_info,
            }).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()
Ejemplo n.º 6
0
    def get(self, request, ora_location, submission_uuid, *args, **kwargs):
        try:
            submission_info = get_submission_info(request, ora_location,
                                                  submission_uuid)

            response_data = FileListSerializer(submission_info).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()