From c41afcbbf9f1236ac78ebf61dcb10e46846b72c8 Mon Sep 17 00:00:00 2001 From: Simon Thornett Date: Thu, 19 Sep 2024 07:44:12 +0100 Subject: [PATCH] WR422914 File cleanup --- amd/build/calendar.min.js | 10 ---------- amd/build/calendar.min.js.map | 1 - amd/build/chart_data.min.js | 11 ----------- amd/build/chart_data.min.js.map | 1 - amd/build/chart_output_chartjs.min.js | 10 ---------- amd/build/chart_output_chartjs.min.js.map | 1 - amd/build/dashboard.min.js.map | 2 +- amd/build/dashboard_assessment.min.js | 11 ----------- amd/build/dashboard_assessment.min.js.map | 1 - amd/build/dashboard_quiz.min.js | 11 ----------- amd/build/dashboard_quiz.min.js.map | 1 - amd/build/dayview.min.js | 10 ---------- amd/build/dayview.min.js.map | 1 - amd/build/form_modal.min.js | 10 ---------- amd/build/form_modal.min.js.map | 1 - amd/build/summary_participants.min.js | 10 ---------- amd/build/summary_participants.min.js.map | 1 - amd/build/table_handler.min.js.map | 2 +- amd/build/zoom_modal.min.js | 10 ---------- amd/build/zoom_modal.min.js.map | 1 - 20 files changed, 2 insertions(+), 104 deletions(-) delete mode 100644 amd/build/calendar.min.js delete mode 100644 amd/build/calendar.min.js.map delete mode 100644 amd/build/chart_data.min.js delete mode 100644 amd/build/chart_data.min.js.map delete mode 100644 amd/build/chart_output_chartjs.min.js delete mode 100644 amd/build/chart_output_chartjs.min.js.map delete mode 100644 amd/build/dashboard_assessment.min.js delete mode 100644 amd/build/dashboard_assessment.min.js.map delete mode 100644 amd/build/dashboard_quiz.min.js delete mode 100644 amd/build/dashboard_quiz.min.js.map delete mode 100644 amd/build/dayview.min.js delete mode 100644 amd/build/dayview.min.js.map delete mode 100644 amd/build/form_modal.min.js delete mode 100644 amd/build/form_modal.min.js.map delete mode 100644 amd/build/summary_participants.min.js delete mode 100644 amd/build/summary_participants.min.js.map delete mode 100644 amd/build/zoom_modal.min.js delete mode 100644 amd/build/zoom_modal.min.js.map diff --git a/amd/build/calendar.min.js b/amd/build/calendar.min.js deleted file mode 100644 index fe24950..0000000 --- a/amd/build/calendar.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Javascript for heatmap calendar generation and display. - * - * @package - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("local_assessfreq/calendar",["core/str","core/notification","core/ajax"],(function(Str,Notification,Ajax){var Calendar={},eventArray=[];const stringArr=[{key:"sun",component:"calendar"},{key:"mon",component:"calendar"},{key:"tue",component:"calendar"},{key:"wed",component:"calendar"},{key:"thu",component:"calendar"},{key:"fri",component:"calendar"},{key:"sat",component:"calendar"},{key:"jan",component:"local_assessfreq"},{key:"feb",component:"local_assessfreq"},{key:"mar",component:"local_assessfreq"},{key:"apr",component:"local_assessfreq"},{key:"may",component:"local_assessfreq"},{key:"jun",component:"local_assessfreq"},{key:"jul",component:"local_assessfreq"},{key:"aug",component:"local_assessfreq"},{key:"sep",component:"local_assessfreq"},{key:"oct",component:"local_assessfreq"},{key:"nov",component:"local_assessfreq"},{key:"dec",component:"local_assessfreq"}];var stringResult,heatRangeMax,heatRangeMin,colorArray,processModules,heatRangeScale={1:0,2:0,3:0,4:0,5:0,6:0};const getContrast=function(hexcolor){return void 0===hexcolor?"#000000":("#"===hexcolor.slice(0,1)&&(hexcolor=hexcolor.slice(1)),(299*parseInt(hexcolor.substr(0,2),16)+587*parseInt(hexcolor.substr(2,2),16)+114*parseInt(hexcolor.substr(4,2),16))/1e3>=128?"#000000":"#FFFFFF")},daysInMonth=function(month,year){return 32-new Date(year,month,32).getDate()},getHeatColors=function(){return new Promise(((resolve,reject)=>{Ajax.call([{methodname:"local_assessfreq_get_heat_colors",args:{}}],!0,!1)[0].done((function(response){colorArray=JSON.parse(response),resolve(colorArray)})).fail((function(){reject(new Error("Failed to get heat colors"))}))}))},getProcessModules=function(){return new Promise(((resolve,reject)=>{Ajax.call([{methodname:"local_assessfreq_get_process_modules",args:{}}],!0,!1)[0].done((function(response){processModules=JSON.parse(response),resolve(processModules)})).fail((function(){reject(new Error("Failed to get process events"))}))}))},getHeat=function(eventCount){if(eventCount==heatRangeMin)return 1;const localPercent=(eventCount-heatRangeMin)/(heatRangeMax-heatRangeMin);let heat=Math.round(5*localPercent+1);return heat<1&&(heat=1),heat>6&&(heat=6),heat},getEvents=function(_ref){let{year:year,metric:metric,modules:modules}=_ref;return new Promise(((resolve,reject)=>{let args={year:year,metric:metric,modules:modules},jsonArgs=JSON.stringify(args);Ajax.call([{methodname:"local_assessfreq_get_frequency",args:{jsondata:jsonArgs}}])[0].done((response=>{eventArray=JSON.parse(response),resolve(eventArray)})).fail((()=>{reject(new Error("Failed to get events"))}))}))},createTables=function(_ref2){let{year:year,startMonth:startMonth,endMonth:endMonth}=_ref2;return new Promise(((resolve,reject)=>{let calendarContainer=document.createElement("div"),month=startMonth;for(let i=startMonth;i<=endMonth;i++){let container=document.createElement("div");container.classList.add("local-assessfreq-month");let table=document.createElement("table");table.classList.add("table-striped");let thead=document.createElement("thead"),tbody=document.createElement("tbody");tbody.id="calendar-body-"+i;let monthRow=document.createElement("tr"),dayrow=document.createElement("tr"),monthHeader=document.createElement("th");monthHeader.colSpan=7,monthHeader.innerHTML=stringResult[7+month];for(let j=0;j<7;j++){let dayHeader=document.createElement("th");dayHeader.innerHTML=stringResult[j],dayrow.appendChild(dayHeader)}monthRow.appendChild(monthHeader),thead.appendChild(monthRow),thead.appendChild(dayrow),table.appendChild(thead),table.appendChild(tbody),container.appendChild(table),calendarContainer.appendChild(container),month++}if(void 0===year||void 0===startMonth||void 0===endMonth)reject(Error("Failed to create calendar tables."));else{resolve({calendarContainer:calendarContainer,year:year,startMonth:startMonth})}}))},getTooltip=function(dayArray){let tipHTML="";for(let[key,value]of Object.entries(dayArray))tipHTML+=""+processModules[key]+": "+value+"
";return tipHTML},populateCalendarDays=function(table,year,month){let firstDay=new Date(year,month).getDay(),monthEvents=function(year,month){let monthevents;return void 0!==eventArray[year]&&void 0!==eventArray[year][month]&&(monthevents=eventArray[year][month]),monthevents}(year,month+1),date=1;for(let i=0;i<6;i++){let row=document.createElement("tr");for(let j=0;j<7;j++){if(0===i&&jdaysInMonth(month,year))break;if(cell=document.createElement("td"),cellText=document.createTextNode(date),void 0!==monthEvents&&monthEvents.hasOwnProperty(date)){let heat=getHeat(monthEvents[date].number);(0==heatRangeScale[heat]||heatRangeScale[heat]>monthEvents[date].number)&&(heatRangeScale[heat]=monthEvents[date].number),cell.style.backgroundColor=colorArray[heat],cell.style.color=getContrast(colorArray[heat]),cell.dataset.toggle="tooltip",cell.dataset.html="true",cell.dataset.event="true",cell.dataset.date=year+"-"+(month+1)+"-"+date,cell.title=getTooltip(monthEvents[date]),cell.style.cursor="pointer"}date++}cell.appendChild(cellText),row.appendChild(cell)}table.appendChild(row)}},populateCalendar=function(_ref3){let{calendarContainer:calendarContainer,year:year,startMonth:startMonth}=_ref3;return new Promise(((resolve,reject)=>{let tables=calendarContainer.getElementsByTagName("tbody"),month=startMonth;for(var i=0;i{let table=document.createElement("table"),tbody=document.createElement("tbody"),trow=document.createElement("tr");for(var i=1;i<7;i++)if(0!==heatRangeScale[i]){let cell=document.createElement("td"),cellText=document.createTextNode(heatRangeScale[i]+"+");cell.appendChild(cellText),cell.style.backgroundColor=colorArray[i],cell.style.color=getContrast(colorArray[i]),trow.appendChild(cell)}tbody.appendChild(trow),table.appendChild(tbody),heatRangeScale={1:0,2:0,3:0,4:0,5:0,6:0},resolve(table)}))},Calendar.generate=function(year,startMonth,endMonth,metric,modules){return new Promise(((resolve,reject)=>{const dateObj={year:year,startMonth:startMonth,endMonth:endMonth},eventObj={year:year,metric:metric,modules:modules};Str.get_strings(stringArr).then((stringReturn=>(stringResult=stringReturn,eventObj))).then(getEvents).then((eventArray=>{!function(eventArray,dateObj){new Promise((resolve=>{if(void 0===eventArray&&(heatRangeMax=0,heatRangeMin=0,resolve(eventArray)),Object.keys(eventArray).length>0&&"undefined"!==eventArray[dateObj.year]){let eventcount=new Array,year=eventArray[dateObj.year];for(let i=0;i<12;i++)if(void 0!==year[i]){let month=year[i];for(let j=0;j<32;j++)void 0!==month[j]&&eventcount.push(month[j].number)}heatRangeMax=Math.max(...eventcount),heatRangeMin=Math.min(...eventcount)}else heatRangeMax=0,heatRangeMin=0;resolve(eventArray)}))}(eventArray,dateObj)})).then(getHeatColors).then(getProcessModules).then((()=>dateObj)).then(createTables).then(populateCalendar).then((calendarHTML=>{void 0!==calendarHTML?resolve(calendarHTML):reject(Error("Could not generate calendar"))}))}))},Calendar})); - -//# sourceMappingURL=calendar.min.js.map \ No newline at end of file diff --git a/amd/build/calendar.min.js.map b/amd/build/calendar.min.js.map deleted file mode 100644 index af3cc6c..0000000 --- a/amd/build/calendar.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"calendar.min.js","sources":["../src/calendar.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript for heatmap calendar generation and display.\n *\n * @package\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['core/str', 'core/notification', 'core/ajax'], function (Str, Notification, Ajax) {\n\n /**\n * Module level variables.\n */\n var Calendar = {};\n var eventArray = [];\n const stringArr = [\n {key: 'sun', component: 'calendar'},\n {key: 'mon', component: 'calendar'},\n {key: 'tue', component: 'calendar'},\n {key: 'wed', component: 'calendar'},\n {key: 'thu', component: 'calendar'},\n {key: 'fri', component: 'calendar'},\n {key: 'sat', component: 'calendar'},\n {key: 'jan', component: 'local_assessfreq'},\n {key: 'feb', component: 'local_assessfreq'},\n {key: 'mar', component: 'local_assessfreq'},\n {key: 'apr', component: 'local_assessfreq'},\n {key: 'may', component: 'local_assessfreq'},\n {key: 'jun', component: 'local_assessfreq'},\n {key: 'jul', component: 'local_assessfreq'},\n {key: 'aug', component: 'local_assessfreq'},\n {key: 'sep', component: 'local_assessfreq'},\n {key: 'oct', component: 'local_assessfreq'},\n {key: 'nov', component: 'local_assessfreq'},\n {key: 'dec', component: 'local_assessfreq'},\n ];\n var stringResult;\n var heatRangeMax;\n var heatRangeMin;\n var colorArray;\n var processModules;\n var heatRangeScale = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0};\n\n /**\n * Pick a contrasting text color based on the background color.\n *\n * @param {String} hexcolor.\n * @return {String} The contrasting color (black or white).\n */\n const getContrast = function (hexcolor) {\n\n if (typeof (hexcolor) === \"undefined\") {\n return '#000000';\n }\n\n // If a leading # is provided, remove it.\n if (hexcolor.slice(0, 1) === '#') {\n hexcolor = hexcolor.slice(1);\n }\n\n // Convert to RGB value.\n var r = parseInt(hexcolor.substr(0,2),16);\n var g = parseInt(hexcolor.substr(2,2),16);\n var b = parseInt(hexcolor.substr(4,2),16);\n\n // Get YIQ ratio.\n var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;\n\n // Check contrast.\n return (yiq >= 128) ? '#000000' : '#FFFFFF';\n };\n\n /**\n * Check how many days in a month code.\n * from https://dzone.com/articles/determining-number-days-month.\n *\n * @method daysInMonth\n * @param {Number} month The month to get the number of days for.\n * @param {Number} year The year to get the number of days for.\n */\n const daysInMonth = function (month, year) {\n return 32 - new Date(year, month, 32).getDate();\n };\n\n /**\n * Get the heat colors to use in the heat map via Ajax.\n *\n * @method getHeatColors\n */\n const getHeatColors = function () {\n return new Promise((resolve, reject) => {\n Ajax.call([{\n methodname: 'local_assessfreq_get_heat_colors',\n args: {},\n }], true, false)[0].done(function (response) {\n colorArray = JSON.parse(response);\n resolve(colorArray);\n }).fail(function () {\n reject(new Error('Failed to get heat colors'));\n });\n });\n };\n\n /**\n * Get the event names that we are processing.\n *\n * @method getProcessEvents\n */\n const getProcessModules = function () {\n return new Promise((resolve, reject) => {\n Ajax.call([{\n methodname: 'local_assessfreq_get_process_modules',\n args: {},\n }], true, false)[0].done(function (response) {\n processModules = JSON.parse(response);\n resolve(processModules);\n }).fail(function () {\n reject(new Error('Failed to get process events'));\n });\n });\n };\n\n /**\n * Calculate the min and max values to use in the heatmap.\n *\n * @method daysInMonth\n * @param {Object} eventArray All the event count for the heatmap.\n * @param {Object} dateObj Date details.\n */\n const calcHeatRange = function (eventArray, dateObj) {\n return new Promise((resolve) => {\n\n // Resolve early if there are no events.\n if (typeof (eventArray) === \"undefined\") {\n heatRangeMax = 0;\n heatRangeMin = 0;\n\n resolve(eventArray);\n }\n // If scheduled tasks have not run yet we may not have any data.\n let eventArrayLength = Object.keys(eventArray).length;\n if ((eventArrayLength > 0) && (eventArray[dateObj.year] !== \"undefined\")) {\n let eventcount = new Array;\n let year = eventArray[dateObj.year];\n\n // Iterate through all the event counts.\n // This code looks nasty but there is only 366 days in a year.\n for (let i = 0; i < 12; i++) {\n if (typeof year[i] !== \"undefined\") {\n let month = year[i];\n for (let j = 0; j < 32; j++) {\n if (typeof month[j] !== \"undefined\") {\n eventcount.push(month[j].number);\n }\n }\n }\n }\n\n // Get min and max values to calculate heat spread.\n heatRangeMax = Math.max(...eventcount);\n heatRangeMin = Math.min(...eventcount);\n } else {\n heatRangeMax = 0;\n heatRangeMin = 0;\n }\n\n resolve(eventArray);\n });\n };\n\n /**\n * Translate assessment frequency to a heat value.\n *\n * @method getHeat\n * @param {Number} eventCount The count to get the heat value.\n * @return {Number} heat The heat value.\n */\n const getHeat = function (eventCount) {\n let scaleMin = 1;\n\n if (eventCount == heatRangeMin) {\n return scaleMin;\n }\n\n const scaleRange = 5; // 0 - 5 steps.\n const localRange = heatRangeMax - heatRangeMin;\n const localPercent = (eventCount - heatRangeMin) / localRange;\n let heat = Math.round((localPercent * scaleRange) + 1);\n\n // Clamp values.\n if (heat < 1) {\n heat = 1;\n }\n\n if (heat > 6) {\n heat = 6;\n }\n\n return heat;\n };\n\n /**\n * Get the events to display in the calendar via ajax call.\n *\n * @method getEvents\n * @param {Object} Object\n * @param {Number} Object.year The year to get the events for.\n * @param {String} Object.metric The type of metric to get, 'students' or 'assess'.\n * @param {Array} Object.modules Array of the modules to get.\n * @return {Promise}\n */\n const getEvents = function ({year, metric, modules}) {\n return new Promise((resolve, reject) => {\n let args = {\n year: year,\n metric: metric,\n modules: modules\n };\n let jsonArgs = JSON.stringify(args);\n\n // Get the events to use in the mapping.\n Ajax.call([{\n methodname: 'local_assessfreq_get_frequency',\n args: {\n jsondata: jsonArgs\n },\n }])[0].done((response) => {\n eventArray = JSON.parse(response);\n resolve(eventArray);\n }).fail(() => {\n reject(new Error('Failed to get events'));\n });\n });\n };\n\n /**\n * Get the events for a particular month and year.\n *\n * @param {Number} year The year to get the number of days for.\n * @param {Number} month The month to get the number of days for.\n * @return {Array} monthevents The events for the supplied month.\n */\n const getMonthEvents = function(year, month) {\n let monthevents;\n\n if ((typeof eventArray[year] !== \"undefined\") && (typeof eventArray[year][month] !== \"undefined\")) {\n monthevents = eventArray[year][month];\n }\n\n return monthevents;\n };\n\n /**\n * Create the table structure for the calendar months.\n *\n * @param {Object} Object\n * @param {Number} Object.year The year to generate the tables for.\n * @param {Number} Object.startMonth The month to start table generation from.\n * @param {Number} Object.endMonth The month to generate the tables to.\n * @return {Promise}\n */\n const createTables = function ({year, startMonth, endMonth}) {\n return new Promise((resolve, reject) => {\n let calendarContainer = document.createElement('div');\n let month = startMonth;\n\n // Itterate through and build are tables.\n for (let i = startMonth; i <= endMonth; i++) {\n // Setup some elements.\n let container = document.createElement('div');\n container.classList.add('local-assessfreq-month');\n let table = document.createElement('table');\n table.classList.add('table-striped');\n let thead = document.createElement('thead');\n let tbody = document.createElement('tbody');\n tbody.id = 'calendar-body-' + i;\n let monthRow = document.createElement('tr');\n let dayrow = document.createElement('tr');\n let monthHeader = document.createElement('th');\n monthHeader.colSpan = 7;\n monthHeader.innerHTML = stringResult[(7 + month)];\n\n for (let j = 0; j < 7; j++) {\n let dayHeader = document.createElement('th');\n dayHeader.innerHTML = stringResult[j];\n dayrow.appendChild(dayHeader);\n }\n\n // Construct the table.\n monthRow.appendChild(monthHeader);\n\n thead.appendChild(monthRow);\n thead.appendChild(dayrow);\n\n table.appendChild(thead);\n table.appendChild(tbody);\n\n container.appendChild(table);\n\n // Add to parent.\n calendarContainer.appendChild(container);\n\n // Increment variables.\n month++;\n }\n\n if ((typeof year === 'undefined') || (typeof startMonth === 'undefined') || (typeof endMonth === 'undefined')) {\n reject(Error('Failed to create calendar tables.'));\n } else {\n const resultObj = {\n calendarContainer : calendarContainer,\n year : year,\n startMonth : startMonth\n };\n resolve(resultObj);\n }\n });\n };\n\n /**\n * Generate the tooltip HTML.\n *\n * @param {Object} dayArray The details of the events for that day/\n * @return {String} tipHTML The HTML for the tooltip.\n */\n const getTooltip = function (dayArray) {\n let tipHTML = '';\n\n for (let [key, value] of Object.entries(dayArray)) {\n tipHTML += '' + processModules[key] + ': ' + value + '
';\n }\n\n return tipHTML;\n };\n\n /**\n * Generate calendar markup for the month.\n *\n * @param {Object} table The base table to populate.\n * @param {Number} year The year to generate calendar for.\n * @param {Number} month The monthe to generate calendar for.\n */\n const populateCalendarDays = function (table, year, month) {\n let firstDay = (new Date(year, month)).getDay(); // Get the starting day of the month.\n let monthEvents = getMonthEvents(year, (month + 1)); // We add one due to month diferences between PHP and JS.\n let date = 1; // Creating all cells.\n\n for (let i = 0; i < 6; i++) {\n let row = document.createElement(\"tr\"); // Creates a table row.\n\n // Creating individual cells, filing them up with data.\n for (let j = 0; j < 7; j++) {\n if (i === 0 && j < firstDay) {\n var cell = document.createElement(\"td\");\n var cellText = document.createTextNode(\"\");\n cell.dataset.event = 'false';\n } else if (date > daysInMonth(month, year)) { // Break if we have generated all the days for this month.\n break;\n } else {\n cell = document.createElement(\"td\");\n cellText = document.createTextNode(date);\n if ((typeof monthEvents !== \"undefined\") && (monthEvents.hasOwnProperty(date))) {\n let heat = getHeat(monthEvents[date]['number']);\n\n if (heatRangeScale[heat] == 0 || heatRangeScale[heat] > monthEvents[date]['number']) {\n heatRangeScale[heat] = monthEvents[date]['number'];\n }\n\n cell.style.backgroundColor = colorArray[heat];\n cell.style.color = getContrast(colorArray[heat]);\n\n // Add tooltip to cell.\n cell.dataset.toggle = 'tooltip';\n cell.dataset.html = 'true';\n cell.dataset.event = 'true';\n cell.dataset.date = year + '-' + (month + 1) + '-' + date;\n cell.title = getTooltip(monthEvents[date]);\n cell.style.cursor = \"pointer\";\n }\n date++;\n }\n\n cell.appendChild(cellText);\n row.appendChild(cell);\n }\n table.appendChild(row); // Appending each row into calendar body.\n }\n };\n\n /**\n * Controls the population of the calendar in to the base tables.\n *\n * @param {Object} Object\n * @param {Object} Object.calendarContainer the container to populate.\n * @param {Number} Object.year The year to generate calendar for.\n * @param {Number} Object.startMonth The month to start generation from.\n * @return {Promise}\n */\n const populateCalendar = function ({calendarContainer, year, startMonth}) {\n return new Promise((resolve, reject) => {\n // Get the table boodies.\n let tables = calendarContainer.getElementsByTagName(\"tbody\");\n let month = startMonth;\n\n // For each table body populate with calendar.\n for (var i = 0; i < tables.length; i++) {\n let table = tables[i];\n populateCalendarDays(table, year, month);\n month++;\n }\n\n if (typeof calendarContainer === 'undefined') {\n reject(Error('Failed to populate calendar tables.'));\n } else {\n resolve(calendarContainer);\n }\n });\n };\n\n /**\n * Create the heatmap scale for the calendar.\n *\n * @method createHeatScale\n */\n Calendar.createHeatScale = function () {\n return new Promise((resolve) => {\n let table = document.createElement('table');\n let tbody = document.createElement('tbody');\n let trow = document.createElement('tr');\n\n for (var i = 1; i < 7; i++) {\n if (heatRangeScale[i] !== 0) {\n let cell = document.createElement('td');\n let cellText = document.createTextNode(heatRangeScale[i] + '+');\n\n cell.appendChild(cellText);\n cell.style.backgroundColor = colorArray[i];\n cell.style.color = getContrast(colorArray[i]);\n\n trow.appendChild(cell);\n }\n }\n\n tbody.appendChild(trow);\n table.appendChild(tbody);\n\n // Reset heat range scale.\n heatRangeScale = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0};\n\n resolve(table);\n });\n };\n\n /**\n * Initialise method for report calendar heatmap creation.\n *\n * @param {Number} year The year to generate the heatmap for.\n * @param {Number} startMonth The month to start with for the heatmap calendar.\n * @param {Number} endMonth The month to end with for the heatmap calendar.\n * @param {String} metric The type of metric to display, 'students' or 'aseess'.\n * @param {Array} modules The modules to display in the heatamp.\n * @return {Promise}\n */\n Calendar.generate = function (year, startMonth, endMonth, metric, modules) {\n return new Promise((resolve, reject) => {\n const dateObj = {\n year : year,\n startMonth : startMonth,\n endMonth : endMonth\n };\n\n const eventObj = {\n year : year,\n metric : metric,\n modules : modules\n };\n\n Str.get_strings(stringArr).then(stringReturn => { // Save string to global to be used later.\n stringResult = stringReturn;\n return eventObj;\n })\n .then(getEvents)\n .then((eventArray) => {\n calcHeatRange(eventArray, dateObj);\n })\n .then(getHeatColors)\n .then(getProcessModules)\n .then(() => {\n return dateObj;\n })\n .then(createTables) // Create tables for calendar.\n .then(populateCalendar)\n .then((calendarHTML) => { // Return the result of the generate function.\n if (typeof calendarHTML !== 'undefined') {\n resolve(calendarHTML);\n } else {\n reject(Error('Could not generate calendar'));\n }\n });\n });\n\n };\n\n return Calendar;\n});\n"],"names":["define","Str","Notification","Ajax","Calendar","eventArray","stringArr","key","component","stringResult","heatRangeMax","heatRangeMin","colorArray","processModules","heatRangeScale","getContrast","hexcolor","slice","parseInt","substr","daysInMonth","month","year","Date","getDate","getHeatColors","Promise","resolve","reject","call","methodname","args","done","response","JSON","parse","fail","Error","getProcessModules","getHeat","eventCount","localPercent","heat","Math","round","getEvents","metric","modules","jsonArgs","stringify","jsondata","createTables","startMonth","endMonth","calendarContainer","document","createElement","i","container","classList","add","table","thead","tbody","id","monthRow","dayrow","monthHeader","colSpan","innerHTML","j","dayHeader","appendChild","getTooltip","dayArray","tipHTML","value","Object","entries","populateCalendarDays","firstDay","getDay","monthEvents","monthevents","getMonthEvents","date","row","cell","cellText","createTextNode","dataset","event","hasOwnProperty","style","backgroundColor","color","toggle","html","title","cursor","populateCalendar","tables","getElementsByTagName","length","createHeatScale","trow","generate","dateObj","eventObj","get_strings","then","stringReturn","keys","eventcount","Array","push","number","max","min","calcHeatRange","calendarHTML"],"mappings":";;;;;;;AAuBAA,mCAAO,CAAC,WAAY,oBAAqB,cAAc,SAAUC,IAAKC,aAAcC,UAK5EC,SAAW,GACXC,WAAa,SACXC,UAAY,CACd,CAACC,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,yBAExBC,aACAC,aACAC,aACAC,WACAC,eACAC,eAAiB,GAAM,IAAQ,IAAQ,IAAQ,IAAQ,IAAQ,SAQ7DC,YAAc,SAAUC,sBAEA,IAAdA,SACD,WAIkB,MAAzBA,SAASC,MAAM,EAAG,KAClBD,SAAWA,SAASC,MAAM,KASd,IALRC,SAASF,SAASG,OAAO,EAAE,GAAG,IAKV,IAJpBD,S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,KAAKmC,GAAoB,KAC5BpC,MAAQC,KAAKmC,OACZ,IAAIa,EAAI,EAAGA,EAAI,GAAIA,SACI,IAAbjD,MAAMiD,IACb2C,WAAWE,KAAK9F,MAAMiD,GAAG8C,QAOzC1G,aAAeiC,KAAK0E,OAAOJ,YAC3BtG,aAAegC,KAAK2E,OAAOL,iBAE3BvG,aAAe,EACfC,aAAe,EAGnBgB,QAAQtB,eA6TJkH,CAAclH,WAAYsG,YAE7BG,KAAKrF,eACLqF,KAAKxE,mBACLwE,MAAK,IACKH,UAEVG,KAAK3D,cACL2D,KAAKV,kBACLU,MAAMU,oBACyB,IAAjBA,aACP7F,QAAQ6F,cAER5F,OAAOS,MAAM,uCAOtBjC"} \ No newline at end of file diff --git a/amd/build/chart_data.min.js b/amd/build/chart_data.min.js deleted file mode 100644 index 550eec2..0000000 --- a/amd/build/chart_data.min.js +++ /dev/null @@ -1,11 +0,0 @@ -define("local_assessfreq/chart_data",["exports","core/fragment","core/notification","core/str","core/templates"],(function(_exports,_fragment,_notification,Str,_templates){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} -/** - * Chart data JS module. - * - * @module local_assessfreq/char_data - * @package - * @copyright 2020 Guillermo Gomez - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */let cards,contextId,fragment,template;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=_exports.getCardCharts=void 0,_fragment=_interopRequireDefault(_fragment),_notification=_interopRequireDefault(_notification),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_templates=_interopRequireDefault(_templates);_exports.getCardCharts=(quizId,hoursFilter,yearSelect)=>{cards.forEach((cardData=>{let cardElement=document.getElementById(cardData.cardId),spinner=cardElement.getElementsByClassName("overlay-icon-container")[0],chartBody=cardElement.getElementsByClassName("chart-body")[0],values={call:cardData.call};hoursFilter&&(values.hoursahead=hoursFilter[0],values.hoursbehind=hoursFilter[1]),quizId&&(values.quiz=quizId),yearSelect&&(values.year=yearSelect);let params={data:JSON.stringify(values)};spinner.classList.remove("hide"),_fragment.default.loadFragment("local_assessfreq",fragment,contextId,params).done((response=>{let resObj=JSON.parse(response);if(!0===resObj.hasdata){let context={withtable:!0,chartdata:JSON.stringify(resObj.chart)};return void 0!==cardData.aspect&&(context.aspect=cardData.aspect),void _templates.default.render(template,context).done(((html,js)=>{spinner.classList.add("hide"),_templates.default.replaceNodeContents(chartBody,html,js)})).fail((()=>{_notification.default.exception(new Error("Failed to load chart template."))}))}Str.get_string("nodata","local_assessfreq").then((str=>{const noDatastr=document.createElement("h3");noDatastr.innerHTML=str,chartBody.innerHTML=noDatastr.outerHTML,spinner.classList.add("hide")}))})).fail((()=>{_notification.default.exception(new Error("Failed to load card."))}))}))};_exports.init=(cardsArray,contextIdChart,fragmentChart,templateChart)=>{cards=cardsArray,contextId=contextIdChart,fragment=fragmentChart,template=templateChart}})); - -//# sourceMappingURL=chart_data.min.js.map \ No newline at end of file diff --git a/amd/build/chart_data.min.js.map b/amd/build/chart_data.min.js.map deleted file mode 100644 index d6d4b03..0000000 --- a/amd/build/chart_data.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"chart_data.min.js","sources":["../src/chart_data.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Chart data JS module.\n *\n * @module local_assessfreq/char_data\n * @package\n * @copyright 2020 Guillermo Gomez \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Fragment from 'core/fragment';\nimport Notification from 'core/notification';\nimport * as Str from 'core/str';\nimport Templates from 'core/templates';\n\n/**\n * Module level variables.\n */\nlet cards;\nlet contextId;\nlet fragment;\nlet template;\n\n/**\n * For each of the cards on the dashboard get their corresponding chart data.\n * Data is based on the year variable from the corresponding dropdown.\n * Chart data is loaded via ajax.\n *\n * @param {int|null} quizId The quiz Id.\n * @param {array|null} hoursFilter Array with hour ahead or behind preference.\n * @param {int|null} yearSelect Year selected.\n */\nexport const getCardCharts = (quizId, hoursFilter, yearSelect) => {\n cards.forEach((cardData) => {\n let cardElement = document.getElementById(cardData.cardId);\n let spinner = cardElement.getElementsByClassName('overlay-icon-container')[0];\n let chartBody = cardElement.getElementsByClassName('chart-body')[0];\n let values = {'call': cardData.call};\n // Add values to Object depending on dashboard type.\n if (hoursFilter) {\n values.hoursahead = hoursFilter[0];\n values.hoursbehind = hoursFilter[1];\n }\n if (quizId) {\n values.quiz = quizId;\n }\n if (yearSelect) {\n values.year = yearSelect;\n }\n let params = {'data': JSON.stringify(values)};\n\n spinner.classList.remove('hide'); // Show sinner if not already shown.\n Fragment.loadFragment('local_assessfreq', fragment, contextId, params)\n .done((response) => {\n let resObj = JSON.parse(response);\n if (resObj.hasdata === true) {\n let context = {\n 'withtable': true, 'chartdata': JSON.stringify(resObj.chart)\n };\n if (typeof cardData.aspect !== 'undefined') {\n context.aspect = cardData.aspect;\n }\n Templates.render(template, context).done((html, js) => {\n spinner.classList.add('hide'); // Hide spinner if not already hidden.\n // Load card body.\n Templates.replaceNodeContents(chartBody, html, js);\n }).fail(() => {\n Notification.exception(new Error('Failed to load chart template.'));\n return;\n });\n return;\n } else {\n Str.get_string('nodata', 'local_assessfreq').then((str) => {\n const noDatastr = document.createElement('h3');\n noDatastr.innerHTML = str;\n chartBody.innerHTML = noDatastr.outerHTML;\n spinner.classList.add('hide'); // Hide spinner if not already hidden.\n return;\n });\n }\n }).fail(() => {\n Notification.exception(new Error('Failed to load card.'));\n return;\n });\n });\n};\n\n/**\n * Initialise method for table handler.\n *\n * @param {array} cardsArray Cards array.\n * @param {int} contextIdChart The context id.\n * @param {string} fragmentChart Fragment name.\n * @param {string} templateChart Template name.\n */\nexport const init = (cardsArray, contextIdChart, fragmentChart, templateChart) => {\n cards = cardsArray;\n contextId = contextIdChart;\n fragment = fragmentChart;\n template = templateChart;\n};\n"],"names":["cards","contextId","fragment","template","quizId","hoursFilter","yearSelect","forEach","cardData","cardElement","document","getElementById","cardId","spinner","getElementsByClassName","chartBody","values","call","hoursahead","hoursbehind","quiz","year","params","JSON","stringify","classList","remove","loadFragment","done","response","resObj","parse","hasdata","context","chart","aspect","render","html","js","add","replaceNodeContents","fail","exception","Error","Str","get_string","then","str","noDatastr","createElement","innerHTML","outerHTML","cardsArray","contextIdChart","fragmentChart","templateChart"],"mappings":";;;;;;;;SAgCIA,MACAC,UACAC,SACAC,w6BAWyB,CAACC,OAAQC,YAAaC,cAC/CN,MAAMO,SAASC,eACPC,YAAcC,SAASC,eAAeH,SAASI,QAC/CC,QAAUJ,YAAYK,uBAAuB,0BAA0B,GACvEC,UAAYN,YAAYK,uBAAuB,cAAc,GAC7DE,OAAS,MAASR,SAASS,MAE3BZ,cACAW,OAAOE,WAAab,YAAY,GAChCW,OAAOG,YAAcd,YAAY,IAEjCD,SACAY,OAAOI,KAAOhB,QAEdE,aACAU,OAAOK,KAAOf,gBAEdgB,OAAS,MAASC,KAAKC,UAAUR,SAErCH,QAAQY,UAAUC,OAAO,0BAChBC,aAAa,mBAAoBzB,SAAUD,UAAWqB,QAC1DM,MAAMC,eACCC,OAASP,KAAKQ,MAAMF,cACD,IAAnBC,OAAOE,QAAkB,KACrBC,QAAU,YACG,YAAmBV,KAAKC,UAAUM,OAAOI,oBAE3B,IAApB1B,SAAS2B,SAChBF,QAAQE,OAAS3B,SAAS2B,gCAEpBC,OAAOjC,SAAU8B,SAASL,MAAK,CAACS,KAAMC,MAC5CzB,QAAQY,UAAUc,IAAI,2BAEZC,oBAAoBzB,UAAWsB,KAAMC,OAChDG,MAAK,2BACSC,UAAU,IAAIC,MAAM,sCAKrCC,IAAIC,WAAW,SAAU,oBAAoBC,MAAMC,YACzCC,UAAYtC,SAASuC,cAAc,MACzCD,UAAUE,UAAYH,IACtBhC,UAAUmC,UAAYF,UAAUG,UAChCtC,QAAQY,UAAUc,IAAI,cAI/BE,MAAK,2BACSC,UAAU,IAAIC,MAAM,8CAc7B,CAACS,WAAYC,eAAgBC,cAAeC,iBAC5DvD,MAAQoD,WACRnD,UAAYoD,eACZnD,SAAWoD,cACXnD,SAAWoD"} \ No newline at end of file diff --git a/amd/build/chart_output_chartjs.min.js b/amd/build/chart_output_chartjs.min.js deleted file mode 100644 index 36d9393..0000000 --- a/amd/build/chart_output_chartjs.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Chart output for chart.js with custom override for aspect config. - * - * @package - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("local_assessfreq/chart_output_chartjs",["core/chart_output_chartjs"],(function(Output){var ChartOutput={},aspectRatio=!1,rtLegendoptions=!1;return Output.prototype._makeConfig=function(){var config={type:this._getChartType(),data:{labels:this._cleanData(this._chart.getLabels()),datasets:this._makeDatasetsConfig()},options:{title:{display:null!==this._chart.getTitle(),text:this._cleanData(this._chart.getTitle())}}},legendOptions=this._chart.getLegendOptions();return legendOptions&&(config.options.legend=legendOptions),rtLegendoptions&&(config.options.legend=rtLegendoptions),this._chart.getXAxes().forEach(function(axis,i){var axisLabels=axis.getLabels();config.options.scales=config.options.scales||{},config.options.scales.xAxes=config.options.scales.xAxes||[],config.options.scales.xAxes[i]=this._makeAxisConfig(axis,"x",i),null!==axisLabels&&(config.options.scales.xAxes[i].ticks.callback=function(value,index){return axisLabels[index]||""}),config.options.scales.xAxes[i].stacked=this._isStacked()}.bind(this)),this._chart.getYAxes().forEach(function(axis,i){var axisLabels=axis.getLabels();config.options.scales=config.options.scales||{},config.options.scales.yAxes=config.options.scales.yAxes||[],config.options.scales.yAxes[i]=this._makeAxisConfig(axis,"y",i),null!==axisLabels&&(config.options.scales.yAxes[i].ticks.callback=function(value){return axisLabels[parseInt(value,10)]||""}),config.options.scales.yAxes[i].stacked=this._isStacked()}.bind(this)),config.options.tooltips={callbacks:{label:this._makeTooltip.bind(this)}},config.options.maintainAspectRatio=aspectRatio,config},ChartOutput.init=function(chartImage,ChartInst,aspect,legend){aspectRatio=aspect,rtLegendoptions=legend,new Output(chartImage,ChartInst)},ChartOutput})); - -//# sourceMappingURL=chart_output_chartjs.min.js.map \ No newline at end of file diff --git a/amd/build/chart_output_chartjs.min.js.map b/amd/build/chart_output_chartjs.min.js.map deleted file mode 100644 index 8b1907d..0000000 --- a/amd/build/chart_output_chartjs.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"chart_output_chartjs.min.js","sources":["../src/chart_output_chartjs.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Chart output for chart.js with custom override for aspect config.\n *\n * @package\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/chart_output_chartjs'], function (Output) {\n\n /**\n * Module level variables.\n */\n var ChartOutput = {};\n var aspectRatio = false;\n var rtLegendoptions = false;\n\n /**\n * Overrride the config.\n *\n * @protected\n * @return {Object} The axis config.\n */\n Output.prototype._makeConfig = function () {\n var config = {\n type: this._getChartType(),\n data: {\n labels: this._cleanData(this._chart.getLabels()),\n datasets: this._makeDatasetsConfig()\n },\n options: {\n title: {\n display: this._chart.getTitle() !== null,\n text: this._cleanData(this._chart.getTitle())\n }\n }\n };\n var legendOptions = this._chart.getLegendOptions();\n if (legendOptions) {\n config.options.legend = legendOptions;\n }\n\n // Override legend options with those provided at run time.\n if (rtLegendoptions) {\n config.options.legend = rtLegendoptions;\n }\n\n this._chart.getXAxes().forEach(function (axis, i) {\n var axisLabels = axis.getLabels();\n\n config.options.scales = config.options.scales || {};\n config.options.scales.xAxes = config.options.scales.xAxes || [];\n config.options.scales.xAxes[i] = this._makeAxisConfig(axis, 'x', i);\n\n if (axisLabels !== null) {\n config.options.scales.xAxes[i].ticks.callback = function (value, index) {\n return axisLabels[index] || '';\n };\n }\n config.options.scales.xAxes[i].stacked = this._isStacked();\n }.bind(this));\n\n this._chart.getYAxes().forEach(function (axis, i) {\n var axisLabels = axis.getLabels();\n\n config.options.scales = config.options.scales || {};\n config.options.scales.yAxes = config.options.scales.yAxes || [];\n config.options.scales.yAxes[i] = this._makeAxisConfig(axis, 'y', i);\n\n if (axisLabels !== null) {\n config.options.scales.yAxes[i].ticks.callback = function (value) {\n return axisLabels[parseInt(value, 10)] || '';\n };\n }\n config.options.scales.yAxes[i].stacked = this._isStacked();\n }.bind(this));\n\n config.options.tooltips = {\n callbacks: {\n label: this._makeTooltip.bind(this)\n }\n };\n\n config.options.maintainAspectRatio = aspectRatio;\n\n return config;\n };\n\n /**\n * Get the aspect ratio setting and initialise the chart.\n */\n ChartOutput.init = function (chartImage, ChartInst, aspect, legend) {\n aspectRatio = aspect;\n rtLegendoptions = legend;\n new Output(chartImage, ChartInst);\n };\n\n return ChartOutput;\n\n});\n"],"names":["define","Output","ChartOutput","aspectRatio","rtLegendoptions","prototype","_makeConfig","config","type","this","_getChartType","data","labels","_cleanData","_chart","getLabels","datasets","_makeDatasetsConfig","options","title","display","getTitle","text","legendOptions","getLegendOptions","legend","getXAxes","forEach","axis","i","axisLabels","scales","xAxes","_makeAxisConfig","ticks","callback","value","index","stacked","_isStacked","bind","getYAxes","yAxes","parseInt","tooltips","callbacks","label","_makeTooltip","maintainAspectRatio","init","chartImage","ChartInst","aspect"],"mappings":";;;;;;;AAsBAA,+CAAO,CAAC,8BAA8B,SAAUC,YAKxCC,YAAc,GACdC,aAAc,EACdC,iBAAkB,SAQtBH,OAAOI,UAAUC,YAAc,eACvBC,OAAS,CACTC,KAAMC,KAAKC,gBACXC,KAAM,CACFC,OAAQH,KAAKI,WAAWJ,KAAKK,OAAOC,aACpCC,SAAUP,KAAKQ,uBAEnBC,QAAS,CACLC,MAAO,CACHC,QAAoC,OAA3BX,KAAKK,OAAOO,WACrBC,KAAMb,KAAKI,WAAWJ,KAAKK,OAAOO,eAI1CE,cAAgBd,KAAKK,OAAOU,0BAC5BD,gBACAhB,OAAOW,QAAQO,OAASF,eAIxBnB,kBACAG,OAAOW,QAAQO,OAASrB,sBAGvBU,OAAOY,WAAWC,QAAQ,SAAUC,KAAMC,OACvCC,WAAaF,KAAKb,YAEtBR,OAAOW,QAAQa,OAASxB,OAAOW,QAAQa,QAAU,GACjDxB,OAAOW,QAAQa,OAAOC,MAAQzB,OAAOW,QAAQa,OAAOC,OAAS,GAC7DzB,OAAOW,QAAQa,OAAOC,MAAMH,GAAKpB,KAAKwB,gBAAgBL,KAAM,IAAKC,GAE9C,OAAfC,aACAvB,OAAOW,QAAQa,OAAOC,MAAMH,GAAGK,MAAMC,SAAW,SAAUC,MAAOC,cACtDP,WAAWO,QAAU,KAGpC9B,OAAOW,QAAQa,OAAOC,MAAMH,GAAGS,QAAU7B,KAAK8B,cAChDC,KAAK/B,YAEFK,OAAO2B,WAAWd,QAAQ,SAAUC,KAAMC,OACvCC,WAAaF,KAAKb,YAEtBR,OAAOW,QAAQa,OAASxB,OAAOW,QAAQa,QAAU,GACjDxB,OAAOW,QAAQa,OAAOW,MAAQnC,OAAOW,QAAQa,OAAOW,OAAS,GAC7DnC,OAAOW,QAAQa,OAAOW,MAAMb,GAAKpB,KAAKwB,gBAAgBL,KAAM,IAAKC,GAE9C,OAAfC,aACAvB,OAAOW,QAAQa,OAAOW,MAAMb,GAAGK,MAAMC,SAAW,SAAUC,cAC/CN,WAAWa,SAASP,MAAO,MAAQ,KAGlD7B,OAAOW,QAAQa,OAAOW,MAAMb,GAAGS,QAAU7B,KAAK8B,cAChDC,KAAK/B,OAEPF,OAAOW,QAAQ0B,SAAW,CACtBC,UAAW,CACPC,MAAOrC,KAAKsC,aAAaP,KAAK/B,QAItCF,OAAOW,QAAQ8B,oBAAsB7C,YAE9BI,QAMXL,YAAY+C,KAAO,SAAUC,WAAYC,UAAWC,OAAQ3B,QACxDtB,YAAciD,OACdhD,gBAAkBqB,WACdxB,OAAOiD,WAAYC,YAGpBjD"} \ No newline at end of file diff --git a/amd/build/dashboard.min.js.map b/amd/build/dashboard.min.js.map index 1807fed..2f8e091 100644 --- a/amd/build/dashboard.min.js.map +++ b/amd/build/dashboard.min.js.map @@ -1 +1 @@ -{"version":3,"file":"dashboard.min.js","sources":["../src/dashboard.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Chart data JS module.\n *\n * @module local_assessfreq/dashboard\n * @package\n * @copyright Simon Thornett \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const init = () => {\n\n // Load the tab cuntionality.\n tabs();\n\n};\n\nconst tabs = () => {\n\n const tabcontent = document.getElementsByClassName(\"tablinks\");\n\n tabcontent.forEach(el => el.addEventListener('click', event => {\n let target = event.target.dataset.target;\n\n let tabcontent = document.getElementsByClassName(\"tabcontent\");\n for (let i = 0; i < tabcontent.length; i++) {\n tabcontent[i].style.display = \"none\";\n }\n\n // Get all elements with class=\"tablinks\" and remove the class \"active\"\n let tablinks = document.getElementsByClassName(\"tablinks\");\n for (let i = 0; i < tablinks.length; i++) {\n tablinks[i].className = tablinks[i].className.replace(\" active\", \"\");\n }\n\n // Show the current tab, and add an \"active\" class to the button that opened the tab\n document.getElementById(target).style.display = \"block\";\n event.currentTarget.className += \" active\";\n }));\n\n const currentUrl = document.URL;\n const urlParts = currentUrl.split('#');\n\n const anchor = (urlParts.length > 1) ? urlParts[1] : null;\n // First tab should be open by default unless we have an anchor.\n if (!anchor || document.querySelector('[data-target=\"tab-' + anchor + '\"]') === null) {\n document.querySelector('[data-target=\"tab-heatmap\"]').click();\n } else {\n document.querySelector('[data-target=\"tab-' + anchor + '\"]').click();\n }\n}\n"],"names":["tabs","document","getElementsByClassName","forEach","el","addEventListener","event","target","dataset","tabcontent","i","length","style","display","tablinks","className","replace","getElementById","currentTarget","urlParts","URL","split","anchor","querySelector","click"],"mappings":"+JAwBoB,KAGhBA,cAIEA,KAAO,KAEUC,SAASC,uBAAuB,YAExCC,SAAQC,IAAMA,GAAGC,iBAAiB,SAASC,YAC9CC,OAASD,MAAMC,OAAOC,QAAQD,OAE9BE,WAAaR,SAASC,uBAAuB,kBAC5C,IAAIQ,EAAI,EAAGA,EAAID,WAAWE,OAAQD,IACnCD,WAAWC,GAAGE,MAAMC,QAAU,WAI9BC,SAAWb,SAASC,uBAAuB,gBAC1C,IAAIQ,EAAI,EAAGA,EAAII,SAASH,OAAQD,IACjCI,SAASJ,GAAGK,UAAYD,SAASJ,GAAGK,UAAUC,QAAQ,UAAW,IAIrEf,SAASgB,eAAeV,QAAQK,MAAMC,QAAU,QAChDP,MAAMY,cAAcH,WAAa,qBAI/BI,SADalB,SAASmB,IACAC,MAAM,KAE5BC,OAAUH,SAASR,OAAS,EAAKQ,SAAS,GAAK,KAEhDG,QAA2E,OAAjErB,SAASsB,cAAc,qBAAuBD,OAAS,MAGlErB,SAASsB,cAAc,qBAAuBD,OAAS,MAAME,QAF7DvB,SAASsB,cAAc,+BAA+BC"} \ No newline at end of file +{"version":3,"file":"dashboard.min.js","sources":["../src/dashboard.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Chart data JS module.\n *\n * @module local_assessfreq/dashboard\n * @package\n * @copyright Simon Thornett \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const init = () => {\n\n // Load the tab cuntionality.\n tabs();\n\n};\n\nconst tabs = () => {\n\n const tabcontent = document.getElementsByClassName(\"tablinks\");\n\n tabcontent.forEach(el => el.addEventListener('click', event => {\n let target = event.target.dataset.target;\n\n let tabcontent = document.getElementsByClassName(\"tabcontent\");\n for (let i = 0; i < tabcontent.length; i++) {\n tabcontent[i].style.display = \"none\";\n }\n\n // Get all elements with class=\"tablinks\" and remove the class \"active\"\n let tablinks = document.getElementsByClassName(\"tablinks\");\n for (let i = 0; i < tablinks.length; i++) {\n tablinks[i].className = tablinks[i].className.replace(\" active\", \"\");\n }\n\n // Show the current tab, and add an \"active\" class to the button that opened the tab\n document.getElementById(target).style.display = \"block\";\n event.currentTarget.className += \" active\";\n }));\n\n const currentUrl = document.URL;\n const urlParts = currentUrl.split('#');\n\n const anchor = (urlParts.length > 1) ? urlParts[1] : null;\n // First tab should be open by default unless we have an anchor.\n if (!anchor || document.querySelector('[data-target=\"tab-' + anchor + '\"]') === null) {\n document.querySelector('[data-target=\"tab-heatmap\"]').click();\n } else {\n document.querySelector('[data-target=\"tab-' + anchor + '\"]').click();\n }\n};\n"],"names":["tabs","document","getElementsByClassName","forEach","el","addEventListener","event","target","dataset","tabcontent","i","length","style","display","tablinks","className","replace","getElementById","currentTarget","urlParts","URL","split","anchor","querySelector","click"],"mappings":"+JAwBoB,KAGhBA,cAIEA,KAAO,KAEUC,SAASC,uBAAuB,YAExCC,SAAQC,IAAMA,GAAGC,iBAAiB,SAASC,YAC9CC,OAASD,MAAMC,OAAOC,QAAQD,OAE9BE,WAAaR,SAASC,uBAAuB,kBAC5C,IAAIQ,EAAI,EAAGA,EAAID,WAAWE,OAAQD,IACnCD,WAAWC,GAAGE,MAAMC,QAAU,WAI9BC,SAAWb,SAASC,uBAAuB,gBAC1C,IAAIQ,EAAI,EAAGA,EAAII,SAASH,OAAQD,IACjCI,SAASJ,GAAGK,UAAYD,SAASJ,GAAGK,UAAUC,QAAQ,UAAW,IAIrEf,SAASgB,eAAeV,QAAQK,MAAMC,QAAU,QAChDP,MAAMY,cAAcH,WAAa,qBAI/BI,SADalB,SAASmB,IACAC,MAAM,KAE5BC,OAAUH,SAASR,OAAS,EAAKQ,SAAS,GAAK,KAEhDG,QAA2E,OAAjErB,SAASsB,cAAc,qBAAuBD,OAAS,MAGlErB,SAASsB,cAAc,qBAAuBD,OAAS,MAAME,QAF7DvB,SAASsB,cAAc,+BAA+BC"} \ No newline at end of file diff --git a/amd/build/dashboard_assessment.min.js b/amd/build/dashboard_assessment.min.js deleted file mode 100644 index 835c060..0000000 --- a/amd/build/dashboard_assessment.min.js +++ /dev/null @@ -1,11 +0,0 @@ -define("local_assessfreq/dashboard_assessment",["exports","core/notification","local_assessfreq/calendar","local_assessfreq/chart_data","local_assessfreq/dayview","local_assessfreq/user_preferences","local_assessfreq/zoom_modal"],(function(_exports,_notification,_calendar,ChartData,_dayview,UserPreference,_zoom_modal){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} -/** - * Javascript for report card display and processing. - * - * @module local_assessfreq/dashboard_assessment - * @package local_assessfreq - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */var contextid,yearselect,yearselectheatmap,metricselectheatmap,timeout;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_notification=_interopRequireDefault(_notification),_calendar=_interopRequireDefault(_calendar),ChartData=_interopRequireWildcard(ChartData),_dayview=_interopRequireDefault(_dayview),UserPreference=_interopRequireWildcard(UserPreference),_zoom_modal=_interopRequireDefault(_zoom_modal);var modulesJson="",heatmapOptionsJson="";const cards=[{cardId:"local-assessfreq-assess-due-month",call:"assess_by_month"},{cardId:"local-assessfreq-assess-by-activity",call:"assess_by_activity"},{cardId:"local-assessfreq-assess-due-month-student",call:"assess_by_month_student"}],yearButtonAction=event=>{event.preventDefault();var element=event.target;"a"===element.tagName.toLowerCase()&&element.dataset.year!==yearselect&&(yearselect=element.dataset.year,UserPreference.setUserPreference("local_assessfreq_overview_year_preference",yearselect),document.getElementById("local-assessfreq-report-overview").getElementsByClassName("local-assessfreq-year")[0].innerHTML=yearselect,ChartData.getCardCharts(0,null,yearselect))},updateHeatmapDebounce=()=>{clearTimeout(timeout),timeout=setTimeout(updateHeatmap(),750)},detailView=event=>{let element=event.target;"td"===element.tagName.toLowerCase()&&"true"===element.dataset.event&&_dayview.default.display(element.dataset.date)},updateHeatmap=()=>{for(var links=document.getElementById("local-assessfreq-heatmap-modules").getElementsByTagName("a"),modules=[],i=0;i{let heatmapOptions=JSON.parse(heatmapOptionsJson),year=parseInt(heatmapOptions.year),metric=heatmapOptions.metric,modules=heatmapOptions.modules,spinner=document.getElementById("local-assessfreq-report-heatmap").getElementsByClassName("overlay-icon-container")[0];spinner.classList.remove("hide"),_calendar.default.generate(year,0,11,metric,modules).then((calendar=>{let calendarContainer=document.getElementById("local-assessfreq-report-heatmap-months");calendarContainer.innerHTML=calendar.innerHTML,calendarContainer.addEventListener("click",detailView)})).then(_calendar.default.createHeatScale).then((heatScale=>{document.getElementById("local-assessfreq-report-heatmap-scale").innerHTML=heatScale.outerHTML,spinner.classList.add("hide")})).catch((()=>{_notification.default.exception(new Error("Failed to calendar."))}))})(),(_ref=>{let{year:year,metric:metric,modules:modules}=_ref,downloadForm=document.getElementById("local-assessfreq-heatmap-form"),formElements=downloadForm.elements,toRemove=new Array;0===modules.length&&(modules=["all"]);for(let i=0;i{event.preventDefault();var element=event.target;"a"===element.tagName.toLowerCase()&&element.dataset.year!==yearselectheatmap&&(yearselectheatmap=element.dataset.year,UserPreference.setUserPreference("local_assessfreq_heatmap_year_preference",yearselectheatmap),document.getElementById("local-assessfreq-report-heatmap").getElementsByClassName("local-assessfreq-year")[0].innerHTML=yearselectheatmap,updateHeatmapDebounce())},metricHeatmapButtonAction=event=>{event.preventDefault();var element=event.target;"a"===element.tagName.toLowerCase()&&element.dataset.metric!==metricselectheatmap&&(metricselectheatmap=element.dataset.metric,UserPreference.setUserPreference("local_assessfreq_heatmap_metric_preference",metricselectheatmap),updateHeatmapDebounce())},triggerZoomGraph=event=>{let call=event.target.closest("div").dataset.call,params={data:JSON.stringify({year:yearselect,call:call})};_zoom_modal.default.zoomGraph(event,params,"get_chart")};_exports.init=context=>{contextid=context;let cardsYearSelectElement=document.getElementById("local-assessfreq-cards-year");yearselect=cardsYearSelectElement.getElementsByClassName("active")[0].dataset.year,cardsYearSelectElement.addEventListener("click",yearButtonAction);let cardsYearSelectHeatmapElement=document.getElementById("local-assessfreq-heatmap-year");yearselectheatmap=cardsYearSelectHeatmapElement.getElementsByClassName("active")[0].dataset.year,cardsYearSelectHeatmapElement.addEventListener("click",yearHeatmapButtonAction);let cardsMetricSelectHeatmapElement=document.getElementById("local-assessfreq-heatmap-metrics");metricselectheatmap=cardsMetricSelectHeatmapElement.getElementsByClassName("active")[0].dataset.metric,cardsMetricSelectHeatmapElement.addEventListener("click",metricHeatmapButtonAction),(element=>{for(var links=element.getElementsByTagName("a"),all=links[0],i=0;i.\n\n/**\n * Javascript for report card display and processing.\n *\n * @module local_assessfreq/dashboard_assessment\n * @package local_assessfreq\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Notification from 'core/notification';\nimport Calendar from 'local_assessfreq/calendar';\nimport * as ChartData from 'local_assessfreq/chart_data';\nimport Dayview from 'local_assessfreq/dayview';\nimport * as UserPreference from 'local_assessfreq/user_preferences';\nimport ZoomModal from 'local_assessfreq/zoom_modal';\n\n/**\n * Module level variables.\n */\nvar contextid;\nvar yearselect;\nvar yearselectheatmap;\nvar metricselectheatmap;\nvar timeout;\nvar modulesJson = '';\nvar heatmapOptionsJson = '';\n\nconst cards = [\n {cardId: 'local-assessfreq-assess-due-month', call: 'assess_by_month'},\n {cardId: 'local-assessfreq-assess-by-activity', call: 'assess_by_activity'},\n {cardId: 'local-assessfreq-assess-due-month-student', call: 'assess_by_month_student'}\n];\n\n/**\n * Get and process the selected year from the dropdown,\n * and update the corresponding user perference.\n *\n * @param {event} event The triggered event for the element.\n */\nconst yearButtonAction = (event) => {\n event.preventDefault();\n var element = event.target;\n\n if (element.tagName.toLowerCase() === 'a' && element.dataset.year !== yearselect) { // Only act on certain elements.\n yearselect = element.dataset.year;\n\n // Save selection as a user preference.\n UserPreference.setUserPreference('local_assessfreq_overview_year_preference', yearselect);\n\n // Update card data based on selected year.\n var yeartitle = document.getElementById('local-assessfreq-report-overview')\n .getElementsByClassName('local-assessfreq-year')[0];\n yeartitle.innerHTML = yearselect;\n\n ChartData.getCardCharts(0, null, yearselect); // Process loading for the assessment cards.\n }\n};\n\n/**\n * Quick and dirty debounce method for the heatmap settings menu.\n * This stops the ajax method that updates the heatmap from being updated\n * while the user is still checking options.\n *\n */\nconst updateHeatmapDebounce = () => {\n clearTimeout(timeout);\n timeout = setTimeout(updateHeatmap(), 750);\n};\n\n/**\n * Display heatmap calendar.\n *\n * @param {event} event The triggered event for the element.\n */\nconst detailView = (event) => {\n let element = event.target;\n if (element.tagName.toLowerCase() === 'td' && element.dataset.event === 'true') { // Only act on certain elements.\n Dayview.display(element.dataset.date);\n }\n};\n\n/**\n * Start heatmap generation.\n *\n */\nconst generateHeatmap = () => {\n let heatmapOptions = JSON.parse(heatmapOptionsJson);\n let year = parseInt(heatmapOptions.year);\n let metric = heatmapOptions.metric;\n let modules = heatmapOptions.modules;\n let heatmapContainer = document.getElementById('local-assessfreq-report-heatmap');\n let spinner = heatmapContainer.getElementsByClassName('overlay-icon-container')[0];\n\n spinner.classList.remove('hide'); // Show spinner if not already shown.\n\n Calendar.generate(year, 0, 11, metric, modules)\n .then(calendar => {\n let calendarContainer = document.getElementById('local-assessfreq-report-heatmap-months');\n calendarContainer.innerHTML = calendar.innerHTML;\n calendarContainer.addEventListener('click', detailView);\n })\n .then(Calendar.createHeatScale)\n .then((heatScale) => {\n let heatScaleContainer = document.getElementById('local-assessfreq-report-heatmap-scale');\n heatScaleContainer.innerHTML = heatScale.outerHTML;\n spinner.classList.add('hide'); // Hide sinner if not already hidden.\n })\n .catch(() => {\n Notification.exception(new Error('Failed to calendar.'));\n return;\n });\n};\n\nconst updateDownload = ({year, metric, modules}) => {\n let downloadForm = document.getElementById('local-assessfreq-heatmap-form');\n let formElements = downloadForm.elements;\n let toRemove = new Array();\n\n if (modules.length === 0) {\n modules = ['all'];\n }\n\n for (let i = 0; i < formElements.length; i++) {\n if (formElements[i] === undefined) {\n continue;\n }\n // Update year field.\n if ((formElements[i].type === 'hidden') && (formElements[i].name === 'year')) {\n formElements[i].value = year;\n continue;\n }\n\n // Update metric field.\n if ((formElements[i].type === 'hidden') && (formElements[i].name === 'metric')) {\n formElements[i].value = metric;\n continue;\n }\n\n // Update module fields.\n if ((formElements[i].type === 'hidden') && (formElements[i].name.startsWith('modules'))) {\n toRemove.push(formElements[i]);\n continue;\n }\n }\n\n for (const element of toRemove) {\n element.remove();\n }\n\n for (let i = 0; i < modules.length; i++) {\n let input = document.createElement('input');\n input.type = 'hidden';\n input.name = 'modules[' + modules[i] + ']';\n input.value = modules[i];\n\n downloadForm.appendChild(input);\n }\n};\n\n/**\n * Update the heatmap based on the current filter settings.\n *\n */\nconst updateHeatmap = () => {\n // Get current state of select menu items.\n var cardsModulesSelectHeatmapElement = document.getElementById('local-assessfreq-heatmap-modules');\n var links = cardsModulesSelectHeatmapElement.getElementsByTagName('a');\n var modules = [];\n\n for (var i = 0; i < links.length; i++) {\n if (links[i].classList.contains('active')) {\n let module = links[i].dataset.module;\n modules.push(module);\n }\n }\n\n // Save selection as a user preference.\n if (modulesJson !== JSON.stringify(modules)) {\n modulesJson = JSON.stringify(modules);\n UserPreference.setUserPreference('local_assessfreq_heatmap_modules_preference', modulesJson);\n }\n\n // Build settings object.\n var optionsObj = {\n 'year': yearselectheatmap,\n 'metric': metricselectheatmap,\n 'modules': modules\n };\n\n var optionsJson = JSON.stringify(optionsObj);\n\n if (optionsJson !== heatmapOptionsJson) { // Compare to global to see if there are any changes.\n // If list has changed fetch heatmap and update user preference.\n heatmapOptionsJson = optionsJson;\n generateHeatmap();\n\n // Update the download options.\n updateDownload(optionsObj);\n }\n};\n\n/**\n * Get and process the selected year from the dropdown for the heatmap display,\n * and update the corresponding user preference.\n *\n * @param {event} event The triggered event for the element.\n */\nconst yearHeatmapButtonAction = (event) => {\n event.preventDefault();\n var element = event.target;\n\n if (element.tagName.toLowerCase() === 'a' && element.dataset.year !== yearselectheatmap) { // Only act on certain elements.\n yearselectheatmap = element.dataset.year;\n\n // Save selection as a user preference.\n UserPreference.setUserPreference('local_assessfreq_heatmap_year_preference', yearselectheatmap);\n\n // Update card data based on selected year.\n var yeartitle = document.getElementById('local-assessfreq-report-heatmap')\n .getElementsByClassName('local-assessfreq-year')[0];\n yeartitle.innerHTML = yearselectheatmap;\n\n updateHeatmapDebounce(); // Call function to update heatmap.\n }\n};\n\n/**\n * Get and process the selected assessment metric from the dropdown for the heatmap display,\n * and update the corresponding user preference.\n *\n * @param {event} event The triggered event for the element.\n */\nconst metricHeatmapButtonAction = (event) => {\n event.preventDefault();\n var element = event.target;\n\n if (element.tagName.toLowerCase() === 'a' && element.dataset.metric !== metricselectheatmap) {\n metricselectheatmap = element.dataset.metric;\n\n // Save selection as a user preference.\n UserPreference.setUserPreference('local_assessfreq_heatmap_metric_preference', metricselectheatmap);\n\n updateHeatmapDebounce(); // Call function to update heatmap.\n }\n};\n\n/**\n * Add the event listeners to the modules in the module select dropdown.\n *\n * @param {Object} element The dropdown HTML element that contains the list of modules as links.\n */\nconst moduleListChildrenEvents = (element) => {\n var links = element.getElementsByTagName('a');\n var all = links[0];\n\n for (var i = 0; i < links.length; i++) {\n let module = links[i].dataset.module;\n\n if (module.toLowerCase() === 'all') {\n links[i].addEventListener('click', function (event) {\n event.preventDefault();\n // Remove active class from all other links.\n for (var j = 0; j < links.length; j++) {\n links[j].classList.remove('active');\n }\n updateHeatmapDebounce(); // Call function to update heatmap.\n });\n } else if (module.toLowerCase() === 'close') {\n links[i].addEventListener('click', function (event) {\n event.preventDefault();\n event.stopPropagation();\n\n var dropdownmenu = document.getElementById('local-assessfreq-heatmap-modules-filter');\n dropdownmenu.classList.remove('show');\n\n updateHeatmapDebounce(); // Call function to update heatmap.\n });\n } else {\n links[i].addEventListener('click', function (event) {\n event.preventDefault();\n event.stopPropagation();\n\n all.classList.remove('active');\n\n event.target.classList.toggle('active');\n updateHeatmapDebounce();\n });\n }\n }\n};\n\n/**\n * Thin wrapper to add extra data to click event.\n *\n * @param {Event} event The triggered event for the element.\n */\nconst triggerZoomGraph = (event) => {\n let call = event.target.closest('div').dataset.call;\n let params = {'data': JSON.stringify({'year': yearselect, 'call': call})};\n let method = 'get_chart';\n\n ZoomModal.zoomGraph(event, params, method);\n};\n\n/**\n * Initialise method for report card rendering.\n *\n * @param {integer} context The current context id.\n */\nexport const init = (context) => {\n contextid = context;\n\n // Set up event listener and related actions for year dropdown on report cards.\n let cardsYearSelectElement = document.getElementById('local-assessfreq-cards-year');\n yearselect = cardsYearSelectElement.getElementsByClassName('active')[0].dataset.year;\n cardsYearSelectElement.addEventListener('click', yearButtonAction);\n\n // Set up event listener and related actions for year dropdown on heatmp.\n let cardsYearSelectHeatmapElement = document.getElementById('local-assessfreq-heatmap-year');\n yearselectheatmap = cardsYearSelectHeatmapElement.getElementsByClassName('active')[0].dataset.year;\n cardsYearSelectHeatmapElement.addEventListener('click', yearHeatmapButtonAction);\n\n // Set up event listener and related actions for metric dropdown on heatmp.\n let cardsMetricSelectHeatmapElement = document.getElementById('local-assessfreq-heatmap-metrics');\n metricselectheatmap = cardsMetricSelectHeatmapElement.getElementsByClassName('active')[0].dataset.metric;\n cardsMetricSelectHeatmapElement.addEventListener('click', metricHeatmapButtonAction);\n\n // Set up event listener and related actions for module dropdown on heatmp.\n let cardsModulesSelectHeatmapElement = document.getElementById('local-assessfreq-heatmap-modules');\n moduleListChildrenEvents(cardsModulesSelectHeatmapElement);\n\n // Set up zoom event listeners.\n let dueMonthZoom = document.getElementById('local-assessfreq-assess-due-month-zoom');\n dueMonthZoom.addEventListener('click', triggerZoomGraph);\n\n let dueActivityZoom = document.getElementById('local-assessfreq-assess-by-activity-zoom');\n dueActivityZoom.addEventListener('click', triggerZoomGraph);\n\n let dueStudentZoom = document.getElementById('local-assessfreq-assess-due-month-student-zoom');\n dueStudentZoom.addEventListener('click', triggerZoomGraph);\n\n // Create the zoom modal.\n ZoomModal.init(context);\n\n // Setup the dayview modal.\n Dayview.init();\n\n // Setup the chart data for each card.\n ChartData.init(cards, contextid, 'get_chart', 'core/chart');\n\n // Process loading for the assessment cards.\n ChartData.getCardCharts(0, null, yearselect);\n\n // Get the data for the heatmap.\n updateHeatmap();\n\n};\n"],"names":["contextid","yearselect","yearselectheatmap","metricselectheatmap","timeout","modulesJson","heatmapOptionsJson","cards","cardId","call","yearButtonAction","event","preventDefault","element","target","tagName","toLowerCase","dataset","year","UserPreference","setUserPreference","document","getElementById","getElementsByClassName","innerHTML","ChartData","getCardCharts","updateHeatmapDebounce","clearTimeout","setTimeout","updateHeatmap","detailView","display","date","links","getElementsByTagName","modules","i","length","classList","contains","module","push","JSON","stringify","optionsObj","optionsJson","heatmapOptions","parse","parseInt","metric","spinner","remove","generate","then","calendar","calendarContainer","addEventListener","Calendar","createHeatScale","heatScale","outerHTML","add","catch","exception","Error","generateHeatmap","_ref","downloadForm","formElements","elements","toRemove","Array","undefined","type","name","startsWith","value","input","createElement","appendChild","updateDownload","yearHeatmapButtonAction","metricHeatmapButtonAction","triggerZoomGraph","closest","params","zoomGraph","context","cardsYearSelectElement","cardsYearSelectHeatmapElement","cardsMetricSelectHeatmapElement","all","j","stopPropagation","toggle","moduleListChildrenEvents","init"],"mappings":";;;;;;;;SAkCIA,UACAC,WACAC,kBACAC,oBACAC,uXACAC,YAAc,GACdC,mBAAqB,SAEnBC,MAAQ,CACV,CAACC,OAAQ,oCAAqCC,KAAM,mBACpD,CAACD,OAAQ,sCAAuCC,KAAM,sBACtD,CAACD,OAAQ,4CAA6CC,KAAM,4BAS1DC,iBAAoBC,QACtBA,MAAMC,qBACFC,QAAUF,MAAMG,OAEkB,MAAlCD,QAAQE,QAAQC,eAAyBH,QAAQI,QAAQC,OAASjB,aAClEA,WAAaY,QAAQI,QAAQC,KAG7BC,eAAeC,kBAAkB,4CAA6CnB,YAG9DoB,SAASC,eAAe,oCACnCC,uBAAuB,yBAAyB,GAC3CC,UAAYvB,WAEtBwB,UAAUC,cAAc,EAAG,KAAMzB,cAUnC0B,sBAAwB,KAC1BC,aAAaxB,SACbA,QAAUyB,WAAWC,gBAAiB,MAQpCC,WAAcpB,YACZE,QAAUF,MAAMG,OACkB,OAAlCD,QAAQE,QAAQC,eAAoD,SAA1BH,QAAQI,QAAQN,wBAClDqB,QAAQnB,QAAQI,QAAQgB,OAsFlCH,cAAgB,aAGdI,MADmCb,SAASC,eAAe,oCAClBa,qBAAqB,KAC9DC,QAAU,GAELC,EAAI,EAAGA,EAAIH,MAAMI,OAAQD,OAC1BH,MAAMG,GAAGE,UAAUC,SAAS,UAAW,KACnCC,OAASP,MAAMG,GAAGpB,QAAQwB,OAC9BL,QAAQM,KAAKD,QAKjBpC,cAAgBsC,KAAKC,UAAUR,WAC/B/B,YAAcsC,KAAKC,UAAUR,SAC7BjB,eAAeC,kBAAkB,8CAA+Cf,kBAIhFwC,WAAa,MACL3C,yBACEC,4BACCiC,SAGXU,YAAcH,KAAK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,KACrCyD,IAAM1D,MAAM,GAEPG,EAAI,EAAGA,EAAIH,MAAMI,OAAQD,IAAK,KAC/BI,OAASP,MAAMG,GAAGpB,QAAQwB,OAED,QAAzBA,OAAOzB,cACPkB,MAAMG,GAAGoB,iBAAiB,SAAS,SAAU9C,OACzCA,MAAMC,qBAED,IAAIiF,EAAI,EAAGA,EAAI3D,MAAMI,OAAQuD,IAC9B3D,MAAM2D,GAAGtD,UAAUa,OAAO,UAE9BzB,2BAE4B,UAAzBc,OAAOzB,cACdkB,MAAMG,GAAGoB,iBAAiB,SAAS,SAAU9C,OACzCA,MAAMC,iBACND,MAAMmF,kBAEazE,SAASC,eAAe,2CAC9BiB,UAAUa,OAAO,QAE9BzB,2BAGJO,MAAMG,GAAGoB,iBAAiB,SAAS,SAAU9C,OACzCA,MAAMC,iBACND,MAAMmF,kBAENF,IAAIrD,UAAUa,OAAO,UAErBzC,MAAMG,OAAOyB,UAAUwD,OAAO,UAC9BpE,6BA4CZqE,CADuC3E,SAASC,eAAe,qCAI5CD,SAASC,eAAe,0CAC9BmC,iBAAiB,QAAS2B,kBAEjB/D,SAASC,eAAe,4CAC9BmC,iBAAiB,QAAS2B,kBAErB/D,SAASC,eAAe,kDAC9BmC,iBAAiB,QAAS2B,sCAG/Ba,KAAKT,0BAGPS,OAGRxE,UAAUwE,KAAK1F,MAAOP,UAAW,YAAa,cAG9CyB,UAAUC,cAAc,EAAG,KAAMzB,YAGjC6B"} \ No newline at end of file diff --git a/amd/build/dashboard_quiz.min.js b/amd/build/dashboard_quiz.min.js deleted file mode 100644 index 85e7f24..0000000 --- a/amd/build/dashboard_quiz.min.js +++ /dev/null @@ -1,11 +0,0 @@ -define("local_assessfreq/dashboard_quiz",["exports","core/ajax","core/notification","core/str","core/templates","local_assessfreq/chart_data","local_assessfreq/form_modal","local_assessfreq/override_modal","local_assessfreq/table_handler","local_assessfreq/user_preferences","local_assessfreq/zoom_modal"],(function(_exports,_ajax,_notification,Str,_templates,ChartData,FormModal,_override_modal,TableHandler,UserPreference,ZoomModal){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} -/** - * Javascript for report card display and processing. - * - * @module local_assessfreq/dashboard_quiz - * @package local_assessfreq - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification),Str=_interopRequireWildcard(Str),_templates=_interopRequireDefault(_templates),ChartData=_interopRequireWildcard(ChartData),FormModal=_interopRequireWildcard(FormModal),_override_modal=_interopRequireDefault(_override_modal),TableHandler=_interopRequireWildcard(TableHandler),UserPreference=_interopRequireWildcard(UserPreference),ZoomModal=_interopRequireWildcard(ZoomModal);var contextid,counterid,selectQuizStr="",quizId=0,refreshPeriod=60;const cards=[{cardId:"local-assessfreq-quiz-summary-graph",call:"participant_summary",aspect:!0},{cardId:"local-assessfreq-quiz-summary-trend",call:"participant_trend",aspect:!1}],refreshCounter=function(){let reset=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],progressElement=document.getElementById("local-assessfreq-period-progress");!0===reset&&(clearInterval(counterid),counterid=null,progressElement.setAttribute("style","width: 100%"),progressElement.setAttribute("aria-valuenow",100)),counterid||(counterid=setInterval((()=>{let progressWidthAria=progressElement.getAttribute("aria-valuenow");const progressStep=100/refreshPeriod;progressWidthAria-progressStep>0?(progressElement.setAttribute("style","width: "+(progressWidthAria-progressStep)+"%"),progressElement.setAttribute("aria-valuenow",progressWidthAria-progressStep)):(clearInterval(counterid),counterid=null,progressElement.setAttribute("style","width: 100%"),progressElement.setAttribute("aria-valuenow",100),processDashboard(quizId),refreshCounter())}),1e3))},processDashboard=quiz=>{quizId=quiz;let titleElement=document.getElementById("local-assessfreq-quiz-title");titleElement.innerHTML=selectQuizStr,_ajax.default.call([{methodname:"local_assessfreq_get_quiz_data",args:{quizid:quiz}}])[0].then((response=>{let quizArray=JSON.parse(response),cardsElement=document.getElementById("local-assessfreq-quiz-dashboard-cards-deck"),trendElement=document.getElementById("local-assessfreq-quiz-dashboard-participant-trend-deck"),summarySpinner=document.getElementById("local-assessfreq-quiz-summary-card").getElementsByClassName("overlay-icon-container")[0],tableElement=document.getElementById("local-assessfreq-quiz-table"),periodElement=document.getElementById("local-assessfreq-period-container"),tableSearchInputElement=document.getElementById("local-assessfreq-quiz-student-table-search"),tableSearchResetElement=document.getElementById("local-assessfreq-quiz-student-table-search-reset"),tableSearchRowsElement=document.getElementById("local-assessfreq-quiz-student-table-rows"),quizLink=document.createElement("a");quizLink.href=quizArray.url,quizLink.innerHTML='',titleElement.innerHTML=quizArray.name+" ",titleElement.appendChild(quizLink);const currentdUrl=new URL(window.location.href),newUrl=currentdUrl.origin+currentdUrl.pathname+"?id="+quizId;history.pushState({},"",newUrl),Str.get_string("dashboard:quiztitle","local_assessfreq",{quiz:quizArray.name,course:quizArray.courseshortname}).then((str=>{document.title=str})),_templates.default.render("local_assessfreq/quiz-summary-card-content",quizArray).done((html=>{summarySpinner.classList.add("hide");let contentcontainer=document.getElementById("local-assessfreq-quiz-summary-card-content");_templates.default.replaceNodeContents(contentcontainer,html,"")})).fail((()=>{_notification.default.exception(new Error("Failed to load quiz summary template."))})),cardsElement.classList.remove("hide"),trendElement.classList.remove("hide"),tableElement.classList.remove("hide"),periodElement.classList.remove("hide"),ChartData.getCardCharts(quizId),TableHandler.getTable(quizId),refreshCounter(),tableSearchInputElement.addEventListener("keyup",TableHandler.tableSearch),tableSearchInputElement.addEventListener("paste",TableHandler.tableSearch),tableSearchResetElement.addEventListener("click",TableHandler.tableSearchReset),tableSearchRowsElement.addEventListener("click",TableHandler.tableSearchRowSet)})).fail((()=>{_notification.default.exception(new Error("Failed to get quiz data"))}))},refreshAction=event=>{event.preventDefault();var element=event.target;null!==element.closest("button")&&"local-assessfreq-refresh-quiz-dashboard"===element.closest("button").id?(refreshCounter(!0),processDashboard(quizId)):"a"===element.tagName.toLowerCase()&&(refreshPeriod=element.dataset.period,refreshCounter(!0),UserPreference.setUserPreference("local_assessfreq_quiz_refresh_preference",refreshPeriod))},triggerZoomGraph=event=>{let call=event.target.closest("div").dataset.call,params={data:JSON.stringify({quiz:quizId,call:call})};ZoomModal.zoomGraph(event,params,"get_quiz_chart")};_exports.init=(context,quiz)=>{contextid=context,FormModal.init(context,processDashboard),ZoomModal.init(context),_override_modal.default.init(context,processDashboard),TableHandler.init(quizId,contextid,"local-assessfreq-quiz-student-table","local-assessfreq-quiz-table","get_student_table","local_assessfreq_quiz_table_rows_preference","local-assessfreq-quiz-student-table-search","local_assessfreq_student_table","local_assessfreq_set_table_preference"),ChartData.init(cards,context,"get_quiz_chart","local_assessfreq/chart"),Str.get_string("loadingquiztitle","local_assessfreq").then((str=>{selectQuizStr=str})).then((()=>{quiz>0&&(quizId=quiz,processDashboard(quiz))})),UserPreference.getUserPreference("local_assessfreq_quiz_refresh_preference").then((response=>{refreshPeriod=response.preferences[0].value?response.preferences[0].value:60})).fail((()=>{_notification.default.exception(new Error("Failed to get use preference: refresh"))})),document.getElementById("local-assessfreq-period-container").addEventListener("click",refreshAction),document.getElementById("local-assessfreq-quiz-summary-graph-zoom").addEventListener("click",triggerZoomGraph),document.getElementById("local-assessfreq-quiz-summary-trend-zoom").addEventListener("click",triggerZoomGraph)}})); - -//# sourceMappingURL=dashboard_quiz.min.js.map \ No newline at end of file diff --git a/amd/build/dashboard_quiz.min.js.map b/amd/build/dashboard_quiz.min.js.map deleted file mode 100644 index 2036763..0000000 --- a/amd/build/dashboard_quiz.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"dashboard_quiz.min.js","sources":["../src/dashboard_quiz.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript for report card display and processing.\n *\n * @module local_assessfreq/dashboard_quiz\n * @package local_assessfreq\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\nimport * as Str from 'core/str';\nimport Templates from 'core/templates';\nimport * as ChartData from 'local_assessfreq/chart_data';\nimport * as FormModal from 'local_assessfreq/form_modal';\nimport OverrideModal from 'local_assessfreq/override_modal';\nimport * as TableHandler from 'local_assessfreq/table_handler';\nimport * as UserPreference from 'local_assessfreq/user_preferences';\nimport * as ZoomModal from 'local_assessfreq/zoom_modal';\n\n// Module level variables.\n\nvar selectQuizStr = '';\nvar contextid;\nvar quizId = 0;\nvar refreshPeriod = 60;\nvar counterid;\n\nconst cards = [\n {cardId: 'local-assessfreq-quiz-summary-graph', call: 'participant_summary', aspect: true},\n {cardId: 'local-assessfreq-quiz-summary-trend', call: 'participant_trend', aspect: false}\n];\n\n/**\n * Function for refreshing the counter.\n *\n * @param {boolean} reset the current count process.\n */\nconst refreshCounter = (reset = true) => {\n let progressElement = document.getElementById('local-assessfreq-period-progress');\n\n // Reset the current count process.\n if (reset === true) {\n clearInterval(counterid);\n counterid = null;\n progressElement.setAttribute('style', 'width: 100%');\n progressElement.setAttribute('aria-valuenow', 100);\n }\n\n // Exit early if there is already a counter running.\n if (counterid) {\n return;\n }\n\n counterid = setInterval(() => {\n let progressWidthAria = progressElement.getAttribute('aria-valuenow');\n const progressStep = 100 / refreshPeriod;\n\n if ((progressWidthAria - progressStep) > 0) {\n progressElement.setAttribute('style', 'width: ' + (progressWidthAria - progressStep) + '%');\n progressElement.setAttribute('aria-valuenow', (progressWidthAria - progressStep));\n } else {\n clearInterval(counterid);\n counterid = null;\n progressElement.setAttribute('style', 'width: 100%');\n progressElement.setAttribute('aria-valuenow', 100);\n processDashboard(quizId);\n refreshCounter();\n }\n }, (1000));\n};\n\n/**\n * Callback function that is called when a quiz is selected from the form.\n * Starts the processing of the dashboard.\n *\n * @param {int} quiz The quiz Id.\n */\nconst processDashboard = (quiz) => {\n quizId = quiz;\n let titleElement = document.getElementById('local-assessfreq-quiz-title');\n titleElement.innerHTML = selectQuizStr;\n // Get quiz data.\n Ajax.call([{\n methodname: 'local_assessfreq_get_quiz_data',\n args: {\n quizid: quiz\n },\n }])[0].then((response) => {\n\n let quizArray = JSON.parse(response);\n let cardsElement = document.getElementById('local-assessfreq-quiz-dashboard-cards-deck');\n let trendElement = document.getElementById('local-assessfreq-quiz-dashboard-participant-trend-deck');\n let summaryElement = document.getElementById('local-assessfreq-quiz-summary-card');\n let summarySpinner = summaryElement.getElementsByClassName('overlay-icon-container')[0];\n let tableElement = document.getElementById('local-assessfreq-quiz-table');\n let periodElement = document.getElementById('local-assessfreq-period-container');\n let tableSearchInputElement = document.getElementById('local-assessfreq-quiz-student-table-search');\n let tableSearchResetElement = document.getElementById('local-assessfreq-quiz-student-table-search-reset');\n let tableSearchRowsElement = document.getElementById('local-assessfreq-quiz-student-table-rows');\n\n let quizLink = document.createElement('a');\n quizLink.href = quizArray.url;\n quizLink.innerHTML = '';\n titleElement.innerHTML = quizArray.name + ' ';\n titleElement.appendChild(quizLink);\n\n // Update page URL with quiz ID, without reloading page so that page navigation and bookmarking works.\n const currentdUrl = new URL(window.location.href);\n const newUrl = currentdUrl.origin + currentdUrl.pathname + '?id=' + quizId;\n history.pushState({}, '', newUrl);\n\n // Update page title with quiz name.\n Str.get_string('dashboard:quiztitle', 'local_assessfreq', {'quiz': quizArray.name, 'course': quizArray.courseshortname})\n .then((str) => {\n document.title = str;\n });\n\n // Populate quiz summary card with details.\n Templates.render('local_assessfreq/quiz-summary-card-content', quizArray).done((html) => {\n summarySpinner.classList.add('hide');\n let contentcontainer = document.getElementById('local-assessfreq-quiz-summary-card-content');\n Templates.replaceNodeContents(contentcontainer, html, '');\n }).fail(() => {\n Notification.exception(new Error('Failed to load quiz summary template.'));\n return;\n });\n\n // Show the cards.\n cardsElement.classList.remove('hide');\n trendElement.classList.remove('hide');\n tableElement.classList.remove('hide');\n periodElement.classList.remove('hide');\n\n ChartData.getCardCharts(quizId);\n TableHandler.getTable(quizId);\n refreshCounter();\n\n tableSearchInputElement.addEventListener('keyup', TableHandler.tableSearch);\n tableSearchInputElement.addEventListener('paste', TableHandler.tableSearch);\n tableSearchResetElement.addEventListener('click', TableHandler.tableSearchReset);\n tableSearchRowsElement.addEventListener('click', TableHandler.tableSearchRowSet);\n\n return;\n }).fail(() => {\n Notification.exception(new Error('Failed to get quiz data'));\n });\n};\n\n/**\n * Handle processing of refresh and period button actions.\n *\n * @param {Event} event The triggered event for the element.\n */\nconst refreshAction = (event) => {\n event.preventDefault();\n var element = event.target;\n\n if (element.closest('button') !== null && element.closest('button').id === 'local-assessfreq-refresh-quiz-dashboard') {\n refreshCounter(true);\n processDashboard(quizId);\n } else if (element.tagName.toLowerCase() === 'a') {\n refreshPeriod = element.dataset.period;\n refreshCounter(true);\n UserPreference.setUserPreference('local_assessfreq_quiz_refresh_preference', refreshPeriod);\n }\n};\n\n/**\n * Trigger the zoom graph. Thin wrapper to add extra data to click event.\n *\n * @param {Event} event The triggered event for the element.\n */\nconst triggerZoomGraph = (event) => {\n let call = event.target.closest('div').dataset.call;\n let params = {'data': JSON.stringify({'quiz': quizId, 'call': call})};\n let method = 'get_quiz_chart';\n\n ZoomModal.zoomGraph(event, params, method);\n};\n\n/**\n * Initialise method for quiz dashboard rendering.\n *\n * @param {int} context The context id.\n * @param {int} quiz The quiz id.\n */\nexport const init = (context, quiz) => {\n contextid = context;\n FormModal.init(context, processDashboard); // Create modal for quiz selection modal.\n ZoomModal.init(context); // Create the zoom modal.\n OverrideModal.init(context, processDashboard);\n TableHandler.init(\n quizId,\n contextid,\n 'local-assessfreq-quiz-student-table',\n 'local-assessfreq-quiz-table',\n 'get_student_table',\n 'local_assessfreq_quiz_table_rows_preference',\n 'local-assessfreq-quiz-student-table-search',\n 'local_assessfreq_student_table',\n 'local_assessfreq_set_table_preference'\n );\n ChartData.init(cards, context, 'get_quiz_chart', 'local_assessfreq/chart');\n Str.get_string('loadingquiztitle', 'local_assessfreq').then((str) => {\n selectQuizStr = str;\n }).then(() => {\n if (quiz > 0) {\n quizId = quiz;\n processDashboard(quiz);\n }\n });\n\n UserPreference.getUserPreference('local_assessfreq_quiz_refresh_preference')\n .then((response) => {\n refreshPeriod = response.preferences[0].value ? response.preferences[0].value : 60;\n })\n .fail(() => {\n Notification.exception(new Error('Failed to get use preference: refresh'));\n });\n\n // Event handling for refresh and period buttons.\n let refreshElement = document.getElementById('local-assessfreq-period-container');\n refreshElement.addEventListener('click', refreshAction);\n\n // Set up zoom event listeners.\n let summaryZoom = document.getElementById('local-assessfreq-quiz-summary-graph-zoom');\n summaryZoom.addEventListener('click', triggerZoomGraph);\n\n let trendZoom = document.getElementById('local-assessfreq-quiz-summary-trend-zoom');\n trendZoom.addEventListener('click', triggerZoomGraph);\n\n};\n"],"names":["contextid","counterid","selectQuizStr","quizId","refreshPeriod","cards","cardId","call","aspect","refreshCounter","reset","progressElement","document","getElementById","clearInterval","setAttribute","setInterval","progressWidthAria","getAttribute","progressStep","processDashboard","quiz","titleElement","innerHTML","methodname","args","quizid","then","response","quizArray","JSON","parse","cardsElement","trendElement","summarySpinner","getElementsByClassName","tableElement","periodElement","tableSearchInputElement","tableSearchResetElement","tableSearchRowsElement","quizLink","createElement","href","url","name","appendChild","currentdUrl","URL","window","location","newUrl","origin","pathname","history","pushState","Str","get_string","courseshortname","str","title","render","done","html","classList","add","contentcontainer","replaceNodeContents","fail","exception","Error","remove","ChartData","getCardCharts","TableHandler","getTable","addEventListener","tableSearch","tableSearchReset","tableSearchRowSet","refreshAction","event","preventDefault","element","target","closest","id","tagName","toLowerCase","dataset","period","UserPreference","setUserPreference","triggerZoomGraph","params","stringify","ZoomModal","zoomGraph","context","FormModal","init","getUserPreference","preferences","value"],"mappings":";;;;;;;;siBAsCIA,UAGAC,UAJAC,cAAgB,GAEhBC,OAAS,EACTC,cAAgB,SAGdC,MAAQ,CACV,CAACC,OAAQ,sCAAuCC,KAAM,sBAAuBC,QAAQ,GACrF,CAACF,OAAQ,sCAAuCC,KAAM,oBAAqBC,QAAQ,IAQjFC,eAAiB,eAACC,iEAChBC,gBAAkBC,SAASC,eAAe,qCAGhC,IAAVH,QACAI,cAAcb,WACdA,UAAY,KACZU,gBAAgBI,aAAa,QAAS,eACtCJ,gBAAgBI,aAAa,gBAAiB,MAI9Cd,YAIJA,UAAYe,aAAY,SAChBC,kBAAoBN,gBAAgBO,aAAa,uBAC/CC,aAAe,IAAMf,cAEtBa,kBAAoBE,aAAgB,GACrCR,gBAAgBI,aAAa,QAAS,WAAaE,kBAAoBE,cAAgB,KACvFR,gBAAgBI,aAAa,gBAAkBE,kBAAoBE,gBAEnEL,cAAcb,WACdA,UAAY,KACZU,gBAAgB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ASC,eAAe,qCAC9B+D,iBAAiB,QAASI,eAGvBpE,SAASC,eAAe,4CAC9B+D,iBAAiB,QAASiB,kBAEtBjF,SAASC,eAAe,4CAC9B+D,iBAAiB,QAASiB"} \ No newline at end of file diff --git a/amd/build/dayview.min.js b/amd/build/dayview.min.js deleted file mode 100644 index 064ec2a..0000000 --- a/amd/build/dayview.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Javascript for heatmap calendar generation and display. - * - * @package local_assessfreq - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("local_assessfreq/dayview",["core/str","core/notification","core/modal_factory","local_assessfreq/modal_large","core/templates","core/ajax"],(function(Str,Notification,ModalFactory,ModalLarge,Templates,Ajax){var modalObj,Dayview={};const spinner='

',stringArr=[{key:"sun",component:"calendar"},{key:"mon",component:"calendar"},{key:"tue",component:"calendar"},{key:"wed",component:"calendar"},{key:"thu",component:"calendar"},{key:"fri",component:"calendar"},{key:"sat",component:"calendar"},{key:"jan",component:"local_assessfreq"},{key:"feb",component:"local_assessfreq"},{key:"mar",component:"local_assessfreq"},{key:"apr",component:"local_assessfreq"},{key:"may",component:"local_assessfreq"},{key:"jun",component:"local_assessfreq"},{key:"jul",component:"local_assessfreq"},{key:"aug",component:"local_assessfreq"},{key:"sep",component:"local_assessfreq"},{key:"oct",component:"local_assessfreq"},{key:"nov",component:"local_assessfreq"},{key:"dec",component:"local_assessfreq"}];var stringResult,systemTimezone="Australia/Melbourne",dayViewTitle="";const getUserDate=function(timestamp,format){return new Promise((resolve=>{const systemTimezoneTime=new Date(1e3*timestamp).toLocaleString("en-US",{timeZone:systemTimezone});let date=new Date(systemTimezoneTime);const year=date.getFullYear(),month=stringResult[7+date.getMonth()],day=date.getDate(),strftimetime=date.getHours()+":"+("0"+date.getMinutes()).substr(-2);resolve("strftimetime"===format?strftimetime:day+" "+month+" "+year+", "+strftimetime)}))},formatData=async function(response){let responseArr=JSON.parse(response),scaler=5/72;for(let i=0;i100&&(width=100-leftMargin),responseArr[i].leftmargin=leftMargin,responseArr[i].width=width,responseArr[i].end=await getUserDate(responseArr[i].timeend,"strftimetime")}return new Promise((resolve=>{resolve(responseArr)}))};return Dayview.display=function(date){modalObj.setBody(spinner),modalObj.show();let args={date:date,modules:["all"]},jsonArgs=JSON.stringify(args);Ajax.call([{methodname:"local_assessfreq_get_day_events",args:{jsondata:jsonArgs}}])[0].then(formatData).then((responseArr=>{let context={rows:responseArr};const year=responseArr[0].endyear,dayDate=responseArr[0].endday+" "+stringResult[6+parseInt(responseArr[0].endmonth)]+" "+year;modalObj.setTitle(dayViewTitle+" "+dayDate),modalObj.setBody(Templates.render("local_assessfreq/dayview",context))})).fail((()=>{Notification.exception(new Error("Failed to load day view"))}))},Dayview.init=function(){Str.get_strings(stringArr).then((stringReturn=>{stringResult=stringReturn})),Ajax.call([{methodname:"local_assessfreq_get_system_timezone",args:{}}],!0,!1)[0].then((response=>{systemTimezone=response})).fail((()=>{Notification.exception(new Error("Failed to get system timezone"))})),Str.get_string("schedule","local_assessfreq").then((title=>{dayViewTitle=title,ModalFactory.create({type:ModalLarge.TYPE,title:title,body:spinner}).done((modal=>{modalObj=modal}))}))},Dayview})); - -//# sourceMappingURL=dayview.min.js.map \ No newline at end of file diff --git a/amd/build/dayview.min.js.map b/amd/build/dayview.min.js.map deleted file mode 100644 index d767b60..0000000 --- a/amd/build/dayview.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"dayview.min.js","sources":["../src/dayview.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript for heatmap calendar generation and display.\n *\n * @package local_assessfreq\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n ['core/str', 'core/notification', 'core/modal_factory', 'local_assessfreq/modal_large', 'core/templates', 'core/ajax'],\n function (Str, Notification, ModalFactory, ModalLarge, Templates, Ajax) {\n\n /**\n * Module level variables.\n */\n var Dayview = {};\n var modalObj;\n const spinner = '

'\n + ''\n + '

';\n\n const stringArr = [\n {key: 'sun', component: 'calendar'},\n {key: 'mon', component: 'calendar'},\n {key: 'tue', component: 'calendar'},\n {key: 'wed', component: 'calendar'},\n {key: 'thu', component: 'calendar'},\n {key: 'fri', component: 'calendar'},\n {key: 'sat', component: 'calendar'},\n {key: 'jan', component: 'local_assessfreq'},\n {key: 'feb', component: 'local_assessfreq'},\n {key: 'mar', component: 'local_assessfreq'},\n {key: 'apr', component: 'local_assessfreq'},\n {key: 'may', component: 'local_assessfreq'},\n {key: 'jun', component: 'local_assessfreq'},\n {key: 'jul', component: 'local_assessfreq'},\n {key: 'aug', component: 'local_assessfreq'},\n {key: 'sep', component: 'local_assessfreq'},\n {key: 'oct', component: 'local_assessfreq'},\n {key: 'nov', component: 'local_assessfreq'},\n {key: 'dec', component: 'local_assessfreq'},\n ];\n var stringResult;\n var systemTimezone = 'Australia/Melbourne';\n var dayViewTitle = '';\n\n const getUserDate = function (timestamp, format) {\n return new Promise((resolve) => {\n const systemTimezoneTime = new Date(timestamp * 1000).toLocaleString('en-US', {timeZone: systemTimezone});\n let date = new Date(systemTimezoneTime);\n const year = date.getFullYear();\n const month = stringResult[(7 + date.getMonth())];\n const day = date.getDate();\n const hours = date.getHours();\n const minutes = '0' + date.getMinutes();\n\n const strftimetime = hours + ':' + minutes.substr(-2); // Will display time in 10:30 format.\n const strftimedatetime = day + ' ' + month + ' ' + year + ', ' + strftimetime;\n\n if (format === 'strftimetime') {\n resolve(strftimetime);\n } else {\n resolve(strftimedatetime);\n }\n\n });\n };\n\n const formatData = async function (response) {\n let responseArr = JSON.parse(response);\n\n // We are displaying the event as a bar whose width represents the start and end time of the event.\n // We need to scale the width of the bar to match the width of the container. Therefore 100% width of the container\n // equals 24 hours (one day).\n // There are 1440 mins per day. 1440 mins equals 100%, therefore 1 min = (100/1440)%. 5/72 == 100/1440.\n let scaler = 5 / 72;\n\n for (let i = 0; i < responseArr.length; i++) {\n const year = responseArr[i].endyear;\n const month = (responseArr[i].endmonth) - 1; // Minus 1 for difference between months in PHP and JS.\n const day = responseArr[i].endday;\n const dayStart = (new Date(year, month, day).getTime()) / 1000;\n const timeStart = new Date(responseArr[i].timestart * 1000).toLocaleString('en-US', {timeZone: systemTimezone});\n const timeStartTimestamp = (new Date(timeStart).getTime()) / 1000;\n const timeEnd = new Date(responseArr[i].timeend * 1000).toLocaleString('en-US', {timeZone: systemTimezone});\n const timeEndTimestamp = (new Date(timeEnd).getTime()) / 1000;\n let secondsSinceDayStart = timeStartTimestamp - dayStart;\n let leftMargin = 0;\n let width = 0;\n\n if (secondsSinceDayStart <= 0) {\n secondsSinceDayStart = 0;\n width = ((timeEndTimestamp - dayStart) / 60) * scaler;\n responseArr[i].start = await getUserDate(responseArr[i].timestart, 'strftimedatetime');\n } else {\n leftMargin = (secondsSinceDayStart / 60) * scaler;\n width = ((timeEndTimestamp - timeStartTimestamp) / 60) * scaler;\n responseArr[i].start = await getUserDate(responseArr[i].timestart, 'strftimetime');\n }\n\n if (leftMargin + width > 100) {\n width = 100 - leftMargin;\n }\n\n responseArr[i].leftmargin = leftMargin;\n responseArr[i].width = width;\n responseArr[i].end = await getUserDate(responseArr[i].timeend, 'strftimetime');\n }\n\n return new Promise((resolve) => {\n resolve(responseArr);\n });\n };\n\n /**\n * Initialise the base modal to be used.\n *\n */\n Dayview.display = function (date) {\n modalObj.setBody(spinner);\n modalObj.show();\n let args = {\n date: date,\n modules: ['all']\n };\n let jsonArgs = JSON.stringify(args);\n Ajax.call([{\n methodname: 'local_assessfreq_get_day_events',\n args: {jsondata: jsonArgs},\n }])[0]\n .then(formatData)\n .then((responseArr) => {\n\n let context = {rows: responseArr};\n const year = responseArr[0].endyear;\n const day = responseArr[0].endday;\n const month = stringResult[(6 + parseInt(responseArr[0].endmonth))];\n const dayDate = day + ' ' + month + ' ' + year;\n\n modalObj.setTitle(dayViewTitle + ' ' + dayDate);\n modalObj.setBody(Templates.render('local_assessfreq/dayview', context));\n\n }).fail(() => {\n Notification.exception(new Error('Failed to load day view'));\n });\n };\n\n /**\n * Initialise the base modal to be used.\n *\n * @param {integer} context The current context id.\n */\n Dayview.init = function () {\n // Load the strings we'll need later.\n Str.get_strings(stringArr).then(stringReturn => { // Save string to global to be used later.\n stringResult = stringReturn;\n });\n\n // Get the system timzone.\n Ajax.call([{\n methodname: 'local_assessfreq_get_system_timezone',\n args: {},\n }], true, false)[0].then((response) => {\n systemTimezone = response;\n return;\n }).fail(() => {\n Notification.exception(new Error('Failed to get system timezone'));\n });\n\n Str.get_string('schedule', 'local_assessfreq').then((title) => {\n dayViewTitle = title;\n\n // Create the Modal.\n ModalFactory.create({\n type: ModalLarge.TYPE,\n title: title,\n body: spinner\n })\n .done((modal) => {\n modalObj = modal;\n\n });\n });\n\n };\n\n return Dayview;\n }\n);\n"],"names":["define","Str","Notification","ModalFactory","ModalLarge","Templates","Ajax","modalObj","Dayview","spinner","stringArr","key","component","stringResult","systemTimezone","dayViewTitle","getUserDate","timestamp","format","Promise","resolve","systemTimezoneTime","Date","toLocaleString","timeZone","date","year","getFullYear","month","getMonth","day","getDate","strftimetime","getHours","getMinutes","substr","formatData","async","response","responseArr","JSON","parse","scaler","i","length","endyear","endmonth","endday","dayStart","getTime","timeStart","timestart","timeStartTimestamp","timeEnd","timeend","timeEndTimestamp","secondsSinceDayStart","leftMargin","width","start","leftmargin","end","display","setBody","show","args","modules","jsonArgs","stringify","call","methodname","jsondata","then","context","rows","dayDate","parseInt","setTitle","render","fail","exception","Error","init","get_strings","stringReturn","get_string","title","create","type","TYPE","body","done","modal"],"mappings":";;;;;;;AAuBAA,kCACI,CAAC,WAAY,oBAAqB,qBAAsB,+BAAgC,iBAAkB,cAC1G,SAAUC,IAAKC,aAAcC,aAAcC,WAAYC,UAAWC,UAM1DC,SADAC,QAAU,SAERC,QAAU,sFAIVC,UAAY,CACd,CAACC,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,YACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,oBACxB,CAACD,IAAK,MAAOC,UAAW,yBAExBC,aACAC,eAAiB,sBACjBC,aAAe,SAEbC,YAAc,SAAUC,UAAWC,eAC9B,IAAIC,SAASC,gBACVC,mBAAqB,IAAIC,KAAiB,IAAZL,WAAkBM,eAAe,QAAS,CAACC,SAAUV,qBACrFW,KAAO,IAAIH,KAAKD,0BACdK,KAAOD,KAAKE,cACZC,MAAQf,aAAc,EAAIY,KAAKI,YAC/BC,IAAML,KAAKM,UAIXC,aAHQP,KAAKQ,WAGU,KAFb,IAAMR,KAAKS,cAEgBC,QAAQ,GAI/Cf,QADW,iBAAXF,OACQc,aAHaF,IAAM,IAAMF,MAAQ,IAAMF,KAAO,KAAOM,kB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,MAC9B3D,KAAK+D,KAAK,CAAC,CACPC,WAAY,kCACZL,KAAM,CAACM,SAAUJ,aACjB,GACHK,KAAKpC,YACLoC,MAAMjC,kBAECkC,QAAU,CAACC,KAAMnC,mBACfb,KAAOa,YAAY,GAAGM,QAGtB8B,QAFMpC,YAAY,GAAGQ,OAEL,IADRlC,aAAc,EAAI+D,SAASrC,YAAY,GAAGO,WACpB,IAAMpB,KAE1CnB,SAASsE,SAAS9D,aAAe,IAAM4D,SACvCpE,SAASwD,QAAQ1D,UAAUyE,OAAO,2BAA4BL,aAE/DM,MAAK,KACJ7E,aAAa8E,UAAU,IAAIC,MAAM,gCASzCzE,QAAQ0E,KAAO,WAEXjF,IAAIkF,YAAYzE,WAAW8D,MAAKY,eAC5BvE,aAAeuE,gBAInB9E,KAAK+D,KAAK,CAAC,CACPC,WAAY,uCACZL,KAAM,MACN,GAAM,GAAO,GAAGO,MAAMlC,WACtBxB,eAAiBwB,YAElByC,MAAK,KACJ7E,aAAa8E,UAAU,IAAIC,MAAM,qCAGrChF,IAAIoF,WAAW,WAAY,oBAAoBb,MAAMc,QACjDvE,aAAeuE,MAGfnF,aAAaoF,OAAO,CAChBC,KAAMpF,WAAWqF,KACjBH,MAAOA,MACPI,KAAMjF,UAETkF,MAAMC,QACHrF,SAAWqF,aAOhBpF"} \ No newline at end of file diff --git a/amd/build/form_modal.min.js b/amd/build/form_modal.min.js deleted file mode 100644 index 8ddcccd..0000000 --- a/amd/build/form_modal.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Javascript for report card display and processing. - * - * @package local_assessfreq - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("local_assessfreq/form_modal",["core/str","core/modal_factory","core/fragment","core/ajax"],(function(Str,ModalFactory,Fragment,Ajax){var contextid,modalObj,callback,FormModal={},resetOptions=[];const spinner='

',observerConfig={attributes:!0,childList:!1,subtree:!0},observer=new MutationObserver((function(mutationsList){for(let i=0;i{let quizArray=JSON.parse(response),selectElement=document.getElementById("id_quiz"),selectElementLength=selectElement.options.length;null!==document.getElementById("noquizwarning")&&document.getElementById("noquizwarning").remove();for(let j=selectElementLength-1;j>=0;j--)selectElement.options[j]=null;if(quizArray.length>0){for(let k=0;k{selectElement.appendChild(option)})),document.getElementById("id_quiz").value=0,selectElement.disabled=!0})).fail((()=>{Notification.exception(new Error("Failed to get quizzes"))}));break}}})),updateModalBody=function(formdata){void 0===formdata&&(formdata={});let params={jsonformdata:JSON.stringify(formdata)};new Promise(((resolve,reject)=>{Str.get_strings([{key:"selectcourse",component:"local_assessfreq"},{key:"loadingquiz",component:"local_assessfreq"}]).then((stringReturn=>{for(let i=0;i{Str.get_string("searchquiz","local_assessfreq").then((title=>{modalObj.setTitle(title),modalObj.setBody(Fragment.loadFragment("local_assessfreq","new_base_form",contextid,params));let modalContainer=document.querySelectorAll('[data-region*="modal-container"]')[0];observer.observe(modalContainer,observerConfig)}))}))},processModalForm=function(e){e.preventDefault();let quizElement=document.getElementById("id_quiz"),quizId=quizElement.options[quizElement.selectedIndex].value,courseId=document.getElementById("id_courses").dataset.course;void 0===courseId||quizId<1?null===document.getElementById("noquizwarning")&&Str.get_string("noquizselected","local_assessfreq").then((warning=>{let element=document.createElement("div");element.innerHTML=warning,element.id="noquizwarning",element.classList.add("alert","alert-danger"),modalObj.getBody().prepend(element)})):(modalObj.hide(),modalObj.setBody(""),observer.disconnect(),callback(quizId,courseId))},displayModalForm=function(){updateModalBody(),modalObj.show()};return FormModal.init=function(context,processDashboard){contextid=context,callback=processDashboard,Str.get_string("loading","local_assessfreq").then((title=>{ModalFactory.create({type:ModalFactory.types.DEFAULT,title:title,body:spinner,large:!0}).done((modal=>{(modalObj=modal).getRoot().on("click","#id_submitbutton",processModalForm),modalObj.getRoot().on("click","#id_cancel",(e=>{e.preventDefault(),modalObj.setBody(spinner),modalObj.hide()}))}))})),document.getElementById("local-assessfreq-find-quiz").addEventListener("click",displayModalForm)},FormModal})); - -//# sourceMappingURL=form_modal.min.js.map \ No newline at end of file diff --git a/amd/build/form_modal.min.js.map b/amd/build/form_modal.min.js.map deleted file mode 100644 index 120bf6b..0000000 --- a/amd/build/form_modal.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"form_modal.min.js","sources":["../src/form_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript for report card display and processing.\n *\n * @package local_assessfreq\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n ['core/str', 'core/modal_factory', 'core/fragment', 'core/ajax'],\n function (Str, ModalFactory, Fragment, Ajax) {\n\n /**\n * Module level variables.\n */\n var FormModal = {};\n var contextid;\n var modalObj;\n var resetOptions = [];\n var callback;\n\n const spinner = '

'\n + ''\n + '

';\n\n const observerConfig = { attributes: true, childList: false, subtree: true };\n\n const ObserverCallback = function (mutationsList) {\n for (let i = 0; i < mutationsList.length; i++) {\n let element = mutationsList[i].target;\n if (element.tagName.toLowerCase() === 'span' && element.classList.contains('badge')) {\n element.addEventListener('click', updateModalBody);\n document.getElementById('id_courses').dataset.course = element.dataset.value;\n\n document.getElementById('id_quiz').value = -1;\n Ajax.call([{\n methodname: 'local_assessfreq_get_quizzes',\n args: {\n query: mutationsList[i].target.dataset.value\n },\n }])[0].done((response) => {\n let quizArray = JSON.parse(response);\n let selectElement = document.getElementById('id_quiz');\n let selectElementLength = selectElement.options.length;\n if (document.getElementById('noquizwarning') !== null) {\n document.getElementById('noquizwarning').remove();\n }\n // Clear exisitng options.\n for (let j = selectElementLength - 1; j >= 0; j--) {\n selectElement.options[j] = null;\n }\n\n if (quizArray.length > 0) {\n // Add new options.\n for (let k = 0; k < quizArray.length; k++) {\n let opt = quizArray[k];\n let el = document.createElement('option');\n el.textContent = opt.name;\n el.value = opt.id;\n selectElement.appendChild(el);\n }\n selectElement.removeAttribute('disabled');\n if (document.getElementById('noquizwarning') !== null) {\n document.getElementById('noquizwarning').remove();\n }\n } else {\n resetOptions.forEach((option) => {\n selectElement.appendChild(option);\n });\n document.getElementById('id_quiz').value = 0;\n selectElement.disabled = true;\n }\n\n }).fail(() => {\n Notification.exception(new Error('Failed to get quizzes'));\n });\n\n break;\n }\n }\n };\n\n const observer = new MutationObserver(ObserverCallback);\n\n /**\n * Create the modal window.\n *\n * @private\n */\n const createModal = function () {\n Str.get_string('loading', 'local_assessfreq').then((title) => {\n // Create the Modal.\n ModalFactory.create({\n type: ModalFactory.types.DEFAULT,\n title: title,\n body: spinner,\n large: true\n })\n .done((modal) => {\n modalObj = modal;\n\n // Explicitly handle form click events.\n modalObj.getRoot().on('click', '#id_submitbutton', processModalForm);\n modalObj.getRoot().on('click', '#id_cancel', (e) => {\n e.preventDefault();\n modalObj.setBody(spinner);\n modalObj.hide();\n });\n });\n return;\n });\n };\n\n const getOptionPlaceholders = function () {\n return new Promise((resolve, reject) => {\n const stringArr = [\n {key: 'selectcourse', component: 'local_assessfreq'},\n {key: 'loadingquiz', component: 'local_assessfreq'},\n ];\n\n Str.get_strings(stringArr).then(stringReturn => { // Save string to global to be used later.\n for (let i = 0; i < stringReturn.length; i++) {\n let el = document.createElement('option');\n el.textContent = stringReturn[i];\n el.value = 0 - i;\n resetOptions.push(el);\n }\n resolve();\n });\n });\n };\n\n /**\n * Updates the body of the modal window.\n *\n * @param {Object} formdata\n * @private\n */\n const updateModalBody = function (formdata) {\n if (typeof formdata === \"undefined\") {\n formdata = {};\n }\n\n let params = {\n 'jsonformdata': JSON.stringify(formdata)\n };\n\n getOptionPlaceholders()\n .then(() => {\n Str.get_string('searchquiz', 'local_assessfreq').then((title) => {\n modalObj.setTitle(title);\n modalObj.setBody(Fragment.loadFragment('local_assessfreq', 'new_base_form', contextid, params));\n let modalContainer = document.querySelectorAll('[data-region*=\"modal-container\"]')[0];\n observer.observe(modalContainer, observerConfig);\n\n return;\n });\n });\n };\n\n /**\n * Updates Moodle form with selected information.\n *\n * @param {Object} e\n * @private\n */\n const processModalForm = function (e) {\n e.preventDefault(); // Stop modal from closing.\n\n let quizElement = document.getElementById('id_quiz');\n let quizId = quizElement.options[quizElement.selectedIndex].value;\n let courseId = document.getElementById('id_courses').dataset.course;\n\n if (courseId === undefined || quizId < 1) {\n if (document.getElementById('noquizwarning') === null) {\n Str.get_string('noquizselected', 'local_assessfreq').then((warning) => {\n let element = document.createElement('div');\n element.innerHTML = warning;\n element.id = 'noquizwarning';\n element.classList.add('alert', 'alert-danger');\n modalObj.getBody().prepend(element);\n\n return;\n });\n }\n } else {\n modalObj.hide(); // Close modal.\n modalObj.setBody(''); // Cleaer form.\n observer.disconnect(); // Remove observer.\n callback(quizId, courseId); // Trigger dashboard update.\n }\n\n };\n\n /**\n * Display the Modal form.\n */\n const displayModalForm = function () {\n updateModalBody();\n modalObj.show();\n };\n\n /**\n * Initialise method for quiz dashboard rendering.\n */\n FormModal.init = function (context, processDashboard) {\n contextid = context;\n callback = processDashboard;\n createModal();\n\n let createBroadcastButton = document.getElementById('local-assessfreq-find-quiz');\n createBroadcastButton.addEventListener('click', displayModalForm);\n };\n\n return FormModal;\n }\n);\n"],"names":["define","Str","ModalFactory","Fragment","Ajax","contextid","modalObj","callback","FormModal","resetOptions","spinner","observerConfig","attributes","childList","subtree","observer","MutationObserver","mutationsList","i","length","element","target","tagName","toLowerCase","classList","contains","addEventListener","updateModalBody","document","getElementById","dataset","course","value","call","methodname","args","query","done","response","quizArray","JSON","parse","selectElement","selectElementLength","options","remove","j","k","opt","el","createElement","textContent","name","id","appendChild","removeAttribute","forEach","option","disabled","fail","Notification","exception","Error","formdata","params","stringify","Promise","resolve","reject","get_strings","key","component","then","stringReturn","push","get_string","title","setTitle","setBody","loadFragment","modalContainer","querySelectorAll","observe","processModalForm","e","preventDefault","quizElement","quizId","selectedIndex","courseId","undefined","warning","innerHTML","add","getBody","prepend","hide","disconnect","displayModalForm","show","init","context","processDashboard","create","type","types","DEFAULT","body","large","modal","getRoot","on"],"mappings":";;;;;;;AAuBAA,qCACI,CAAC,WAAY,qBAAsB,gBAAiB,cACpD,SAAUC,IAAKC,aAAcC,SAAUC,UAM/BC,UACAC,SAEAC,SAJAC,UAAY,GAGZC,aAAe,SAGbC,QAAU,sFAIVC,eAAiB,CAAEC,YAAY,EAAMC,WAAW,EAAOC,SAAS,GAyDhEC,SAAW,IAAIC,kBAvDI,SAAUC,mBAC1B,IAAIC,EAAI,EAAGA,EAAID,cAAcE,OAAQD,IAAK,KACvCE,QAAUH,cAAcC,GAAGG,UACO,SAAlCD,QAAQE,QAAQC,eAA4BH,QAAQI,UAAUC,SAAS,SAAU,CACjFL,QAAQM,iBAAiB,QAASC,iBAClCC,SAASC,eAAe,cAAcC,QAAQC,OAASX,QAAQU,QAAQE,MAEvEJ,SAASC,eAAe,WAAWG,OAAS,EAC5C5B,KAAK6B,KAAK,CAAC,CACPC,WAAY,+BACZC,KAAM,CACFC,MAAOnB,cAAcC,GAAGG,OAAOS,QAAQE,UAE3C,GAAGK,MAAMC,eACLC,UAAYC,KAAKC,MAAMH,UACvBI,cAAgBd,SAASC,eAAe,WACxCc,oBAAsBD,cAAcE,QAAQzB,OACC,OAA7CS,SAASC,eAAe,kBACxBD,SAASC,eAAe,iBAAiBgB,aAGxC,IAAIC,EAAIH,oBAAsB,EAAGG,GAAK,EAAGA,IAC1CJ,cAAcE,QAAQE,GAAK,QAG3BP,UAAUpB,OAAS,EAAG,KAEjB,IAAI4B,EAAI,EAAGA,EAAIR,UAAUpB,OAAQ4B,IAAK,KACnCC,IAAMT,UAAUQ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BH,MAAMmB,cACnDvE,QAAUQ,SAASsB,cAAc,OACrC9B,QAAQwE,UAAYD,QACpBvE,QAAQiC,GAAK,gBACbjC,QAAQI,UAAUqE,IAAI,QAAS,gBAC/BvF,SAASwF,UAAUC,QAAQ3E,aAMnCd,SAAS0F,OACT1F,SAASwE,QAAQ,IACjB/D,SAASkF,aACT1F,SAASgF,OAAQE,YAQnBS,iBAAmB,WACrBvE,kBACArB,SAAS6F,eAMb3F,UAAU4F,KAAO,SAAUC,QAASC,kBAChCjG,UAAYgG,QACZ9F,SAAW+F,iBArHXrG,IAAI0E,WAAW,UAAW,oBAAoBH,MAAMI,QAEhD1E,aAAaqG,OAAO,CAChBC,KAAMtG,aAAauG,MAAMC,QACzB9B,MAAOA,MACP+B,KAAMjG,QACNkG,OAAO,IAEVvE,MAAMwE,SACHvG,SAAWuG,OAGFC,UAAUC,GAAG,QAAS,mBAAoB5B,kBACnD7E,SAASwG,UAAUC,GAAG,QAAS,cAAe3B,IAC1CA,EAAEC,iBACF/E,SAASwE,QAAQpE,SACjBJ,SAAS0F,gBAwGOpE,SAASC,eAAe,8BAC9BH,iBAAiB,QAASwE,mBAG7C1F"} \ No newline at end of file diff --git a/amd/build/summary_participants.min.js b/amd/build/summary_participants.min.js deleted file mode 100644 index b0cf1a2..0000000 --- a/amd/build/summary_participants.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Javascript for summary participants graph. - * - * @package local_assessfreq - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("local_assessfreq/summary_participants",["core/fragment","core/templates","core/str","core/notification"],(function(Fragment,Templates,Str,Notification){var Summary={chart:function(assessids,contextid){assessids.forEach((assessid=>{let chartElement=document.getElementById(assessid+"-summary-graph"),params={data:JSON.stringify({quiz:assessid,call:"participant_summary"})};Fragment.loadFragment("local_assessfreq","get_quiz_chart",contextid,params).done((response=>{let resObj=JSON.parse(response);if(1!=resObj.hasdata)Str.get_string("nodata","local_assessfreq").then((str=>{const noDatastr=document.createElement("h3");noDatastr.innerHTML=str,chartElement.innerHTML=noDatastr.outerHTML}));else{let legend={position:"left"},context={withtable:!1,chartdata:JSON.stringify(resObj.chart),aspect:!1,legend:JSON.stringify(legend)};Templates.render("local_assessfreq/chart",context).done(((html,js)=>{Templates.replaceNodeContents(chartElement,html,js)})).fail((()=>{Notification.exception(new Error("Failed to load chart template."))}))}})).fail((()=>{Notification.exception(new Error("Failed to load card."))}))}))}};return Summary})); - -//# sourceMappingURL=summary_participants.min.js.map \ No newline at end of file diff --git a/amd/build/summary_participants.min.js.map b/amd/build/summary_participants.min.js.map deleted file mode 100644 index 94c0eaf..0000000 --- a/amd/build/summary_participants.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"summary_participants.min.js","sources":["../src/summary_participants.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript for summary participants graph.\n *\n * @package local_assessfreq\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n ['core/fragment', 'core/templates', 'core/str', 'core/notification'],\n function (Fragment, Templates, Str, Notification) {\n\n /**\n * Module level variables.\n */\n var Summary = {};\n\n Summary.chart = function (assessids, contextid) {\n assessids.forEach((assessid) => {\n let chartElement = document.getElementById(assessid + '-summary-graph');\n let params = {'data': JSON.stringify({'quiz' : assessid, 'call': 'participant_summary'})};\n\n Fragment.loadFragment('local_assessfreq', 'get_quiz_chart', contextid, params)\n .done((response) => {\n let resObj = JSON.parse(response);\n if (resObj.hasdata == true) {\n let legend = {position: 'left'};\n let context = {\n 'withtable' : false,\n 'chartdata' : JSON.stringify(resObj.chart),\n 'aspect' : false,\n 'legend' : JSON.stringify(legend)\n };\n Templates.render('local_assessfreq/chart', context).done((html, js) => {\n // Load card body.\n Templates.replaceNodeContents(chartElement, html, js);\n }).fail(() => {\n Notification.exception(new Error('Failed to load chart template.'));\n return;\n });\n return;\n } else {\n Str.get_string('nodata', 'local_assessfreq').then((str) => {\n const noDatastr = document.createElement('h3');\n noDatastr.innerHTML = str;\n chartElement.innerHTML = noDatastr.outerHTML;\n return;\n });\n }\n }).fail(() => {\n Notification.exception(new Error('Failed to load card.'));\n return;\n });\n });\n };\n\n return Summary;\n }\n);\n"],"names":["define","Fragment","Templates","Str","Notification","Summary","assessids","contextid","forEach","assessid","chartElement","document","getElementById","params","JSON","stringify","loadFragment","done","response","resObj","parse","hasdata","get_string","then","str","noDatastr","createElement","innerHTML","outerHTML","legend","position","context","chart","render","html","js","replaceNodeContents","fail","exception","Error"],"mappings":";;;;;;;AAuBAA,+CACI,CAAC,gBAAiB,iBAAkB,WAAY,sBAChD,SAAUC,SAAUC,UAAWC,IAAKC,kBAK5BC,QAAU,CAEdA,MAAgB,SAAUC,UAAWC,WACjCD,UAAUE,SAASC,eACXC,aAAeC,SAASC,eAAeH,SAAW,kBAClDI,OAAS,MAASC,KAAKC,UAAU,MAAUN,cAAkB,yBAEjER,SAASe,aAAa,mBAAoB,iBAAkBT,UAAWM,QACtEI,MAAMC,eACCC,OAASL,KAAKM,MAAMF,aACF,GAAlBC,OAAOE,QAiBPlB,IAAImB,WAAW,SAAU,oBAAoBC,MAAMC,YACzCC,UAAYd,SAASe,cAAc,MACzCD,UAAUE,UAAYH,IACtBd,aAAaiB,UAAYF,UAAUG,sBAnBnCC,OAAS,CAACC,SAAU,QACpBC,QAAU,YACI,YACAjB,KAAKC,UAAUI,OAAOa,eACzB,SACAlB,KAAKC,UAAUc,SAE9B3B,UAAU+B,OAAO,yBAA0BF,SAASd,MAAK,CAACiB,KAAMC,MAE5DjC,UAAUkC,oBAAoB1B,aAAcwB,KAAMC,OACnDE,MAAK,KACJjC,aAAakC,UAAU,IAAIC,MAAM,0CAY1CF,MAAK,KACJjC,aAAakC,UAAU,IAAIC,MAAM,wCAMtClC"} \ No newline at end of file diff --git a/amd/build/table_handler.min.js.map b/amd/build/table_handler.min.js.map index 0909724..3cb88dd 100644 --- a/amd/build/table_handler.min.js.map +++ b/amd/build/table_handler.min.js.map @@ -1 +1 @@ -{"version":3,"file":"table_handler.min.js","sources":["../src/table_handler.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Table handler JS module.\n *\n * @module local_assessfreq/table_handler\n * @package\n * @copyright 2020 Guillermo Gomez \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Fragment from 'core/fragment';\nimport Notification from 'core/notification';\nimport Templates from 'core/templates';\nimport * as Debouncer from 'local_assessfreq/debouncer';\nimport OverrideModal from 'local_assessfreq/override_modal';\nimport * as UserPreference from 'local_assessfreq/user_preferences';\n\nexport default class TableHandler {\n\n constructor(activity,\n context,\n tableElementId,\n tableFragmentComponent,\n tableFragmentValue,\n tableRowPreference,\n tableSortPreference,\n tableSearchElement,\n tableId = null,\n tableMethodName = null) {\n this.activityId = activity;\n this.contextId = context;\n this.elementId = tableElementId;\n this.fragmentComponent = tableFragmentComponent;\n this.fragmentValue = tableFragmentValue;\n this.rowPreference = tableRowPreference;\n this.sortPreference = tableSortPreference;\n this.searchElement = tableSearchElement;\n this.id = tableId;\n this.methodName = tableMethodName;\n this.overridden = false;\n }\n\n /**\n * Display the table that contains all the students in the exam as well as their attempts.\n *\n * @param {int|string|null} page Page number.\n */\n getTable = (page = 0) => {\n this.overridden = false;\n\n let search = document.getElementById(this.searchElement).value.trim();\n let tableElement = document.getElementById(this.elementId);\n let spinner = tableElement.getElementsByClassName('overlay-icon-container')[0];\n let tableBody = tableElement.getElementsByClassName('table-body')[0];\n let values = {'search': search, 'page': page};\n\n // Add values to Object depending on dashboard type.\n if (this.activityId > 0) {\n values.activityid = this.activityId;\n }\n\n let params = {'data': JSON.stringify(values)};\n\n spinner.classList.remove('hide'); // Show spinner if not already shown.\n Fragment.loadFragment(this.fragmentComponent, this.fragmentValue, this.contextId, params)\n .done((response, js) => {\n tableBody.innerHTML = response;\n if (js) {\n Templates.runTemplateJS(js); // Magic call the initialises JS from template included in response template HTML.\n }\n spinner.classList.add('hide');\n this.tableEventListeners(); // Re-add table event listeners.\n\n }).fail(() => {\n Notification.exception(new Error('Failed to update table.'))\n });\n };\n\n /**\n * This stops the ajax method that updates the table from being updated\n * while the user is still checking options.\n *\n */\n debounceTable = Debouncer.debouncer(() => {\n this.getTable();\n }, 750);\n\n /**\n * Process the sort click events from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableSort = (event) => {\n event.preventDefault();\n\n let sortArray = {};\n const linkUrl = new URL(event.target.closest('a').href);\n const targetSortBy = linkUrl.searchParams.get('tsort');\n let targetSortOrder = linkUrl.searchParams.get('tdir');\n\n // We want to flip the clicked column.\n if (targetSortOrder === '') {\n targetSortOrder = \"4\";\n }\n\n sortArray[targetSortBy] = targetSortOrder;\n\n // Set option via ajax.\n // eslint-disable-next-line promise/catch-or-return\n Ajax.call([{\n methodname: this.methodName,\n args: {\n tableid: this.id,\n preference: 'sortby',\n values: JSON.stringify(sortArray)\n },\n // eslint-disable-next-line promise/always-return\n }])[0].then(() => {\n this.getTable(); // Reload the table.\n });\n\n };\n\n /**\n * Process the sort click events from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableHide = (event) => {\n event.preventDefault();\n\n let hideArray = {};\n const linkUrl = new URL(event.target.closest('a').href);\n const tableElement = document.getElementById(this.elementId);\n const links = tableElement.querySelectorAll('a');\n let targetAction;\n let targetColumn;\n let action;\n let column;\n\n if (linkUrl.search.indexOf('thide') !== -1) {\n targetAction = 'hide';\n targetColumn = linkUrl.searchParams.get('thide');\n } else {\n targetAction = 'show';\n targetColumn = linkUrl.searchParams.get('tshow');\n }\n\n for (let i = 0; i < links.length; i++) {\n let hideLinkUrl = new URL(links[i].href);\n if (hideLinkUrl.search.indexOf('thide') !== -1) {\n action = 'hide';\n column = hideLinkUrl.searchParams.get('thide');\n } else {\n action = 'show';\n column = hideLinkUrl.searchParams.get('tshow');\n }\n\n if (action === 'show') {\n hideArray[column] = 1;\n }\n }\n\n hideArray[targetColumn] = (targetAction === 'hide') ? 1 : 0; // We want to flip the clicked column.\n\n // Set option via ajax.\n // eslint-disable-next-line promise/catch-or-return\n Ajax.call([{\n methodname: this.methodName,\n args: {\n tableid: this.id,\n preference: 'collapse',\n values: JSON.stringify(hideArray)\n },\n // eslint-disable-next-line promise/always-return\n }])[0].then(() => {\n this.getTable(); // Reload the table.\n });\n\n };\n\n /**\n * Process the reset click event from the table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableReset = (event) => {\n event.preventDefault();\n\n // Set option via ajax.\n // eslint-disable-next-line promise/catch-or-return\n Ajax.call([{\n methodname: this.methodName,\n args: {\n tableid: this.id,\n preference: 'reset',\n values: JSON.stringify({})\n },\n // eslint-disable-next-line promise/always-return\n }])[0].then(() => {\n this.getTable(); // Reload the table.\n });\n\n };\n\n /**\n * Process the search events from the student table.\n *\n * @param {Event} event\n * @return {Boolean}\n */\n tableSearch = (event) => {\n if (event.key === 'Meta' || event.ctrlKey) {\n return false;\n }\n\n if (event.target.value.length === 0 || event.target.value.length > 2) {\n this.debounceTable();\n }\n return true;\n };\n\n /**\n * Process the search reset click event from the student table.\n *\n */\n tableSearchReset = () => {\n let tableSearchInputElement = document.getElementById(this.searchElement);\n tableSearchInputElement.value = '';\n tableSearchInputElement.focus();\n this.getTable();\n };\n\n /**\n * Process the row set event from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableSearchRowSet = (event) => {\n event.preventDefault();\n if (event.target.tagName.toLowerCase() === 'a') {\n let rows = event.target.dataset.metric;\n UserPreference.setUserPreference(this.rowPreference, rows)\n // eslint-disable-next-line promise/always-return\n .then(() => {\n this.getTable(); // Reload the table.\n })\n .fail(() => {\n Notification.exception(new Error('Failed to update user preference: rows'));\n });\n }\n };\n\n /**\n * Process the nav event from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableNav = (event) => {\n event.preventDefault();\n\n const linkUrl = new URL(event.target.closest('a').href);\n const page = linkUrl.searchParams.get('page');\n\n if (page) {\n this.getTable(page);\n }\n };\n\n /**\n * Get and process the selected assessment metric from the dropdown for the heatmap display,\n * and update the corresponding user preference.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableSortButtonAction = (event) => {\n event.preventDefault();\n var element = event.target;\n\n if (element.tagName.toLowerCase() === 'a' && element.dataset.sort !== this.sortValue) {\n this.sortValue = element.dataset.sort;\n\n let links = element.parentNode.getElementsByTagName('a');\n for (let i = 0; i < links.length; i++) {\n links[i].classList.remove('active');\n }\n\n element.classList.add('active');\n\n // Save selection as a user preference.\n UserPreference.setUserPreference(this.sortPreference, this.sortValue);\n\n this.debounceTable(); // Call function to update table.\n }\n };\n\n /**\n * Re-add event listeners when the student table is updated.\n */\n tableEventListeners = () => {\n const tableElement = document.getElementById(this.elementId);\n const links = tableElement.querySelectorAll('a');\n const resetLink = tableElement.getElementsByClassName('resettable');\n const overrideLinks = tableElement.getElementsByClassName('action-icon override');\n const disabledLinks = tableElement.getElementsByClassName('action-icon disabled');\n const tableNavElement = tableElement.querySelectorAll('nav'); // There are two nav paging elements per table.\n\n for (let i = 0; i < links.length; i++) {\n let linkUrl = new URL(links[i].href);\n if (linkUrl.search.indexOf('thide') !== -1 || linkUrl.search.indexOf('tshow') !== -1) {\n links[i].addEventListener('click', this.tableHide);\n } else if (linkUrl.search.indexOf('tsort') !== -1) {\n links[i].addEventListener('click', this.tableSort);\n }\n }\n\n if (resetLink.length > 0) {\n resetLink[0].addEventListener('click', this.tableReset);\n }\n\n for (let i = 0; i < overrideLinks.length; i++) {\n overrideLinks[i].addEventListener('click', this.triggerOverrideModal);\n }\n\n for (let i = 0; i < disabledLinks.length; i++) {\n disabledLinks[i].addEventListener('click', (event) => {\n event.preventDefault();\n });\n }\n\n tableNavElement.forEach((navElement) => {\n navElement.addEventListener('click', this.tableNav);\n });\n };\n\n /**\n * Trigger the override modal form. Thin wrapper to add extra data to click event.\n *\n * @param {Event} event The triggered event for the element.\n */\n triggerOverrideModal = (event) => {\n event.preventDefault();\n let userid = event.target.closest('a').id.substring(25);\n if (userid.includes('-')) {\n let elements = userid.split('-');\n this.activityId = elements.pop();\n userid = elements.pop();\n }\n\n OverrideModal.displayModalForm(this.activityId, userid, this.hoursFilter);\n };\n}\n"],"names":["constructor","activity","context","tableElementId","tableFragmentComponent","tableFragmentValue","tableRowPreference","tableSortPreference","tableSearchElement","tableId","tableMethodName","activityId","contextId","elementId","fragmentComponent","fragmentValue","rowPreference","sortPreference","searchElement","id","methodName","overridden","getTable","page","_this","search","document","getElementById","value","trim","tableElement","spinner","getElementsByClassName","tableBody","values","activityid","params","JSON","stringify","classList","remove","loadFragment","done","response","js","innerHTML","runTemplateJS","add","tableEventListeners","fail","exception","Error","debounceTable","Debouncer","debouncer","tableSort","event","preventDefault","sortArray","linkUrl","URL","target","closest","href","targetSortBy","searchParams","get","targetSortOrder","call","methodname","this","args","tableid","preference","then","tableHide","hideArray","links","querySelectorAll","targetAction","targetColumn","action","column","indexOf","i","length","hideLinkUrl","tableReset","tableSearch","key","ctrlKey","tableSearchReset","tableSearchInputElement","focus","tableSearchRowSet","tagName","toLowerCase","rows","dataset","metric","UserPreference","setUserPreference","tableNav","tableSortButtonAction","element","sort","sortValue","parentNode","getElementsByTagName","resetLink","overrideLinks","disabledLinks","tableNavElement","addEventListener","triggerOverrideModal","forEach","navElement","userid","substring","includes","elements","split","pop","displayModalForm","hoursFilter"],"mappings":";;;;;;;;icAkCIA,YAAYC,SACAC,QACAC,eACAC,uBACAC,mBACAC,mBACAC,oBACAC,wBACAC,+DAAU,KACVC,uEAAkB,UACrBC,WAAaV,cACbW,UAAYV,aACZW,UAAYV,oBACZW,kBAAoBV,4BACpBW,cAAgBV,wBAChBW,cAAgBV,wBAChBW,eAAiBV,yBACjBW,cAAgBV,wBAChBW,GAAKV,aACLW,WAAaV,qBACbW,YAAa,EAQtBC,qCAAW,eAACC,4DAAO,EACfC,MAAKH,YAAa,MAEdI,OAASC,SAASC,eAAeH,MAAKN,eAAeU,MAAMC,OAC3DC,aAAeJ,SAASC,eAAeH,MAAKX,WAC5CkB,QAAUD,aAAaE,uBAAuB,0BAA0B,GACxEC,UAAYH,aAAaE,uBAAuB,cAAc,GAC9DE,OAAS,QAAWT,YAAgBF,MAGpCC,MAAKb,WAAa,IAClBuB,OAAOC,WAAaX,MAAKb,gBAGzByB,OAAS,MAASC,KAAKC,UAAUJ,SAErCH,QAAQQ,UAAUC,OAAO,0BAChBC,aAAajB,MAAKV,kBAAmBU,MAAKT,cAAeS,MAAKZ,UAAWwB,QAC7EM,MAAK,CAACC,SAAUC,MACbX,UAAUY,UAAYF,SAClBC,uBACUE,cAAcF,IAE5Bb,QAAQQ,UAAUQ,IAAI,QACtBvB,MAAKwB,yBAENC,MAAK,2BACSC,UAAU,IAAIC,MAAM,oCAS7CC,cAAgBC,UAAUC,WAAU,UAC3BhC,aACN,KAOHiC,UAAaC,QACTA,MAAMC,qBAEFC,UAAY,SACVC,QAAU,IAAIC,IAAIJ,MAAMK,OAAOC,QAAQ,KAAKC,MAC5CC,aAAeL,QAAQM,aAAaC,IA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AAI,EAAGA,EAAIP,MAAMQ,OAAQD,IAAK,KAC/BzB,QAAU,IAAIC,IAAIiB,MAAMO,GAAGrB,OACU,IAArCJ,QAAQlC,OAAO0D,QAAQ,WAAwD,IAArCxB,QAAQlC,OAAO0D,QAAQ,SACjEN,MAAMO,GAAG6B,iBAAiB,QAAS3C,KAAKK,YACI,IAArChB,QAAQlC,OAAO0D,QAAQ,UAC9BN,MAAMO,GAAG6B,iBAAiB,QAAS3C,KAAKf,WAI5CsD,UAAUxB,OAAS,GACnBwB,UAAU,GAAGI,iBAAiB,QAAS3C,KAAKiB,gBAG3C,IAAIH,EAAI,EAAGA,EAAI0B,cAAczB,OAAQD,IACtC0B,cAAc1B,GAAG6B,iBAAiB,QAAS3C,KAAK4C,0BAG/C,IAAI9B,EAAI,EAAGA,EAAI2B,cAAc1B,OAAQD,IACtC2B,cAAc3B,GAAG6B,iBAAiB,SAAUzD,QACxCA,MAAMC,oBAIduD,gBAAgBG,SAASC,aACrBA,WAAWH,iBAAiB,QAAS3C,KAAKgC,cASlDY,qBAAwB1D,QACpBA,MAAMC,qBACF4D,OAAS7D,MAAMK,OAAOC,QAAQ,KAAK3C,GAAGmG,UAAU,OAChDD,OAAOE,SAAS,KAAM,KAClBC,SAAWH,OAAOI,MAAM,UACvB9G,WAAa6G,SAASE,MAC3BL,OAASG,SAASE,8BAGRC,iBAAiBrD,KAAK3D,WAAY0G,OAAQ/C,KAAKsD"} \ No newline at end of file +{"version":3,"file":"table_handler.min.js","sources":["../src/table_handler.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Table handler JS module.\n *\n * @module local_assessfreq/table_handler\n * @package\n * @copyright 2020 Guillermo Gomez \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Fragment from 'core/fragment';\nimport Notification from 'core/notification';\nimport Templates from 'core/templates';\nimport * as Debouncer from 'local_assessfreq/debouncer';\nimport OverrideModal from 'local_assessfreq/override_modal';\nimport * as UserPreference from 'local_assessfreq/user_preferences';\n\nexport default class TableHandler {\n\n constructor(activity,\n context,\n tableElementId,\n tableFragmentComponent,\n tableFragmentValue,\n tableRowPreference,\n tableSortPreference,\n tableSearchElement,\n tableId = null,\n tableMethodName = null) {\n this.activityId = activity;\n this.contextId = context;\n this.elementId = tableElementId;\n this.fragmentComponent = tableFragmentComponent;\n this.fragmentValue = tableFragmentValue;\n this.rowPreference = tableRowPreference;\n this.sortPreference = tableSortPreference;\n this.searchElement = tableSearchElement;\n this.id = tableId;\n this.methodName = tableMethodName;\n this.overridden = false;\n }\n\n /**\n * Display the table that contains all the students in the exam as well as their attempts.\n *\n * @param {int|string|null} page Page number.\n */\n getTable = (page = 0) => {\n this.overridden = false;\n\n let search = document.getElementById(this.searchElement).value.trim();\n let tableElement = document.getElementById(this.elementId);\n let spinner = tableElement.getElementsByClassName('overlay-icon-container')[0];\n let tableBody = tableElement.getElementsByClassName('table-body')[0];\n let values = {'search': search, 'page': page};\n\n // Add values to Object depending on dashboard type.\n if (this.activityId > 0) {\n values.activityid = this.activityId;\n }\n\n let params = {'data': JSON.stringify(values)};\n\n spinner.classList.remove('hide'); // Show spinner if not already shown.\n Fragment.loadFragment(this.fragmentComponent, this.fragmentValue, this.contextId, params)\n .done((response, js) => {\n tableBody.innerHTML = response;\n if (js) {\n Templates.runTemplateJS(js); // Magic call the initialises JS from template included in response template HTML.\n }\n spinner.classList.add('hide');\n this.tableEventListeners(); // Re-add table event listeners.\n\n }).fail(() => {\n Notification.exception(new Error('Failed to update table.'));\n });\n };\n\n /**\n * This stops the ajax method that updates the table from being updated\n * while the user is still checking options.\n *\n */\n debounceTable = Debouncer.debouncer(() => {\n this.getTable();\n }, 750);\n\n /**\n * Process the sort click events from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableSort = (event) => {\n event.preventDefault();\n\n let sortArray = {};\n const linkUrl = new URL(event.target.closest('a').href);\n const targetSortBy = linkUrl.searchParams.get('tsort');\n let targetSortOrder = linkUrl.searchParams.get('tdir');\n\n // We want to flip the clicked column.\n if (targetSortOrder === '') {\n targetSortOrder = \"4\";\n }\n\n sortArray[targetSortBy] = targetSortOrder;\n\n // Set option via ajax.\n // eslint-disable-next-line promise/catch-or-return\n Ajax.call([{\n methodname: this.methodName,\n args: {\n tableid: this.id,\n preference: 'sortby',\n values: JSON.stringify(sortArray)\n },\n // eslint-disable-next-line promise/always-return\n }])[0].then(() => {\n this.getTable(); // Reload the table.\n });\n\n };\n\n /**\n * Process the sort click events from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableHide = (event) => {\n event.preventDefault();\n\n let hideArray = {};\n const linkUrl = new URL(event.target.closest('a').href);\n const tableElement = document.getElementById(this.elementId);\n const links = tableElement.querySelectorAll('a');\n let targetAction;\n let targetColumn;\n let action;\n let column;\n\n if (linkUrl.search.indexOf('thide') !== -1) {\n targetAction = 'hide';\n targetColumn = linkUrl.searchParams.get('thide');\n } else {\n targetAction = 'show';\n targetColumn = linkUrl.searchParams.get('tshow');\n }\n\n for (let i = 0; i < links.length; i++) {\n let hideLinkUrl = new URL(links[i].href);\n if (hideLinkUrl.search.indexOf('thide') !== -1) {\n action = 'hide';\n column = hideLinkUrl.searchParams.get('thide');\n } else {\n action = 'show';\n column = hideLinkUrl.searchParams.get('tshow');\n }\n\n if (action === 'show') {\n hideArray[column] = 1;\n }\n }\n\n hideArray[targetColumn] = (targetAction === 'hide') ? 1 : 0; // We want to flip the clicked column.\n\n // Set option via ajax.\n // eslint-disable-next-line promise/catch-or-return\n Ajax.call([{\n methodname: this.methodName,\n args: {\n tableid: this.id,\n preference: 'collapse',\n values: JSON.stringify(hideArray)\n },\n // eslint-disable-next-line promise/always-return\n }])[0].then(() => {\n this.getTable(); // Reload the table.\n });\n\n };\n\n /**\n * Process the reset click event from the table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableReset = (event) => {\n event.preventDefault();\n\n // Set option via ajax.\n // eslint-disable-next-line promise/catch-or-return\n Ajax.call([{\n methodname: this.methodName,\n args: {\n tableid: this.id,\n preference: 'reset',\n values: JSON.stringify({})\n },\n // eslint-disable-next-line promise/always-return\n }])[0].then(() => {\n this.getTable(); // Reload the table.\n });\n\n };\n\n /**\n * Process the search events from the student table.\n *\n * @param {Event} event\n * @return {Boolean}\n */\n tableSearch = (event) => {\n if (event.key === 'Meta' || event.ctrlKey) {\n return false;\n }\n\n if (event.target.value.length === 0 || event.target.value.length > 2) {\n this.debounceTable();\n }\n return true;\n };\n\n /**\n * Process the search reset click event from the student table.\n *\n */\n tableSearchReset = () => {\n let tableSearchInputElement = document.getElementById(this.searchElement);\n tableSearchInputElement.value = '';\n tableSearchInputElement.focus();\n this.getTable();\n };\n\n /**\n * Process the row set event from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableSearchRowSet = (event) => {\n event.preventDefault();\n if (event.target.tagName.toLowerCase() === 'a') {\n let rows = event.target.dataset.metric;\n UserPreference.setUserPreference(this.rowPreference, rows)\n // eslint-disable-next-line promise/always-return\n .then(() => {\n this.getTable(); // Reload the table.\n })\n .fail(() => {\n Notification.exception(new Error('Failed to update user preference: rows'));\n });\n }\n };\n\n /**\n * Process the nav event from the student table.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableNav = (event) => {\n event.preventDefault();\n\n const linkUrl = new URL(event.target.closest('a').href);\n const page = linkUrl.searchParams.get('page');\n\n if (page) {\n this.getTable(page);\n }\n };\n\n /**\n * Get and process the selected assessment metric from the dropdown for the heatmap display,\n * and update the corresponding user preference.\n *\n * @param {Event} event The triggered event for the element.\n */\n tableSortButtonAction = (event) => {\n event.preventDefault();\n var element = event.target;\n\n if (element.tagName.toLowerCase() === 'a' && element.dataset.sort !== this.sortValue) {\n this.sortValue = element.dataset.sort;\n\n let links = element.parentNode.getElementsByTagName('a');\n for (let i = 0; i < links.length; i++) {\n links[i].classList.remove('active');\n }\n\n element.classList.add('active');\n\n // Save selection as a user preference.\n UserPreference.setUserPreference(this.sortPreference, this.sortValue);\n\n this.debounceTable(); // Call function to update table.\n }\n };\n\n /**\n * Re-add event listeners when the student table is updated.\n */\n tableEventListeners = () => {\n const tableElement = document.getElementById(this.elementId);\n const links = tableElement.querySelectorAll('a');\n const resetLink = tableElement.getElementsByClassName('resettable');\n const overrideLinks = tableElement.getElementsByClassName('action-icon override');\n const disabledLinks = tableElement.getElementsByClassName('action-icon disabled');\n const tableNavElement = tableElement.querySelectorAll('nav'); // There are two nav paging elements per table.\n\n for (let i = 0; i < links.length; i++) {\n let linkUrl = new URL(links[i].href);\n if (linkUrl.search.indexOf('thide') !== -1 || linkUrl.search.indexOf('tshow') !== -1) {\n links[i].addEventListener('click', this.tableHide);\n } else if (linkUrl.search.indexOf('tsort') !== -1) {\n links[i].addEventListener('click', this.tableSort);\n }\n }\n\n if (resetLink.length > 0) {\n resetLink[0].addEventListener('click', this.tableReset);\n }\n\n for (let i = 0; i < overrideLinks.length; i++) {\n overrideLinks[i].addEventListener('click', this.triggerOverrideModal);\n }\n\n for (let i = 0; i < disabledLinks.length; i++) {\n disabledLinks[i].addEventListener('click', (event) => {\n event.preventDefault();\n });\n }\n\n tableNavElement.forEach((navElement) => {\n navElement.addEventListener('click', this.tableNav);\n });\n };\n\n /**\n * Trigger the override modal form. Thin wrapper to add extra data to click event.\n *\n * @param {Event} event The triggered event for the element.\n */\n triggerOverrideModal = (event) => {\n event.preventDefault();\n let userid = event.target.closest('a').id.substring(25);\n if (userid.includes('-')) {\n let elements = userid.split('-');\n this.activityId = elements.pop();\n userid = elements.pop();\n }\n\n OverrideModal.displayModalForm(this.activityId, userid, this.hoursFilter);\n };\n}\n"],"names":["constructor","activity","context","tableElementId","tableFragmentComponent","tableFragmentValue","tableRowPreference","tableSortPreference","tableSearchElement","tableId","tableMethodName","activityId","contextId","elementId","fragmentComponent","fragmentValue","rowPreference","sortPreference","searchElement","id","methodName","overridden","getTable","page","_this","search","document","getElementById","value","trim","tableElement","spinner","getElementsByClassName","tableBody","values","activityid","params","JSON","stringify","classList","remove","loadFragment","done","response","js","innerHTML","runTemplateJS","add","tableEventListeners","fail","exception","Error","debounceTable","Debouncer","debouncer","tableSort","event","preventDefault","sortArray","linkUrl","URL","target","closest","href","targetSortBy","searchParams","get","targetSortOrder","call","methodname","this","args","tableid","preference","then","tableHide","hideArray","links","querySelectorAll","targetAction","targetColumn","action","column","indexOf","i","length","hideLinkUrl","tableReset","tableSearch","key","ctrlKey","tableSearchReset","tableSearchInputElement","focus","tableSearchRowSet","tagName","toLowerCase","rows","dataset","metric","UserPreference","setUserPreference","tableNav","tableSortButtonAction","element","sort","sortValue","parentNode","getElementsByTagName","resetLink","overrideLinks","disabledLinks","tableNavElement","addEventListener","triggerOverrideModal","forEach","navElement","userid","substring","includes","elements","split","pop","displayModalForm","hoursFilter"],"mappings":";;;;;;;;icAkCIA,YAAYC,SACAC,QACAC,eACAC,uBACAC,mBACAC,mBACAC,oBACAC,wBACAC,+DAAU,KACVC,uEAAkB,UACrBC,WAAaV,cACbW,UAAYV,aACZW,UAAYV,oBACZW,kBAAoBV,4BACpBW,cAAgBV,wBAChBW,cAAgBV,wBAChBW,eAAiBV,yBACjBW,cAAgBV,wBAChBW,GAAKV,aACLW,WAAaV,qBACbW,YAAa,EAQtBC,qCAAW,eAACC,4DAAO,EACfC,MAAKH,YAAa,MAEdI,OAASC,SAASC,eAAeH,MAAKN,eAAeU,MAAMC,OAC3DC,aAAeJ,SAASC,eAAeH,MAAKX,WAC5CkB,QAAUD,aAAaE,uBAAuB,0BAA0B,GACxEC,UAAYH,aAAaE,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MAAMC,qBACF4D,OAAS7D,MAAMK,OAAOC,QAAQ,KAAK3C,GAAGmG,UAAU,OAChDD,OAAOE,SAAS,KAAM,KAClBC,SAAWH,OAAOI,MAAM,UACvB9G,WAAa6G,SAASE,MAC3BL,OAASG,SAASE,8BAGRC,iBAAiBrD,KAAK3D,WAAY0G,OAAQ/C,KAAKsD"} \ No newline at end of file diff --git a/amd/build/zoom_modal.min.js b/amd/build/zoom_modal.min.js deleted file mode 100644 index 77cda55..0000000 --- a/amd/build/zoom_modal.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Javascript for report card display and processing. - * - * @package local_assessfreq - * @copyright 2020 Matt Porritt - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define("local_assessfreq/zoom_modal",["core/str","core/modal_factory","core/fragment","core/ajax","core/templates","local_assessfreq/modal_large","core/notification"],(function(Str,ModalFactory,Fragment,Ajax,Templates,ModalLarge,Notification){var contextid,modalObj,ZoomModal={};ZoomModal.zoomGraph=function(event,params,method){let title=event.target.parentElement.dataset.title;Fragment.loadFragment("local_assessfreq",method,contextid,params).done((response=>{let resObj=JSON.parse(response);if(1==resObj.hasdata){var context={withtable:!1,chartdata:JSON.stringify(resObj.chart),aspect:!1};return modalObj.setTitle(title),modalObj.setBody(Templates.render("local_assessfreq/chart",context)),void modalObj.show()}Str.get_string("nodata","local_assessfreq").then((str=>{const noDatastr=document.createElement("h3");noDatastr.innerHTML=str,modalObj.setTitle(title),modalObj.setBody(noDatastr.outerHTML),modalObj.show()}))})).fail((()=>{Notification.exception(new Error("Failed to load zoomed graph"))}))};return ZoomModal.init=function(context){contextid=context,new Promise(((resolve,reject)=>{Str.get_string("loading","core").then((title=>{ModalFactory.create({type:ModalLarge.TYPE,title:title,body:'

'}).done((modal=>{modalObj=modal,resolve()}))}))}))},ZoomModal})); - -//# sourceMappingURL=zoom_modal.min.js.map \ No newline at end of file diff --git a/amd/build/zoom_modal.min.js.map b/amd/build/zoom_modal.min.js.map deleted file mode 100644 index 9e7151d..0000000 --- a/amd/build/zoom_modal.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"zoom_modal.min.js","sources":["../src/zoom_modal.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript for report card display and processing.\n *\n * @package local_assessfreq\n * @copyright 2020 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n ['core/str', 'core/modal_factory', 'core/fragment', 'core/ajax', 'core/templates', 'local_assessfreq/modal_large',\n 'core/notification'],\n function (Str, ModalFactory, Fragment, Ajax, Templates, ModalLarge, Notification) {\n\n /**\n * Module level variables.\n */\n var ZoomModal = {};\n var contextid;\n var modalObj;\n const spinner = '

'\n + ''\n + '

';\n\n /**\n * Provides zoom functionality for card graphs.\n */\n ZoomModal.zoomGraph = function (event, params, method) {\n let title = event.target.parentElement.dataset.title;\n\n Fragment.loadFragment('local_assessfreq', method, contextid, params)\n .done((response) => {\n let resObj = JSON.parse(response);\n if (resObj.hasdata == true) {\n var context = { 'withtable' : false, 'chartdata' : JSON.stringify(resObj.chart), aspect: false};\n modalObj.setTitle(title);\n modalObj.setBody(Templates.render('local_assessfreq/chart', context));\n modalObj.show();\n return;\n } else {\n Str.get_string('nodata', 'local_assessfreq').then((str) => {\n const noDatastr = document.createElement('h3');\n noDatastr.innerHTML = str;\n modalObj.setTitle(title);\n modalObj.setBody(noDatastr.outerHTML);\n modalObj.show();\n return;\n });\n }\n }).fail(() => {\n Notification.exception(new Error('Failed to load zoomed graph'));\n return;\n });\n\n };\n\n /**\n * Create the modal window for graph zooming.\n *\n * @private\n */\n const createModal = function () {\n return new Promise((resolve, reject) => {\n Str.get_string('loading', 'core').then((title) => {\n // Create the Modal.\n ModalFactory.create({\n type: ModalLarge.TYPE,\n title: title,\n body: spinner\n })\n .done((modal) => {\n modalObj = modal;\n resolve();\n });\n });\n });\n };\n\n /**\n * Initialise method for quiz dashboard rendering.\n */\n ZoomModal.init = function (context) {\n contextid = context;\n createModal();\n };\n\n return ZoomModal;\n }\n);\n"],"names":["define","Str","ModalFactory","Fragment","Ajax","Templates","ModalLarge","Notification","contextid","modalObj","ZoomModal","zoomGraph","event","params","method","title","target","parentElement","dataset","loadFragment","done","response","resObj","JSON","parse","hasdata","context","stringify","chart","aspect","setTitle","setBody","render","show","get_string","then","str","noDatastr","document","createElement","innerHTML","outerHTML","fail","exception","Error","init","Promise","resolve","reject","create","type","TYPE","body","modal"],"mappings":";;;;;;;AAuBAA,qCACI,CAAC,WAAY,qBAAsB,gBAAiB,YAAa,iBAAkB,+BACnF,sBACA,SAAUC,IAAKC,aAAcC,SAAUC,KAAMC,UAAWC,WAAYC,kBAM5DC,UACAC,SAFAC,UAAY,GAUhBA,UAAUC,UAAY,SAAUC,MAAOC,OAAQC,YACvCC,MAAQH,MAAMI,OAAOC,cAAcC,QAAQH,MAE/CZ,SAASgB,aAAa,mBAAoBL,OAAQN,UAAWK,QAC5DO,MAAMC,eACCC,OAASC,KAAKC,MAAMH,aACF,GAAlBC,OAAOG,QAAiB,KACpBC,QAAU,YAAgB,YAAqBH,KAAKI,UAAUL,OAAOM,OAAQC,QAAQ,UACzFpB,SAASqB,SAASf,OAClBN,SAASsB,QAAQ1B,UAAU2B,OAAO,yBAA0BN,eAC5DjB,SAASwB,OAGThC,IAAIiC,WAAW,SAAU,oBAAoBC,MAAMC,YACzCC,UAAYC,SAASC,cAAc,MACzCF,UAAUG,UAAYJ,IACtB3B,SAASqB,SAASf,OAClBN,SAASsB,QAAQM,UAAUI,WAC3BhC,SAASwB,aAIlBS,MAAK,KACJnC,aAAaoC,UAAU,IAAIC,MAAM,2CA+BzClC,UAAUmC,KAAO,SAAUnB,SACvBlB,UAAYkB,QApBL,IAAIoB,SAAQ,CAACC,QAASC,UACzB/C,IAAIiC,WAAW,UAAW,QAAQC,MAAMpB,QAEpCb,aAAa+C,OAAO,CAChBC,KAAM5C,WAAW6C,KACjBpC,MAAOA,MACPqC,KAhDA,wFAkDHhC,MAAMiC,QACH5C,SAAW4C,MACXN,oBAcTrC"} \ No newline at end of file