/** * Fetches Statements from the LRS. This is used for completion tracking - we check for a statement matching certain criteria for each learner. * * @package mod_tincanlaunch * @category tincan * @param string $url LRS endpoint URL * @param string $basicLogin login/key for the LRS * @param string $basicPass pass/secret for the LRS * @param string $version version of xAPI to use * @param string $activityid Activity Id to filter by * @param TinCan Agent $agent Agent to filter by * @param string $verb Verb Id to filter by * @return TinCan LRS Response */ function tincanlaunch_get_statements($url, $basicLogin, $basicPass, $version, $activityid, $agent, $verb) { $lrs = new \TinCan\RemoteLRS($url, $version, $basicLogin, $basicPass); $statementsQuery = array("agent" => $agent, "verb" => new \TinCan\Verb(array("id" => trim($verb))), "activity" => new \TinCan\Activity(array("id" => trim($activityid))), "related_activities" => "false", "format" => "ids"); //Get all the statements from the LRS $statementsResponse = $lrs->queryStatements($statementsQuery); if ($statementsResponse->success == false) { return $statementsResponse; } $allTheStatements = $statementsResponse->content->getStatements(); $moreStatementsURL = $statementsResponse->content->getMore(); while (!is_null($moreStatementsURL)) { $moreStmtsResponse = $lrs->moreStatements($moreStatementsURL); if ($moreStmtsResponse->success == false) { return $moreStmtsResponse; } $moreStatements = $moreStmtsResponse->content->getStatements(); $moreStatementsURL = $moreStmtsResponse->content->getMore(); //Note: due to the structure of the arrays, array_merge does not work as expected. foreach ($moreStatements as $moreStatement) { array_push($allTheStatements, $moreStatement); } } return new \TinCan\LRSResponse($statementsResponse->success, $allTheStatements, $statementsResponse->httpResponse); }
<?php $loader = (require 'vendor/autoload.php'); $lrs = new TinCan\RemoteLRS('http://cloud.scorm.com/tc/public', '1.0.1', 'user', 'pass'); $response = $lrs->queryStatements(['limit' => 2]); print_r($response);