From 141de5865429e832935c0194c352abadcd583302 Mon Sep 17 00:00:00 2001 From: Tom Reijnders Date: Tue, 16 Jul 2019 12:15:03 +0200 Subject: [PATCH] Fixes to dashboard and merge from students with fixes for topXQ and textCorrection --- lti_launch.php | 3 +- .../models_html5/adaptiveContent.html | 20 +- .../Nottingham/models_html5/gapFill.html | 2 +- .../models_html5/textCorrection.html | 6 +- .../Nottingham/wizards/en-GB/data.xwd | 4 +- modules/xerte/xAPI/xttracking_xapi.js | 14 +- src/Nottingham/wizards/en-GB/template.xwd | 4 +- .../wizards/en-GB/textCorrection.xwd | 2 +- src/Nottingham/wizards/en-GB/topXQ.xwd | 2 - .../php/properties/properties_library.php | 14 +- website_code/php/xAPI/xAPI_library.php | 17 ++ website_code/scripts/xapi_dashboard_data.js | 217 ++++++++++++++++++ xapi_launch.php | 3 +- xapi_proxy.php | 2 + 14 files changed, 285 insertions(+), 25 deletions(-) diff --git a/lti_launch.php b/lti_launch.php index f8df455bb5..7de089cb8f 100644 --- a/lti_launch.php +++ b/lti_launch.php @@ -20,6 +20,7 @@ $tsugi_disable_xerte_session = true; require_once(dirname(__FILE__) . "/config.php"); require_once($xerte_toolkits_site->tsugi_dir . "/config.php"); +require_once(dirname(__FILE__) . "/website_code/php/xAPI/xAPI_library.php"); ini_set('display_errors', 0); error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT); @@ -128,7 +129,7 @@ 'lrssecret' => $row['tsugi_xapi_secret'], ); } - + $lrs = CheckLearningLocker($lrs); $_SESSION['XAPI_PROXY'] = $lrs; diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html index bd17dfb9aa..36fd126c4f 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html @@ -403,8 +403,12 @@ function getUrl(xerteurl, xertelo, xertelabel, opinionClass) { - var url = xerteurl + xertelo + '/' + xertelabel.replace(/ /g, "_"); - if (opinionClass != '' && opinionClass != null) { + var url = xerteurl + xertelo; + if (xertelabel != undefined && xertelabel != '') + { + url += '/' + xertelabel.replace(/ /g, "_"); + } + if (opinionClass != undefined && opinionClass != '' ) { url += '/' + opinionClass.replace(/ /g, "_"); } return url; @@ -456,7 +460,7 @@ } */ if (typeof actor != "undefined") { - actor.account.homePage = xerteurl + xertelo; + //actor.account.homePage = xerteurl + xertelo; q['agent'] = JSON.stringify(actor); } } @@ -688,11 +692,7 @@ nrParticipantsText = 'The number of participants is {0}'; } - url = xerteurl + xertelo + '/' + xertelabel; - if (opinionClass != '' && opinionClass != null) { - url += '/' + opinionClass; - - } + url = getUrl(xerteurl, xertelo, xertelabel, opinionClass); var $this = this; divUrl = escapeUrl(url, interactionType, interactionIndex); name = interaction.getAttribute('name'); @@ -841,7 +841,7 @@ //score = interaction.score; if (interaction.getAttribute("showScore") == "true") { var txt = scoreLabelText; - txt = txt.replace(/\{0\}/, score); + txt = txt.replace(/\{0\}/, Math.round(score*10)/10); $('#' + escapeUrl(url, type, interactionIndex) + ' .score .stats').append('

' + txt + '%

'); } @@ -1748,7 +1748,7 @@ var scoretext = ""; if (interaction.score != Number.MAX_VALUE) { - scoretext = "

" + scoreLabelText.replace('{0}', interaction.score) + "

"; + scoretext = "

" + scoreLabelText.replace('{0}', Math.round(interaction.score*10)/10) + "

"; } div.html('

' + name + '

' + diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/gapFill.html b/modules/xerte/parent_templates/Nottingham/models_html5/gapFill.html index c1fdb66697..6461f72036 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/gapFill.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/gapFill.html @@ -1006,7 +1006,7 @@ $targetHolder.find("input").each(function() { var $this = $(this), currvalue = !casesensitive ? $this.val().trim().toLowerCase() : $this.val().trim(); - var feedback = "Incorrect" + var feedback = "Incorrect"; var correct = false; var answer = currvalue; diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/textCorrection.html b/modules/xerte/parent_templates/Nottingham/models_html5/textCorrection.html index a5fe10d0da..aa913542ff 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/textCorrection.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/textCorrection.html @@ -146,7 +146,11 @@ textCorrection.answer = answer; - var copyText = x_currentPageXML.getAttribute("copyText").trim(); + var copyText = false; + if (x_currentPageXML.getAttribute("copyText") != undefined) + { + copyText = x_currentPageXML.getAttribute("copyText").trim(); + } var $textArea = $("#text"); if( copyText === "true"){ question = $("
").html(question).text().trim(); diff --git a/modules/xerte/parent_templates/Nottingham/wizards/en-GB/data.xwd b/modules/xerte/parent_templates/Nottingham/wizards/en-GB/data.xwd index 904b181879..829c5461b1 100644 --- a/modules/xerte/parent_templates/Nottingham/wizards/en-GB/data.xwd +++ b/modules/xerte/parent_templates/Nottingham/wizards/en-GB/data.xwd @@ -4675,7 +4675,7 @@ - + @@ -5164,8 +5164,6 @@ - - diff --git a/modules/xerte/xAPI/xttracking_xapi.js b/modules/xerte/xAPI/xttracking_xapi.js index daa3334df0..b35a66148a 100644 --- a/modules/xerte/xAPI/xttracking_xapi.js +++ b/modules/xerte/xAPI/xttracking_xapi.js @@ -1673,6 +1673,18 @@ function XTInitialise(category) { } ); */ + + // // Check if aggretate is set for the lrsEndpoint, than assume this is learning locker and change normal API accordingly and save aggregate for XTGetStatements + // if (lrsEndpoint.indexOf("api/statements/aggregate/") >= 0) + // { + // state.aggregate = true; + // state.lrsAggregateEndpoint = lrsEndpont; + // apos = lrsEndpoint.indexOf("api/statements/aggregate"); + // lrsEndpoint = lrsEndpoint.substr(0, lrsEndpoint.Length - apos) + 'data/xAPI'; + // } + // else { + // state.aggregate = false; + // } var conf = { "endpoint": lrsEndpoint + '/', "user": lrsUsername, @@ -3214,7 +3226,7 @@ function XTResults(fullcompletion) { correctAnswer = state.interactions[i].correctAnswers; break; } - if (state.interactions[i].ia_type != "match") { + if (state.interactions[i].ia_type != "match" && state.interactions[i].result != undefined) { subinteraction.question = state.interactions[i].ia_name; subinteraction.correct = state.interactions[i].result.success; subinteraction.learnerAnswer = learnerAnswer; diff --git a/src/Nottingham/wizards/en-GB/template.xwd b/src/Nottingham/wizards/en-GB/template.xwd index 904b181879..829c5461b1 100644 --- a/src/Nottingham/wizards/en-GB/template.xwd +++ b/src/Nottingham/wizards/en-GB/template.xwd @@ -4675,7 +4675,7 @@ - + @@ -5164,8 +5164,6 @@ - - diff --git a/src/Nottingham/wizards/en-GB/textCorrection.xwd b/src/Nottingham/wizards/en-GB/textCorrection.xwd index 5ad31f4925..b19381c6b4 100644 --- a/src/Nottingham/wizards/en-GB/textCorrection.xwd +++ b/src/Nottingham/wizards/en-GB/textCorrection.xwd @@ -13,7 +13,7 @@ - + diff --git a/src/Nottingham/wizards/en-GB/topXQ.xwd b/src/Nottingham/wizards/en-GB/topXQ.xwd index a724d30ff3..d12ee0244e 100644 --- a/src/Nottingham/wizards/en-GB/topXQ.xwd +++ b/src/Nottingham/wizards/en-GB/topXQ.xwd @@ -26,8 +26,6 @@ - - diff --git a/website_code/php/properties/properties_library.php b/website_code/php/properties/properties_library.php index 6992754991..95ae3f92b6 100644 --- a/website_code/php/properties/properties_library.php +++ b/website_code/php/properties/properties_library.php @@ -22,6 +22,7 @@ require_once("../../../config.php"); require_once("../template_library.php"); +require_once("../xAPI/xAPI_library.php"); _load_language_file("/website_code/php/properties/publish.inc"); @@ -598,12 +599,23 @@ function statistics_prepare($template_id) $params = array($template_id); $row = db_query_one($query_for_names, $params); - $row_sitedetails = db_query_one("select dashboard_allowed_links from {$prefix}sitedetails"); + $row_sitedetails = db_query_one("select dashboard_allowed_links, LRS_Endpoint from {$prefix}sitedetails"); if ($row['tsugi_xapi_enabled'] && ($row['tsugi_xapi_useglobal'] || ($row['tsugi_xapi_endpoint'] != "" && $row['tsugi_xapi_key'] != "" && $row['tsugi_xapi_secret'] != ""))) { $info->info = $html; + $lrsendpoint = array(); + if ($row['tsugi_xapi_useglobal']) + { + $lrsendpoint['lrsendpoint'] = $row_sitedetails['LRS_Endpoint']; + } + else + { + $lrsendpoint['lrsendpoint'] = $row['tsugi_xapi_endpoint']; + } + $lrsendpoint = CheckLearningLocker($lrsendpoint); $lrs = new stdClass(); $lrs->lrsendpoint = $xerte_toolkits_site->site_url . "xapi_proxy.php"; + $lrs->lrs_use_aggregate = $lrsendpoint['aggregate']; $lrs->lrskey = ""; $lrs->lrssecret = ""; diff --git a/website_code/php/xAPI/xAPI_library.php b/website_code/php/xAPI/xAPI_library.php index 7f5bbb6a8d..6161367e68 100644 --- a/website_code/php/xAPI/xAPI_library.php +++ b/website_code/php/xAPI/xAPI_library.php @@ -1,5 +1,22 @@ group = $_REQUEST{'group'}; diff --git a/xapi_proxy.php b/xapi_proxy.php index 61b89a41e2..6a54dcc7c2 100644 --- a/xapi_proxy.php +++ b/xapi_proxy.php @@ -171,6 +171,7 @@ { require_once ("config.php"); } +require_once("website_code/php/xAPI/xAPI_library.php"); if (!function_exists('getallheaders')) { /** @@ -256,6 +257,7 @@ function convertToCurl($headers) $lrs['lrskey'] = $row['tsugi_xapi_key']; $lrs['lrssecret'] = $row['tsugi_xapi_secret']; } + $lrs = CheckLearningLocker($lrs); $_SESSION['XAPI_PROXY'] = $lrs; } else