-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2350 from 1911aditi/master
added an extension for quick math quiz
- Loading branch information
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Quick Math Quiz", | ||
"version": "1.0", | ||
"description": "A quick math quiz to test your skills!", | ||
"action": { | ||
"default_popup": "popup.html" | ||
}, | ||
"permissions": [] | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
text-align: center; | ||
background-color: #f0f0f0; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#quiz { | ||
margin: 20px auto; | ||
} | ||
|
||
h1 { | ||
color: #333; | ||
} | ||
|
||
input, button { | ||
padding: 10px; | ||
margin: 10px; | ||
font-size: 16px; | ||
} | ||
|
||
#feedback { | ||
margin-top: 10px; | ||
font-weight: bold; | ||
} | ||
|
||
#score { | ||
font-size: 20px; | ||
font-weight: bold; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Quick Math Quiz</title> | ||
<link rel="stylesheet" href="popup.css"> | ||
</head> | ||
<body> | ||
<div id="quiz"> | ||
<h1>Quick Math Quiz</h1> | ||
<p id="question">Question will appear here</p> | ||
<input type="number" id="answer" placeholder="Your answer"> | ||
<button id="submit">Submit</button> | ||
<p id="feedback"></p> | ||
<p>Score: <span id="score">0</span></p> | ||
</div> | ||
<script src="popup.js"></script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const questionElement = document.getElementById('question'); | ||
const answerInput = document.getElementById('answer'); | ||
const submitButton = document.getElementById('submit'); | ||
const feedbackElement = document.getElementById('feedback'); | ||
const scoreElement = document.getElementById('score'); | ||
|
||
let score = 0; | ||
let currentQuestion = {}; | ||
|
||
function generateQuestion() { | ||
const num1 = Math.floor(Math.random() * 10) + 1; | ||
const num2 = Math.floor(Math.random() * 10) + 1; | ||
currentQuestion = { | ||
question: `${num1} + ${num2}`, | ||
answer: num1 + num2 | ||
}; | ||
questionElement.textContent = currentQuestion.question; | ||
answerInput.value = ''; | ||
feedbackElement.textContent = ''; | ||
} | ||
|
||
submitButton.addEventListener('click', function() { | ||
const userAnswer = parseInt(answerInput.value, 10); | ||
if (userAnswer === currentQuestion.answer) { | ||
feedbackElement.textContent = 'Correct!'; | ||
score++; | ||
} else { | ||
feedbackElement.textContent = 'Wrong. Try again!'; | ||
} | ||
scoreElement.textContent = score; | ||
generateQuestion(); | ||
}); | ||
|
||
generateQuestion(); | ||
}); | ||
|