'Handler function for LTI 2.0 JSON/REST result service.
See http://www.imsglobal.org/lti/ltiv2p0/uml/purl.imsglobal.org/vocab/lis/v2/outcomes/Result/service.html
An example JSON object:
"@context" : "http://purl.imsglobal.org/ctx/lis/v2/Result",
"@type" : "Result",
"resultScore" : 0.83,
"comment" : "This is exceptional work."
For PUTs, the content type must be "application/vnd.ims.lis.v2.result+json".
We use the "suffix" parameter to parse out the user from the end of the URL.  An example endpoint url is
http://localhost:8000/courses/org/num/run/xblock/i4x:;_;_org;_num;_lti;_GUID/handler_noauth/lti_2_0_result_rest_handler/user/<anon_id>
so suffix is of the form "user/<anon_id>"
Failures result in 401, 404, or 500s without any body.  Successes result in 200.  Again see
http://www.imsglobal.org/lti/ltiv2p0/uml/purl.imsglobal.org/vocab/lis/v2/outcomes/Result/service.html
(Note: this prevents good debug messages for the client, so we might want to change this, or the spec)
Arguments:
request (xblock.django.request.DjangoWebobRequest):  Request object for current HTTP request
suffix (unicode):  request path after "lti_2_0_result_rest_handler/".  expected to be "user/<anon_id>"
Returns:
webob.response:  response to this request.  See above for details.'

@XBlock.handler
def lti_2_0_result_rest_handler(self, request, suffix):

    if self.system.debug:
        self._log_correct_authorization_header(request)
    if ((not self.accept_grades_past_due) and self.is_past_due()):
        return Response(status=404)
    try:
        anon_id = self.parse_lti_2_0_handler_suffix(suffix)
    except LTIError:
        return Response(status=404)
    try:
        self.verify_lti_2_0_result_rest_headers(request, verify_content_type=True)
    except LTIError:
        return Response(status=401)
    real_user = self.system.get_real_user(anon_id)
    if (not real_user):
        msg = '[LTI]:    Real    user    not    found    against    anon_id:    {}'.format(anon_id)
        log.info(msg)
        return Response(status=404)
    if (request.method == 'PUT'):
        return self._lti_2_0_result_put_handler(request, real_user)
    elif (request.method == 'GET'):
        return self._lti_2_0_result_get_handler(request, real_user)
    elif (request.method == 'DELETE'):
        return self._lti_2_0_result_del_handler(request, real_user)
    else:
        return Response(status=404)
