Example #1
0
 def test_generate_response_xml(self):
     '''
     Should generate response XML.
     '''
     response = OutcomeResponse()
     response.process_xml(self.response_xml)
     self.assertEqual(response.generate_response_xml(), self.response_xml)
def grade_passback():
    outcome_request = OutcomeRequest.from_post_request(request)
    sourcedid = outcome_request.lis_result_sourcedid
    consumer = ToolConsumer('test', 'secret')

    print "outcomes service url triggered"
    #    if consumer.is_valid_request(request):
    if True:

        # TODO: Check oauth timestamp
        # TODO: Check oauth nonce

        response = OutcomeResponse()
        response.message_ref_identifier = outcome_request.message_identifier
        response.operation = outcome_request.operation
        response.code_major = 'success'
        response.severity = 'status'

        if outcome_request.is_replace_request():
            response.description = 'Your old score of 0 has been replaced with %s' % (
                outcome_request.score)
            global outcome
            outcome = outcome_request.score
        elif outcome_request.is_read_request():
            response.description = 'Your score is 50'
            response.score = 50
        elif outcome_request.is_delete_request():
            response.description = 'Your score has been cleared'
        else:
            response.code_major = 'unsupported'
            response.severity = 'status'
            response.description = '%s is not supported' % (
                outcome_request.operation)
        return response.generate_response_xml()
    else:
        throw_oauth_error()