diff --git a/MainPage/stas/WoerterLernen.html b/MainPage/stas/WoerterLernen.html index b1b6fce..fbef0e3 100644 --- a/MainPage/stas/WoerterLernen.html +++ b/MainPage/stas/WoerterLernen.html @@ -58,15 +58,22 @@
-

Wählt einen Schwierigkeitsgrad:

- - - +

Wählt eine Trainingsart:

+ +
+ + + + + +
-
-
-
+ + + + +
diff --git a/MainPage/stas/eigenerCode.js b/MainPage/stas/eigenerCode.js index 5f062d1..5c1618f 100644 --- a/MainPage/stas/eigenerCode.js +++ b/MainPage/stas/eigenerCode.js @@ -231,7 +231,7 @@ function zeigeNaechsteKarte() { // Rendert eine einzelne Karte im leichten Modus. function renderLeichtKarte(karte) { - const container = document.getElementById("trainingLeicht"); + const container = document.getElementById("trainingFlip"); container.innerHTML = ""; const cardEl = document.createElement("div"); @@ -307,7 +307,7 @@ function ladeMittelRunde() { // Rendert das Matching-Layout für den mittleren Modus. function renderMittelMatching() { - const container = document.getElementById("trainingMittel"); + const container = document.getElementById("trainingMatching"); container.innerHTML = ""; const links = document.createElement("div"); @@ -450,16 +450,49 @@ function beendeMittelRunde() { // Tauscht zwei Ziehkarten anhand ihrer Indizes function swapZiehKarten(index1, index2) { - - const temp = trainingsZustand.ziehKarten[index1]; - trainingsZustand.ziehKarten[index1] = - trainingsZustand.ziehKarten[index2]; - trainingsZustand.ziehKarten[index2] = temp; + [trainingsZustand.ziehKarten[index1], trainingsZustand.ziehKarten[index2]] = + [trainingsZustand.ziehKarten[index2], trainingsZustand.ziehKarten[index1]]; const container = document.querySelector(".spalte-rechts"); - const cards = container.children; + container.innerHTML = ""; - container.insertBefore(cards[index2], cards[index1]); + trainingsZustand.ziehKarten.forEach((karte, idx) => { + const ziehKarte = document.createElement("div"); + ziehKarte.className = "training-card zieh-karte"; + ziehKarte.draggable = true; + ziehKarte.dataset.index = idx; + + if (trainingsZustand.richtung === "EN_DE") { + ziehKarte.innerHTML = ` +
+

${karte.deutsch}

+
${karte.beispielDE}
+
+ `; + } else { + ziehKarte.innerHTML = ` +
+

${karte.englisch}

+
${karte.ipa}
+
${karte.beispielEN}
+
+ `; + } + + ziehKarte.addEventListener("dragstart", e => { + e.dataTransfer.setData("draggedIndex", idx); + }); + + ziehKarte.addEventListener("dragover", e => e.preventDefault()); + + ziehKarte.addEventListener("drop", e => { + e.preventDefault(); + const draggedIndex = Number(e.dataTransfer.getData("draggedIndex")); + swapZiehKarten(draggedIndex, idx); + }); + + container.appendChild(ziehKarte); + }); } // Blendet alle Trainingslevel-Ansichten aus @@ -472,37 +505,260 @@ function showMode(id) { } function showLevel(id) { - document.getElementById("trainingLeicht").classList.add("hidden"); - document.getElementById("trainingMittel").classList.add("hidden"); - document.getElementById("trainingSchwer").classList.add("hidden"); + document.querySelectorAll("#onlineTraining .training-view").forEach(view => { + if (view.id !== "trainingLevels") { + view.classList.add("hidden"); + } + }); document.getElementById(id).classList.remove("hidden"); } document.querySelectorAll(".level-btn").forEach(btn => { btn.addEventListener("click", () => { - const level = btn.dataset.level; - console.log("Level ausgewähl:", level); + const type = btn.dataset.level; + console.log("Trainingsart:", type); - if (level === "leicht") { - showLevel("trainingLeicht"); + if (type === "flip") { + showLevel("trainingFlip"); startLeichtTraining(); - document.getElementById("checkBtn").style.display = "none"; } - if (level === "mittel") { - showLevel("trainingMittel"); + if (type === "matching") { + showLevel("trainingMatching"); startMittelTraining(); - document.getElementById("checkBtn").style.display = "block"; } - if (level === "schwer") { - showLevel("trainingSchwer"); - startSchwerTraining(); + if (type === "multiple") { + showLevel("trainingMultiple"); + startMultipleTraining(); + document.getElementById("checkBtn").style.display = "none"; + } + if (type === "hint") { + showLevel("trainingHint"); + startHintTraining(); + document.getElementById("checkBtn").style.display = "none"; + } + + if (type === "write") { + showLevel("trainingWrite"); + startWriteTraining(); document.getElementById("checkBtn").style.display = "none"; } }); }); + +function startMultipleTraining() { + trainingsZustand.modus = "multiple"; + trainingsZustand.quelleKarten = mischeArray([...parsedArray]); + trainingsZustand.aktuelleKarte = null; + trainingsZustand.gelernt = []; + trainingsZustand.nichtGelernt = []; + + zeigeNaechsteMultipleKarte(); +} + +function generiereMultipleOptionen(karte) { + const optionen = [karte.deutsch]; + + const falscheOptionen = parsedArray + .filter(k => k.id !== karte.id) + .map(k => k.deutsch); + + mischeArray(falscheOptionen); + + optionen.push(...falscheOptionen.slice(0, 4)); + + return mischeArray(optionen); +} + +function generiereHint(deutsch) { + const chars = deutsch.split(''); + const anzahlZuVerstecken = Math.floor(chars.length / 2); + + const indices = Array.from(chars.keys()); + mischeArray(indices); + + for (let i = 0; i < anzahlZuVerstecken; i++) { + chars[indices[i]] = '*'; + } + + return chars.join(''); +} + + +function zeigeNaechsteMultipleKarte() { + if (trainingsZustand.quelleKarten.length === 0) { + alert(`Training beendet! +Gelernt: ${trainingsZustand.gelernt.length} +Nicht gelernt: ${trainingsZustand.nichtGelernt.length}`); + return; + } + + const karte = trainingsZustand.quelleKarten.shift(); + trainingsZustand.aktuelleKarte = karte; + + const container = document.getElementById("trainingMultiple"); + container.innerHTML = ""; + + const frage = document.createElement("div"); + frage.className = "multiple-frage"; + frage.innerHTML = `

${karte.englisch}

`; + container.appendChild(frage); + + const optionen = generiereMultipleOptionen(karte); + const optionContainer = document.createElement("div"); + optionContainer.className = "multiple-optionen"; + + optionen.forEach(text => { + const btn = document.createElement("button"); + btn.className = "multiple-option"; + btn.innerText = text; + + btn.onclick = () => { + if (text === karte.deutsch) { + trainingsZustand.gelernt.push(karte); + zeigeNaechsteMultipleKarte(); + } else { + btn.style.textDecoration = "line-through"; + btn.disabled = true; + } + }; + + optionContainer.appendChild(btn); + }); + + container.appendChild(optionContainer); +} + +trainingsZustand.hintCards = []; + +function startHintTraining() { + trainingsZustand.modus = "hint"; + trainingsZustand.hintCards = mischeArray([...parsedArray]); + zeigeNaechsteHintKarte(); +} + +function zeigeNaechsteHintKarte() { + if (trainingsZustand.hintCards.length === 0) { + alert(`Training beendet! + Gelernt: ${trainingsZustand.gelernt.length} + Nicht gelernt: ${trainingsZustand.nichtGelernt.length}`); + return; + } + + const karte = trainingsZustand.hintCards.shift(); + trainingsZustand.aktuelleKarte = karte; + + const container = document.getElementById("trainingHint"); + container.innerHTML = ""; + + const frage = document.createElement("div"); + frage.className = "hint-frage"; + frage.innerHTML = `

${karte.englisch}

`; + container.appendChild(frage); + + const clue = document.createElement("div"); + clue.className = "hint-clue"; + clue.innerText = generiereHint(karte.deutsch); + container.appendChild(clue); + + const input = document.createElement("input"); + input.className = "hint-input"; + input.placeholder = "Schreibe die Übersetzung hier..."; + container.appendChild(input); + + const button = document.createElement("button"); + button.className = "hint-button"; + button.innerText = "Überprüfen"; + container.appendChild(button); + + const feedback = document.createElement("div"); + feedback.className = "hint-feedback"; + container.appendChild(feedback); + + button.onclick = () => { + const answer = input.value.trim(); + if (answer.toLowerCase() === karte.deutsch.toLowerCase()) { + feedback.innerText = "✅ Richtig!"; + trainingsZustand.gelernt.push(karte); + setTimeout(() => zeigeNaechsteHintKarte(), 800); + } else { + feedback.innerText = `❌ Falsch! Richtige Antwort: ${karte.deutsch}`; + trainingsZustand.nichtGelernt.push(karte); + setTimeout(() => zeigeNaechsteHintKarte(), 1200); + } + }; +} + +function startWriteTraining() { + trainingsZustand.modus = "write"; + trainingsZustand.quelleKarten = mischeArray([...parsedArray]); + trainingsZustand.aktuelleKarte = null; + trainingsZustand.gelernt = []; + trainingsZustand.nichtGelernt = []; + + zeigeNaechsteWriteKarte(); +} + +function zeigeNaechsteWriteKarte() { + if (trainingsZustand.quelleKarten.length === 0) { + const container = document.getElementById("trainingWrite"); + container.innerHTML = ` +
+ Training beendet!
+ Gelernt: ${trainingsZustand.gelernt.length}
+ Nicht gelernt: ${trainingsZustand.nichtGelernt.length} +
+ `; + return; + } + + const karte = trainingsZustand.quelleKarten.shift(); + trainingsZustand.aktuelleKarte = karte; + + const container = document.getElementById("trainingWrite"); + container.innerHTML = ""; + + const frage = document.createElement("div"); + frage.className = "schwer-frage"; + frage.innerHTML = `

${karte.englisch}

`; + container.appendChild(frage); + + const input = document.createElement("input"); + input.type = "text"; + input.placeholder = "Schreibe die Übersetzung hier..."; + input.style.fontSize = "18px"; + input.style.width = "300px"; + input.style.padding = "8px"; + container.appendChild(input); + + const submitBtn = document.createElement("button"); + submitBtn.innerText = "Überprüfen"; + submitBtn.style.marginTop = "10px"; + submitBtn.onclick = () => { + const answer = input.value.trim(); + const resultDiv = document.createElement("div"); + resultDiv.style.marginTop = "12px"; + resultDiv.style.fontWeight = "600"; + + if (answer.toLowerCase() === karte.deutsch.toLowerCase()) { + trainingsZustand.gelernt.push(karte); + resultDiv.style.color = "#28a745"; + resultDiv.innerText = "Richtig!"; + } else { + trainingsZustand.nichtGelernt.push(karte); + resultDiv.style.color = "#dc3545"; + resultDiv.innerText = `Falsch! Richtige Antwort: ${karte.deutsch}`; + } + + container.appendChild(resultDiv); + + setTimeout(() => zeigeNaechsteWriteKarte(), 2000); + }; + + container.appendChild(submitBtn); +} diff --git a/MainPage/stas/style.css b/MainPage/stas/style.css index 9ec44ed..1c2c5ab 100644 --- a/MainPage/stas/style.css +++ b/MainPage/stas/style.css @@ -288,11 +288,11 @@ h1 { cursor: pointer; } -#trainingLeicht .training-card { +#trainingFlip .training-card { height: 180px; } -#trainingMittel .training-card { +#trainingMatching .training-card { height: 100px; font-size: 0.9rem; margin: 0; @@ -367,13 +367,11 @@ h1 { } #pdfPages, -#onlineTraining, -#trainingMittel, -#trainingSchwer { +#onlineTraining { display: none; } -#trainingMittel { +#trainingMatching { display: flex; justify-content: center; gap: 10px; @@ -425,3 +423,172 @@ h1 { background-repeat: repeat; background-size: 80px; } + +#trainingMultiple { + display: flex; + flex-direction: column; + align-items: center; + justify-content: flex-start; + gap: 20px; + margin-top: 30px; +} + +.multiple-frage { + text-align: center; + font-size: 28px; + font-weight: bold; +} + +.multiple-optionen { + display: flex; + flex-direction: column; + gap: 10px; + width: 300px; +} + +.multiple-option { + padding: 10px 15px; + font-size: 16px; + cursor: pointer; + border: 1px solid #ccc; + border-radius: 5px; + background-color: #f0f0f0; + text-align: center; + transition: background-color 0.2s, transform 0.1s; +} + +.multiple-option:hover { + background-color: #e0e0e0; + transform: scale(1.03); +} + +.multiple-option[disabled] { + text-decoration: line-through; + background-color: #f5a8a8; + color: #800; +} + +#trainingHint { + display: flex; + flex-direction: column; + align-items: center; + gap: 20px; + margin-top: 30px; +} + +.hint-frage { + text-align: center; + font-size: 28px; + font-weight: bold; +} + +.hint-input { + width: 300px; + font-size: 18px; + padding: 10px; + text-align: center; + border-radius: 6px; +} + +.hint-button { + padding: 10px 15px; + font-size: 16px; + cursor: pointer; + border-radius: 6px; + border: none; + background-color: #005b5b; + color: white; + transition: 0.2s; +} + +.hint-button:hover { + background-color: #007070; +} + +.hint-feedback { + font-size: 16px; + font-weight: 600; + margin-top: 10px; +} + +.hint-clue { + font-size: 20px; + letter-spacing: 2px; + margin-bottom: 10px; + color: #555; + text-align: center; + font-family: monospace; +} + +#trainingWrite { + display: flex; + flex-direction: column; + align-items: center; + justify-content: flex-start; + gap: 20px; + margin-top: 30px; +} + +#trainingWrite .schwer-frage { + text-align: center; + font-size: 28px; + font-weight: bold; +} + +#trainingWrite input[type="text"] { + font-size: 18px; + border-radius: 6px; +} + +#trainingWrite button { + padding: 10px 15px; + font-size: 16px; + cursor: pointer; + border-radius: 6px; + border: none; + background-color: #005b5b; + color: white; + transition: 0.2s; +} + +#trainingWrite button:hover { + background-color: #007070; +} + +#trainingLevels { + display: flex; + flex-direction: column; + gap: 15px; + width: 100%; +} + +.training-title { + margin: 0 0 10px 0; + font-size: 20px; + font-weight: 600; + text-align: left; +} + +#trainingLevels .buttons-row { + display: flex; + gap: 10px; + width: 100%; +} + +#trainingLevels .buttons-row .level-btn { + flex: 1; + padding: 12px 0; + font-size: 16px; + font-weight: 600; + border: none; + border-radius: 8px; + background-color: #f0f0f0; + cursor: pointer; + text-align: center; + transition: background-color 0.2s, transform 0.1s; +} + +#trainingLevels .buttons-row .level-btn:hover { + background-color: #e0e0e0; + transform: scale(1.02); +}