我正在使用react和Django框架来构建一个LTI - LMS工具使用者,我的工具提供者是一个均值堆栈项目,在使用者端,请求体的代码如下所示。
<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>在工具提供商方面,我尝试将成绩发回,如下所示:
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);
}
}所以我在工具提供者那端得到了一个错误,说未定义
{错误消息:未定义}
是不是我在请求体中遗漏了什么,或者来自工具使用者端的无效数据?
发布于 2021-07-29 03:13:03
从您的问题中,我不能确定您要填充到'options‘对象中的是什么,但是您必须确保您正在设置
lis_result_sourcedid对于resource_link_id / user_id的每一种组合都是唯一的,但它的值可能会在每次发布时发生变化。工具提供商(TP)应仅为特定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);
})
};有关POX有效负载的其他文档和示例,您可以查看针对grade passback services.的Canvas API实现指南
https://stackoverflow.com/questions/67818504
复制相似问题