Skip to content

Commit

Permalink
Merge pull request #4772 from KapuluruBhuvaneswariVspdbct/main
Browse files Browse the repository at this point in the history
solved #4771 added quiz to swap reads
  • Loading branch information
sailaja-adapa authored Nov 8, 2024
2 parents 1443a7e + 5de3445 commit 40b93bd
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
│ │ ├── mood.html
│ │ ├── mylogin.html
│ │ ├── mythology.html
│ │ ├── nectar.html
│ │ ├── ngo.html
│ │ ├── noir.html
│ │ ├── nonfiction.html
Expand Down
152 changes: 152 additions & 0 deletions assets/html/nectar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nectar in a Sieve 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 */
}
</style>
</head>
<body>

<div class="quiz-container">
<h1>Nectar in a Sieve 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='index.html';">Return to Home</button>
</div>

<script>
const quizData = [
{
question: "Who is the protagonist of 'Nectar in a Sieve'?",
options: ["Rukmani", "Ira", "Puli", "Kundumani"],
answer: "Rukmani"
},
{
question: "What is the primary occupation of Rukmani's husband, Nathan?",
options: ["Farmer", "Trader", "Blacksmith", "Teacher"],
answer: "Farmer"
},
{
question: "Which major event disrupts the life of Rukmani and her family?",
options: ["The arrival of the tannery", "A natural disaster", "A war", "A famine"],
answer: "The arrival of the tannery"
},
{
question: "What is the name of Rukmani's first child?",
options: ["Ira", "Kundumani", "Arjun", "Murugan"],
answer: "Arjun"
},
{
question: "Which of the following themes is central to the novel?",
options: ["Love and sacrifice", "Industrialization and its impact on rural life", "War and conflict", "The effects of colonialism"],
answer: "Industrialization and its impact on rural life"
}
];

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>
28 changes: 18 additions & 10 deletions assets/html/quizzes.html
Original file line number Diff line number Diff line change
Expand Up @@ -1312,17 +1312,25 @@ <h4>Quiz Questions:</h4>
</div>
</div>

<div class="card" onclick="this.classList.toggle('flip')">
<div class="card-inner">
<div class="card-front nectar"><h1>Nectar in a Sieve</h1></div>
<div class="card-back">
<h3>Author: Kamala Markandaya</h3>
<button onclick="startQuiz(event, this)">Start Quiz</button>
<div class="quiz" style="display: none;">Quiz coming soon!</div>
</div>

<div class="card" onclick="this.classList.toggle('flip')">
<div class="card-inner">
<div class="card-front nectar">
<h1>Nectar in a sieve</h1>
</div>
</div>

<div class="card-back">
<button onclick="window.location.href='nectar.html';">Start Quiz</button>
<div class="quiz" style="display: none;">
<h4>Quiz Questions:</h4>
<div id="quiz-questions">
<!-- Questions will be inserted here -->
</div>
<button onclick="submitQuiz("#nectar.html")">Submit</button>
<div id="quiz-result" style="display: none;"></div>
</div>
</div>
</div>
</div>
<div class="card" onclick="this.classList.toggle('flip')">
<div class="card-inner">
<div class="card-front un"><h1>Untouchable</h1></div>
Expand Down
1 change: 1 addition & 0 deletions repo_structure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
│ │ ├── mood.html
│ │ ├── mylogin.html
│ │ ├── mythology.html
│ │ ├── nectar.html
│ │ ├── ngo.html
│ │ ├── noir.html
│ │ ├── nonfiction.html
Expand Down

0 comments on commit 40b93bd

Please sign in to comment.