首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LTI期望来自工具使用者的请求正文

LTI期望来自工具使用者的请求正文
EN

Stack Overflow用户
提问于 2021-06-03 17:03:39
回答 1查看 53关注 0票数 0

我正在使用react和Django框架来构建一个LTI - LMS工具使用者,我的工具提供者是一个均值堆栈项目,在使用者端,请求体的代码如下所示。

代码语言:javascript
复制
<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="yoga@teachedison.com"
  /><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>

在工具提供商方面,我尝试将成绩发回,如下所示:

代码语言:javascript
复制
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);
    }
}

所以我在工具提供者那端得到了一个错误,说未定义

{错误消息:未定义}

是不是我在请求体中遗漏了什么,或者来自工具使用者端的无效数据?

EN

回答 1

Stack Overflow用户

发布于 2021-07-29 03:13:03

从您的问题中,我不能确定您要填充到'options‘对象中的是什么,但是您必须确保您正在设置

  • 消费者密钥
  • 消费者机密
  • 服务Url
  • source_id

lis_result_sourcedid对于resource_link_id / user_id的每一种组合都是唯一的,但它的值可能会在每次发布时发生变化。工具提供商(TP)应仅为特定resource_link_id / user_id保留此字段的最新值。

代码语言:javascript
复制
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);
  })
 };

有关POX有效负载的其他文档和示例,您可以查看针对grade passback services.的Canvas API实现指南

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67818504

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档