Update Compass QoL Enhancer to 1.25.0

- Show learning tasks' general and grades visibility
This commit is contained in:
blankie 2024-02-05 23:25:36 +11:00
parent e14623ba5d
commit 4aec87e0eb
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 25 additions and 4 deletions

View File

@ -2,7 +2,7 @@
// @name Compass QoL Enhancer // @name Compass QoL Enhancer
// @namespace blankie-scripts // @namespace blankie-scripts
// @match http*://*.compass.education/* // @match http*://*.compass.education/*
// @version 1.24.5 // @version 1.25.0
// @author blankie // @author blankie
// @description A userscript that adds small but useful features for Compass, such as the ability to close windows by clicking on the background // @description A userscript that adds small but useful features for Compass, such as the ability to close windows by clicking on the background
// @inject-into page // @inject-into page
@ -156,15 +156,15 @@ if (NewsfeedAlertItemWidget) {
}; };
} }
// Automatically open learning tasks specified in the URL
let LearningTasksDetailsWidgetNew = getExtClass("Compass.widgets.LearningTasksDetailsWidgetNew"); let LearningTasksDetailsWidgetNew = getExtClass("Compass.widgets.LearningTasksDetailsWidgetNew");
if (LearningTasksDetailsWidgetNew) { if (LearningTasksDetailsWidgetNew) {
let original = LearningTasksDetailsWidgetNew.prototype.forceOpenLearningTaskOnLoad; // Automatically open learning tasks specified in the URL
let originalFOLTOL = LearningTasksDetailsWidgetNew.prototype.forceOpenLearningTaskOnLoad;
LearningTasksDetailsWidgetNew.prototype.forceOpenLearningTaskOnLoad = function() { LearningTasksDetailsWidgetNew.prototype.forceOpenLearningTaskOnLoad = function() {
// stole this from the function above // stole this from the function above
let toOpen = this.initialLoadComplete && !this.firstLoad; let toOpen = this.initialLoadComplete && !this.firstLoad;
let exit = !toOpen || this.openLearningTaskId || qolLearningTaskOpened; let exit = !toOpen || this.openLearningTaskId || qolLearningTaskOpened;
original.apply(this, arguments); originalFOLTOL.apply(this, arguments);
if (exit) { if (exit) {
return; return;
} }
@ -183,6 +183,26 @@ if (LearningTasksDetailsWidgetNew) {
} }
this.launchLearningTasksSubmissionWidget(learningTaskRecord.data.gridRecordId, false); this.launchLearningTasksSubmissionWidget(learningTaskRecord.data.gridRecordId, false);
}; };
// Show "Grades" and "Task" visibility for learning tasks
let originalCreateBasicTaskGrid = LearningTasksDetailsWidgetNew.prototype.createBasicTaskGrid;
LearningTasksDetailsWidgetNew.prototype.createBasicTaskGrid = function() {
let widget = this;
let taskGrid = originalCreateBasicTaskGrid.apply(this, arguments);
let originalRenderer = taskGrid.columns[0].renderer;
taskGrid.columns[0].renderer = function() {
let isStudentView = widget.isStudentView;
let isStudentOrParent = widget.isStudentOrParent;
widget.isStudentView = widget.isStudentOrParent = false;
let ret = originalRenderer.apply(this, arguments);
widget.isStudentView = isStudentView;
widget.isStudentOrParent = isStudentOrParent;
return ret;
};
return taskGrid;
}
} }
// Automatically add (and remove) the currently open learning task to the URL // Automatically add (and remove) the currently open learning task to the URL

View File

@ -49,6 +49,7 @@ A userscript that adds small but useful features for Compass. Features are:
everything else everything else
- Learning tasks now being links (you can ctrl-click them) - Learning tasks now being links (you can ctrl-click them)
- Opening a learning task will automatically add its ID to the URL - Opening a learning task will automatically add its ID to the URL
- Learning tasks' grades and general visibility are now shown
- The previous/next buttons and sessions dropdown are now links (you can now - The previous/next buttons and sessions dropdown are now links (you can now
use [Link Hints] and ctrl-click to open them) use [Link Hints] and ctrl-click to open them)
- Class and news feed items can now be opened by simply clicking on their - Class and news feed items can now be opened by simply clicking on their