RusticiSoftware / TinCanPHP

PHP library for the Experience API (Tin Can API)
http://rusticisoftware.github.io/TinCanPHP/
Apache License 2.0
87 stars 79 forks source link

SubStatements - possible inconsistency with specification #78

Closed GrantBailey closed 8 years ago

GrantBailey commented 8 years ago

This comment refers to the passage within the xAPI specification which refers to SubStatements (at https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#substatements).

According to the specification, a SubStatement MUST NOT have the "id", "stored", "version" or "authority" properties. The example given in the specification is consistent with this requirement, however, the Tin Can API appears to require an ID property. Omitting the ID property throws the error 'Activity ID 'null' is not an absolute URI'.

Example code which is consistent with the specification but throws an error in the PHP API:

$id = guidv4(generateRandomString()); $actor = new TinCan\Agent ( [ 'objectType' => 'Agent', 'name' => 'John Example', 'mbox' => 'mailto:john@example.com' ] ); $verb = new TinCan\Verb( [ 'id' => 'http://adlnet.gov/expapi/verbs/attempted', 'display' => ['en-US' => 'attempted'] ] ); $activity = new TinCan\Activity ( [ 'objectType' => 'SubStatement', 'actor' => [ 'objectType' => 'Agent', 'mbox' => 'mailto:test@example.com' ], 'verb' => [ 'id' => 'http://example.com/visited', 'display' => [ 'en-US' => 'will visit' ] ], 'object' => [ 'objectType' => 'Activity', 'id' => 'http://example.com/website', 'definition' => [ 'name' => [ 'en-US' => 'Some awesome website' ] ] ] ] );

Inserting an Activity ID into the above code resolves the error.

garemoko commented 8 years ago

Hey @GrantBailey!

You're confusing statement id with activity id. Activities always have to have an activity id wherever they are used.

Andrew

brianjmiller commented 8 years ago

+1 to what @garemoko said. You are passing the properties of a SubStatement to TinCan\Activity, so it is likely just ignoring the ones it doesn't recognize (so all of them). You would need to create a SubStatement with new TinCan\SubStatement(...).

GrantBailey commented 8 years ago

Andrew, Brian: Many thanks indeed for your clarifications.