Ejemplo n.º 1
0
/**
 * Check if the H5P item has been completed by the current user.
 */
function isH5pCompleted($h5pId)
{
    $activityUrl = getH5pObjectUrlById($h5pId);
    if (!get_option("ti_xapi_endpoint_url")) {
        return FALSE;
    }
    $xapi = new Xapi(get_option("ti_xapi_endpoint_url"), get_option("ti_xapi_username"), get_option("ti_xapi_password"));
    $user = wp_get_current_user();
    if (!$user || !$user->user_email) {
        return;
    }
    $params = array();
    $params["agentEmail"] = $user->user_email;
    $params["activity"] = $activityUrl;
    $params["verb"] = "http://adlnet.gov/expapi/verbs/completed";
    $statements = $xapi->getStatements($params);
    return sizeof($statements) > 0;
}
Ejemplo n.º 2
0
<?php

require_once __DIR__ . "/xapi.php";
$xapi = new Xapi("http://localhost/repo/learninglocker/public/data/xAPI/", "7b880fc1f371715ce24309b90e051fcd24d700c3", "c089ce76ca667862e615995b909f2ddf9acc1795");
$statements = $xapi->getStatements();
$progressed = 0;
$completed = 0;
for ($i = 0; $i < sizeof($statements); $i++) {
    $statement = $statements[$i];
    //		echo $statement["verb"]["id"]."\n";
    //		echo $statement["actor"]["mbox"]."\n";
    if ($statement["verb"]["id"] == "http://adlnet.gov/expapi/verbs/progressed") {
        $progressed++;
    }
    if ($statement["verb"]["id"] == "http://adlnet.gov/expapi/verbs/completed") {
        $completed++;
    }
}
echo "progressed: {$progressed}\n";
echo "completed: {$completed}\n";