How to execute a query on tin-can statements?

佐手、 提交于 2019-12-01 07:41:34

问题


I am using Learning Locker (Learning Record Store). I succeed inserting statements to it via the REST API. But I did not succeed fetching statements from it. How do I preform a query on statements? REST API?


回答1:


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;
    }



回答2:


If it's via javascript you can use the ADL xAPI Wrapper. It simplifies communication with an LRS... https://github.com/adlnet/xAPIWrapper#get-statements

In general you do a GET request on endpoint /statements... try just that first and see if you get a json response with a "statements" and a "more" property. Then if that works, you can narrow down results with filters. See the spec for the details and options. https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#stmtapiget

try that curl command.. it should return a statement result albeit from the ADL LRS...

curl --user tom:1234 GET https://lrs.adlnet.gov/xapi/statements



来源:https://stackoverflow.com/questions/26528322/how-to-execute-a-query-on-tin-can-statements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!