From c13df8a8dac58d598560fc13dbf13a350dddda0e Mon Sep 17 00:00:00 2001 From: Tom Reijnders Date: Fri, 30 Nov 2018 14:34:07 +0100 Subject: [PATCH] Add Course and Module to metainformation of LO's - Add group filtering to adaptiveContent - Add modelAnswer block to adaptiveContent --- .../Nottingham/common_html5/js/xenith.js | 36 ++-- .../models_html5/adaptiveContent.html | 158 +++++++++++++++--- .../Nottingham/wizards/en-GB/data.xwd | 6 +- modules/xerte/xAPI/xttracking_xapi.js | 19 ++- .../wizards/en-GB/adaptiveContent.xwd | 6 +- src/Nottingham/wizards/en-GB/template.xwd | 6 +- 6 files changed, 184 insertions(+), 47 deletions(-) diff --git a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js index 1296676192..dc6d3bec22 100644 --- a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js +++ b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js @@ -368,13 +368,13 @@ x_projectDataLoaded = function(xmlData) { // sort any parameters in url - these will override those in xml var tempUrlParams = window.location.search.substr(1, window.location.search.length).split("&"); - var urlParams = {}; + x_urlParams = {}; for (i = 0; i < tempUrlParams.length; i++) { - urlParams[tempUrlParams[i].split("=")[0]] = tempUrlParams[i].split("=")[1]; + x_urlParams[tempUrlParams[i].split("=")[0]] = tempUrlParams[i].split("=")[1]; } // url embed parameter uses ideal setup for embedding in iframes - can be overridden with other parameters below - if (urlParams.embed == 'true') { + if (x_urlParams.embed == 'true') { x_params.embed = true; x_params.displayMode = 'full screen'; x_params.responsive = 'false'; @@ -382,18 +382,18 @@ x_projectDataLoaded = function(xmlData) { } // url display parameter will set size of LO (display=fixed|full|fill - or a specified size e.g. display=200,200) - if (urlParams.display != undefined) { - if ($.isNumeric(urlParams.display.split(",")[0]) == true && $.isNumeric(urlParams.display.split(",")[1]) == true) { - x_params.displayMode = urlParams.display.split(","); + if (x_urlParams.display != undefined) { + if ($.isNumeric(x_urlParams.display.split(",")[0]) == true && $.isNumeric(x_urlParams.display.split(",")[1]) == true) { + x_params.displayMode = x_urlParams.display.split(","); x_fillWindow = false; // overrides fill window for touchscreen devices - } else if (urlParams.display == "fixed" || urlParams.display == "default" || urlParams.display == "full" || urlParams.display == "fill") { + } else if (x_urlParams.display == "fixed" || x_urlParams.display == "default" || x_urlParams.display == "full" || x_urlParams.display == "fill") { if (x_browserInfo.touchScreen == true) { x_fillWindow = true; } - if (urlParams.display == "fixed" || urlParams.display == "default") { // default fixed size using values in css (800,600) + if (x_urlParams.display == "fixed" || x_urlParams.display == "default") { // default fixed size using values in css (800,600) x_params.displayMode = "default"; - } else if (urlParams.display == "full" || urlParams.display == "fill") { + } else if (x_urlParams.display == "full" || x_urlParams.display == "fill") { x_params.displayMode = "full screen" } } @@ -410,30 +410,30 @@ x_projectDataLoaded = function(xmlData) { } // url hide parameter will remove x_headerBlock &/or x_footerBlock divs - if (urlParams.hide != undefined) { - if (urlParams.hide == "none") { + if (x_urlParams.hide != undefined) { + if (x_urlParams.hide == "none") { x_params.hideHeader = "false"; x_params.hideFooter = "false"; - } else if (urlParams.hide == "both") { + } else if (x_urlParams.hide == "both") { x_params.hideHeader = "true"; x_params.hideFooter = "true"; - } else if (urlParams.hide == "bottom") { + } else if (x_urlParams.hide == "bottom") { x_params.hideHeader = "false"; x_params.hideFooter = "true"; - } else if (urlParams.hide == "top") { + } else if (x_urlParams.hide == "top") { x_params.hideHeader = "true"; x_params.hideFooter = "false"; } } // url parameter to turn responsive on / off - if (urlParams.responsive != undefined && (urlParams.responsive == "true" || urlParams.responsive == "false")) { - x_params.responsive = urlParams.responsive; + if (x_urlParams.responsive != undefined && (x_urlParams.responsive == "true" || x_urlParams.responsive == "false")) { + x_params.responsive = x_urlParams.responsive; } - if (urlParams.theme != undefined && (x_params.themeurl == undefined || x_params.themeurl != 'true')) + if (x_urlParams.theme != undefined && (x_params.themeurl == undefined || x_params.themeurl != 'true')) { - x_params.theme = urlParams.theme; + x_params.theme = x_urlParams.theme; } x_getLangData(x_params.language); diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html index e1fe495885..a322db895e 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html @@ -37,6 +37,7 @@ var numUserSubmits = 0; var textSize = 12; + // We assume the data contains identical data sets // TODO: Check this if (numSubmits == 0) { @@ -249,36 +250,37 @@ ); } + function matchActor(statement) + { + switch (studentidmode) { + case 0: + case 2: + if (statement.actor.mbox == 'mailto:' + username) { + return true; + } + break; + case 1: + if (statement.actor.mbox_sha1sum == mboxsha1) { + return true; + } + break; + case 3: + if (statement.actor.account != undefined && statement.actor.account.name == groupname) { + return true; + } + break; + } + return false; + } + function filterOwnStatements(data) { - statements = []; + var statements = []; for (var i = 0; i < data.length; i++) { - statement = data[i]; - matchactor = false; - switch (studentidmode) { - case 0: - case 2: - if (statement.actor.mbox == 'mailto:' + username) { - matchactor = true; - } - break; - case 1: - if (statement.actor.mbox_sha1sum == mboxsha1) { - matchactor = true; - } - break; - case 3: - if (statement.actor.account != undefined && statement.actor.account.name == groupname) { - matchactor = true; - } - break; - } - - if (matchactor) { + if (matchActor(data[i])) { statements.push(data[i]); } } - return statements; } @@ -356,6 +358,7 @@ type, retrieveAll, interactionIndex, + group, handler ) { url = xerteurl + xertelo + '/' + xertelabel.replace(/ /g, "_"); @@ -391,6 +394,10 @@ */ q['activity'] = url; q['verb'] = 'http://adlnet.gov/expapi/verbs/scored'; + if (group != "") + { + q['group'] = group; + } /* queryStatements( lrsEndpoint + '/api/connection/statement', @@ -437,6 +444,16 @@ // pageChanged & sizeChanged functions are needed in every model file // other functions for model should also be in here to avoid conflicts. var adaptiveContent = new function() { + var xerteurl = ""; + var xertelo = ""; + var xertelabel = ""; + var name = ""; + var interactionType = ""; + var opinionClass = ""; + var url = ""; + var divUrl = ""; + var group = ""; + this.loadJS = function() { if (numLoaded < 2) { var fileToLoad; @@ -564,6 +581,33 @@ if (opinionClass == undefined) { opinionClass = ''; } + group = interaction.getAttribute('groupFromUrl'); + if (group == undefined) { + group = ''; + } + else { + if (group == "true") + { + if (x_urlParams['group'] != undefined) + { + group = x_urlParams['group'] + } + else + { + if (interaction.getAttribute('groupName') != undefined) + { + group = interaction.getAttribute('groupName'); + } + else { + group = ""; + } + } + } + else { + group = ""; + } + } + url = xerteurl + xertelo + '/' + xertelabel; if (opinionClass != '') { @@ -608,6 +652,7 @@ interactionType, hasToRetrieveAll(interaction), interactionIndex, + group, function(data, interaction, url, type, interactionIndex) { statements = filterOwnStatements(data); if (statements.length > 0) { @@ -802,6 +847,7 @@ interactionType, hasToRetrieveAll(interaction), interactionIndex, + group, function(data, interaction, url, type, interactionIndex) { statements = filterOwnStatements(data); if (statements.length > 0) { @@ -1000,6 +1046,7 @@ interactionType, hasToRetrieveAll(interaction), interactionIndex, + group, function(data, interaction, url, type, interactionIndex) { jsonData = data.map(function(d) { var obj = {} @@ -1028,6 +1075,69 @@ } ); } + else if (interactionType == "open") + { + statements = getStatements( + xerteurl, + xertelo, + xertelabel, + opinionClass, + interactionType, + hasToRetrieveAll(interaction), + interactionIndex, + group, + function(data, interaction, url, type, interactionIndex) { + statements = filterOwnStatements(data); + if (statements.length > 0) { + score = statements[0].result.score.raw; + if (interaction.getAttribute("showScore") == "true") { + var txt = scoreLabelText; + txt = txt.replace(/\{0\}/, score); + $('#' + escapeUrl(url, type, interactionIndex) + ' .score').html('

' + txt + '%

'); + } + } + var allAnswers= []; + var myAnswers = []; + for (var i=0; i 0) + { + html = "
    "; + for (i=0; i"; + } + html += "
"; + } + if (allAnswers.length > 0) + { + html += "
    "; + for (i=0; i"; + } + html += "
"; + } + $('#' + escapeUrl(url, type, interactionIndex) + ' .message').html(html); + }); + } } 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 7e16af9eae..6f3bec71f9 100644 --- a/modules/xerte/parent_templates/Nottingham/wizards/en-GB/data.xwd +++ b/modules/xerte/parent_templates/Nottingham/wizards/en-GB/data.xwd @@ -320,7 +320,7 @@