forked from anuragverma108/SwapReads
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67beb65
commit de12ad3
Showing
4 changed files
with
357 additions
and
1 deletion.
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,158 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>The Story of Experiments with Truth Quiz</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #ffd2d3; /* Changed to pink color */ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.quiz-container { | ||
background: white; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
width: 300px; | ||
text-align: center; | ||
} | ||
|
||
button { | ||
padding: 10px 20px; | ||
margin-top: 20px; | ||
cursor: pointer; | ||
background-color: #b00000; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
display: block; /* Make buttons block elements for vertical display */ | ||
width: 100%; /* Make buttons full width */ | ||
} | ||
|
||
button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
h4 { | ||
margin: 10px 0; | ||
} | ||
|
||
.option { | ||
margin: 5px 0; /* Space between options */ | ||
} | ||
|
||
.solution { | ||
margin-top: 10px; | ||
text-align: left; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<div class="quiz-container"> | ||
<h1>The Story of Experiments with Truth Quiz</h1> | ||
<div id="quiz-questions"> | ||
<!-- Questions will be inserted here --> | ||
</div> | ||
<button id="submit-button" onclick="submitQuiz()">Submit</button> | ||
<div id="quiz-result" style="display: none;"></div> | ||
<button id="home-button" style="display: none;" onclick="window.location.href='quizzes.html';">Return to Quizzes</button> | ||
</div> | ||
|
||
<script> | ||
const quizData = [ | ||
{ | ||
question: "What is the full title of the autobiography written by Mahatma Gandhi?", | ||
options: ["The Story of Experiments with Truth", "Truth and Non-Violence", "My Experiments with Truth", "Gandhi's Truth Journey"], | ||
answer: "The Story of Experiments with Truth" | ||
}, | ||
{ | ||
question: "Where was Mahatma Gandhi born?", | ||
options: ["Pune", "Delhi", "Porbandar", "Mumbai"], | ||
answer: "Porbandar" | ||
}, | ||
{ | ||
question: "What was the name of the movement led by Gandhi to end British rule in India?", | ||
options: ["Non-Cooperation Movement", "Salt March", "Quit India Movement", "Civil Disobedience Movement"], | ||
answer: "Non-Cooperation Movement" | ||
}, | ||
{ | ||
question: "What did Gandhi do to protest against the British Salt Tax?", | ||
options: ["Fast until death", "Salt March", "Non-violent protests", "Boycott British goods"], | ||
answer: "Salt March" | ||
}, | ||
{ | ||
question: "What principle did Gandhi adopt for his political and social work?", | ||
options: ["Satya (Truth)", "Ahimsa (Non-violence)", "Swaraj (Self-rule)", "All of the above"], | ||
answer: "All of the above" | ||
} | ||
]; | ||
|
||
let currentQuestionIndex = 0; | ||
let score = 0; | ||
|
||
function loadQuestion() { | ||
const questionElement = document.getElementById('quiz-questions'); | ||
questionElement.innerHTML = ''; | ||
|
||
const currentQuestion = quizData[currentQuestionIndex]; | ||
const questionText = document.createElement('h4'); | ||
questionText.innerText = currentQuestion.question; | ||
questionElement.appendChild(questionText); | ||
|
||
currentQuestion.options.forEach(option => { | ||
const optionButton = document.createElement('button'); | ||
optionButton.classList.add('option'); | ||
optionButton.innerText = option; | ||
optionButton.onclick = () => selectAnswer(option); | ||
questionElement.appendChild(optionButton); | ||
}); | ||
} | ||
|
||
function selectAnswer(selectedOption) { | ||
const currentQuestion = quizData[currentQuestionIndex]; | ||
if (selectedOption === currentQuestion.answer) { | ||
score++; | ||
} | ||
currentQuestionIndex++; | ||
|
||
if (currentQuestionIndex < quizData.length) { | ||
loadQuestion(); | ||
} else { | ||
showResult(); | ||
} | ||
} | ||
|
||
function showResult() { | ||
const quizContainer = document.querySelector('.quiz-container'); | ||
quizContainer.innerHTML = `<h2>Your Score: ${score}/${quizData.length}</h2>`; | ||
|
||
// Create the return home button | ||
const homeButton = document.createElement('button'); | ||
homeButton.onclick = () => window.location.href = 'quizzes.html'; | ||
homeButton.innerText = 'Return to Quizzes'; | ||
quizContainer.appendChild(homeButton); | ||
} | ||
|
||
function submitQuiz() { | ||
if (currentQuestionIndex < quizData.length) { | ||
alert("Please answer all questions before submitting!"); | ||
} else { | ||
showResult(); | ||
} | ||
} | ||
|
||
// Load the first question when the page is ready | ||
document.addEventListener('DOMContentLoaded', loadQuestion); | ||
</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,158 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Home and the World Quiz</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #ffd2d3; /* Changed to pink color */ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.quiz-container { | ||
background: white; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
width: 300px; | ||
text-align: center; | ||
} | ||
|
||
button { | ||
padding: 10px 20px; | ||
margin-top: 20px; | ||
cursor: pointer; | ||
background-color: #b00000; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
display: block; /* Make buttons block elements for vertical display */ | ||
width: 100%; /* Make buttons full width */ | ||
} | ||
|
||
button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
h4 { | ||
margin: 10px 0; | ||
} | ||
|
||
.option { | ||
margin: 5px 0; /* Space between options */ | ||
} | ||
|
||
.solution { | ||
margin-top: 10px; | ||
text-align: left; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<div class="quiz-container"> | ||
<h1>Home and the World Quiz</h1> | ||
<div id="quiz-questions"> | ||
<!-- Questions will be inserted here --> | ||
</div> | ||
<button id="submit-button" onclick="submitQuiz()">Submit</button> | ||
<div id="quiz-result" style="display: none;"></div> | ||
<button id="home-button" style="display: none;" onclick="window.location.href='quizzes.html';">Return to Quizzes</button> | ||
</div> | ||
|
||
<script> | ||
const quizData = [ | ||
{ | ||
question: "Who is the author of the book 'Home and the World'?", | ||
options: ["Rabindranath Tagore", "Mahatma Gandhi", "Sarojini Naidu", "Jawaharlal Nehru"], | ||
answer: "Rabindranath Tagore" | ||
}, | ||
{ | ||
question: "In 'Home and the World', what is the central theme of the novel?", | ||
options: ["Independence Movement", "Social Reforms", "Nationalism and Modernity", "Cultural Heritage"], | ||
answer: "Nationalism and Modernity" | ||
}, | ||
{ | ||
question: "Which character in 'Home and the World' is a symbol of traditional Indian values?", | ||
options: ["Bimala", "Nikhil", "Sandip", "Aunt"], | ||
answer: "Bimala" | ||
}, | ||
{ | ||
question: "What is the role of Nikhil in 'Home and the World'?", | ||
options: ["A nationalist leader", "Bimala's husband", "A freedom fighter", "A spiritual guide"], | ||
answer: "Bimala's husband" | ||
}, | ||
{ | ||
question: "In the novel, which character represents the modern, nationalist ideology?", | ||
options: ["Bimala", "Sandip", "Nikhil", "Aunt"], | ||
answer: "Sandip" | ||
} | ||
]; | ||
|
||
let currentQuestionIndex = 0; | ||
let score = 0; | ||
|
||
function loadQuestion() { | ||
const questionElement = document.getElementById('quiz-questions'); | ||
questionElement.innerHTML = ''; | ||
|
||
const currentQuestion = quizData[currentQuestionIndex]; | ||
const questionText = document.createElement('h4'); | ||
questionText.innerText = currentQuestion.question; | ||
questionElement.appendChild(questionText); | ||
|
||
currentQuestion.options.forEach(option => { | ||
const optionButton = document.createElement('button'); | ||
optionButton.classList.add('option'); | ||
optionButton.innerText = option; | ||
optionButton.onclick = () => selectAnswer(option); | ||
questionElement.appendChild(optionButton); | ||
}); | ||
} | ||
|
||
function selectAnswer(selectedOption) { | ||
const currentQuestion = quizData[currentQuestionIndex]; | ||
if (selectedOption === currentQuestion.answer) { | ||
score++; | ||
} | ||
currentQuestionIndex++; | ||
|
||
if (currentQuestionIndex < quizData.length) { | ||
loadQuestion(); | ||
} else { | ||
showResult(); | ||
} | ||
} | ||
|
||
function showResult() { | ||
const quizContainer = document.querySelector('.quiz-container'); | ||
quizContainer.innerHTML = `<h2>Your Score: ${score}/${quizData.length}</h2>`; | ||
|
||
// Create the return home button | ||
const homeButton = document.createElement('button'); | ||
homeButton.onclick = () => window.location.href = 'quizzes.html'; | ||
homeButton.innerText = 'Return to Quizzes'; | ||
quizContainer.appendChild(homeButton); | ||
} | ||
|
||
function submitQuiz() { | ||
if (currentQuestionIndex < quizData.length) { | ||
alert("Please answer all questions before submitting!"); | ||
} else { | ||
showResult(); | ||
} | ||
} | ||
|
||
// Load the first question when the page is ready | ||
document.addEventListener('DOMContentLoaded', loadQuestion); | ||
</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
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