Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite student_search_table query #151

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -16,12 +16,12 @@
/**
* Javascript for heatmap calendar generation and display.
*
* @package local_assessfreq

Check failure on line 19 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

@Package should be empty

Check failure on line 19 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

@Package should be empty

Check failure on line 19 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

@Package should be empty

Check failure on line 19 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

@Package should be empty
* @copyright 2020 Matt Porritt <[email protected]>
* @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 @@ -56,10 +56,10 @@
var processModules;
var heatRangeScale = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0};

/**

Check failure on line 59 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

Missing JSDoc @param "hexcolor" declaration

Check failure on line 59 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

Missing JSDoc @param "hexcolor" declaration

Check failure on line 59 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

Missing JSDoc @param "hexcolor" declaration

Check failure on line 59 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

Missing JSDoc @param "hexcolor" declaration
* Pick a contrasting text color based on the background color.
*
* @param {String} A hexcolor value.

Check failure on line 62 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

Expected @param names to be "hexcolor". Got "A"

Check failure on line 62 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

Expected @param names to be "hexcolor". Got "A"

Check failure on line 62 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

Expected @param names to be "hexcolor". Got "A"

Check failure on line 62 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

Expected @param names to be "hexcolor". Got "A"
* @return {String} The contrasting color (black or white).
*/
const getContrast = function (hexcolor) {
Expand Down Expand Up @@ -93,7 +93,7 @@
* @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 @@
*
* @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 @@
*
* @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 @@
* @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 @@
// 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 @@
* @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 @@ -220,11 +219,11 @@
*
* @method getEvents
* @param {Number} year The year to get the events for.
* @param {String} metric The type of metric to get, 'students' or 'assess'.

Check failure on line 222 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

@param "metric" does not match an existing function parameter

Check failure on line 222 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

@param "metric" does not match an existing function parameter

Check failure on line 222 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

@param "metric" does not match an existing function parameter

Check failure on line 222 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

@param "metric" does not match an existing function parameter
* @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 @@
* @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 @@ -270,10 +269,10 @@
*
* @oaram {Number} year The year to generate the tables for.
* @param {Number} startMonth The month to start table generation from.
* @param {Number} endMonth The month to generate the tables to.

Check failure on line 272 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

@param "endMonth" does not match an existing function parameter

Check failure on line 272 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

@param "endMonth" does not match an existing function parameter

Check failure on line 272 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

@param "endMonth" does not match an existing function parameter

Check failure on line 272 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

@param "endMonth" does not match an existing function parameter
* @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 @@
* @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 @@
* @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 @@
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 @@
cell.dataset.date = year + '-' + (month + 1) + '-' + date;
cell.title = getTooltip(monthEvents[date]);
cell.style.cursor = "pointer";

}
date++;
}
Expand All @@ -403,15 +400,15 @@
}
};

/**

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

Missing JSDoc @param "calendarContainer.calendarContainer" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

Missing JSDoc @param "calendarContainer.year" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

Missing JSDoc @param "calendarContainer.startMonth" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

Missing JSDoc @param "calendarContainer.calendarContainer" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

Missing JSDoc @param "calendarContainer.year" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

Missing JSDoc @param "calendarContainer.startMonth" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

Missing JSDoc @param "calendarContainer.calendarContainer" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

Missing JSDoc @param "calendarContainer.year" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

Missing JSDoc @param "calendarContainer.startMonth" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

Missing JSDoc @param "calendarContainer.calendarContainer" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

Missing JSDoc @param "calendarContainer.year" declaration

Check failure on line 403 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

Missing JSDoc @param "calendarContainer.startMonth" declaration
* Controls the population of the calendar in to the base tables.
*
* @param {Object} calendarContainer the container to populate.

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

Missing @param "calendarContainer.calendarContainer"

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.1 - local_assessfreq

Missing @param "calendarContainer.year"

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

Missing @param "calendarContainer.calendarContainer"

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - pgsql - php 8.0 - local_assessfreq

Missing @param "calendarContainer.year"

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

Missing @param "calendarContainer.calendarContainer"

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.0 - local_assessfreq

Missing @param "calendarContainer.year"

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

Missing @param "calendarContainer.calendarContainer"

Check failure on line 406 in amd/src/calendar.js

View workflow job for this annotation

GitHub Actions / ci / MOODLE_402_STABLE - mariadb - php 8.1 - local_assessfreq

Missing @param "calendarContainer.year"
* @param {Number} year The year to generate calendar for.
* @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 @@
*
* @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 @@

trow.appendChild(cell);
}

}

tbody.appendChild(trow);
Expand All @@ -477,7 +473,7 @@
* @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
Loading