diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css index c17933081d..ba67c5b938 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css +++ b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.css @@ -90,7 +90,7 @@ li.select-interaction.selected { } .summary { - width: 45%; + width: 40%; float: left; } @@ -99,13 +99,13 @@ li.select-interaction.selected { } .graph-container { - width: 45%; + width: 60%; float: right; display: inline-flex; } .graph-container fieldset.noStyle { - width: 50%; + width: 100%; float: left; } @@ -132,16 +132,8 @@ li.select-interaction.selected { } } -.panel.legend { - width: 35% !important; -} - -.panel.legend p{ - font-size: 1.75vmin; -} - -.graph-container-wide { - width: 100%; +.panel.legend, .panel.legend p, .panel.legend ol, .panel.legend ul, .panel.legend li{ + font-size: inherit; } .graph { @@ -157,7 +149,13 @@ li.select-interaction.selected { } .graph-container{ - width: 45%; + width: 60%; + margin-bottom: 2vmin; + margin-top: 2vmin; +} + +.graph-container-wide { + width: 100%; } .container-print{ @@ -165,6 +163,24 @@ li.select-interaction.selected { flex-direction: column; } +#print-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + z-index: 1; +} + +#print-overlay-spinner { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 2; +} + @media screen and (max-width: 1200px) { .graph-container { width: 95% !important; diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html index bb50c40631..9b81682c4a 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/adaptiveContent.html @@ -70,7 +70,7 @@ } if (classnames[i] == null) { - classnames[i] = obj.graph.classnames[i]; + classnames[i] = x_GetTrackingTextFromHTML(obj.graph.classnames[i], obj.graph.classnames[i]); } if (classtitles[i] == null) { if ( @@ -78,7 +78,7 @@ typeof obj.graph.classtitles[i] != "undefined" && obj.graph.classtitles[i] != "" ) { - classtitles[i] = obj.graph.classtitles[i]; + classtitles[i] = x_GetTrackingTextFromHTML(obj.graph.classtitles[i], obj.graph.classtitles[i]); } else { classtitles[i] = classnames[i]; } @@ -186,21 +186,26 @@ 1 ); - var avgAllLabelText = interaction.getAttribute("AvgLabel"); + var avgAllLabelText = interaction.getAttribute("avgAllLabelText"); if (avgAllLabelText == undefined) { avgAllLabelText = "Avg. of all attempts"; } - var personalLabelText = interaction.getAttribute("PersonalLastLabel"); + var personalLabelText = interaction.getAttribute("personalLabelText"); if (personalLabelText == undefined) { personalLabelText = "Your last attempt"; } - var personalAvgLabelText = interaction.getAttribute("PersonalAvgLabel"); + var personalAvgLabelText = interaction.getAttribute("personalAvgLabelText"); if (personalAvgLabelText == undefined) { personalAvgLabelText = "Avg. of your attempts"; } + var groupAverageLabelText = interaction.getAttribute("groupAverageLabelText"); + if (groupAverageLabelText == undefined) { + groupAverageLabelText = "Group Average"; + } + var datasets = []; if (showall_only || latest == null) { // Only show mean_all @@ -250,12 +255,23 @@ r: { beginAtZero: true, max: 100, - fontSize: textSize - 10, + pointLabels: { + font: { + size: textSize + }, + }, + ticks: { + font: { + size: textSize - 4 + }, + } }, }, legend: { labels: { - fontSize: textSize, + font: { + size: textSize + }, }, }, responsive: true, @@ -280,74 +296,113 @@ let labelCounter = 0; let data = []; - datasets[0].data.forEach((val, key) => { - data.push({ - x: classtitles[key], - y: Math.round(val, 2), - goals: [ - { - name: "Group average", - value: datasets[2].data[key], - strokeWidth: 5, - strokeColor: "#775DD0", - }, - ], - }); - labelCounter += 1; - }); - var options = { - series: [ - { - data, - }, - ], - chart: { - toolbar: { - show: false, - }, - height: 350, - type: "bar", - }, - plotOptions: { - bar: { - horizontal: true, - distributed: true, - }, - }, - colors: [ - "#FF6384", - "#4BC0C0", - "#FFCD56", - "#C9CBCF", - "#36A2EB", - "#B284BE", - ], - dataLabels: { - formatter: function (val, opt) { - const goals = - opt.w.config.series[opt.seriesIndex].data[opt.dataPointIndex] - .goals; - - if (goals && goals.length) { - return `${val}%`; - } - return val; - }, - }, - legend: { - show: true, - showForSingleSeries: true, - customLegendItems: ["Group Average"], - markers: { - fillColors: ["#775DD0"], - }, - }, - }; - var chart = new ApexCharts( - document.querySelector(`${ctx}`), - options - ); - chart.render(); + if (datasets.length < 2) + { + var insufficientDataText = interaction.getAttribute("insufficientDataText"); + if (insufficientDataText == undefined) { + insufficientDataText = "There is insufficient data for this graph"; + } + $(ctx).parent().append('
' + insufficientDataText + '
'); + } + else { + const avgDataSet = datasets.length - 1; + + datasets[0].data.forEach((val, key) => { + data.push({ + x: classtitles[key], + y: Math.round(val, 2), + goals: [ + { + name: groupAverageLabelText, + value: datasets[avgDataSet].data[key], + strokeWidth: 5, + strokeColor: "#775DD0", + }, + ], + }); + labelCounter += 1; + }); + let colors = [ + "#FF6384", + "#4BC0C0", + "#FFCD56", + "#C9CBCF", + "#36A2EB", + "#B284BE", + ]; + if (interaction.getAttribute('graphColorScale') != null && interaction.getAttribute('graphColorScale') != "") { + colors = interaction.getAttribute('graphColorScale').split(","); + } + var options = { + series: [ + { + data, + }, + ], + chart: { + toolbar: { + show: false, + }, + height: 350, + type: "bar", + }, + plotOptions: { + bar: { + horizontal: true, + distributed: true, + }, + }, + colors: colors, + dataLabels: { + formatter: function (val, opt) { + const goals = + opt.w.config.series[opt.seriesIndex].data[opt.dataPointIndex] + .goals; + + if (goals && goals.length) { + return `${val}%`; + } + return val; + }, + style: { + fontSize: textSize + 'px', + } + }, + legend: { + show: true, + showForSingleSeries: true, + customLegendItems: [groupAverageLabelText], + markers: { + fillColors: ["#775DD0"], + }, + style: { + fontSize: textSize + 'px', + } + }, + xaxis: { + position: 'bottom', + labels: { + offsetY: 1, + style: { + fontSize: textSize + 'px', + }, + }, + }, + yaxis: { + labels: { + style: { + fontSize: textSize + 'px', + }, + }, + }, + }; + var chart = new ApexCharts( + document.querySelector(`${ctx}`), + options + ); + chart.render(); + $(ctx + ' svg text').css('font-size', textSize + 'px'); + } } }; @@ -558,8 +613,8 @@ secondHandler ) { var url; - var q = {}; - if (type != "grouping") { + var q = {} + if (type != "grouping" && type != "opinionclasses") { url = getUrl(xerteurl, xertelo, xertelabel, opinionClass); } else { url = getUrl(xerteurl, xertelo); @@ -795,18 +850,13 @@ for (var i = 0; i < data.length; i++) { if ( - data[i].context != undefined && - data[i].context.extensions != undefined && - data[i].context.extensions[ - "http://xerte.org.uk/learningObjectLevel" - ] != undefined && - data[i].context.extensions[ - "http://xerte.org.uk/learningObjectLevel" - ] == "interactivity" && - data[i].context.extensions[ - "http://xerte.org.uk/opinionClass" - ] != undefined && - data[i].context.contextActivities != undefined + data[i].context != undefined && + data[i].context.extensions != undefined && + data[i].context.extensions["http://xerte.org.uk/learningObjectLevel"] != undefined && + data[i].context.extensions["http://xerte.org.uk/learningObjectLevel"] == "interactivity" && + data[i].context.extensions["http://xerte.org.uk/opinionClass"] != undefined && + data[i].context.contextActivities != undefined && + data[i].object.id.indexOf(url + '/' + xertelabel) != -1 ) { statements.push(data[i]); } @@ -999,6 +1049,7 @@ }; this.init = function () { + debugger; var loadFiles = true; for (var i = 0; i < x_pageInfo.length; i++) { if ( @@ -1060,7 +1111,7 @@ nrParticipantsText = "The number of participants is {0}"; } - if (interactionType != "grouping") { + if (interactionType != "grouping" && interactionType != "opinionclasses") { url = getUrl(xerteurl, xertelo, xertelabel, opinionClass); } else { url = getUrl(xerteurl, xertelo); @@ -1334,6 +1385,7 @@ } } else if (interactionType == "opinionclasses") { // check open question special options + debugger; var verb = "http://adlnet.gov/expapi/verbs/answered"; if (interaction.data != null) { var url = getUrl(xerteurl, xertelo, xertelabel, opinionClass); @@ -1642,10 +1694,10 @@ //.attr('preserveAspectRatio','xMinYMin') } if (showExplanation == "true" && Explanation != "") { + var textSize = Math.round(interaction.getAttribute("labelFontSize")); + if (textSize == null || textSize == 0) textSize = 12; div.append( - '