1

我很困惑如何使用 ims-lti 节点应用程序将成绩发送回 LMS。

我试图发送 json 和 xml,但它们都不适合我。

var aa = '<?xml version = "1.0" encoding = "UTF-8"?><imsx_POXEnvelopeRequest xmlns="'+req.body.lis_outcome_service_url+'">  <imsx_POXHeader>    <imsx_POXRequestHeaderInfo>      <imsx_version>V1.0</imsx_version>      <imsx_messageIdentifier>999999123</imsx_messageIdentifier>    </imsx_POXRequestHeaderInfo>  </imsx_POXHeader>  <imsx_POXBody>    <replaceResultRequest>      <resultRecord>        <sourcedGUID>          <sourcedId>3124567</sourcedId>        </sourcedGUID>        <result>          <resultScore>            <language>en</language>            <textString>0.92</textString>          </resultScore>          <!-- Added element -->          <resultData>            <text>text data for anvas submission</text>          </resultData>        </result>      </resultRecord>    </replaceResultRequest>  </imsx_POXBody></imsx_POXEnvelopeRequest>';
var request = require('request');
  request.post({
    headers: {'content-type' : 'application/x-www-form-urlencoded'},
    url:     req.body.lis_outcome_service_url,
    form:    {param1:aa}
  }, function(error, response, body){
  console.log(body);
});

当我运行它时,我收到 XML 形式的错误

<?xml version="1.0" encoding="UTF-8"?>
<imsx_POXEnvelopeResponse xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">
    <imsx_POXHeader>
        <imsx_POXResponseHeaderInfo>
            <imsx_version>V1.0</imsx_version>
            <imsx_messageIdentifier>1008098201</imsx_messageIdentifier>
            <imsx_statusInfo><imsx_codeMajor>failure</imsx_codeMajor>
            <imsx_severity>status</imsx_severity>
            <imsx_description>Missing or invalid consumer key or access token.</imsx_description>
        <imsx_messageRefIdentifier/>
        <imsx_operationRefIdentifier>unknownRequest</imsx_operationRefIdentifier>
    </imsx_statusInfo>
</imsx_POXResponseHeaderInfo>
</imsx_POXHeader>
<imsx_POXBody>
    <unknownResponse/>
</imsx_POXBody>
</imsx_POXEnvelopeResponse>

4

1 回答 1

0

我得到了答案。
- 我们可以使用 ims-lti 工具来创建 XML 并将其发送到 LMS 本身,而不是将完整的 XML 传递给 LMS。
- 首先我们必须创建提供者对象
- 调用结果服务将成绩发送回 LMS

var lti = require('ims-lti');
provider = new lti.Provider(public_key, private_key);
provider.valid_request(req, function(err, isValid) {

    if (isValid== true){
        // Pass the grades in the place of .5
        // Grades can be passed between 0.0 to 1.0
        provider.outcome_service.send_replace_result(.5, function(err, result){
            console.log(result);
        });
    }
}
于 2019-07-25T03:08:08.200 回答