简体   繁体   English

如何通过代理通过 javascript 查询 LRS

[英]How to query LRS by agent via javascript

I feel like I've tried everything, but I keep coming up short.我觉得我已经尝试了一切,但我一直在做空。 I am working on a course in Storyline 360, and I am able to return statements just fine when using verbs and object IDs, but no matter what I do to try and return statements for a specific Agent, I cannot get a query to go through.我正在编写 Storyline 360 中的一门课程,并且在使用动词和 object ID 时,我能够很好地返回语句,但无论我如何尝试返回特定代理的语句,我都无法通过 go .

Here's my code as it stands now - where I do return plenty of statements...what I need to know is how to have it query the current learner's statements for matches.这是我现在的代码 - 我确实返回了大量的语句......我需要知道的是如何让它查询当前学习者的语句以进行匹配。 I'm able to pull in their name or mbox, but trying to pass those through in my params fails on me every time.我可以输入他们的名字或 mbox,但是每次尝试在我的参数中传递它们都失败了。

Any help is very much appreciated!很感谢任何形式的帮助!

var lrs;
var statementFound = false;
var player = GetPlayer();
try {
    lrs = new TinCan.LRS(
        {
            endpoint: "https://cloud.scorm.com/lrs/MYINFO/",
            username: "MYINFO",
            password: "MYINFO",
            allowFail: false
        }
    );
}
catch (ex) {
    console.log("Failed to setup LRS object: ", ex);
    // TODO: do something with error, can't communicate with LRS
};

var myObj = JSON.parse(getParameterByName('actor'));
lrs.queryStatements(
    {
        params: {
            verb: new TinCan.Verb(
                { 
                   id:  "http://adlnet.gov/expapi/verbs/answered"
                }
            )
    },
        callback: function (err, sr) {
            if (err !== null) {
                console.log("Failed to query statements: " + err);
                // TODO: do something with error, didn't get statements
                return;
             }

            if (sr.more !== null) {
                // TODO: additional page(s) of statements should be fetched
             }

           if (sr.statements.length > 0) {
            statementFound = true;
             console.log(sr.statements);
             player.SetVar("sf",statementFound);
            }
        }
    }
);

var myObj is able to pull in the necessary info to ID the learner if needed - but again, I just can't figure out how to get it passed in the query. var myObj 能够在需要时提取必要的信息来识别学习者 - 但同样,我只是不知道如何在查询中传递它。

You need to set an agent property in the params object passed in the first argument.您需要在第一个参数中传递的params object 中设置agent属性。 Assuming the Agent is the actor in statements.假设代理是语句中的actor

lrs.queryStatements(
    {
        params: {
            agent: TinCan.Agent.fromJSON(getParameterByName('actor'))
        }
    },
    ...
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM