From 96eb6fe00126f0946a7fa952c267ffc8ddb03fe8 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 1 May 2026 14:38:22 +0200 Subject: generalize loading of Online-IDE logins Find the Online-IDE Logins from the course index. --- Info/9/3/Planet/modellierung/landung/online-ide.md | 54 +++++++++++++++------- 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'Info') diff --git a/Info/9/3/Planet/modellierung/landung/online-ide.md b/Info/9/3/Planet/modellierung/landung/online-ide.md index e94e77fa..f98c74cf 100644 --- a/Info/9/3/Planet/modellierung/landung/online-ide.md +++ b/Info/9/3/Planet/modellierung/landung/online-ide.md @@ -14,28 +14,48 @@ include-after: | console.error('Error fetching JSON:', error); } } + + const findInMenu = (selector, keywords) => { + // Sucht in allen Links der Seite nach den Modulen + const links = Array.from(document.querySelectorAll(`a[href*="${selector}"]`)); + const match = links.find(a => keywords.some(k => a.innerText.toLowerCase().includes(k.toLowerCase()))); + return match ? match.href : (links.length > 0 ? links[0].href : null); + }; // Get the user's firstname via the moodle generico filter const firstname = "{firstname}"; const lastname = "{lastname}"; - - const resource = 90441121; - // Moodle some insists in wrapping urls in tags breaking the JS code. - // We use a base64 encoding for the url: https://lernplattform.bycs.de/mod/resource/view.php?id= - const resourceUrl = "aHR0cHM6Ly9sZXJucGxhdHRmb3JtLmJ5Y3MuZGUvbW9kL3Jlc291cmNlL3ZpZXcucGhwP2lkPQo="; - const url = window.atob(resourceUrl) + resource; - - fetchJson(url).then((logins) => { - if (logins) { - for (const user of logins) { - if (!(user.Name.includes("{firstname}") && user.Name.includes("{lastname}"))) - continue; - - let loginDiv = document.querySelector(".oide-login"); - loginDiv.innerHTML = `Benutzername: ${user.Benutzername}
Passwort: ${user.Passwort}`; + let loginsUrl = null; + + function fetchLogin() { + fetchJson(loginsUrl).then((logins) => { + if (logins) { + for (const user of logins) { + if (!(user.Name.includes("{firstname}") && user.Name.includes("{lastname}"))) + continue; + + let loginDiv = document.querySelector(".oide-login"); + loginDiv.innerHTML = `Benutzername: ${user.Benutzername}
Passwort: ${user.Passwort}`; + } } + }); + } + + const sleep = ms => new Promise(r => setTimeout(r, ms)); + async function updateLogin() { + for(let i = 0; i < 10; i++) { + loginsUrl = findInMenu("/mod/resource/", ["Online-IDE Logins"]); + if (loginsUrl) { + fetchLogin(); + break; + } + await sleep(500); } - }); + } + + window.addEventListener('load', function() { + updateLogin(); + }) --- @@ -50,6 +70,8 @@ Rufe die Seite auf und melde dich an. Die YASA hat dir einen Zugang für die Online-IDE angelegt. ::::{.oide-login} +Benutzername: UNBEKANNT +Passwort: BITTE_FRAG_NACH :::: Bitte ändere dein Passwort per Klick auf die kleine Figur neben deinem Namen im Controls-Fenster und notiere dir deine Login-Informationen! -- cgit v1.2.3