LTI expected request body from the tool consumer

374 Views Asked by At

I am using react with Django framework to build a LTI - LMS tool consumer, and my tool provider is a MEAN stack project, at the consumer side the code for the request body is something like this.

<form
  action="https://https://2569bae4ae0f.ngrok.io/lti/problem/58dca6ea802b38713d41e46a"
  method="POST"
  target="_blank"
  class=""
>
  <input
    type="hidden"
    name="lti_message_type"
    value="basic-lti-launch-request"
  /><input type="hidden" name="lti_version" value="LTI-1p0" /><input
    type="hidden"
    name="resource_link_id"
    value="78"
  /><input type="hidden" name="lis_person_name_full" value="Yoganandan" /><input
    type="hidden"
    name="lis_person_contact_email_primary"
    value="[email protected]"
  /><input type="hidden" name="roles" value="Learner" /><input
    type="hidden"
    name="launch_presentation_return_url"
    value="http://yoganandan.lvh.me:3000/error/lti?error=lti"
  /><input type="hidden" name="lis_result_sourcedid" value="143" /><input
    type="hidden"
    name="lis_outcome_service_url"
    value="http://fd74c8c9e31b.ngrok.io"
  /><input
    type="hidden"
    name="oauth_nonce"
    value="120035684498606871101622702599"
  /><input type="hidden" name="oauth_timestamp" value="1622702599" /><input
    type="hidden"
    name="oauth_version"
    value="1.0"
  /><input
    type="hidden"
    name="oauth_signature_method"
    value="HMAC-SHA1"
  /><input type="hidden" name="oauth_consumer_key" value="teDrqXuV" /><input
    type="hidden"
    name="oauth_signature"
    value="+8/kEGMVadv7ORCAzhM08tS9sRQ="
  /><button type="submit" class="btn btn-primary">
    Click here to View in New Tab
  </button>
</form>

And in the tool provider side I am trying to send back the grades doing something like this:-

import * as lti from 'ims-lti';
var outcomes_service = new lti.OutcomeService(options);
                            outcomes_service.send_replace_result(grade, (err, result) => {
    if (err) {
          console.log(err)
          reject(err);
    }
}

so I am getting an error at the tool provider side saying undefined

{ [Error] message: undefined }

Is there something I am missing in the request body or any invalid data from the tool consumer side ?

1

There are 1 best solutions below

0
On

I'm not sure from your question what you are populating into the 'options' object, however you must make sure you are setting

  • Consumer Key
  • Consumer Secret
  • The Service Url
  • The source_id

The lis_result_sourcedid is unique for every combination of resource_link_id / user_id but its value may change from one launch to the next. The Tool Provider (TP) should only retain the most recent value for this field for a particular resource_link_id / user_id.

var send_outcomes = function(endpoint,sourced_id) {
var options = {};

  options.consumer_key=consumer_key;
  options.consumer_secret=consumer_secret;
  options.service_url=endpoint;
  options.source_did=sourced_id;

  var outcomes_service = new lti.OutcomeService(options);

  outcomes_service.send_replace_result(.5, function(err,result) {
    console.log(result); //True or false
    return Boolean(result);
  })
 };

For additional documentation and examples of the POX payloads, you can look at the Canvas API implementation guide for the grade passback services.