Update Compass QoL Enhancer to 1.27.0

- Make files submitted to learning tasks also links
This commit is contained in:
blankie 2024-02-26 15:00:14 +11:00
parent 25e4f6e593
commit 32711ae01e
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 15 additions and 6 deletions

View File

@ -2,7 +2,7 @@
// @name Compass QoL Enhancer
// @namespace blankie-scripts
// @match http*://*.compass.education/*
// @version 1.26.0
// @version 1.27.0
// @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
// @inject-into page
@ -547,19 +547,28 @@ function handleLearningTasksTable(element) {
}
}
// Make links submitted to a learning task actual links
// Make files and links submitted to a learning task actual links
function handleLearningTaskSubmissionTable(element) {
let LearningTasksSubmissionFileType = unsafeWindow.Compass.enums.LearningTasksSubmissionFileType;
let taskId = unsafeWindow.Ext.getCmp(element.closest(".x-window").id).learningTask.data.id;
let items = unsafeWindow.Ext.getCmp(element.id).store.data.items;
let lastColumns = element.querySelectorAll(".x-grid-cell-last img");
for (let i = 0; i < items.length; i++) {
let item = items[i].data;
let img = lastColumns[i];
if (item.submissionFileType !== unsafeWindow.Compass.enums.LearningTasksSubmissionFileType.SubmissionUrl) {
let url;
if (item.submissionFileType === LearningTasksSubmissionFileType.File) {
url = `/Services/FileDownload/FileRequestHandler?FileDownloadType=2&taskId=${taskId}&submissionId=${item.id}`;
} else if (item.submissionFileType === LearningTasksSubmissionFileType.SubmissionUrl) {
url = item.fileName;
} else {
continue;
}
let a = document.createElement("a");
a.href = item.fileName;
a.href = url;
a.addEventListener("click", function(event) {
event.stopImmediatePropagation();
}, {passive: true});

View File

@ -43,8 +43,8 @@ A userscript that adds small but useful features for Compass. Features are:
- Fix submitting links by simply pressing Enter
- Links inside lesson plans now open in the parent tab by default instead of
creating a new tab
- Links submitted to learning tasks are now actual links (they now work with
[Link Hints] and they can be ctrl-clicked)
- Files and links submitted to learning tasks are now actual links (they now
work with [Link Hints] and they can be ctrl-clicked)
- Ctrl-clicking an activity in a user's learning tasks tab no longer collapses
everything else
- Learning tasks now being links (you can ctrl-click them)