keepyoursins commited on
Commit
0b82439
Β·
verified Β·
1 Parent(s): e4f83c5

Create a Quiz App, with a quiz section, and a history section.

Browse files
Files changed (4) hide show
  1. README.md +7 -4
  2. history.html +205 -0
  3. index.html +137 -18
  4. quiz.html +333 -0
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Quizcraft Pro Brainy Battles History Trails
3
- emoji: πŸ’»
4
- colorFrom: green
5
  colorTo: yellow
 
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: QuizCraft Pro - Brainy Battles & History Trails 🧠
3
+ colorFrom: pink
 
4
  colorTo: yellow
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://deepsite.hf.co).
history.html ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>QuizCraft Pro - History</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.waves.min.js"></script>
12
+ <script src="https://cdn.jsdelivr.net/npm/animejs/lib/anime.min.js"></script>
13
+ <style>
14
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
15
+ body {
16
+ font-family: 'Poppins', sans-serif;
17
+ }
18
+ .glass-card {
19
+ background: rgba(255, 255, 255, 0.1);
20
+ backdrop-filter: blur(10px);
21
+ border: 1px solid rgba(255, 255, 255, 0.2);
22
+ }
23
+ .stat-card {
24
+ background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2);
25
+ }
26
+ .history-item {
27
+ transition: all 0.3s ease;
28
+ }
29
+ .history-item:hover {
30
+ transform: translateX(5px);
31
+ background: rgba(255, 255, 255, 0.05);
32
+ }
33
+ </style>
34
+ </head>
35
+ <body class="min-h-screen bg-gradient-to-br from-blue-900 via-purple-900 to-indigo-900 text-white">
36
+ <div id="vanta-waves" class="fixed top-0 left-0 w-full h-full z-0"></div>
37
+
38
+ <!-- Navigation -->
39
+ <nav class="glass-card rounded-lg m-4 p-4 relative z-10">
40
+ <div class="container mx-auto flex justify-between items-center">
41
+ <div class="flex items-center space-x-2">
42
+ <i data-feather="award" class="text-purple-400"></i>
43
+ <span class="text-xl font-bold">QuizCraft Pro</span>
44
+ </div>
45
+ <div class="flex space-x-6">
46
+ <a href="index.html" class="hover:text-purple-300 transition-colors">Home</a>
47
+ <a href="quiz.html" class="hover:text-purple-300 transition-colors">Quiz</a>
48
+ <a href="history.html" class="hover:text-purple-300 transition-colors">History</a>
49
+ </div>
50
+ </div>
51
+ </nav>
52
+
53
+ <!-- Main Content -->
54
+ <div class="container mx-auto px-4 py-8 max-w-6xl relative z-10">
55
+ <!-- Header -->
56
+ <div class="text-center mb-12">
57
+ <h1 class="text-4xl md:text-5xl font-bold mb-4 bg-gradient-to-r from-blue-400 to-purple-400 bg-clip-text text-transparent">
58
+ Your Quiz Journey
59
+ </h1>
60
+ <p class="text-xl text-gray-300">
61
+ Track your progress and see how far you've come
62
+ </p>
63
+ </div>
64
+
65
+ <!-- Statistics Cards -->
66
+ <div class="grid md:grid-cols-3 gap-6 mb-12">
67
+ <div class="stat-card p-6 rounded-xl text-center">
68
+ <i data-feather="trending-up" class="w-8 h-8 mx-auto mb-3 text-green-400"></i>
69
+ <div class="text-3xl font-bold" id="total-quizzes">0</div>
70
+ <div class="text-gray-300">Total Quizzes</div>
71
+ </div>
72
+ <div class="stat-card p-6 rounded-xl text-center">
73
+ <i data-feather="target" class="w-8 h-8 mx-auto mb-3 text-blue-400"></i>
74
+ <div class="text-3xl font-bold" id="average-score">0%</div>
75
+ <div class="text-gray-300">Average Score</div>
76
+ </div>
77
+ <div class="stat-card p-6 rounded-xl text-center">
78
+ <i data-feather="star" class="w-8 h-8 mx-auto mb-3 text-yellow-400"></i>
79
+ <div class="text-3xl font-bold" id="best-score">0%</div>
80
+ <div class="text-gray-300">Best Score</div>
81
+ </div>
82
+ </div>
83
+
84
+ <!-- History List -->
85
+ <div class="glass-card p-6 rounded-xl">
86
+ <h2 class="text-2xl font-semibold mb-6">Recent Attempts</h2>
87
+
88
+ <div id="history-list" class="space-y-4">
89
+ <!-- History items will be dynamically inserted here -->
90
+ <div class="text-center py-8 text-gray-400" id="empty-state">
91
+ <i data-feather="inbox" class="w-12 h-12 mx-auto mb-4"></i>
92
+ <p>No quiz attempts yet. Start your first quiz!</p>
93
+ <a href="quiz.html" class="btn-primary inline-block mt-4 px-6 py-2 rounded-full">
94
+ Take a Quiz
95
+ </a>
96
+ </div>
97
+ </div>
98
+ </div>
99
+
100
+ <!-- Clear History Button -->
101
+ <div class="text-center mt-8">
102
+ <button id="clear-history" class="glass-card px-6 py-3 rounded-full font-semibold text-red-400 hover:text-red-300 transition-colors">
103
+ <i data-feather="trash-2" class="inline mr-2"></i>Clear All History
104
+ </button>
105
+ </div>
106
+ </div>
107
+
108
+ <script>
109
+ feather.replace();
110
+
111
+ // Initialize Vanta.js waves
112
+ VANTA.WAVES({
113
+ el: "#vanta-waves",
114
+ mouseControls: true,
115
+ touchControls: true,
116
+ gyroControls: false,
117
+ minHeight: 200.00,
118
+ minWidth: 200.00,
119
+ scale: 1.00,
120
+ scaleMobile: 1.00,
121
+ color: 0x667eea,
122
+ shininess: 35.00,
123
+ waveHeight: 15.00,
124
+ waveSpeed: 0.70,
125
+ zoom: 0.75
126
+ });
127
+
128
+ // Load and display history
129
+ function loadHistory() {
130
+ const history = JSON.parse(localStorage.getItem('quizHistory') || '[]');
131
+ const historyList = document.getElementById('history-list');
132
+ const emptyState = document.getElementById('empty-state');
133
+
134
+ // Update statistics
135
+ const totalQuizzes = document.getElementById('total-quizzes');
136
+ const averageScore = document.getElementById('average-score');
137
+ const bestScore = document.getElementById('best-score');
138
+
139
+ totalQuizzes.textContent = history.length;
140
+
141
+ if (history.length > 0) {
142
+ emptyState.style.display = 'none';
143
+
144
+ const totalScore = history.reduce((sum, quiz) => sum + quiz.score, 0);
145
+ const avgScore = Math.round(totalScore / history.length);
146
+ averageScore.textContent = `${avgScore}%`;
147
+
148
+ const best = Math.max(...history.map(quiz => quiz.score));
149
+ bestScore.textContent = `${best}%`;
150
+
151
+ // Clear existing items
152
+ historyList.innerHTML = '';
153
+
154
+ // Add history items
155
+ history.forEach((quiz, index) => {
156
+ const historyItem = document.createElement('div');
157
+ historyItem.className = 'history-item p-4 rounded-lg border border-gray-700';
158
+ historyItem.innerHTML = `
159
+ <div class="flex justify-between items-center">
160
+ <div class="flex items-center space-x-4">
161
+ <div class="w-12 h-12 rounded-full bg-gradient-to-r from-purple-500 to-blue-500 flex items-center justify-center">
162
+ <span class="font-bold">${quiz.score}</span>
163
+ </div>
164
+ <div class="flex-1">
165
+ <h3 class="font-semibold">${quiz.category}</h3>
166
+ <p class="text-sm text-gray-400">${new Date(quiz.date).toLocaleDateString()}</p>
167
+ </div>
168
+ <div class="text-right">
169
+ <div class="text-2xl font-bold">${quiz.score}%</h3>
170
+ <p class="text-sm text-gray-400">${quiz.score}/${quiz.totalQuestions}</p>
171
+ </div>
172
+ </div>
173
+ </div>
174
+ `;
175
+ historyList.appendChild(historyItem);
176
+ });
177
+ } else {
178
+ emptyState.style.display = 'block';
179
+ }
180
+ }
181
+
182
+ // Clear history
183
+ document.getElementById('clear-history').addEventListener('click', function() {
184
+ if (confirm('Are you sure you want to clear all your quiz history? This action cannot be undone.')) {
185
+ localStorage.removeItem('quizHistory');
186
+ loadHistory();
187
+ }
188
+ });
189
+
190
+ // Load history on page load
191
+ document.addEventListener('DOMContentLoaded', function() {
192
+ loadHistory();
193
+
194
+ // Add entrance animations
195
+ anime({
196
+ targets: '.glass-card, .stat-card',
197
+ translateY: [30, 0],
198
+ opacity: [0, 1],
199
+ duration: 800,
200
+ delay: anime.stagger(100)
201
+ });
202
+ });
203
+ </script>
204
+ </body>
205
+ </html>
index.html CHANGED
@@ -1,19 +1,138 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>QuizCraft Pro - Home</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
12
+ <script src="https://cdn.jsdelivr.net/npm/animejs/lib/anime.min.js"></script>
13
+ <style>
14
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
15
+ body {
16
+ font-family: 'Poppins', sans-serif;
17
+ }
18
+ .vanta-bg {
19
+ position: fixed;
20
+ top: 0;
21
+ left: 0;
22
+ width: 100%;
23
+ height: 100%;
24
+ z-index: -1;
25
+ }
26
+ .glass-card {
27
+ background: rgba(255, 255, 255, 0.1);
28
+ backdrop-filter: blur(10px);
29
+ border: 1px solid rgba(255, 255, 255, 0.2);
30
+ }
31
+ .btn-primary {
32
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
33
+ transition: all 0.3s ease;
34
+ }
35
+ .btn-primary:hover {
36
+ transform: translateY(-2px);
37
+ box-shadow: 0 10px 20px rgba(0,0,0,0.2);
38
+ }
39
+ .btn-secondary {
40
+ background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
41
+ transition: all 0.3s ease;
42
+ }
43
+ .btn-secondary:hover {
44
+ transform: translateY(-2px);
45
+ box-shadow: 0 10px 20px rgba(0,0,0,0.2);
46
+ }
47
+ </style>
48
+ </head>
49
+ <body class="min-h-screen text-white overflow-x-hidden">
50
+ <div id="vanta-bg" class="vanta-bg"></div>
51
+
52
+ <!-- Navigation -->
53
+ <nav class="glass-card rounded-lg m-4 p-4">
54
+ <div class="container mx-auto flex justify-between items-center">
55
+ <div class="flex items-center space-x-2">
56
+ <i data-feather="award" class="text-purple-400"></i>
57
+ <span class="text-xl font-bold">QuizCraft Pro</span>
58
+ </div>
59
+ <div class="flex space-x-6">
60
+ <a href="index.html" class="hover:text-purple-300 transition-colors">Home</a>
61
+ <a href="quiz.html" class="hover:text-purple-300 transition-colors">Quiz</a>
62
+ <a href="history.html" class="hover:text-purple-300 transition-colors">History</a>
63
+ </div>
64
+ </div>
65
+ </nav>
66
+
67
+ <!-- Hero Section -->
68
+ <section class="container mx-auto px-4 py-16 text-center">
69
+ <div class="max-w-4xl mx-auto">
70
+ <h1 class="text-5xl md:text-7xl font-bold mb-6 bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent">
71
+ Challenge Your Mind
72
+ </h1>
73
+ <p class="text-xl md:text-2xl mb-8 text-gray-300">
74
+ Dive into endless knowledge, track your progress, and become the ultimate quiz master!
75
+ </p>
76
+ <div class="flex flex-col sm:flex-row gap-4 justify-center">
77
+ <a href="quiz.html" class="btn-primary px-8 py-4 rounded-full font-semibold text-lg">
78
+ <i data-feather="play" class="inline mr-2"></i>Start Quiz
79
+ </a>
80
+ <a href="history.html" class="btn-secondary px-8 py-4 rounded-full font-semibold text-lg">
81
+ <i data-feather="bar-chart-2" class="inline mr-2"></i>View History
82
+ </a>
83
+ </div>
84
+ </div>
85
+ </section>
86
+
87
+ <!-- Features Section -->
88
+ <section class="container mx-auto px-4 py-16">
89
+ <div class="grid md:grid-cols-3 gap-8">
90
+ <div class="glass-card p-6 rounded-xl text-center">
91
+ <i data-feather="zap" class="w-12 h-12 mx-auto mb-4 text-yellow-400"></i>
92
+ <h3 class="text-xl font-semibold mb-3">Lightning Fast</h3>
93
+ <p class="text-gray-300">Instant feedback and seamless transitions for the best quiz experience</p>
94
+ </div>
95
+ <div class="glass-card p-6 rounded-xl text-center">
96
+ <i data-feather="trending-up" class="w-12 h-12 mx-auto mb-4 text-green-400"></i>
97
+ <h3 class="text-xl font-semibold mb-3">Track Progress</h3>
98
+ <p class="text-gray-300">Monitor your improvement with detailed analytics and history</p>
99
+ </div>
100
+ <div class="glass-card p-6 rounded-xl text-center">
101
+ <i data-feather="database" class="w-12 h-12 mx-auto mb-4 text-blue-400"></i>
102
+ <h3 class="text-xl font-semibold mb-3">Vast Categories</h3>
103
+ <p class="text-gray-300">Thousands of questions across multiple topics and difficulty levels</p>
104
+ </div>
105
+ </div>
106
+ </section>
107
+
108
+ <script>
109
+ // Initialize Vanta.js globe
110
+ VANTA.GLOBE({
111
+ el: "#vanta-bg",
112
+ mouseControls: true,
113
+ touchControls: true,
114
+ gyroControls: false,
115
+ minHeight: 200.00,
116
+ minWidth: 200.00,
117
+ scale: 1.00,
118
+ scaleMobile: 1.00,
119
+ color: 0x764ba2,
120
+ backgroundColor: 0x0
121
+ });
122
+
123
+ // Initialize feather icons
124
+ feather.replace();
125
+
126
+ // Add some entrance animations
127
+ document.addEventListener('DOMContentLoaded', function() {
128
+ anime({
129
+ targets: 'h1, p, .btn-primary, .btn-secondary',
130
+ translateY: [50, 0],
131
+ opacity: [0, 1],
132
+ duration: 1000,
133
+ delay: anime.stagger(200)
134
+ });
135
+ });
136
+ </script>
137
+ </body>
138
  </html>
quiz.html ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>QuizCraft Pro - Quiz</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/animejs/lib/anime.min.js"></script>
12
+ <style>
13
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
14
+ body {
15
+ font-family: 'Poppins', sans-serif;
16
+ }
17
+ .glass-card {
18
+ background: rgba(255, 255, 255, 0.1);
19
+ backdrop-filter: blur(10px);
20
+ border: 1px solid rgba(255, 255, 255, 0.2);
21
+ }
22
+ .btn-primary {
23
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
24
+ transition: all 0.3s ease;
25
+ }
26
+ .btn-primary:hover {
27
+ transform: translateY(-2px);
28
+ box-shadow: 0 10px 20px rgba(0,0,0,0.2);
29
+ }
30
+ .option-card {
31
+ transition: all 0.3s ease;
32
+ cursor: pointer;
33
+ }
34
+ .option-card:hover {
35
+ transform: translateY(-2px);
36
+ background: rgba(255, 255, 255, 0.15);
37
+ }
38
+ .option-card.selected {
39
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
40
+ }
41
+ .progress-bar {
42
+ transition: width 0.5s ease-in-out;
43
+ }
44
+ </style>
45
+ </head>
46
+ <body class="min-h-screen bg-gradient-to-br from-purple-900 via-blue-900 to-indigo-900 text-white">
47
+ <!-- Navigation -->
48
+ <nav class="glass-card rounded-lg m-4 p-4">
49
+ <div class="container mx-auto flex justify-between items-center">
50
+ <div class="flex items-center space-x-2">
51
+ <i data-feather="award" class="text-purple-400"></i>
52
+ <span class="text-xl font-bold">QuizCraft Pro</span>
53
+ </div>
54
+ <div class="flex space-x-6">
55
+ <a href="index.html" class="hover:text-purple-300 transition-colors">Home</a>
56
+ <a href="quiz.html" class="hover:text-purple-300 transition-colors">Quiz</a>
57
+ <a href="history.html" class="hover:text-purple-300 transition-colors">History</a>
58
+ </div>
59
+ </div>
60
+ </nav>
61
+
62
+ <!-- Quiz Container -->
63
+ <div class="container mx-auto px-4 py-8 max-w-4xl">
64
+ <!-- Category Selection -->
65
+ <div id="category-selection" class="glass-card p-8 rounded-xl mb-8">
66
+ <h2 class="text-3xl font-bold mb-6 text-center">Choose Your Challenge</h2>
67
+ <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
68
+ <div class="option-card p-4 rounded-lg text-center border-2 border-purple-500" data-category="9">
69
+ <i data-feather="brain" class="w-8 h-8 mx-auto mb-2"></i>
70
+ <span>General Knowledge</span>
71
+ </div>
72
+ <div class="option-card p-4 rounded-lg text-center border-2 border-blue-500" data-category="17">
73
+ <i data-feather="atom" class="w-8 h-8 mx-auto mb-2"></i>
74
+ <span>Science</span>
75
+ </div>
76
+ <div class="option-card p-4 rounded-lg text-center border-2 border-green-500" data-category="22">
77
+ <i data-feather="map" class="w-8 h-8 mx-auto mb-2"></i>
78
+ <span>Geography</span>
79
+ </div>
80
+ <div class="option-card p-4 rounded-lg text-center border-2 border-yellow-500" data-category="23">
81
+ <i data-feather="book" class="w-8 h-8 mx-auto mb-2"></i>
82
+ <span>History</span>
83
+ </div>
84
+ </div>
85
+ <div class="text-center mt-6">
86
+ <button id="start-quiz" class="btn-primary px-8 py-3 rounded-full font-semibold">
87
+ Start Quiz <i data-feather="arrow-right" class="inline ml-2"></i>
88
+ </button>
89
+ </div>
90
+ </div>
91
+
92
+ <!-- Quiz Interface -->
93
+ <div id="quiz-interface" class="hidden">
94
+ <!-- Progress Bar -->
95
+ <div class="glass-card p-4 rounded-xl mb-6">
96
+ <div class="flex justify-between items-center mb-2">
97
+ <span class="text-sm">Question <span id="current-question">1</span> of 10</span>
98
+ <span id="score" class="text-sm">Score: 0</span>
99
+ </div>
100
+ <div class="w-full bg-gray-700 rounded-full h-2">
101
+ <div id="progress-bar" class="progress-bar h-2 rounded-full bg-gradient-to-r from-purple-400 to-pink-400" style="width: 10%"></div>
102
+ </div>
103
+
104
+ <!-- Question Card -->
105
+ <div id="question-card" class="glass-card p-8 rounded-xl mb-6">
106
+ <h2 id="question-text" class="text-2xl font-semibold mb-6 text-center"></h2>
107
+ <div id="options-container" class="grid gap-4">
108
+ <!-- Options will be dynamically inserted here -->
109
+ </div>
110
+ </div>
111
+
112
+ <!-- Navigation Buttons -->
113
+ <div class="flex justify-between">
114
+ <button id="prev-question" class="glass-card px-6 py-3 rounded-full font-semibold opacity-50 cursor-not-allowed">
115
+ <i data-feather="arrow-left" class="inline mr-2"></i>Previous
116
+ </button>
117
+ <button id="next-question" class="btn-primary px-6 py-3 rounded-full font-semibold">
118
+ Next <i data-feather="arrow-right" class="inline ml-2"></i>
119
+ </button>
120
+ </div>
121
+ </div>
122
+
123
+ <!-- Results Screen -->
124
+ <div id="results-screen" class="hidden glass-card p-8 rounded-xl text-center">
125
+ <i data-feather="award" class="w-16 h-16 mx-auto mb-4 text-yellow-400"></i>
126
+ <h2 class="text-4xl font-bold mb-4">Quiz Complete!</h2>
127
+ <div id="final-score" class="text-6xl font-bold mb-4 bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent"></div>
128
+ <p id="performance-message" class="text-xl mb-6"></p>
129
+ <div class="flex flex-col sm:flex-row gap-4 justify-center">
130
+ <button id="play-again" class="btn-primary px-6 py-3 rounded-full font-semibold">
131
+ <i data-feather="refresh-cw" class="inline mr-2"></i>Play Again
132
+ </button>
133
+ <a href="history.html" class="btn-secondary px-6 py-3 rounded-full font-semibold">
134
+ <i data-feather="bar-chart-2" class="inline mr-2"></i>View History
135
+ </a>
136
+ </div>
137
+ </div>
138
+ </div>
139
+
140
+ <script>
141
+ feather.replace();
142
+
143
+ // Quiz state
144
+ let currentCategory = null;
145
+ let currentQuestionIndex = 0;
146
+ let score = 0;
147
+ let questions = [];
148
+ let selectedOptions = new Array(10).fill(null);
149
+
150
+ // DOM Elements
151
+ const categorySelection = document.getElementById('category-selection');
152
+ const quizInterface = document.getElementById('quiz-interface');
153
+ const resultsScreen = document.getElementById('results-screen');
154
+ const startQuizBtn = document.getElementById('start-quiz');
155
+ const questionText = document.getElementById('question-text');
156
+ const optionsContainer = document.getElementById('options-container');
157
+ const currentQuestionSpan = document.getElementById('current-question');
158
+ const scoreSpan = document.getElementById('score');
159
+ const progressBar = document.getElementById('progress-bar');
160
+ const prevQuestionBtn = document.getElementById('prev-question');
161
+ const nextQuestionBtn = document.getElementById('next-question');
162
+ const finalScore = document.getElementById('final-score');
163
+ const performanceMessage = document.getElementById('performance-message');
164
+ const playAgainBtn = document.getElementById('play-again');
165
+
166
+ // Category selection
167
+ document.querySelectorAll('.option-card').forEach(card => {
168
+ card.addEventListener('click', function() {
169
+ document.querySelectorAll('.option-card').forEach(c => {
170
+ c.classList.remove('selected', 'border-white');
171
+ c.classList.add('border-opacity-50');
172
+ });
173
+ this.classList.add('selected', 'border-white');
174
+ this.classList.remove('border-opacity-50');
175
+ currentCategory = this.dataset.category;
176
+ });
177
+ });
178
+
179
+ // Start quiz
180
+ startQuizBtn.addEventListener('click', async function() {
181
+ if (!currentCategory) {
182
+ alert('Please select a category first!');
183
+ return;
184
+ }
185
+
186
+ try {
187
+ const response = await fetch(`https://opentdb.com/api.php?amount=10&category=${currentCategory}&type=multiple`);
188
+ const data = await response.json();
189
+ questions = data.results;
190
+
191
+ categorySelection.classList.add('hidden');
192
+ quizInterface.classList.remove('hidden');
193
+ loadQuestion(0);
194
+ } catch (error) {
195
+ console.error('Error fetching questions:', error);
196
+ alert('Failed to load questions. Please try again.');
197
+ }
198
+ });
199
+
200
+ // Load question
201
+ function loadQuestion(index) {
202
+ const question = questions[index];
203
+ currentQuestionIndex = index;
204
+
205
+ // Update UI
206
+ currentQuestionSpan.textContent = index + 1;
207
+ scoreSpan.textContent = `Score: ${score}`;
208
+ progressBar.style.width = `${((index + 1) / 10) * 100}%`;
209
+
210
+ // Set question text
211
+ questionText.textContent = decodeHTML(question.question);
212
+
213
+ // Create options
214
+ const allOptions = [...question.incorrect_answers, question.correct_answer]
215
+ .sort(() => Math.random() - 0.5);
216
+
217
+ optionsContainer.innerHTML = '';
218
+ allOptions.forEach((option, optionIndex) => {
219
+ const optionDiv = document.createElement('div');
220
+ optionDiv.className = `option-card p-4 rounded-lg border-2 border-gray-600 ${
221
+ selectedOptions[index] === option ? 'selected' : ''
222
+ }`;
223
+ optionDiv.innerHTML = `
224
+ <div class="flex items-center justify-between">
225
+ <span>${decodeHTML(option)}</span>
226
+ ${selectedOptions[index] === option ? '<i data-feather="check" class="w-5 h-5"></i>' : ''}
227
+ </div>
228
+ `;
229
+
230
+ optionDiv.addEventListener('click', () => selectOption(option, index));
231
+ optionsContainer.appendChild(optionDiv);
232
+ });
233
+
234
+ // Update navigation buttons
235
+ prevQuestionBtn.disabled = index === 0;
236
+ prevQuestionBtn.classList.toggle('opacity-50', index === 0);
237
+ prevQuestionBtn.classList.toggle('cursor-not-allowed', index === 0);
238
+
239
+ if (index === 9) {
240
+ nextQuestionBtn.textContent = 'Finish Quiz';
241
+ nextQuestionBtn.innerHTML = 'Finish Quiz <i data-feather="check" class="inline ml-2"></i>';
242
+ } else {
243
+ nextQuestionBtn.textContent = 'Next';
244
+ nextQuestionBtn.innerHTML = 'Next <i data-feather="arrow-right" class="inline ml-2"></i>';
245
+ }
246
+
247
+ feather.replace();
248
+ }
249
+
250
+ // Select option
251
+ function selectOption(option, index) {
252
+ selectedOptions[index] = option;
253
+ const isCorrect = option === questions[index].correct_answer;
254
+
255
+ // Update score if this is a new selection
256
+ if (isCorrect && selectedOptions[index] !== option) {
257
+ score += 10;
258
+ }
259
+
260
+ loadQuestion(index); // Reload to show selection
261
+ }
262
+
263
+ // Navigation
264
+ prevQuestionBtn.addEventListener('click', () => {
265
+ if (currentQuestionIndex > 0) {
266
+ loadQuestion(currentQuestionIndex - 1);
267
+ }
268
+ });
269
+
270
+ nextQuestionBtn.addEventListener('click', () => {
271
+ if (currentQuestionIndex < 9) {
272
+ loadQuestion(currentQuestionIndex + 1);
273
+ } else {
274
+ // Show results
275
+ showResults();
276
+ }
277
+ });
278
+
279
+ // Show results
280
+ function showResults() {
281
+ quizInterface.classList.add('hidden');
282
+ resultsScreen.classList.remove('hidden');
283
+
284
+ finalScore.textContent = `${score}/100`;
285
+
286
+ if (score >= 90) {
287
+ performanceMessage.textContent = 'Outstanding! You are a quiz master! 🌟';
288
+ } else if (score >= 70) {
289
+ performanceMessage.textContent = 'Great job! You know your stuff! πŸ’ͺ';
290
+ } else if (score >= 50) {
291
+ performanceMessage.textContent = 'Good effort! Keep learning! πŸ“š';
292
+ } else {
293
+ performanceMessage.textContent = 'Nice try! Practice makes perfect! πŸ”„';
294
+ }
295
+
296
+ // Save to localStorage for history
297
+ const quizResult = {
298
+ category: document.querySelector('.selected span').textContent,
299
+ score: score,
300
+ date: new Date().toISOString(),
301
+ totalQuestions: 10
302
+ };
303
+
304
+ let history = JSON.parse(localStorage.getItem('quizHistory') || '[]');
305
+ history.unshift(quizResult);
306
+ localStorage.setItem('quizHistory', JSON.stringify(history));
307
+ }
308
+
309
+ // Play again
310
+ playAgainBtn.addEventListener('click', () => {
311
+ location.reload();
312
+ });
313
+
314
+ // Utility function to decode HTML entities
315
+ function decodeHTML(html) {
316
+ const txt = document.createElement('textarea');
317
+ txt.innerHTML = html;
318
+ return txt.value;
319
+ }
320
+
321
+ // Entrance animations
322
+ document.addEventListener('DOMContentLoaded', function() {
323
+ anime({
324
+ targets: '.glass-card',
325
+ translateY: [30, 0],
326
+ opacity: [0, 1],
327
+ duration: 800,
328
+ delay: anime.stagger(100)
329
+ });
330
+ });
331
+ </script>
332
+ </body>
333
+ </html>