我正在使用Learning Locker(学习记录存储)。 我成功通过REST API向它插入语句。 但我没有成功从中获取陈述。 如何在语句上执行查询? REST API?
答案 0 :(得分:2)
I used tinCanPhp library.
this is how you establish a connection with the learning-Locker database and query it in PHP
for example:
$lrs = new TinCan\RemoteLRS(
'endpoint/public/data/xAPI/',
'1.0.1',
'username',
'key'
);
$actor = new TinCan\Agent(
[ 'mbox' => 'mailto:dikla@gmail.com' ]
);
$verb = new TinCan\Verb(
[ 'id' => 'http://adlnet.gov/expapi/verbs/progressed' ]
);
$activity = new TinCan\Activity(
[ 'id' => 'http://game.t-shirt' ]
);
$statement = new TinCan\Statement(
[
'actor' => $actor,
'verb' => $verb,
'object' => $activity,
]
);
//get All Actor activity by his unique id
function getAllActorActivity($actorUri){
global $lrs;
$actor = new TinCan\Agent(
[ 'mbox' => $actorUri ]//actorUri should look like this 'mailto:dikla@gmail.com'
);
$answer=$lrs->queryStatements(['agent' => $actor]);
return $answer;
}
答案 1 :(得分:1)
如果是通过javascript,您可以使用ADL xAPI Wrapper。它简化了与LRS的通信...... https://github.com/adlnet/xAPIWrapper#get-statements
通常,您在端点/语句上执行GET请求...首先尝试,然后查看是否获得带有“语句”和“更多”属性的json响应。然后,如果可行,您可以使用过滤器缩小结果范围。有关详细信息和选项,请参阅规范。 https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#stmtapiget
尝试使用curl命令..它应该返回一个语句结果,尽管来自ADL LRS ......
curl --user tom:1234 GET https://lrs.adlnet.gov/xapi/statements