Skip to content

Commit

Permalink
Issue #78: Add filters to Quizzes in Progress Dashboard
Browse files Browse the repository at this point in the history
commit e08f777fa6a9558347ee5e922377f60150a03dad
Author: Guillermo Gomez <[email protected]>
Date:   Thu Mar 11 14:21:03 2021 +1000

    Issue #78: Initialise look ahead and behind values in DashboardQuizInprogress

commit fb01bb6ba6001a3de6d277a2ca25047ec68d4a88
Author: Guillermo Gomez <[email protected]>
Date:   Wed Mar 10 15:28:50 2021 +1000

    Issue #78: Show in upcomming quizzes graph inprogress quizzes that are upcomming quizzes with override

commit b7efc6aeeed9abc570df9e9b1b4d755c6b8d7f1f
Author: Guillermo Gomez <[email protected]>
Date:   Wed Mar 10 14:09:25 2021 +1000

    Issue #78: Add look ahead and look in participant summary graph

commit 45394fb4bf077f8ca1a73a45419dc8178f04db31
Author: Guillermo Gomez <[email protected]>
Date:   Tue Mar 9 14:14:01 2021 +1000

    Issue #78: Add look ahead and look behind filters in quizzes in progress dashboard
  • Loading branch information
guillogo committed Mar 12, 2021
1 parent 147e971 commit bb0779b
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 13 deletions.
2 changes: 1 addition & 1 deletion amd/build/dashboard_quiz_inprogress.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/dashboard_quiz_inprogress.min.js.map

Large diffs are not rendered by default.

70 changes: 68 additions & 2 deletions amd/src/dashboard_quiz_inprogress.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function(Ajax, Templates, Fragment, ZoomModal, Str, Notification) {
var refreshPeriod = 60;
var counterid;
var tablesort = 'name_asc';
var hoursAhead = 0;
var hoursBehind = 0;

const cards = [
{cardId: 'local-assessfreq-quiz-summary-upcomming-graph', call: 'upcomming_quizzes', aspect: true},
Expand Down Expand Up @@ -168,7 +170,9 @@ function(Ajax, Templates, Fragment, ZoomModal, Str, Notification) {
let cardElement = document.getElementById(cardData.cardId);
let spinner = cardElement.getElementsByClassName('overlay-icon-container')[0];
let chartbody = cardElement.getElementsByClassName('chart-body')[0];
let params = {'data': JSON.stringify({'call': cardData.call})};
let params = {
'data': JSON.stringify({'call': cardData.call, 'hoursahead': hoursAhead, 'hoursbehind': hoursBehind
})};

spinner.classList.remove('hide'); // Show sinner if not already shown.
Fragment.loadFragment('local_assessfreq', 'get_quiz_inprogress_chart', contextid, params)
Expand Down Expand Up @@ -290,7 +294,10 @@ function(Ajax, Templates, Fragment, ZoomModal, Str, Notification) {
let sorton = sortarray[0];
let direction = sortarray[1];

let params = {'data': JSON.stringify({'search': search, 'page': page, 'sorton': sorton, 'direction': direction})};
let params = {'data': JSON.stringify(
{'search': search, 'page': page, 'sorton': sorton, 'direction': direction,
'hoursahead': hoursAhead, 'hoursbehind': hoursBehind}
)};

spinner.classList.remove('hide'); // Show sinner if not already shown.

Expand Down Expand Up @@ -384,6 +391,42 @@ function(Ajax, Templates, Fragment, ZoomModal, Str, Notification) {
ZoomModal.zoomGraph(event, params, method);
};

/**
* Process the hours ahead event from the in progress quizzes table.
*/
const quizzesAheadSet = function(event) {
event.preventDefault();
if (event.target.tagName.toLowerCase() === 'a') {
let hours = event.target.dataset.metric;
setUserPreference('local_assessfreq_quizzes_inprogress_table_hoursahead_preference', hours)
.then(() => {
hoursAhead = hours;
processDashboard(); // Reload the table.
})
.fail(() => {
Notification.exception(new Error('Failed to update user preference: hours ahead'));
});
}
};

/**
* Process the hours behind event from the in progress quizzes table.
*/
const quizzesBehindSet = function(event) {
event.preventDefault();
if (event.target.tagName.toLowerCase() === 'a') {
let hours = event.target.dataset.metric;
setUserPreference('local_assessfreq_quizzes_inprogress_table_hoursbehind_preference', hours)
.then(() => {
hoursBehind = hours;
processDashboard(); // Reload the table.
})
.fail(() => {
Notification.exception(new Error('Failed to update user preference: hours behind'));
});
}
};

/**
* Initialise method for quizzes in progress dashboard rendering.
*/
Expand All @@ -407,6 +450,22 @@ function(Ajax, Templates, Fragment, ZoomModal, Str, Notification) {
Notification.exception(new Error('Failed to get use preference: tablesort'));
});

getUserPreference('local_assessfreq_quizzes_inprogress_table_hoursahead_preference')
.then((response) => {
hoursAhead = response.preferences[0].value ? response.preferences[0].value : 0;
})
.fail(() => {
Notification.exception(new Error('Failed to get use preference: hoursahead'));
});

getUserPreference('local_assessfreq_quizzes_inprogress_table_hoursbehind_preference')
.then((response) => {
hoursBehind = response.preferences[0].value ? response.preferences[0].value : 0;
})
.fail(() => {
Notification.exception(new Error('Failed to get use preference: hoursbehind'));
});

// Event handling for refresh and period buttons.
let refreshElement = document.getElementById('local-assessfreq-period-container');
refreshElement.addEventListener('click', refreshAction);
Expand All @@ -418,6 +477,13 @@ function(Ajax, Templates, Fragment, ZoomModal, Str, Notification) {
let upcommingZoom = document.getElementById('local-assessfreq-quiz-summary-upcomming-graph-zoom');
upcommingZoom.addEventListener('click', triggerZoomGraph);

// Set up behind and ahead quizzes event listeners.
let quizzesAheadElement = document.getElementById('local-assessfreq-quiz-student-table-hoursahead');
quizzesAheadElement.addEventListener('click', quizzesAheadSet);

let quizzesBehindElement = document.getElementById('local-assessfreq-quiz-student-table-hoursbehind');
quizzesBehindElement.addEventListener('click', quizzesBehindSet);

processDashboard();

};
Expand Down
Loading

0 comments on commit bb0779b

Please sign in to comment.