index.html
style.css script.js
This commit is contained in:
33
MainPage/ismail/index.html
Normal file
33
MainPage/ismail/index.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Mathematik Lernen</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h1>Mathematik Lernen</h1>
|
||||
|
||||
<div class="mode">
|
||||
<button onclick="setMode('addition')">Addition</button>
|
||||
<button onclick="setMode('subtraktion')">Subtraktion</button>
|
||||
<button onclick="setMode('multiplikation')">Multiplikation</button>
|
||||
</div>
|
||||
|
||||
<div class="question-box">
|
||||
<h2 id="question">Klicke auf eine Rechenart, um zu beginnen</h2>
|
||||
<input type="number" id="answer" placeholder="Deine Antwort">
|
||||
<button onclick="checkAnswer()">Überprüfen</button>
|
||||
<p id="result"></p>
|
||||
</div>
|
||||
|
||||
<div class="score">
|
||||
Punktzahl: <span id="score">0</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
52
MainPage/ismail/script.js
Normal file
52
MainPage/ismail/script.js
Normal file
@@ -0,0 +1,52 @@
|
||||
let num1, num2;
|
||||
let correctAnswer;
|
||||
let score = 0;
|
||||
let currentMode = "";
|
||||
|
||||
function setMode(mode) {
|
||||
currentMode = mode;
|
||||
generateQuestion();
|
||||
}
|
||||
|
||||
function generateQuestion() {
|
||||
num1 = Math.floor(Math.random() * 10);
|
||||
num2 = Math.floor(Math.random() * 10);
|
||||
|
||||
if (currentMode === "addition") {
|
||||
correctAnswer = num1 + num2;
|
||||
document.getElementById("question").textContent =
|
||||
`${num1} + ${num2} = ?`;
|
||||
}
|
||||
|
||||
if (currentMode === "subtraktion") {
|
||||
correctAnswer = num1 - num2;
|
||||
document.getElementById("question").textContent =
|
||||
`${num1} - ${num2} = ?`;
|
||||
}
|
||||
|
||||
if (currentMode === "multiplikation") {
|
||||
correctAnswer = num1 * num2;
|
||||
document.getElementById("question").textContent =
|
||||
`${num1} × ${num2} = ?`;
|
||||
}
|
||||
|
||||
document.getElementById("answer").value = "";
|
||||
}
|
||||
|
||||
function checkAnswer() {
|
||||
let userAnswer = Number(document.getElementById("answer").value);
|
||||
let resultText = document.getElementById("result");
|
||||
|
||||
if (userAnswer === correctAnswer) {
|
||||
resultText.textContent =
|
||||
"✅ Richtig! Sehr gut! Die Antwort ist " + correctAnswer;
|
||||
score++;
|
||||
document.getElementById("score").textContent = score;
|
||||
} else {
|
||||
resultText.textContent =
|
||||
"❌ Falsch! Die richtige Antwort ist " + correctAnswer;
|
||||
}
|
||||
|
||||
// 2 Sekunden warten, dann neue Frage
|
||||
setTimeout(generateQuestion, 2000);
|
||||
}
|
||||
47
MainPage/ismail/style.css
Normal file
47
MainPage/ismail/style.css
Normal file
@@ -0,0 +1,47 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f0f8ff;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
margin: 5px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #45a049;
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 10px;
|
||||
font-size: 16px;
|
||||
width: 150px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.question-box {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.score {
|
||||
margin-top: 20px;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
Reference in New Issue
Block a user