def set_score(submission_uuid, points_earned, points_possible,<EOL>annotation_creator=None, annotation_type=None, annotation_reason=None):
try:<EOL><INDENT>submission_model = _get_submission_model(submission_uuid)<EOL><DEDENT>except Submission.DoesNotExist:<EOL><INDENT>raise SubmissionNotFoundError(<EOL>u"<STR_LIT>".format(submission_uuid)<EOL>)<EOL><DEDENT>except DatabaseError:<EOL><INDENT>error_msg = u"<STR_LIT>".format(<EOL>submission_uuid<EOL>)<EOL>logger.exception(error_msg)<EOL>raise SubmissionRequestError(msg=error_msg)<EOL><DEDENT>score = ScoreSerializer(<EOL>data={<EOL>"<STR_LIT>": submission_model.student_item.pk,<EOL>"<STR_LIT>": submission_model.pk,<EOL>"<STR_LIT>": points_earned,<EOL>"<STR_LIT>": points_possible,<EOL>}<EOL>)<EOL>if not score.is_valid():<EOL><INDENT>logger.exception(score.errors)<EOL>raise SubmissionInternalError(score.errors)<EOL><DEDENT>try:<EOL><INDENT>score_model = score.save()<EOL>_log_score(score_model)<EOL>if annotation_creator is not None:<EOL><INDENT>score_annotation = ScoreAnnotation(<EOL>score=score_model,<EOL>creator=annotation_creator,<EOL>annotation_type=annotation_type,<EOL>reason=annotation_reason<EOL>)<EOL>score_annotation.save()<EOL><DEDENT>score_set.send(<EOL>sender=None,<EOL>points_possible=points_possible,<EOL>points_earned=points_earned,<EOL>anonymous_user_id=submission_model.student_item.student_id,<EOL>course_id=submission_model.student_item.course_id,<EOL>item_id=submission_model.student_item.item_id,<EOL>created_at=score_model.created_at,<EOL>)<EOL><DEDENT>except IntegrityError:<EOL><INDENT>pass<EOL><DEDENT>
Set a score for a particular submission.

    Sets the score for a particular submission. This score is calculated
    externally to the API.

    Args:
        submission_uuid (str): UUID for the submission (must exist).
        points_earned (int): The earned points for this submission.
        points_possible (int): The total points possible for this particular student item.

        annotation_creator (str): An optional field for recording who gave this particular score
        annotation_type (str): An optional field for recording what type of annotation should be created,
                                e.g. "staff_override".
        annotation_reason (str): An optional field for recording why this score was set to its value.

    Returns:
        None

    Raises:
        SubmissionInternalError: Thrown if there was an internal error while
            attempting to save the score.
        SubmissionRequestError: Thrown if the given student item or submission
            are not found.

    Examples:
        >>> set_score("a778b933-9fb3-11e3-9c0f-040ccee02800", 11, 12)
        {
            'student_item': 2,
            'submission': 1,
            'points_earned': 11,
            'points_possible': 12,
            'created_at': datetime.datetime(2014, 2, 7, 20, 6, 42, 331156, tzinfo=<UTC>)
        }