deva / index.html
jai0123's picture
quiz game for why engineer day celebrate with student rugistration - Initial Deployment
40e70fd verified
Raw History Blame Contribute Delete
16.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Engineer's Day Quiz Challenge</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
.gradient-bg {
background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
}
.option:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
</style>
</head>
<body class="min-h-screen bg-gray-100">
<!-- Hero Section -->
<div id="hero" class="gradient-bg text-white py-20 px-4">
<div class="max-w-6xl mx-auto text-center">
<h1 class="text-4xl md:text-6xl font-bold mb-6" data-aos="fade-down">Engineer's Day Quiz Challenge</h1>
<p class="text-xl md:text-2xl mb-8" data-aos="fade-up" data-aos-delay="100">Test your knowledge about why we celebrate Engineer's Day!</p>
<button id="startQuizBtn" class="bg-white text-blue-600 font-bold py-3 px-8 rounded-full text-lg hover:bg-gray-100 transition-all pulse" data-aos="zoom-in" data-aos-delay="200">
Start Quiz Now
</button>
</div>
</div>
<!-- Registration Form (Hidden Initially) -->
<div id="registrationForm" class="hidden max-w-md mx-auto my-16 bg-white rounded-xl shadow-md overflow-hidden p-8" data-aos="fade-up">
<div class="text-center mb-8">
<h2 class="text-2xl font-bold text-gray-800">Student Registration</h2>
<p class="text-gray-600">Register to participate in the quiz</p>
</div>
<form id="registerForm">
<div class="mb-4">
<label class="block text-gray-700 text-sm font-bold mb-2" for="name">
Full Name
</label>
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="name" type="text" placeholder="Your name" required>
</div>
<div class="mb-4">
<label class="block text-gray-700 text-sm font-bold mb-2" for="email">
Email
</label>
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="email" type="email" placeholder="your@email.com" required>
</div>
<div class="mb-4">
<label class="block text-gray-700 text-sm font-bold mb-2" for="college">
College/University
</label>
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="college" type="text" placeholder="Institution name" required>
</div>
<div class="mb-6">
<label class="block text-gray-700 text-sm font-bold mb-2" for="department">
Engineering Department
</label>
<select class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="department" required>
<option value="">Select your department</option>
<option value="Computer">Computer Engineering</option>
<option value="Mechanical">Mechanical Engineering</option>
<option value="Electrical">Electrical Engineering</option>
<option value="Civil">Civil Engineering</option>
<option value="Electronics">Electronics Engineering</option>
<option value="Other">Other</option>
</select>
</div>
<div class="flex items-center justify-between">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full" type="submit">
Register & Start Quiz
</button>
</div>
</form>
</div>
<!-- Quiz Container (Hidden Initially) -->
<div id="quizContainer" class="hidden max-w-3xl mx-auto my-16 bg-white rounded-xl shadow-md overflow-hidden p-8">
<div class="flex justify-between items-center mb-8">
<div class="text-lg font-semibold text-gray-700">Question <span id="currentQuestion">1</span>/10</div>
<div class="text-lg font-semibold text-gray-700">Score: <span id="score">0</span></div>
</div>
<div id="question" class="text-xl font-bold mb-8 text-gray-800"></div>
<div id="options" class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-8">
<!-- Options will be inserted here by JavaScript -->
</div>
<div class="flex justify-between">
<button id="prevBtn" class="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded hidden">
Previous
</button>
<button id="nextBtn" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Next
</button>
</div>
</div>
<!-- Results Container (Hidden Initially) -->
<div id="resultsContainer" class="hidden max-w-md mx-auto my-16 bg-white rounded-xl shadow-md overflow-hidden p-8 text-center">
<div class="mb-8">
<i data-feather="award" class="w-16 h-16 text-yellow-500 mx-auto mb-4"></i>
<h2 class="text-2xl font-bold text-gray-800 mb-2">Quiz Completed!</h2>
<p class="text-gray-600 mb-4">Congratulations on completing the Engineer's Day Quiz</p>
<div class="text-4xl font-bold text-blue-600 mb-6">Your Score: <span id="finalScore">0</span>/10</div>
<div id="certificateBtn" class="bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-6 rounded-full inline-block cursor-pointer">
Download Your Certificate
</div>
</div>
<div class="border-t pt-6">
<h3 class="text-xl font-semibold text-gray-800 mb-4">Why We Celebrate Engineer's Day</h3>
<p class="text-gray-600 mb-4 text-left">
Engineer's Day is celebrated on September 15th in India to commemorate the birth anniversary of the legendary engineer Sir M. Visvesvaraya, who made outstanding contributions to engineering and nation-building.
</p>
<p class="text-gray-600 text-left">
This day recognizes the achievements of engineers and their role in technological advancement and societal development.
</p>
</div>
</div>
<script>
// Initialize AOS and Feather Icons
document.addEventListener('DOMContentLoaded', function() {
AOS.init({
duration: 800,
easing: 'ease-in-out',
once: true
});
feather.replace();
// Quiz questions
const questions = [
{
question: "On which date is Engineer's Day celebrated in India?",
options: ["September 15", "October 5", "November 20", "December 25"],
answer: 0
},
{
question: "Engineer's Day in India commemorates the birth anniversary of which famous engineer?",
options: ["A.P.J. Abdul Kalam", "C.V. Raman", "M. Visvesvaraya", "Homi Bhabha"],
answer: 2
},
{
question: "In which year was Sir M. Visvesvaraya awarded the Bharat Ratna?",
options: ["1945", "1955", "1965", "1975"],
answer: 1
},
{
question: "Which of these engineering marvels is Sir M. Visvesvaraya known for?",
options: ["Taj Mahal", "Krishna Raja Sagara Dam", "Qutub Minar", "Gateway of India"],
answer: 1
},
{
question: "What was Sir M. Visvesvaraya's profession before becoming an engineer?",
options: ["Doctor", "Teacher", "Farmer", "He was always an engineer"],
answer: 1
},
{
question: "Which country celebrates Engineer's Day on the same date as India?",
options: ["Sri Lanka", "Singapore", "Germany", "None of these"],
answer: 0
},
{
question: "What was Sir M. Visvesvaraya's contribution to flood protection?",
options: ["Invented the first dam", "Developed automatic sluice gates", "Created flood warning systems", "All of the above"],
answer: 1
},
{
question: "Which engineering college did Sir M. Visvesvaraya help establish?",
options: ["IIT Bombay", "College of Engineering, Pune", "University Visvesvaraya College of Engineering", "BITS Pilani"],
answer: 2
},
{
question: "What was Sir M. Visvesvaraya's role in Mysore state?",
options: ["King", "Chief Engineer", "Diwan (Prime Minister)", "Court Jester"],
answer: 2
},
{
question: "What is the theme of Engineer's Day 2023?",
options: ["Engineering for Sustainable Development", "Engineering Innovations for a Better World", "Engineering Solutions for Climate Change", "The official theme hasn't been announced yet"],
answer: 3
}
];
// Quiz variables
let currentQuestionIndex = 0;
let score = 0;
let userAnswers = [];
let userData = {};
// DOM elements
const startQuizBtn = document.getElementById('startQuizBtn');
const registrationForm = document.getElementById('registrationForm');
const registerForm = document.getElementById('registerForm');
const quizContainer = document.getElementById('quizContainer');
const resultsContainer = document.getElementById('resultsContainer');
const questionElement = document.getElementById('question');
const optionsElement = document.getElementById('options');
const currentQuestionElement = document.getElementById('currentQuestion');
const scoreElement = document.getElementById('score');
const finalScoreElement = document.getElementById('finalScore');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const certificateBtn = document.getElementById('certificateBtn');
// Event listeners
startQuizBtn.addEventListener('click', showRegistrationForm);
registerForm.addEventListener('submit', startQuiz);
nextBtn.addEventListener('click', nextQuestion);
prevBtn.addEventListener('click', prevQuestion);
certificateBtn.addEventListener('click', generateCertificate);
// Show registration form
function showRegistrationForm() {
document.getElementById('hero').classList.add('hidden');
registrationForm.classList.remove('hidden');
}
// Start quiz after registration
function startQuiz(e) {
e.preventDefault();
// Save user data
userData = {
name: document.getElementById('name').value,
email: document.getElementById('email').value,
college: document.getElementById('college').value,
department: document.getElementById('department').value
};
registrationForm.classList.add('hidden');
quizContainer.classList.remove('hidden');
loadQuestion();
}
// Load current question
function loadQuestion() {
const question = questions[currentQuestionIndex];
questionElement.textContent = question.question;
currentQuestionElement.textContent = currentQuestionIndex + 1;
scoreElement.textContent = score;
// Clear previous options
optionsElement.innerHTML = '';
// Add new options
question.options.forEach((option, index) => {
const optionElement = document.createElement('div');
optionElement.className = 'option bg-white border border-gray-200 rounded-lg p-4 cursor-pointer transition-all hover:border-blue-500';
optionElement.innerHTML = `
<div class="flex items-center">
<div class="w-6 h-6 rounded-full border border-gray-300 mr-3 flex items-center justify-center">${String.fromCharCode(65 + index)}</div>
<div>${option}</div>
</div>
`;
// Check if user has already answered this question
if (userAnswers[currentQuestionIndex] !== undefined) {
if (userAnswers[currentQuestionIndex] === index) {
optionElement.classList.add('bg-blue-50', 'border-blue-500');
}
optionElement.classList.add('pointer-events-none');
}
optionElement.addEventListener('click', () => selectAnswer(index));
optionsElement.appendChild(optionElement);
});
// Update navigation buttons
prevBtn.classList.toggle('hidden', currentQuestionIndex === 0);
nextBtn.textContent = currentQuestionIndex === questions.length - 1 ? 'Finish' : 'Next';
}
// Select answer
function selectAnswer(index) {
// If already answered, do nothing
if (userAnswers[currentQuestionIndex] !== undefined) return;
// Mark answer
userAnswers[currentQuestionIndex] = index;
// Highlight selected option
const options = optionsElement.querySelectorAll('.option');
options.forEach(option => option.classList.remove('bg-blue-50', 'border-blue-500'));
options[index].classList.add('bg-blue-50', 'border-blue-500');
// Check if correct
if (index === questions[currentQuestionIndex].answer) {
score++;
scoreElement.textContent = score;
}
}
// Next question
function nextQuestion() {
// If last question, show results
if (currentQuestionIndex === questions.length - 1) {
showResults();
return;
}
// Move to next question
currentQuestionIndex++;
loadQuestion();
}
// Previous question
function prevQuestion() {
currentQuestionIndex--;
loadQuestion();
}
// Show results
function showResults() {
quizContainer.classList.add('hidden');
resultsContainer.classList.remove('hidden');
finalScoreElement.textContent = score;
}
// Generate certificate (simulated)
function generateCertificate() {
alert(`Certificate generated for ${userData.name}!\n(Simulated function - in a real app, this would generate a PDF)`);
}
});
</script>
</body>
</html>