Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
120 lines (99 sloc) 4.39 KB
//common environment attributes including search paths. not specific to Learnosity
include_once '../env_config.php';
//site scaffolding
include_once 'includes/header.php';
//common Learnosity config elements including API version control vars
include_once '../lrn_config.php';
use LearnositySdk\Request\Init;
use LearnositySdk\Utils\Uuid;
$security = [
'consumer_key' => $consumer_key,
'domain' => $domain
//simple api request object for Reports API
$request = [
'reports' => [
'id' => 'report',
'type' => 'lastscore-by-activity-by-user',
'scoring_type' => 'partial',
'ui' => 'numeric',
'user_id' => 'mce_student',
'display_time_spent' => true,
'activities' => [
['id' => 'Weekly_Math_Quiz', 'name' => 'Weekly Math Quiz'],
['id' => 'Summer_Test_1', 'name' => 'Summer Test']
'users' => [
['id' => 'mce_student', 'name' => 'Jesse Pinkman'],
['id' => 'mce_student_1', 'name' => 'Walter White'],
['id' => 'mce_student_2', 'name' => 'Saul Goodman']
$Init = new Init('reports', $security, $consumer_secret, $request);
$signedRequest = $Init->generate();
<div class="jumbotron section">
<div class="toolbar">
<ul class="list-inline">
<li data-toggle="tooltip" data-original-title="Preview API Initialisation Object"><a href="#" data-toggle="modal" data-target="#initialisation-preview"><span class="glyphicon glyphicon-search"></span></a></li>
<li data-toggle="tooltip" data-original-title="Visit the documentation"><a href="" title="Documentation"><span class="glyphicon glyphicon-book"></span></a></li>
<div class="overview">
<h2>Use Click Events to Display Additional Information and Reports</h2>
<p>Click events are events that are provided by certain reports, to provide mechanisms to bind to specific click events within the report. For more information about click events, and to see which reports they can be used in, please see our <a href="" target="_blank">documentation</a>.</p>
<div class="section pad-sml">
<!-- Container for the reports api to load into -->
<h4>Report: Last Score by Activity by User</h4>
<div id="report"></div>
<!-- Demo Report OnClick Modal -->
<div class="modal fade" id="lrn-reports-demos-modal" tabindex="-1" role="dialog" aria-labelledby="lrn-reports-demos-modal-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<script src="<?php echo $url_reports; ?>"></script>
var initializationObject = <?php echo $signedRequest; ?>;
//optional callbacks for ready
var callbacks = {
readyListener: function () {
errorListener: function (err) {
var reportsApp = LearnosityReports.init(initializationObject, callbacks);
function onReportsReady() {
// load modal from a remote location that initialize an instance of the reports api
var onClickFunction = function(data) {
'remote': 'reports-click-events-modal.php'
+ '?session_id=' + data.session_id
+ '&user_id=' + data.user_id
+ '&activity_id=' + data.activity_id
$('body').on('', '.modal', function () {
var groupLastScoreByActivityByUser = reportsApp.getReport('report');
// onclick events
groupLastScoreByActivityByUser.on('click:score', function (data) {
include_once 'views/modals/initialisation-preview.php';
include_once 'includes/footer.php';