php-xapi / client解析getStatements方法对象

时间:2018-04-11 14:14:53

标签: php tin-can-api

我使用php-xapi / client库来获取存储在LRS中的所有语句。

代码:

$results = $statementsApiClient->getStatements();

文件链接:

https://github.com/php-xapi/client/blob/master/doc/statements.md

它返回StatementResult对象。但是我无法访问它的私有财产。他们的文件中没有提到任何内容。

以下是输出:

Xabbuh\XApi\Model\StatementResult Object
(
    [statements:Xabbuh\XApi\Model\StatementResult:private] => Array
        (
            [0] => Xabbuh\XApi\Model\Statement Object
                (
                    [id:Xabbuh\XApi\Model\Statement:private] => Xabbuh\XApi\Model\StatementId Object
                        (
                            [uuid:Xabbuh\XApi\Model\StatementId:private] => Rhumsaa\Uuid\Uuid Object
                                (
                                    [fields:protected] => Array
                                        (
                                            [time_low] => e994a27f
                                            [time_mid] => cbfe
                                            [time_hi_and_version] => 4272
                                            [clock_seq_hi_and_reserved] => bf
                                            [clock_seq_low] => d7
                                            [node] => 147d334723b3
                                        )

                                )

                        )

                    [verb:Xabbuh\XApi\Model\Statement:private] => Xabbuh\XApi\Model\Verb Object
                        (
                            [id:Xabbuh\XApi\Model\Verb:private] => Xabbuh\XApi\Model\IRI Object
                                (
                                    [value:Xabbuh\XApi\Model\IRI:private] => http://adlnet.gov/expapi/verbs/experienced
                                )

                            [display:Xabbuh\XApi\Model\Verb:private] => Xabbuh\XApi\Model\LanguageMap Object
                                (
                                    [map:Xabbuh\XApi\Model\LanguageMap:private] => Array
                                        (
                                            [en-US] => experienced
                                        )

                                )

                        )

                    [actor:Xabbuh\XApi\Model\Statement:private] => Xabbuh\XApi\Model\Agent Object
                        (
                            [iri:Xabbuh\XApi\Model\Actor:private] => Xabbuh\XApi\Model\InverseFunctionalIdentifier Object
                                (
                                    [mbox:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => Xabbuh\XApi\Model\IRI Object
                                        (
                                            [value:Xabbuh\XApi\Model\IRI:private] => mailto:cwaghmare@xento.com
                                        )

                                    [mboxSha1Sum:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => 
                                    [openId:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => 
                                    [account:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => 
                                )

                            [name:Xabbuh\XApi\Model\Actor:private] => Chinmay
                        )

                    [object:Xabbuh\XApi\Model\Statement:private] => Xabbuh\XApi\Model\Activity Object
                        (
                            [id:Xabbuh\XApi\Model\Activity:private] => Xabbuh\XApi\Model\IRI Object
                                (
                                    [value:Xabbuh\XApi\Model\IRI:private] => http:///68DFljpCPci
                                )

                            [definition:Xabbuh\XApi\Model\Activity:private] => Xabbuh\XApi\Model\Definition Object
                                (
                                    [name:Xabbuh\XApi\Model\Definition:private] => Xabbuh\XApi\Model\LanguageMap Object
                                        (
                                            [map:Xabbuh\XApi\Model\LanguageMap:private] => Array
                                                (
                                                    [und] => Video Slide 1
                                                )

                                        )

                                    [description:Xabbuh\XApi\Model\Definition:private] => Xabbuh\XApi\Model\LanguageMap Object
                                        (
                                            [map:Xabbuh\XApi\Model\LanguageMap:private] => Array
                                                (
                                                    [und] => Video Slide 1
                                                )

                                        )

                                    [type:Xabbuh\XApi\Model\Definition:private] => Xabbuh\XApi\Model\IRI Object
                                        (
                                            [value:Xabbuh\XApi\Model\IRI:private] => http://adlnet.gov/expapi/activities/module
                                        )

                                    [moreInfo:Xabbuh\XApi\Model\Definition:private] => 
                                    [extensions:Xabbuh\XApi\Model\Definition:private] => 
                                )

                        )

                    [result:Xabbuh\XApi\Model\Statement:private] => 
                    [authority:Xabbuh\XApi\Model\Statement:private] => Xabbuh\XApi\Model\Agent Object
                        (
                            [iri:Xabbuh\XApi\Model\Actor:private] => Xabbuh\XApi\Model\InverseFunctionalIdentifier Object
                                (
                                    [mbox:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => Xabbuh\XApi\Model\IRI Object
                                        (
                                            [value:Xabbuh\XApi\Model\IRI:private] => mailto:hello@learninglocker.net
                                        )

                                    [mboxSha1Sum:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => 
                                    [openId:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => 
                                    [account:Xabbuh\XApi\Model\InverseFunctionalIdentifier:private] => 
                                )

                            [name:Xabbuh\XApi\Model\Actor:private] => New Client
                        )

                    [created:Xabbuh\XApi\Model\Statement:private] => DateTime Object
                        (
                            [date] => 2018-04-11 06:46:15.231000
                            [timezone_type] => 2
                            [timezone] => Z
                        )

                    [stored:Xabbuh\XApi\Model\Statement:private] => DateTime Object
                        (
                            [date] => 2018-04-11 06:46:14.746000
                            [timezone_type] => 2
                            [timezone] => Z
                        )

                    [context:Xabbuh\XApi\Model\Statement:private] => Xabbuh\XApi\Model\Context Object
                        (
                            [registration:Xabbuh\XApi\Model\Context:private] => 
                            [instructor:Xabbuh\XApi\Model\Context:private] => 
                            [team:Xabbuh\XApi\Model\Context:private] => 
                            [contextActivities:Xabbuh\XApi\Model\Context:private] => Xabbuh\XApi\Model\ContextActivities Object
                                (
                                    [parentActivities:Xabbuh\XApi\Model\ContextActivities:private] => Array
                                        (
                                            [0] => Xabbuh\XApi\Model\Activity Object
                                                (
                                                    [id:Xabbuh\XApi\Model\Activity:private] => Xabbuh\XApi\Model\IRI Object
                                                        (
                                                            [value:Xabbuh\XApi\Model\IRI:private] => http://
                                                        )

                                                    [definition:Xabbuh\XApi\Model\Activity:private] => 
                                                )

                                        )

                                    [groupingActivities:Xabbuh\XApi\Model\ContextActivities:private] => Array
                                        (
                                            [0] => Xabbuh\XApi\Model\Activity Object
                                                (
                                                    [id:Xabbuh\XApi\Model\Activity:private] => Xabbuh\XApi\Model\IRI Object
                                                        (
                                                            [value:Xabbuh\XApi\Model\IRI:private] => http://
                                                        )

                                                    [definition:Xabbuh\XApi\Model\Activity:private] => 
                                                )

                                        )

                                    [categoryActivities:Xabbuh\XApi\Model\ContextActivities:private] => 
                                    [otherActivities:Xabbuh\XApi\Model\ContextActivities:private] => 
                                )

                            [revision:Xabbuh\XApi\Model\Context:private] => 
                            [platform:Xabbuh\XApi\Model\Context:private] => 
                            [language:Xabbuh\XApi\Model\Context:private] => 
                            [statement:Xabbuh\XApi\Model\Context:private] => 
                            [extensions:Xabbuh\XApi\Model\Context:private] => 
                        )

                    [attachments:Xabbuh\XApi\Model\Statement:private] => 
                )
        )

    [moreUrlPath:Xabbuh\XApi\Model\StatementResult:private] => Xabbuh\XApi\Model\IRL Object
        (
            [value:Xabbuh\XApi\Model\IRL:private] => 
        )

)

如何访问上述StatementResult对象的Id,Actor和Verb属性?

任何帮助都会受到高度赞赏。

1 个答案:

答案 0 :(得分:1)

StatementResult对象不包含这些属性,它包含一个语句列表,其中每个对象将包含这些属性。您需要调用$statements = $results->getStatements();来检索Statement对象的数组,然后通过Statement类接口访问这些属性(id,actor等)。单个模型类在单独的仓库中定义,请参阅https://github.com/php-xapi/model/tree/master/src