How to execute a query on tin-can statements?

前端 未结 2 1860
独厮守ぢ
独厮守ぢ 2021-01-15 07:59

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 prefor

2条回答
  •  隐瞒了意图╮
    2021-01-15 08:32

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

提交回复
热议问题