Created
September 28, 2021 13:40
-
-
Save emilfolino/1e3e58fcfd3c3167aafc81be52c4b102 to your computer and use it in GitHub Desktop.
Andra inlämningar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const pathname = window.location.pathname; | |
const queryString = window.location.search; | |
const courseID = pathname.split("/")[2]; | |
const studentMatch = /student_id=(\d+)/i; | |
const studentID = queryString.match(studentMatch)[1]; | |
const canvasAuth = "Bearer [ERSÄTT MED egen token]"; | |
const canvasURL = `https://bth.instructure.com/api/v1/courses/${courseID}/assignments`; | |
let box = document.createElement("div"); | |
box.style = "position:absolute;top:50px;right:10px;background-color:#2C3539;color:#fff;padding:10px;"; | |
const nextStudent = document.getElementById("next-student-button"); | |
nextStudent.addEventListener("click", function() { | |
console.log("click"); | |
box.remove(); | |
}); | |
fetch(canvasURL, { | |
headers: { | |
"Authorization": canvasAuth | |
} | |
}) | |
.then(function(response) { | |
return response.json(); | |
}) | |
.then(function(result) { | |
renderBox(result); | |
}); | |
function renderBox(assignments) { | |
assignments.forEach(function(assignment) { | |
let assignmentElement = document.createElement("p"); | |
let link = document.createElement("a"); | |
link.textContent = assignment.name; | |
link.href = `https://bth.instructure.com/courses/${courseID}/gradebook/speed_grader?assignment_id=${assignment.id}&student_id=${studentID}`; | |
link.target = "_blank"; | |
assignmentElement.appendChild(link); | |
box.appendChild(assignmentElement); | |
}); | |
document.body.appendChild(box); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
För att skaffa egen Token gå till https://bth.instructure.com/profile/settings och tryck ny åtkomst token enligt bilden nedan:
Lägg sedan ersätt [ERSÄTT MED egen token] ovan med din token. Ersätt även [ ].
Kopiera sedan koden och lägg den som ett bokmärke med javascript: framför i till exempel Firefox eller Chrome enligt nedan bild:
Det ska nu gå att trycka på knappen och få upp en lista med länkar till alla uppgifter studenten har i kursen.