From c2fe185e6500a0a01325c6b6430055dd309c69d8 Mon Sep 17 00:00:00 2001 From: Tom Reijnders Date: Mon, 5 Dec 2022 15:21:34 +0100 Subject: [PATCH] Fixed #1181 - Adaptive content page not always showing correct data $release $bugfix --- modules/site/xAPI/xttracking_xapi.js | 14 +++++++++++--- .../Nottingham/models_html5/adaptiveContent.css | 15 +++++++++++++++ .../Nottingham/models_html5/adaptiveContent.html | 15 +++++++++++++++ modules/xerte/xAPI/xttracking_xapi.js | 10 ++++++---- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/modules/site/xAPI/xttracking_xapi.js b/modules/site/xAPI/xttracking_xapi.js index 085a1b56c7..eb2d0a22e5 100644 --- a/modules/site/xAPI/xttracking_xapi.js +++ b/modules/site/xAPI/xttracking_xapi.js @@ -1883,12 +1883,20 @@ function getStatements(q, one, callback) // lastSubmit = JSON.parse(sr.statements[x].result.extensions["http://xerte.org.uk/xapi/JSONGraph"]); //} if (group != "" - && (body.statements[x].context.team == undefined + && (body.statements[x].context == undefined + || body.statements[x].context.team == undefined || body.statements[x].context.team.account == undefined || body.statements[x].context.team.account.name == undefined || body.statements[x].context.team.account.name != group)) { continue; } + if (context_id != "" + && (body.statements[x].context == undefined + || body.statements[x].context.extensions == undefined + || body.statements[x].context.extensions["http://xerte.org.uk/lti_context_id"] == undefined + || body.statements[x].context.extensions["http://xerte.org.uk/lti_context_id"] != context_id)) { + continue; + } statements.push(body.statements[x]); } //stringObjects.push(lastSubmit); @@ -1897,8 +1905,8 @@ function getStatements(q, one, callback) // TODO: do something with error, didn't get statements return; } - if (res.more && res.more !== "") { - ADL.XAPIWrapper.getStatements(null, res.more, getmorestatements); + if (body.more && body.more !== "") { + ADL.XAPIWrapper.getStatements(null, body.more, getmorestatements); } else { callback(statements, search); } diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css index ba67c5b938..5237efd210 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css +++ b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css @@ -77,6 +77,21 @@ li.select-interaction.selected { font-size:smaller; } +.interaction_load { + position: relative; + left: 50%; + top: 50%; + width: 66px; + margin-left: -33px; /* -1 * div width / 2 */ +} + +.loader-gif { + margin-left: auto; + margin-right:auto; + display:block; +} + + #adaptiveContentMain .splitScreen .left, #adaptiveContentMain .splitScreen .right { overflow-y: auto; } diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html index 3b7b0c4c69..4d7675cd0f 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html @@ -1186,6 +1186,7 @@ div.html( `

${name}

` + `
${introductionText}
` + + '
' + '
' + summaryDiv + graphContainer + @@ -1431,6 +1432,8 @@ interactionIndex, fullWidth ) { + // remove loader + $("#interaction_load_" + interactionIndex).remove(); let scoreLabelText = interaction.getAttribute("scoreText"); if (scoreLabelText == null) { scoreLabelText = "Your score is {0}"; @@ -2272,6 +2275,9 @@ interactionIndex, fullWidth ) { + // remove loader + $("#interaction_load_" + interactionIndex).remove(); + var answerLabelText = interaction.getAttribute("answerText"); if (answerLabelText == undefined) { answerLabelText = "Your answer is {0}"; @@ -2571,6 +2577,9 @@ interactionIndex, fullWidth ) { + // remove loader + $("#interaction_load_" + interactionIndex).remove(); + var scoreLabelText = interaction.getAttribute("scoreText"); if (scoreLabelText == null) { scoreLabelText = "Your score is {0}"; @@ -2659,6 +2668,9 @@ interactionIndex, fullWidth ) { + // remove loader + $("#interaction_load_" + interactionIndex).remove(); + var answerLabelText = interaction.getAttribute("answerText"); if (answerLabelText == undefined) { answerLabelText = "Your answer is {0}"; @@ -2799,6 +2811,9 @@ interactionIndex, fullWidth ) { + // remove loader + $("#interaction_load_" + interactionIndex).remove(); + // reshuffle var groupingStatements = []; var userGrouping = []; diff --git a/modules/xerte/xAPI/xttracking_xapi.js b/modules/xerte/xAPI/xttracking_xapi.js index 0d42930ae8..09c7094b68 100644 --- a/modules/xerte/xAPI/xttracking_xapi.js +++ b/modules/xerte/xAPI/xttracking_xapi.js @@ -1894,14 +1894,16 @@ function getStatements(q, one, callback) // lastSubmit = JSON.parse(sr.statements[x].result.extensions["http://xerte.org.uk/xapi/JSONGraph"]); //} if (group != "" - && (body.statements[x].context.team == undefined + && (body.statements[x].context == undefined + || body.statements[x].context.team == undefined || body.statements[x].context.team.account == undefined || body.statements[x].context.team.account.name == undefined || body.statements[x].context.team.account.name != group)) { continue; } if (context_id != "" - && (body.statements[x].context.extensions == undefined + && (body.statements[x].context == undefined + || body.statements[x].context.extensions == undefined || body.statements[x].context.extensions["http://xerte.org.uk/lti_context_id"] == undefined || body.statements[x].context.extensions["http://xerte.org.uk/lti_context_id"] != context_id)) { continue; @@ -1914,8 +1916,8 @@ function getStatements(q, one, callback) // TODO: do something with error, didn't get statements return; } - if (res.more && res.more !== "") { - ADL.XAPIWrapper.getStatements(null, res.more, getmorestatements); + if (body.more && body.more !== "") { + ADL.XAPIWrapper.getStatements(null, body.more, getmorestatements); } else { callback(statements, search); }