diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index 866502f..c73860e 100644 --- a/Compass QoL Enhancer.user.js +++ b/Compass QoL Enhancer.user.js @@ -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}); diff --git a/README.md b/README.md index f05f5aa..3848bde 100644 --- a/README.md +++ b/README.md @@ -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)