Spaces:
Running
Running
Fix issues and it's not working - Initial Deployment
Browse files- README.md +7 -5
- index.html +583 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 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: pythonquizgenerator
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,583 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
<!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>Python Quiz Generator</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<script>
|
| 10 |
+
tailwind.config = {
|
| 11 |
+
theme: {
|
| 12 |
+
extend: {
|
| 13 |
+
colors: {
|
| 14 |
+
'python-blue': '#306998',
|
| 15 |
+
'python-yellow': '#FFD43B',
|
| 16 |
+
'python-light': '#4B8BBE',
|
| 17 |
+
},
|
| 18 |
+
animation: {
|
| 19 |
+
'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
| 20 |
+
'bounce-slow': 'bounce 2s infinite',
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
</script>
|
| 26 |
+
<style>
|
| 27 |
+
@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600;700&display=swap');
|
| 28 |
+
|
| 29 |
+
body {
|
| 30 |
+
font-family: 'Source Code Pro', monospace;
|
| 31 |
+
background: linear-gradient(135deg, #1a2a6c, #2c3e50);
|
| 32 |
+
min-height: 100vh;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.python-logo {
|
| 36 |
+
animation: spin 20s linear infinite;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
@keyframes spin {
|
| 40 |
+
0% { transform: rotate(0deg); }
|
| 41 |
+
100% { transform: rotate(360deg); }
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.option-card {
|
| 45 |
+
transition: all 0.3s ease;
|
| 46 |
+
transform: scale(1);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.option-card:hover {
|
| 50 |
+
transform: scale(1.03);
|
| 51 |
+
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.correct-answer {
|
| 55 |
+
animation: correct-pulse 0.5s ease;
|
| 56 |
+
box-shadow: 0 0 0 4px rgba(72, 187, 120, 0.5);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.incorrect-answer {
|
| 60 |
+
animation: shake 0.5s ease;
|
| 61 |
+
box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.5);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
@keyframes correct-pulse {
|
| 65 |
+
0% { transform: scale(1); }
|
| 66 |
+
50% { transform: scale(1.05); }
|
| 67 |
+
100% { transform: scale(1); }
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
@keyframes shake {
|
| 71 |
+
0%, 100% { transform: translateX(0); }
|
| 72 |
+
25% { transform: translateX(-5px); }
|
| 73 |
+
75% { transform: translateX(5px); }
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.progress-bar {
|
| 77 |
+
transition: width 0.5s ease;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.snake-animation {
|
| 81 |
+
animation: snake-move 8s linear infinite;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
@keyframes snake-move {
|
| 85 |
+
0% { transform: translateX(-100%); }
|
| 86 |
+
100% { transform: translateX(100%); }
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.code-block {
|
| 90 |
+
font-family: 'Source Code Pro', monospace;
|
| 91 |
+
background: #2d3748;
|
| 92 |
+
border-left: 4px solid #4B8BBE;
|
| 93 |
+
}
|
| 94 |
+
</style>
|
| 95 |
+
</head>
|
| 96 |
+
<body class="text-gray-100">
|
| 97 |
+
<!-- Main Container -->
|
| 98 |
+
<div class="container mx-auto px-4 py-8 max-w-4xl">
|
| 99 |
+
<!-- Header -->
|
| 100 |
+
<header class="text-center mb-12">
|
| 101 |
+
<div class="flex justify-center mb-4">
|
| 102 |
+
<div class="python-logo bg-python-blue rounded-full w-24 h-24 flex items-center justify-center">
|
| 103 |
+
<div class="bg-python-yellow rounded-full w-16 h-16 flex items-center justify-center">
|
| 104 |
+
<i class="fas fa-code text-python-blue text-3xl"></i>
|
| 105 |
+
</div>
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
<h1 class="text-4xl md:text-5xl font-bold mb-2 bg-gradient-to-r from-python-yellow to-python-light bg-clip-text text-transparent">
|
| 109 |
+
Python Quiz Generator
|
| 110 |
+
</h1>
|
| 111 |
+
<p class="text-xl text-gray-300">Test your Python knowledge with interactive challenges!</p>
|
| 112 |
+
</header>
|
| 113 |
+
|
| 114 |
+
<!-- Quiz Controls -->
|
| 115 |
+
<div class="bg-gray-800 rounded-xl shadow-2xl p-6 mb-8">
|
| 116 |
+
<div class="flex flex-wrap justify-between items-center gap-4">
|
| 117 |
+
<div>
|
| 118 |
+
<h2 class="text-2xl font-bold mb-2">Quiz Settings</h2>
|
| 119 |
+
<p class="text-gray-400">Customize your quiz experience</p>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
<div class="flex flex-wrap gap-3">
|
| 123 |
+
<div class="flex items-center">
|
| 124 |
+
<label class="mr-2">Questions:</label>
|
| 125 |
+
<select id="questionCount" class="bg-gray-700 text-white rounded px-3 py-1">
|
| 126 |
+
<option>5</option>
|
| 127 |
+
<option selected>10</option>
|
| 128 |
+
<option>15</option>
|
| 129 |
+
<option>20</option>
|
| 130 |
+
</select>
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
<div class="flex items-center">
|
| 134 |
+
<label class="mr-2">Difficulty:</label>
|
| 135 |
+
<select id="difficulty" class="bg-gray-700 text-white rounded px-3 py-1">
|
| 136 |
+
<option>Beginner</option>
|
| 137 |
+
<option selected>Intermediate</option>
|
| 138 |
+
<option>Advanced</option>
|
| 139 |
+
</select>
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<button id="generateBtn" class="bg-python-blue hover:bg-python-light text-white font-bold py-2 px-6 rounded-lg transition-all transform hover:scale-105 flex items-center">
|
| 143 |
+
<i class="fas fa-bolt mr-2"></i> Generate Quiz
|
| 144 |
+
</button>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
|
| 149 |
+
<!-- Quiz Container -->
|
| 150 |
+
<div id="quizContainer" class="hidden">
|
| 151 |
+
<!-- Progress Bar -->
|
| 152 |
+
<div class="mb-6">
|
| 153 |
+
<div class="flex justify-between mb-2">
|
| 154 |
+
<div class="text-lg font-bold">
|
| 155 |
+
Question <span id="currentQuestion">1</span> of <span id="totalQuestions">10</span>
|
| 156 |
+
</div>
|
| 157 |
+
<div class="text-lg font-bold">
|
| 158 |
+
Score: <span id="score">0</span>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
<div class="h-3 bg-gray-700 rounded-full overflow-hidden">
|
| 162 |
+
<div id="progressBar" class="h-full bg-python-blue rounded-full progress-bar" style="width: 10%"></div>
|
| 163 |
+
</div>
|
| 164 |
+
</div>
|
| 165 |
+
|
| 166 |
+
<!-- Question Area -->
|
| 167 |
+
<div class="bg-gray-800 rounded-xl shadow-2xl p-6 mb-6">
|
| 168 |
+
<div class="flex items-start mb-6">
|
| 169 |
+
<div class="bg-python-blue text-python-yellow rounded-full w-10 h-10 flex items-center justify-center mr-4 flex-shrink-0">
|
| 170 |
+
<i class="fas fa-question"></i>
|
| 171 |
+
</div>
|
| 172 |
+
<div>
|
| 173 |
+
<h3 id="questionText" class="text-xl font-bold mb-2">What is the output of the following Python code?</h3>
|
| 174 |
+
<div class="code-block p-4 rounded-lg mt-3">
|
| 175 |
+
<pre id="questionCode" class="text-green-400">print(2 + 2 * 3)</pre>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
|
| 180 |
+
<!-- Options -->
|
| 181 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-6">
|
| 182 |
+
<div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
|
| 183 |
+
<div class="flex items-center">
|
| 184 |
+
<div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">A</div>
|
| 185 |
+
<span class="option-text">8</span>
|
| 186 |
+
</div>
|
| 187 |
+
</div>
|
| 188 |
+
<div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
|
| 189 |
+
<div class="flex items-center">
|
| 190 |
+
<div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">B</div>
|
| 191 |
+
<span class="option-text">10</span>
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
+
<div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
|
| 195 |
+
<div class="flex items-center">
|
| 196 |
+
<div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">C</div>
|
| 197 |
+
<span class="option-text">12</span>
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
<div class="option-card bg-gray-700 rounded-lg p-4 cursor-pointer">
|
| 201 |
+
<div class="flex items-center">
|
| 202 |
+
<div class="bg-gray-600 rounded-full w-8 h-8 flex items-center justify-center mr-3">D</div>
|
| 203 |
+
<span class="option-text">6</span>
|
| 204 |
+
</div>
|
| 205 |
+
</div>
|
| 206 |
+
</div>
|
| 207 |
+
</div>
|
| 208 |
+
|
| 209 |
+
<!-- Explanation -->
|
| 210 |
+
<div id="explanation" class="hidden bg-gray-800 rounded-xl shadow-2xl p-6 mb-6">
|
| 211 |
+
<div class="flex items-start">
|
| 212 |
+
<div class="bg-green-500 text-white rounded-full w-10 h-10 flex items-center justify-center mr-4 flex-shrink-0">
|
| 213 |
+
<i class="fas fa-lightbulb"></i>
|
| 214 |
+
</div>
|
| 215 |
+
<div>
|
| 216 |
+
<h3 class="text-xl font-bold mb-2">Explanation</h3>
|
| 217 |
+
<p id="explanationText" class="text-gray-300">In Python, multiplication has higher precedence than addition. So 2 * 3 is calculated first (resulting in 6), then 2 + 6 is calculated, giving 8.</p>
|
| 218 |
+
</div>
|
| 219 |
+
</div>
|
| 220 |
+
</div>
|
| 221 |
+
|
| 222 |
+
<!-- Navigation -->
|
| 223 |
+
<div class="flex justify-between">
|
| 224 |
+
<button id="prevBtn" class="bg-gray-700 hover:bg-gray-600 text-white font-bold py-2 px-6 rounded-lg transition-all">
|
| 225 |
+
<i class="fas fa-arrow-left mr-2"></i> Previous
|
| 226 |
+
</button>
|
| 227 |
+
<button id="nextBtn" class="bg-python-blue hover:bg-python-light text-white font-bold py-2 px-6 rounded-lg transition-all transform hover:scale-105">
|
| 228 |
+
Next <i class="fas fa-arrow-right ml-2"></i>
|
| 229 |
+
</button>
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
|
| 233 |
+
<!-- Snake Animation Decoration -->
|
| 234 |
+
<div class="relative h-4 my-12 overflow-hidden">
|
| 235 |
+
<div class="snake-animation absolute top-0 left-0 w-full">
|
| 236 |
+
<div class="flex">
|
| 237 |
+
<div class="w-4 h-4 bg-python-blue rounded-full mx-1"></div>
|
| 238 |
+
<div class="w-4 h-4 bg-python-yellow rounded-full mx-1"></div>
|
| 239 |
+
<div class="w-4 h-4 bg-python-light rounded-full mx-1"></div>
|
| 240 |
+
<div class="w-4 h-4 bg-python-blue rounded-full mx-1"></div>
|
| 241 |
+
<div class="w-4 h-4 bg-python-yellow rounded-full mx-1"></div>
|
| 242 |
+
<div class="w-4 h-4 bg-python-light rounded-full mx-1"></div>
|
| 243 |
+
</div>
|
| 244 |
+
</div>
|
| 245 |
+
</div>
|
| 246 |
+
|
| 247 |
+
<!-- Results Container -->
|
| 248 |
+
<div id="resultsContainer" class="hidden bg-gray-800 rounded-xl shadow-2xl p-8 text-center">
|
| 249 |
+
<div class="flex justify-center mb-6">
|
| 250 |
+
<div class="bg-gradient-to-br from-python-blue to-python-light rounded-full w-24 h-24 flex items-center justify-center">
|
| 251 |
+
<i class="fas fa-trophy text-white text-4xl"></i>
|
| 252 |
+
</div>
|
| 253 |
+
</div>
|
| 254 |
+
<h2 class="text-3xl font-bold mb-4">Quiz Completed!</h2>
|
| 255 |
+
<div class="text-5xl font-bold mb-6 bg-gradient-to-r from-python-yellow to-python-light bg-clip-text text-transparent">
|
| 256 |
+
<span id="finalScore">8</span>/<span id="finalTotal">10</span>
|
| 257 |
+
</div>
|
| 258 |
+
<p id="resultMessage" class="text-xl mb-8">Great job! You have a solid understanding of Python fundamentals.</p>
|
| 259 |
+
<div class="flex justify-center gap-4">
|
| 260 |
+
<button id="restartBtn" class="bg-python-blue hover:bg-python-light text-white font-bold py-3 px-8 rounded-lg transition-all transform hover:scale-105">
|
| 261 |
+
<i class="fas fa-redo mr-2"></i> Try Again
|
| 262 |
+
</button>
|
| 263 |
+
<button id="newQuizBtn" class="bg-gray-700 hover:bg-gray-600 text-white font-bold py-3 px-8 rounded-lg transition-all">
|
| 264 |
+
<i class="fas fa-plus mr-2"></i> New Quiz
|
| 265 |
+
</button>
|
| 266 |
+
</div>
|
| 267 |
+
</div>
|
| 268 |
+
</div>
|
| 269 |
+
|
| 270 |
+
<script>
|
| 271 |
+
// Quiz questions database
|
| 272 |
+
const questions = [
|
| 273 |
+
{
|
| 274 |
+
question: "What is the output of the following Python code?",
|
| 275 |
+
code: "print(2 + 2 * 3)",
|
| 276 |
+
options: ["8", "10", "12", "6"],
|
| 277 |
+
answer: 0,
|
| 278 |
+
explanation: "In Python, multiplication has higher precedence than addition. So 2 * 3 is calculated first (resulting in 6), then 2 + 6 is calculated, giving 8."
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
question: "Which of the following is used to create a virtual environment in Python?",
|
| 282 |
+
code: "",
|
| 283 |
+
options: ["venv", "virtualenv", "pipenv", "All of the above"],
|
| 284 |
+
answer: 3,
|
| 285 |
+
explanation: "All of these tools can be used to create virtual environments in Python. venv is built into Python 3, virtualenv is a third-party tool, and pipenv combines virtual environment management with package management."
|
| 286 |
+
},
|
| 287 |
+
{
|
| 288 |
+
question: "What does the 'yield' keyword do in Python?",
|
| 289 |
+
code: "",
|
| 290 |
+
options: [
|
| 291 |
+
"Returns a value and terminates the function",
|
| 292 |
+
"Pauses the function and returns a generator object",
|
| 293 |
+
"Used for exception handling",
|
| 294 |
+
"Defines a static method"
|
| 295 |
+
],
|
| 296 |
+
answer: 1,
|
| 297 |
+
explanation: "The yield keyword is used in generator functions to pause execution and return a value. When called again, the function resumes where it left off."
|
| 298 |
+
},
|
| 299 |
+
{
|
| 300 |
+
question: "What is the output of the following code?",
|
| 301 |
+
code: "x = [1, 2, 3]\ny = x\ny.append(4)\nprint(x)",
|
| 302 |
+
options: ["[1, 2, 3]", "[1, 2, 3, 4]", "[4]", "Error"],
|
| 303 |
+
answer: 1,
|
| 304 |
+
explanation: "When we assign y = x, both variables point to the same list in memory. So modifying y also modifies x."
|
| 305 |
+
},
|
| 306 |
+
{
|
| 307 |
+
question: "Which method would you use to remove the last element from a list?",
|
| 308 |
+
code: "",
|
| 309 |
+
options: ["list.remove()", "list.pop()", "list.delete()", "list.cut()"],
|
| 310 |
+
answer: 1,
|
| 311 |
+
explanation: "The pop() method removes and returns the last element by default. You can also specify an index to remove an element at a specific position."
|
| 312 |
+
},
|
| 313 |
+
{
|
| 314 |
+
question: "What is the purpose of __init__ in a Python class?",
|
| 315 |
+
code: "",
|
| 316 |
+
options: [
|
| 317 |
+
"To initialize the class object",
|
| 318 |
+
"To create class methods",
|
| 319 |
+
"To define class variables",
|
| 320 |
+
"To terminate the class instance"
|
| 321 |
+
],
|
| 322 |
+
answer: 0,
|
| 323 |
+
explanation: "The __init__ method is called when a new instance of a class is created. It's used to initialize the object's attributes."
|
| 324 |
+
},
|
| 325 |
+
{
|
| 326 |
+
question: "What does the 'with' statement do?",
|
| 327 |
+
code: "",
|
| 328 |
+
options: [
|
| 329 |
+
"Creates a loop",
|
| 330 |
+
"Handles exceptions",
|
| 331 |
+
"Manages resources and ensures cleanup",
|
| 332 |
+
"Defines a context for variable scope"
|
| 333 |
+
],
|
| 334 |
+
answer: 2,
|
| 335 |
+
explanation: "The 'with' statement simplifies resource management by ensuring that setup and cleanup operations are performed automatically."
|
| 336 |
+
},
|
| 337 |
+
{
|
| 338 |
+
question: "What is the output of the following code?",
|
| 339 |
+
code: "print([i for i in range(10) if i % 2 == 0])",
|
| 340 |
+
options: [
|
| 341 |
+
"[0, 2, 4, 6, 8]",
|
| 342 |
+
"[2, 4, 6, 8]",
|
| 343 |
+
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
|
| 344 |
+
"[1, 3, 5, 7, 9]"
|
| 345 |
+
],
|
| 346 |
+
answer: 0,
|
| 347 |
+
explanation: "This list comprehension generates numbers from 0 to 9, but only includes even numbers (where i % 2 == 0)."
|
| 348 |
+
},
|
| 349 |
+
{
|
| 350 |
+
question: "Which of these is NOT a valid variable name?",
|
| 351 |
+
code: "",
|
| 352 |
+
options: ["_private", "2nd_variable", "variable_name", "camelCase"],
|
| 353 |
+
answer: 1,
|
| 354 |
+
explanation: "Variable names cannot start with a number. They must start with a letter or underscore."
|
| 355 |
+
},
|
| 356 |
+
{
|
| 357 |
+
question: "What is the purpose of the 'pass' statement?",
|
| 358 |
+
code: "",
|
| 359 |
+
options: [
|
| 360 |
+
"To terminate the program",
|
| 361 |
+
"To skip the current iteration in a loop",
|
| 362 |
+
"As a placeholder where syntax requires a statement",
|
| 363 |
+
"To pass arguments to a function"
|
| 364 |
+
],
|
| 365 |
+
answer: 2,
|
| 366 |
+
explanation: "The pass statement is a null operation - it does nothing. It's used when a statement is required syntactically but no action is needed."
|
| 367 |
+
}
|
| 368 |
+
];
|
| 369 |
+
|
| 370 |
+
// DOM Elements
|
| 371 |
+
const quizContainer = document.getElementById('quizContainer');
|
| 372 |
+
const resultsContainer = document.getElementById('resultsContainer');
|
| 373 |
+
const generateBtn = document.getElementById('generateBtn');
|
| 374 |
+
const questionText = document.getElementById('questionText');
|
| 375 |
+
const questionCode = document.getElementById('questionCode');
|
| 376 |
+
const optionElements = document.querySelectorAll('.option-card');
|
| 377 |
+
const optionTexts = document.querySelectorAll('.option-text');
|
| 378 |
+
const explanation = document.getElementById('explanation');
|
| 379 |
+
const explanationText = document.getElementById('explanationText');
|
| 380 |
+
const currentQuestionEl = document.getElementById('currentQuestion');
|
| 381 |
+
const totalQuestionsEl = document.getElementById('totalQuestions');
|
| 382 |
+
const scoreEl = document.getElementById('score');
|
| 383 |
+
const progressBar = document.getElementById('progressBar');
|
| 384 |
+
const prevBtn = document.getElementById('prevBtn');
|
| 385 |
+
const nextBtn = document.getElementById('nextBtn');
|
| 386 |
+
const finalScore = document.getElementById('finalScore');
|
| 387 |
+
const finalTotal = document.getElementById('finalTotal');
|
| 388 |
+
const resultMessage = document.getElementById('resultMessage');
|
| 389 |
+
const restartBtn = document.getElementById('restartBtn');
|
| 390 |
+
const newQuizBtn = document.getElementById('newQuizBtn');
|
| 391 |
+
|
| 392 |
+
// Quiz state
|
| 393 |
+
let currentQuestionIndex = 0;
|
| 394 |
+
let score = 0;
|
| 395 |
+
let userAnswers = [];
|
| 396 |
+
let quizQuestions = [];
|
| 397 |
+
|
| 398 |
+
// Initialize
|
| 399 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 400 |
+
generateBtn.addEventListener('click', startQuiz);
|
| 401 |
+
optionElements.forEach((option, index) => {
|
| 402 |
+
option.addEventListener('click', () => selectAnswer(index));
|
| 403 |
+
});
|
| 404 |
+
nextBtn.addEventListener('click', nextQuestion);
|
| 405 |
+
prevBtn.addEventListener('click', prevQuestion);
|
| 406 |
+
restartBtn.addEventListener('click', restartQuiz);
|
| 407 |
+
newQuizBtn.addEventListener('click', () => {
|
| 408 |
+
resultsContainer.classList.add('hidden');
|
| 409 |
+
document.querySelector('.container').classList.remove('hidden');
|
| 410 |
+
});
|
| 411 |
+
});
|
| 412 |
+
|
| 413 |
+
// Start quiz
|
| 414 |
+
function startQuiz() {
|
| 415 |
+
const questionCount = parseInt(document.getElementById('questionCount').value);
|
| 416 |
+
const difficulty = document.getElementById('difficulty').value;
|
| 417 |
+
|
| 418 |
+
// Select random questions based on count
|
| 419 |
+
quizQuestions = [...questions].sort(() => 0.5 - Math.random()).slice(0, questionCount);
|
| 420 |
+
|
| 421 |
+
// Reset state
|
| 422 |
+
currentQuestionIndex = 0;
|
| 423 |
+
score = 0;
|
| 424 |
+
userAnswers = [];
|
| 425 |
+
|
| 426 |
+
// Update UI
|
| 427 |
+
quizContainer.classList.remove('hidden');
|
| 428 |
+
document.querySelector('.container > div:nth-child(2)').classList.add('hidden'); // Hide settings
|
| 429 |
+
totalQuestionsEl.textContent = quizQuestions.length;
|
| 430 |
+
scoreEl.textContent = score;
|
| 431 |
+
updateQuestion();
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
// Update question display
|
| 435 |
+
function updateQuestion() {
|
| 436 |
+
const question = quizQuestions[currentQuestionIndex];
|
| 437 |
+
|
| 438 |
+
questionText.textContent = question.question;
|
| 439 |
+
questionCode.textContent = question.code || "";
|
| 440 |
+
questionCode.parentElement.style.display = question.code ? "block" : "none";
|
| 441 |
+
|
| 442 |
+
optionTexts.forEach((option, index) => {
|
| 443 |
+
option.textContent = question.options[index];
|
| 444 |
+
});
|
| 445 |
+
|
| 446 |
+
currentQuestionEl.textContent = currentQuestionIndex + 1;
|
| 447 |
+
scoreEl.textContent = score;
|
| 448 |
+
progressBar.style.width = `${((currentQuestionIndex + 1) / quizQuestions.length) * 100}%`;
|
| 449 |
+
|
| 450 |
+
// Reset option styles
|
| 451 |
+
optionElements.forEach(option => {
|
| 452 |
+
option.classList.remove('correct-answer', 'incorrect-answer');
|
| 453 |
+
option.style.pointerEvents = 'auto';
|
| 454 |
+
});
|
| 455 |
+
|
| 456 |
+
explanation.classList.add('hidden');
|
| 457 |
+
prevBtn.disabled = currentQuestionIndex === 0;
|
| 458 |
+
|
| 459 |
+
// Hide next button until answer is selected
|
| 460 |
+
nextBtn.classList.add('hidden');
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
// Handle answer selection
|
| 464 |
+
function selectAnswer(selectedIndex) {
|
| 465 |
+
const question = quizQuestions[currentQuestionIndex];
|
| 466 |
+
const correctIndex = question.answer;
|
| 467 |
+
|
| 468 |
+
// Only allow one selection
|
| 469 |
+
if (userAnswers[currentQuestionIndex] !== undefined) return;
|
| 470 |
+
|
| 471 |
+
// Disable further selections
|
| 472 |
+
optionElements.forEach(option => {
|
| 473 |
+
option.style.pointerEvents = 'none';
|
| 474 |
+
});
|
| 475 |
+
|
| 476 |
+
// Mark correct answer
|
| 477 |
+
optionElements[correctIndex].classList.add('correct-answer');
|
| 478 |
+
|
| 479 |
+
// Store user answer
|
| 480 |
+
userAnswers[currentQuestionIndex] = selectedIndex;
|
| 481 |
+
|
| 482 |
+
// Check if answer is correct
|
| 483 |
+
if (selectedIndex === correctIndex) {
|
| 484 |
+
score++;
|
| 485 |
+
scoreEl.textContent = score;
|
| 486 |
+
} else {
|
| 487 |
+
// Mark incorrect answer
|
| 488 |
+
optionElements[selectedIndex].classList.add('incorrect-answer');
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
// Show explanation
|
| 492 |
+
explanationText.textContent = question.explanation;
|
| 493 |
+
explanation.classList.remove('hidden');
|
| 494 |
+
|
| 495 |
+
// Show next button if not last question
|
| 496 |
+
if (currentQuestionIndex < quizQuestions.length - 1) {
|
| 497 |
+
nextBtn.classList.remove('hidden');
|
| 498 |
+
} else {
|
| 499 |
+
nextBtn.textContent = "Finish Quiz";
|
| 500 |
+
nextBtn.classList.remove('hidden');
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
// Navigate to next question
|
| 505 |
+
function nextQuestion() {
|
| 506 |
+
if (currentQuestionIndex < quizQuestions.length - 1) {
|
| 507 |
+
currentQuestionIndex++;
|
| 508 |
+
updateQuestion();
|
| 509 |
+
} else {
|
| 510 |
+
// Only show results if all questions answered
|
| 511 |
+
if (userAnswers.length === quizQuestions.length) {
|
| 512 |
+
showResults();
|
| 513 |
+
}
|
| 514 |
+
}
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
// Navigate to previous question
|
| 518 |
+
function prevQuestion() {
|
| 519 |
+
if (currentQuestionIndex > 0) {
|
| 520 |
+
currentQuestionIndex--;
|
| 521 |
+
updateQuestion();
|
| 522 |
+
|
| 523 |
+
// Reapply answer state if already answered
|
| 524 |
+
if (userAnswers[currentQuestionIndex] !== undefined) {
|
| 525 |
+
const question = quizQuestions[currentQuestionIndex];
|
| 526 |
+
const correctIndex = question.answer;
|
| 527 |
+
const userAnswer = userAnswers[currentQuestionIndex];
|
| 528 |
+
|
| 529 |
+
optionElements.forEach(option => {
|
| 530 |
+
option.style.pointerEvents = 'none';
|
| 531 |
+
});
|
| 532 |
+
|
| 533 |
+
optionElements[correctIndex].classList.add('correct-answer');
|
| 534 |
+
|
| 535 |
+
if (userAnswer !== correctIndex) {
|
| 536 |
+
optionElements[userAnswer].classList.add('incorrect-answer');
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
explanationText.textContent = question.explanation;
|
| 540 |
+
explanation.classList.remove('hidden');
|
| 541 |
+
nextBtn.classList.remove('hidden');
|
| 542 |
+
}
|
| 543 |
+
}
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
// Show results
|
| 547 |
+
function showResults() {
|
| 548 |
+
quizContainer.classList.add('hidden');
|
| 549 |
+
resultsContainer.classList.remove('hidden');
|
| 550 |
+
|
| 551 |
+
finalScore.textContent = score;
|
| 552 |
+
finalTotal.textContent = quizQuestions.length;
|
| 553 |
+
|
| 554 |
+
// Custom message based on score
|
| 555 |
+
const percentage = (score / quizQuestions.length) * 100;
|
| 556 |
+
if (percentage >= 90) {
|
| 557 |
+
resultMessage.textContent = "Python Master! Your skills are exceptional.";
|
| 558 |
+
} else if (percentage >= 70) {
|
| 559 |
+
resultMessage.textContent = "Great job! You have a strong understanding of Python.";
|
| 560 |
+
} else if (percentage >= 50) {
|
| 561 |
+
resultMessage.textContent = "Good effort! Keep practicing to improve your skills.";
|
| 562 |
+
} else {
|
| 563 |
+
resultMessage.textContent = "Keep learning! Review the basics and try again.";
|
| 564 |
+
}
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
// Restart quiz
|
| 568 |
+
function restartQuiz() {
|
| 569 |
+
resultsContainer.classList.add('hidden');
|
| 570 |
+
quizContainer.classList.remove('hidden');
|
| 571 |
+
document.querySelector('.container > div:nth-child(2)').classList.remove('hidden');
|
| 572 |
+
|
| 573 |
+
// Reset to first question
|
| 574 |
+
currentQuestionIndex = 0;
|
| 575 |
+
score = 0;
|
| 576 |
+
userAnswers = [];
|
| 577 |
+
|
| 578 |
+
updateQuestion();
|
| 579 |
+
nextBtn.textContent = "Next";
|
| 580 |
+
}
|
| 581 |
+
</script>
|
| 582 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=casv/pythonquizgenerator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 583 |
+
</html>
|