Skip to content

Commit

Permalink
Merge pull request catalyst#151 from marxjohnson/student-search-query
Browse files Browse the repository at this point in the history
Rewrite student_search_table query
  • Loading branch information
marxjohnson authored Feb 14, 2024
2 parents 3ba6987 + 0b6fff9 commit 57564af
Show file tree
Hide file tree
Showing 98 changed files with 2,158 additions and 2,219 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
# Required if you plan to publish (uncomment the below)
# secrets:
# moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }}
# with:
# Any further options in this section
with:
disable_phpcpd: true
40 changes: 18 additions & 22 deletions amd/src/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notification, Ajax) {
define(['core/str', 'core/notification', 'core/ajax'], function (Str, Notification, Ajax) {

/**
* Module level variables.
Expand Down Expand Up @@ -93,7 +93,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Number} month The month to get the number of days for.
* @param {Number} year The year to get the number of days for.
*/
const daysInMonth = function(month, year) {
const daysInMonth = function (month, year) {
return 32 - new Date(year, month, 32).getDate();
};

Expand All @@ -102,15 +102,15 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
*
* @method getHeatColors
*/
const getHeatColors = function() {
const getHeatColors = function () {
return new Promise((resolve, reject) => {
Ajax.call([{
methodname: 'local_assessfreq_get_heat_colors',
args: {},
}], true, false)[0].done(function(response) {
}], true, false)[0].done(function (response) {
colorArray = JSON.parse(response);
resolve(colorArray);
}).fail(function() {
}).fail(function () {
reject(new Error('Failed to get heat colors'));
});
});
Expand All @@ -121,15 +121,15 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
*
* @method getProcessEvents
*/
const getProcessModules = function() {
const getProcessModules = function () {
return new Promise((resolve, reject) => {
Ajax.call([{
methodname: 'local_assessfreq_get_process_modules',
args: {},
}], true, false)[0].done(function(response) {
}], true, false)[0].done(function (response) {
processModules = JSON.parse(response);
resolve(processModules);
}).fail(function() {
}).fail(function () {
reject(new Error('Failed to get process events'));
});
});
Expand All @@ -142,7 +142,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Object} eventArray All the event count for the heatmap.
* @param {Object} dateObj Date details.
*/
const calcHeatRange = function(eventArray, dateObj) {
const calcHeatRange = function (eventArray, dateObj) {
return new Promise((resolve) => {

// Resolve early if there are no events.
Expand All @@ -155,7 +155,6 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
// If scheduled tasks have not run yet we may not have any data.
let eventArrayLength = Object.keys(eventArray).length;
if ((eventArrayLength > 0) && (eventArray[dateObj.year] !== "undefined")) {

let eventcount = new Array;
let year = eventArray[dateObj.year];

Expand Down Expand Up @@ -191,7 +190,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Number} eventCount The count to get the heat value.
* @return {Number} heat The heat value.
*/
const getHeat = function(eventCount) {
const getHeat = function (eventCount) {
let scaleMin = 1;

if (eventCount == heatRangeMin) {
Expand Down Expand Up @@ -224,7 +223,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Array} modules Array of the modules to get.
* @return {Promise}
*/
const getEvents = function({year, metric, modules}) {
const getEvents = function ({year, metric, modules}) {
return new Promise((resolve, reject) => {
let args = {
year: year,
Expand Down Expand Up @@ -255,7 +254,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Number} month The month to get the number of days for.
* @return {Array} monthevents The events for the supplied month.
*/
const getMonthEvents = function(year, month) {
const getMonthEvents = function (year, month) {
let monthevents;

if ((typeof eventArray[year] !== "undefined") && (typeof eventArray[year][month] !== "undefined")) {
Expand All @@ -273,7 +272,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Number} endMonth The month to generate the tables to.
* @return {Promise}
*/
const createTables = function({year, startMonth, endMonth}) {
const createTables = function ({year, startMonth, endMonth}) {
return new Promise((resolve, reject) => {
let calendarContainer = document.createElement('div');
let month = startMonth;
Expand Down Expand Up @@ -337,7 +336,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Object} dayArray The details of the events for that day/
* @return {String} tipHTML The HTML for the tooltip.
*/
const getTooltip = function(dayArray) {
const getTooltip = function (dayArray) {
let tipHTML = '';

for (let [key, value] of Object.entries(dayArray)) {
Expand All @@ -354,7 +353,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Number} year The year to generate calendar for.
* @param {Number} month The monthe to generate calendar for.
*/
const populateCalendarDays = function(table, year, month) {
const populateCalendarDays = function (table, year, month) {
let firstDay = (new Date(year, month)).getDay(); // Get the starting day of the month.
let monthEvents = getMonthEvents(year, (month + 1)); // We add one due to month diferences between PHP and JS.
let date = 1; // Creating all cells.
Expand All @@ -368,7 +367,6 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
var cell = document.createElement("td");
var cellText = document.createTextNode("");
cell.dataset.event = 'false';

} else if (date > daysInMonth(month, year)) { // Break if we have generated all the days for this month.
break;
} else {
Expand All @@ -391,7 +389,6 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
cell.dataset.date = year + '-' + (month + 1) + '-' + date;
cell.title = getTooltip(monthEvents[date]);
cell.style.cursor = "pointer";

}
date++;
}
Expand All @@ -411,7 +408,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Number} startMonth The month to start generation from.
* @return {Promise}
*/
const populateCalendar = function({calendarContainer, year, startMonth}) {
const populateCalendar = function ({calendarContainer, year, startMonth}) {
return new Promise((resolve, reject) => {
// Get the table boodies.
let tables = calendarContainer.getElementsByTagName("tbody");
Expand All @@ -437,7 +434,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
*
* @method createHeatScale
*/
Calendar.createHeatScale = function() {
Calendar.createHeatScale = function () {
return new Promise((resolve) => {
let table = document.createElement('table');
let tbody = document.createElement('tbody');
Expand All @@ -454,7 +451,6 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio

trow.appendChild(cell);
}

}

tbody.appendChild(trow);
Expand All @@ -477,7 +473,7 @@ define(['core/str', 'core/notification', 'core/ajax'], function(Str, Notificatio
* @param {Array} modules The modules to display in the heatamp.
* @return {Promise}
*/
Calendar.generate = function(year, startMonth, endMonth, metric, modules) {
Calendar.generate = function (year, startMonth, endMonth, metric, modules) {
return new Promise((resolve, reject) => {
const dateObj = {
year : year,
Expand Down
6 changes: 3 additions & 3 deletions amd/src/chart_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ export const getCardCharts = (quizId, hoursFilter, yearSelect) => {
});
}
}).fail(() => {
Notification.exception(new Error('Failed to load card.'));
return;
});
Notification.exception(new Error('Failed to load card.'));
return;
});
});
};

Expand Down
16 changes: 8 additions & 8 deletions amd/src/chart_output_chartjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @copyright 2020 Matt Porritt <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['core/chart_output_chartjs'], function(Output) {
define(['core/chart_output_chartjs'], function (Output) {

/**
* Module level variables.
Expand All @@ -36,7 +36,7 @@ define(['core/chart_output_chartjs'], function(Output) {
* @param {module:core/chart_axis} axis The axis.
* @return {Object} The axis config.
*/
Output.prototype._makeConfig = function() {
Output.prototype._makeConfig = function () {
var config = {
type: this._getChartType(),
data: {
Expand All @@ -56,34 +56,34 @@ define(['core/chart_output_chartjs'], function(Output) {
}

// Override legend options with those provided at run time.
if (rtLegendoptions) {
if (rtLegendoptions) {
config.options.legend = rtLegendoptions;
}

this._chart.getXAxes().forEach(function(axis, i) {
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);

if (axisLabels !== null) {
config.options.scales.xAxes[i].ticks.callback = function(value, index) {
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) {
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);

if (axisLabels !== null) {
config.options.scales.yAxes[i].ticks.callback = function(value) {
config.options.scales.yAxes[i].ticks.callback = function (value) {
return axisLabels[parseInt(value, 10)] || '';
};
}
Expand All @@ -104,7 +104,7 @@ define(['core/chart_output_chartjs'], function(Output) {
/**
* Get the aspect ratio setting and initialise the chart.
*/
ChartOutput.init = function(chartImage, ChartInst, aspect, legend) {
ChartOutput.init = function (chartImage, ChartInst, aspect, legend) {
aspectRatio = aspect;
rtLegendoptions = legend;
new Output(chartImage, ChartInst);
Expand Down
6 changes: 3 additions & 3 deletions amd/src/course_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @licensehttp://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define(['core/ajax', 'core/notification'], function(Ajax, Notification) {
define(['core/ajax', 'core/notification'], function (Ajax, Notification) {

/**
* Module level variables.
Expand All @@ -38,7 +38,7 @@ define(['core/ajax', 'core/notification'], function(Ajax, Notification) {
* @param {Function} callback A callback function receiving an array of results.
* @return {Void}
*/
CourseSelector.transport = function(selector, query, callback) {
CourseSelector.transport = function (selector, query, callback) {
Ajax.call([{
methodname: 'local_assessfreq_get_courses',
args: {
Expand All @@ -59,7 +59,7 @@ define(['core/ajax', 'core/notification'], function(Ajax, Notification) {
* @param {Array} results An array or results.
* @return {Array} New array of results.
*/
CourseSelector.processResults = function(selector, results) {
CourseSelector.processResults = function (selector, results) {
let options = [];
results.forEach((element) => {
options.push({
Expand Down
8 changes: 3 additions & 5 deletions amd/src/dashboard_assessment.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const moduleListChildrenEvents = (element) => {
let module = links[i].dataset.module;

if (module.toLowerCase() === 'all') {
links[i].addEventListener('click', function(event){
links[i].addEventListener('click', function (event) {
event.preventDefault();
// Remove active class from all other links.
for (var j = 0; j < links.length; j++) {
Expand All @@ -281,7 +281,7 @@ const moduleListChildrenEvents = (element) => {
updateHeatmapDebounce(); // Call function to update heatmap.
});
} else if (module.toLowerCase() === 'close') {
links[i].addEventListener('click', function(event){
links[i].addEventListener('click', function (event) {
event.preventDefault();
event.stopPropagation();

Expand All @@ -290,9 +290,8 @@ const moduleListChildrenEvents = (element) => {

updateHeatmapDebounce(); // Call function to update heatmap.
});

} else {
links[i].addEventListener('click', function(event){
links[i].addEventListener('click', function (event) {
event.preventDefault();
event.stopPropagation();

Expand All @@ -302,7 +301,6 @@ const moduleListChildrenEvents = (element) => {
updateHeatmapDebounce();
});
}

}
};

Expand Down
5 changes: 2 additions & 3 deletions amd/src/dashboard_quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ import * as TableHandler from 'local_assessfreq/table_handler';
import * as UserPreference from 'local_assessfreq/user_preferences';
import * as ZoomModal from 'local_assessfreq/zoom_modal';

/**
* Module level variables.
*/
// Module level variables.

var selectQuizStr = '';
var contextid;
var quizId = 0;
Expand Down
Loading

0 comments on commit 57564af

Please sign in to comment.