Fetching statements from Learning Locker LRS using TinCan API

江枫思渺然 提交于 2019-12-23 21:14:48

问题


I am trying to execute queries on statements stored in Learning Locker via PHP and TinCanPHP API. Going by this answer, I was able to fetch a response from Learning Locker. Here is a part of the response:

TinCan\LRSResponse Object
(
    [success] => 1
    [content] => TinCan\StatementsResult Object
        (
            [statements:protected] => Array
                (
                    [0] => TinCan\Statement Object
                        (
                            [id:protected] => 9ea9e6b6-8278-4545-a02c-c46113f3ba30
                            [stored:protected] => 2016-02-28T12:04:01.670600+00:00
                            [authority:protected] => TinCan\Agent Object
                                (
                                    [objectType:protected] => Agent
                                    [name:protected] => New Client
                                    [mbox:protected] => mailto:hello@learninglocker.net
                                    [mbox_sha1sum:protected] => 
                                    [openid:protected] => 
                                    [account:protected] => 
                                )

                            [version:protected] => 1.0.0
                            [attachments:protected] => Array
                                (
                                )

                            [actor:protected] => TinCan\Agent Object
                                (
                                    [objectType:protected] => Agent
                                    [name:protected] => Subhayan Roy
                                    [mbox:protected] => mailto:subhayanroy5@gmail.com
                                    [mbox_sha1sum:protected] => 
                                    [openid:protected] => 
                                    [account:protected] => 
                                )

                            [verb:protected] => TinCan\Verb Object
                                (
                                    [id:protected] => http://activitystrea.ms/schema/1.0/search
                                    [display:protected] => TinCan\LanguageMap Object
                                        (
                                            [_map:protected] => Array
                                                (
                                                    [en-US] => Searched
                                                )

                                        )

                                )

The list of statements returned has permission protected, so I'm not being able to access them. How do I access the statements? What am I missing here?


回答1:


You need to use the methods built into the library. In this case the one you want is getStatements.

$statementResult->content->getStatements();

See the documentation here: http://rusticisoftware.github.io/TinCanPHP/doc/api/latest/classes/TinCan.StatementsResult.html#method_getStatements

To answer the question which you will ask next (Why aren't I getting all statements returned in the result?), Take a look at the Statement Result getMore method which gives you the more URL and the Remote LRS moreStatements method which accepts a more URL and fetches the next batch of statements. See this code sample: https://github.com/garemoko/TinBadgesPHP/blob/b8789042f4af23f0f7927596e8e7f2a06655db72/TinBadges/RemoteLRS.php#L84-L96



来源:https://stackoverflow.com/questions/35693090/fetching-statements-from-learning-locker-lrs-using-tincan-api

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