feat: add function to navigate to course by ID

Introduce goToCourse function that updates the window location
to navigate to a course view page using a given ID. This function
is now accessible via window.top as goToCourse, improving navigation
throughout the application and promoting code reuse.
This commit is contained in:
Kumi 2024-09-23 08:50:58 +02:00
parent 17e8bc0c18
commit 110ac67686
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -178,12 +178,17 @@
} }
} }
function goToCourse(id) {
window.top.location.href = "/course/view.php?id=" + id;
}
// Attach global functions to window.top // Attach global functions to window.top
window.top.nextContent = nextContent; window.top.nextContent = nextContent;
window.top.openQuizModal = openQuizModal; window.top.openQuizModal = openQuizModal;
window.top.openModal = openQuizModal; window.top.openModal = openQuizModal;
window.top.closeQuizModal = closeQuizModal; window.top.closeQuizModal = closeQuizModal;
window.top.goToQuiz = window.top.nextContent; window.top.goToQuiz = window.top.nextContent;
window.top.goToCourse = goToCourse;
var contentName = $(currentScript).attr("data-activity-name"); var contentName = $(currentScript).attr("data-activity-name");