Batzuul commited on
Commit
47c51a3
·
verified ·
1 Parent(s): be1050b

3-р ангийн сурагчдад зориулсан математик хичээлийн бүх агуулгыг багтаасан интерактив дасгалын веб хөтөч бүтээж өгнө үү - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +1026 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Math 3 Class
3
- emoji: 🔥
4
- colorFrom: purple
5
- colorTo: indigo
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: math-3-class
3
+ emoji: 🐳
4
+ colorFrom: gray
5
+ colorTo: purple
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,1026 @@
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>3-р ангийн математик | Интерактив дасгал</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
+ <style>
10
+ @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap');
11
+ body {
12
+ font-family: 'Montserrat', sans-serif;
13
+ background-color: #f0f9ff;
14
+ }
15
+ .progress-ring__circle {
16
+ transition: stroke-dashoffset 0.35s;
17
+ transform: rotate(-90deg);
18
+ transform-origin: 50% 50%;
19
+ }
20
+ .floating {
21
+ animation: floating 3s ease-in-out infinite;
22
+ }
23
+ @keyframes floating {
24
+ 0% { transform: translateY(0px); }
25
+ 50% { transform: translateY(-10px); }
26
+ 100% { transform: translateY(0px); }
27
+ }
28
+ .bounce {
29
+ animation: bounce 1s infinite;
30
+ }
31
+ @keyframes bounce {
32
+ 0%, 100% { transform: translateY(0); }
33
+ 50% { transform: translateY(-10px); }
34
+ }
35
+ </style>
36
+ </head>
37
+ <body class="min-h-screen">
38
+ <!-- Header -->
39
+ <header class="bg-blue-600 text-white shadow-lg">
40
+ <div class="container mx-auto px-4 py-6">
41
+ <div class="flex justify-between items-center">
42
+ <div class="flex items-center space-x-2">
43
+ <i class="fas fa-calculator text-3xl"></i>
44
+ <h1 class="text-2xl font-bold">3-р ангийн математик</h1>
45
+ </div>
46
+ <div class="flex items-center space-x-4">
47
+ <div id="score-display" class="flex items-center bg-blue-500 px-3 py-1 rounded-full">
48
+ <i class="fas fa-star text-yellow-300 mr-1"></i>
49
+ <span id="score">0</span>
50
+ </div>
51
+ <button id="sound-btn" class="p-2 rounded-full bg-blue-500 hover:bg-blue-700 transition">
52
+ <i class="fas fa-volume-up"></i>
53
+ </button>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </header>
58
+
59
+ <!-- Main Content -->
60
+ <main class="container mx-auto px-4 py-8">
61
+ <!-- Welcome Section -->
62
+ <section id="welcome-section" class="text-center mb-12">
63
+ <div class="max-w-3xl mx-auto">
64
+ <div class="floating inline-block mb-6">
65
+ <img src="https://img.icons8.com/color/96/000000/math.png" alt="Math Icon" class="w-24 h-24">
66
+ </div>
67
+ <h2 class="text-3xl font-bold text-blue-800 mb-4">Математикийн дугуйланд тавтай морил!</h2>
68
+ <p class="text-lg text-gray-700 mb-6">3-р ангийн математикийн бүх сэдвээр дасгал хийж, чадвараа сайжруулна уу!</p>
69
+ <button id="start-btn" class="bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-8 rounded-full text-lg shadow-lg transition transform hover:scale-105">
70
+ Эхлэх <i class="fas fa-arrow-right ml-2"></i>
71
+ </button>
72
+ </div>
73
+ </section>
74
+
75
+ <!-- Topic Selection -->
76
+ <section id="topic-section" class="hidden mb-12">
77
+ <h2 class="text-2xl font-bold text-center text-blue-800 mb-8">Сэдвээр сонгох</h2>
78
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
79
+ <!-- Topic Cards -->
80
+ <div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="addition">
81
+ <div class="p-6">
82
+ <div class="flex items-center mb-4">
83
+ <div class="bg-blue-100 p-3 rounded-full mr-4">
84
+ <i class="fas fa-plus text-blue-600 text-xl"></i>
85
+ </div>
86
+ <h3 class="text-xl font-bold text-gray-800">Нэмэх үйлдэл</h3>
87
+ </div>
88
+ <p class="text-gray-600">2-3 оронтой тоонуудын нэмэх үйлдэл</p>
89
+ </div>
90
+ </div>
91
+
92
+ <div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="subtraction">
93
+ <div class="p-6">
94
+ <div class="flex items-center mb-4">
95
+ <div class="bg-red-100 p-3 rounded-full mr-4">
96
+ <i class="fas fa-minus text-red-600 text-xl"></i>
97
+ </div>
98
+ <h3 class="text-xl font-bold text-gray-800">Хасах үйлдэл</h3>
99
+ </div>
100
+ <p class="text-gray-600">2-3 оронтой тоонуудын хасах үйлдэл</p>
101
+ </div>
102
+ </div>
103
+
104
+ <div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="multiplication">
105
+ <div class="p-6">
106
+ <div class="flex items-center mb-4">
107
+ <div class="bg-yellow-100 p-3 rounded-full mr-4">
108
+ <i class="fas fa-times text-yellow-600 text-xl"></i>
109
+ </div>
110
+ <h3 class="text-xl font-bold text-gray-800">Үржүүлэх үйлдэл</h3>
111
+ </div>
112
+ <p class="text-gray-600">1-2 оронтой тоонуудын үржүүлэх</p>
113
+ </div>
114
+ </div>
115
+
116
+ <div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="division">
117
+ <div class="p-6">
118
+ <div class="flex items-center mb-4">
119
+ <div class="bg-purple-100 p-3 rounded-full mr-4">
120
+ <i class="fas fa-divide text-purple-600 text-xl"></i>
121
+ </div>
122
+ <h3 class="text-xl font-bold text-gray-800">Хуваах үйлдэл</h3>
123
+ </div>
124
+ <p class="text-gray-600">2 оронтой тоог 1 оронтой тоонд хуваах</p>
125
+ </div>
126
+ </div>
127
+
128
+ <div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="fractions">
129
+ <div class="p-6">
130
+ <div class="flex items-center mb-4">
131
+ <div class="bg-pink-100 p-3 rounded-full mr-4">
132
+ <i class="fas fa-superscript text-pink-600 text-xl"></i>
133
+ </div>
134
+ <h3 class="text-xl font-bold text-gray-800">Бутархай тоо</h3>
135
+ </div>
136
+ <p class="text-gray-600">Энгийн бутархай тоонуудын үйлдэл</p>
137
+ </div>
138
+ </div>
139
+
140
+ <div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="geometry">
141
+ <div class="p-6">
142
+ <div class="flex items-center mb-4">
143
+ <div class="bg-green-100 p-3 rounded-full mr-4">
144
+ <i class="fas fa-shapes text-green-600 text-xl"></i>
145
+ </div>
146
+ <h3 class="text-xl font-bold text-gray-800">Геометр</h3>
147
+ </div>
148
+ <p class="text-gray-600">Дүрсүүдийн талаарх мэдлэг</p>
149
+ </div>
150
+ </div>
151
+ </div>
152
+ </section>
153
+
154
+ <!-- Difficulty Selection -->
155
+ <section id="difficulty-section" class="hidden mb-12">
156
+ <h2 class="text-2xl font-bold text-center text-blue-800 mb-8">Хэмжээ сонгох</h2>
157
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6 max-w-4xl mx-auto">
158
+ <div class="difficulty-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer p-6 text-center" data-difficulty="easy">
159
+ <div class="bg-green-100 p-4 rounded-full inline-block mb-4">
160
+ <i class="fas fa-smile text-green-600 text-3xl"></i>
161
+ </div>
162
+ <h3 class="text-xl font-bold text-gray-800 mb-2">Амархан</h3>
163
+ <p class="text-gray-600">Энгийн дасгалууд</p>
164
+ </div>
165
+
166
+ <div class="difficulty-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer p-6 text-center" data-difficulty="medium">
167
+ <div class="bg-yellow-100 p-4 rounded-full inline-block mb-4">
168
+ <i class="fas fa-meh text-yellow-600 text-3xl"></i>
169
+ </div>
170
+ <h3 class="text-xl font-bold text-gray-800 mb-2">Дунд зэрэг</h3>
171
+ <p class="text-gray-600">Дунд зэргийн дасгалууд</p>
172
+ </div>
173
+
174
+ <div class="difficulty-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer p-6 text-center" data-difficulty="hard">
175
+ <div class="bg-red-100 p-4 rounded-full inline-block mb-4">
176
+ <i class="fas fa-frown text-red-600 text-3xl"></i>
177
+ </div>
178
+ <h3 class="text-xl font-bold text-gray-800 mb-2">Хэцүү</h3>
179
+ <p class="text-gray-600">Хэцүү дасгалууд</p>
180
+ </div>
181
+ </div>
182
+ </section>
183
+
184
+ <!-- Quiz Section -->
185
+ <section id="quiz-section" class="hidden">
186
+ <div class="max-w-3xl mx-auto bg-white rounded-xl shadow-lg overflow-hidden">
187
+ <!-- Progress Bar -->
188
+ <div class="bg-gray-200 h-2">
189
+ <div id="progress-bar" class="bg-blue-600 h-2 transition-all duration-300" style="width: 0%"></div>
190
+ </div>
191
+
192
+ <div class="p-6 md:p-8">
193
+ <!-- Question Counter -->
194
+ <div class="flex justify-between items-center mb-6">
195
+ <div class="flex items-center">
196
+ <span id="question-counter" class="font-bold text-blue-600">1/10</span>
197
+ </div>
198
+ <div class="flex items-center space-x-2">
199
+ <div class="relative w-12 h-12">
200
+ <svg class="w-full h-full" viewBox="0 0 36 36">
201
+ <circle cx="18" cy="18" r="16" fill="none" class="stroke-gray-200" stroke-width="2"></circle>
202
+ <circle id="timer-circle" cx="18" cy="18" r="16" fill="none" class="stroke-blue-600 progress-ring__circle" stroke-width="2" stroke-dasharray="100" stroke-dashoffset="0"></circle>
203
+ </svg>
204
+ <span id="timer" class="absolute inset-0 flex items-center justify-center text-sm font-bold">30</span>
205
+ </div>
206
+ </div>
207
+ </div>
208
+
209
+ <!-- Question -->
210
+ <div id="question-container" class="mb-8">
211
+ <h3 id="question" class="text-xl font-bold text-gray-800 mb-4"></h3>
212
+
213
+ <!-- For normal questions -->
214
+ <div id="options-container" class="grid grid-cols-1 md:grid-cols-2 gap-3"></div>
215
+
216
+ <!-- For input questions -->
217
+ <div id="input-container" class="hidden mt-4">
218
+ <input type="number" id="answer-input" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Хариултаа оруулна уу...">
219
+ <button id="submit-answer" class="mt-3 bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-lg transition">
220
+ Илгээх <i class="fas fa-paper-plane ml-1"></i>
221
+ </button>
222
+ </div>
223
+ </div>
224
+
225
+ <!-- Feedback -->
226
+ <div id="feedback-container" class="hidden p-4 rounded-lg mb-6">
227
+ <div class="flex items-start">
228
+ <i id="feedback-icon" class="text-2xl mt-1 mr-3"></i>
229
+ <div>
230
+ <h4 id="feedback-title" class="font-bold"></h4>
231
+ <p id="feedback-message" class="text-sm"></p>
232
+ </div>
233
+ </div>
234
+ </div>
235
+
236
+ <!-- Navigation -->
237
+ <div class="flex justify-between">
238
+ <button id="back-btn" class="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-lg transition hidden">
239
+ <i class="fas fa-arrow-left mr-2"></i> Буцах
240
+ </button>
241
+ <button id="next-btn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-lg transition ml-auto">
242
+ Дараах <i class="fas fa-arrow-right ml-2"></i>
243
+ </button>
244
+ </div>
245
+ </div>
246
+ </div>
247
+ </section>
248
+
249
+ <!-- Results Section -->
250
+ <section id="results-section" class="hidden max-w-3xl mx-auto text-center">
251
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden p-8">
252
+ <div class="mb-6">
253
+ <div class="relative w-32 h-32 mx-auto mb-6">
254
+ <svg class="w-full h-full" viewBox="0 0 36 36">
255
+ <circle cx="18" cy="18" r="16" fill="none" class="stroke-gray-200" stroke-width="2"></circle>
256
+ <circle id="result-circle" cx="18" cy="18" r="16" fill="none" class="stroke-green-500 progress-ring__circle" stroke-width="2" stroke-dasharray="100" stroke-dashoffset="0"></circle>
257
+ </svg>
258
+ <span id="result-percent" class="absolute inset-0 flex items-center justify-center text-2xl font-bold">0%</span>
259
+ </div>
260
+ <h2 class="text-3xl font-bold text-gray-800 mb-2" id="result-title">Сайн байна!</h2>
261
+ <p class="text-gray-600 mb-4" id="result-message">Та <span id="correct-answers">0</span> асуултанд зөв хариулсан!</p>
262
+ <div class="flex justify-center space-x-2 mb-6">
263
+ <div id="star-1" class="text-gray-300 text-2xl"><i class="fas fa-star"></i></div>
264
+ <div id="star-2" class="text-gray-300 text-2xl"><i class="fas fa-star"></i></div>
265
+ <div id="star-3" class="text-gray-300 text-2xl"><i class="fas fa-star"></i></div>
266
+ </div>
267
+ </div>
268
+
269
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-8">
270
+ <div class="bg-blue-50 p-4 rounded-lg">
271
+ <div class="text-blue-600 font-bold text-lg" id="score-earned">0</div>
272
+ <div class="text-gray-600 text-sm">Оноо</div>
273
+ </div>
274
+ <div class="bg-green-50 p-4 rounded-lg">
275
+ <div class="text-green-600 font-bold text-lg" id="time-taken">0с</div>
276
+ <div class="text-gray-600 text-sm">Хугацаа</div>
277
+ </div>
278
+ </div>
279
+
280
+ <div class="flex flex-col space-y-3">
281
+ <button id="restart-btn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded-lg transition">
282
+ Дахь эхлэх <i class="fas fa-redo ml-2"></i>
283
+ </button>
284
+ <button id="new-topic-btn" class="bg-white hover:bg-gray-100 text-blue-600 font-bold py-3 px-6 border border-blue-600 rounded-lg transition">
285
+ Шинэ сэдвээр дасгал хийх <i class="fas fa-book-open ml-2"></i>
286
+ </button>
287
+ </div>
288
+ </div>
289
+ </section>
290
+ </main>
291
+
292
+ <!-- Footer -->
293
+ <footer class="bg-gray-800 text-white py-6">
294
+ <div class="container mx-auto px-4 text-center">
295
+ <p>3-р ангийн математикийн интерактив дасгалууд</p>
296
+ <p class="text-gray-400 text-sm mt-2">© 2023 Боловсролын технологи</p>
297
+ </div>
298
+ </footer>
299
+
300
+ <!-- Confetti Effect -->
301
+ <canvas id="confetti-canvas" class="fixed top-0 left-0 w-full h-full pointer-events-none z-50 hidden"></canvas>
302
+
303
+ <script>
304
+ // App State
305
+ const state = {
306
+ currentScreen: 'welcome',
307
+ selectedTopic: null,
308
+ selectedDifficulty: null,
309
+ questions: [],
310
+ currentQuestionIndex: 0,
311
+ score: 0,
312
+ correctAnswers: 0,
313
+ timer: 30,
314
+ timerInterval: null,
315
+ startTime: null,
316
+ soundEnabled: true,
317
+ topics: {
318
+ addition: {
319
+ title: "Нэмэх үйлдэл",
320
+ icon: "fa-plus",
321
+ color: "blue",
322
+ questions: {
323
+ easy: [
324
+ { question: "25 + 34 = ?", answer: "59", options: ["53", "59", "64", "69"] },
325
+ { question: "47 + 18 = ?", answer: "65", options: ["55", "59", "65", "69"] },
326
+ { question: "63 + 29 = ?", answer: "92", options: ["82", "87", "92", "97"] },
327
+ { question: "56 + 37 = ?", answer: "93", options: ["83", "89", "93", "97"] },
328
+ { question: "78 + 15 = ?", answer: "93", options: ["83", "88", "93", "98"] }
329
+ ],
330
+ medium: [
331
+ { question: "125 + 234 = ?", answer: "359", options: ["349", "359", "369", "379"] },
332
+ { question: "147 + 218 = ?", answer: "365", options: ["355", "365", "375", "385"] },
333
+ { question: "263 + 129 = ?", answer: "392", options: ["382", "387", "392", "397"] },
334
+ { question: "356 + 237 = ?", answer: "593", options: ["583", "589", "593", "597"] },
335
+ { question: "478 + 315 = ?", answer: "793", options: ["783", "788", "793", "798"] }
336
+ ],
337
+ hard: [
338
+ { question: "425 + 334 + 125 = ?", answer: "884", options: ["874", "879", "884", "889"] },
339
+ { question: "547 + 218 + 135 = ?", answer: "900", options: ["890", "895", "900", "905"] },
340
+ { question: "663 + 229 + 178 = ?", answer: "1070", options: ["1060", "1065", "1070", "1075"] },
341
+ { question: "756 + 337 + 289 = ?", answer: "1382", options: ["1372", "1377", "1382", "1387"] },
342
+ { question: "878 + 415 + 326 = ?", answer: "1619", options: ["1609", "1614", "1619", "1624"] }
343
+ ]
344
+ }
345
+ },
346
+ subtraction: {
347
+ title: "Хасах үйлдэл",
348
+ icon: "fa-minus",
349
+ color: "red",
350
+ questions: {
351
+ easy: [
352
+ { question: "45 - 23 = ?", answer: "22", options: ["12", "18", "22", "28"] },
353
+ { question: "67 - 19 = ?", answer: "48", options: ["42", "48", "52", "58"] },
354
+ { question: "83 - 27 = ?", answer: "56", options: ["46", "56", "66", "76"] },
355
+ { question: "95 - 38 = ?", answer: "57", options: ["47", "57", "67", "77"] },
356
+ { question: "72 - 45 = ?", answer: "27", options: ["17", "27", "37", "47"] }
357
+ ],
358
+ medium: [
359
+ { question: "145 - 23 = ?", answer: "122", options: ["112", "118", "122", "128"] },
360
+ { question: "267 - 119 = ?", answer: "148", options: ["142", "148", "152", "158"] },
361
+ { question: "383 - 127 = ?", answer: "256", options: ["246", "256", "266", "276"] },
362
+ { question: "495 - 238 = ?", answer: "257", options: ["247", "257", "267", "277"] },
363
+ { question: "572 - 345 = ?", answer: "227", options: ["217", "227", "237", "247"] }
364
+ ],
365
+ hard: [
366
+ { question: "425 - 134 - 125 = ?", answer: "166", options: ["156", "161", "166", "171"] },
367
+ { question: "547 - 218 - 135 = ?", answer: "194", options: ["184", "189", "194", "199"] },
368
+ { question: "763 - 229 - 178 = ?", answer: "356", options: ["346", "351", "356", "361"] },
369
+ { question: "856 - 337 - 289 = ?", answer: "230", options: ["220", "225", "230", "235"] },
370
+ { question: "978 - 415 - 326 = ?", answer: "237", options: ["227", "232", "237", "242"] }
371
+ ]
372
+ }
373
+ },
374
+ multiplication: {
375
+ title: "Үржүүлэх үйлдэл",
376
+ icon: "fa-times",
377
+ color: "yellow",
378
+ questions: {
379
+ easy: [
380
+ { question: "5 × 7 = ?", answer: "35", options: ["25", "30", "35", "40"] },
381
+ { question: "8 × 6 = ?", answer: "48", options: ["38", "42", "48", "54"] },
382
+ { question: "9 × 4 = ?", answer: "36", options: ["27", "32", "36", "40"] },
383
+ { question: "7 × 9 = ?", answer: "63", options: ["54", "56", "63", "70"] },
384
+ { question: "6 × 8 = ?", answer: "48", options: ["40", "42", "48", "56"] }
385
+ ],
386
+ medium: [
387
+ { question: "12 × 7 = ?", answer: "84", options: ["72", "77", "84", "91"] },
388
+ { question: "15 × 6 = ?", answer: "90", options: ["75", "80", "90", "100"] },
389
+ { question: "11 × 11 = ?", answer: "121", options: ["100", "110", "121", "132"] },
390
+ { question: "13 × 8 = ?", answer: "104", options: ["91", "96", "104", "112"] },
391
+ { question: "14 × 9 = ?", answer: "126", options: ["112", "117", "126", "133"] }
392
+ ],
393
+ hard: [
394
+ { question: "25 × 12 = ?", answer: "300", options: ["250", "275", "300", "325"] },
395
+ { question: "34 × 15 = ?", answer: "510", options: ["450", "480", "510", "540"] },
396
+ { question: "18 × 22 = ?", answer: "396", options: ["360", "378", "396", "414"] },
397
+ { question: "27 × 14 = ?", answer: "378", options: ["350", "364", "378", "392"] },
398
+ { question: "19 × 21 = ?", answer: "399", options: ["361", "380", "399", "418"] }
399
+ ]
400
+ }
401
+ },
402
+ division: {
403
+ title: "Хуваах үйлдэл",
404
+ icon: "fa-divide",
405
+ color: "purple",
406
+ questions: {
407
+ easy: [
408
+ { question: "36 ÷ 6 = ?", answer: "6", options: ["4", "5", "6", "7"] },
409
+ { question: "42 ÷ 7 = ?", answer: "6", options: ["5", "6", "7", "8"] },
410
+ { question: "56 ÷ 8 = ?", answer: "7", options: ["6", "7", "8", "9"] },
411
+ { question: "72 ÷ 9 = ?", answer: "8", options: ["7", "8", "9", "10"] },
412
+ { question: "45 ÷ 5 = ?", answer: "9", options: ["8", "9", "10", "11"] }
413
+ ],
414
+ medium: [
415
+ { question: "144 ÷ 12 = ?", answer: "12", options: ["10", "11", "12", "13"] },
416
+ { question: "169 ÷ 13 = ?", answer: "13", options: ["11", "12", "13", "14"] },
417
+ { question: "196 ÷ 14 = ?", answer: "14", options: ["12", "13", "14", "15"] },
418
+ { question: "225 ÷ 15 = ?", answer: "15", options: ["13", "14", "15", "16"] },
419
+ { question: "256 ÷ 16 = ?", answer: "16", options: ["14", "15", "16", "17"] }
420
+ ],
421
+ hard: [
422
+ { question: "576 ÷ 24 = ?", answer: "24", options: ["22", "23", "24", "25"] },
423
+ { question: "625 ÷ 25 = ?", answer: "25", options: ["23", "24", "25", "26"] },
424
+ { question: "676 ÷ 26 = ?", answer: "26", options: ["24", "25", "26", "27"] },
425
+ { question: "729 ÷ 27 = ?", answer: "27", options: ["25", "26", "27", "28"] },
426
+ { question: "784 ÷ 28 = ?", answer: "28", options: ["26", "27", "28", "29"] }
427
+ ]
428
+ }
429
+ },
430
+ fractions: {
431
+ title: "Бутархай тоо",
432
+ icon: "fa-superscript",
433
+ color: "pink",
434
+ questions: {
435
+ easy: [
436
+ { question: "1/2 + 1/4 = ?", answer: "3/4", options: ["1/4", "1/2", "3/4", "1"] },
437
+ { question: "3/4 - 1/4 = ?", answer: "1/2", options: ["1/4", "1/2", "3/4", "1"] },
438
+ { question: "1/3 + 1/3 = ?", answer: "2/3", options: ["1/3", "1/2", "2/3", "3/4"] },
439
+ { question: "5/6 - 1/6 = ?", answer: "2/3", options: ["1/3", "1/2", "2/3", "3/4"] },
440
+ { question: "1/2 × 1/2 = ?", answer: "1/4", options: ["1/8", "1/4", "1/2", "3/4"] }
441
+ ],
442
+ medium: [
443
+ { question: "2/3 + 3/4 = ?", answer: "17/12", options: ["5/7", "11/12", "17/12", "5/4"] },
444
+ { question: "5/6 - 2/3 = ?", answer: "1/6", options: ["1/6", "1/3", "1/2", "2/3"] },
445
+ { question: "3/4 × 2/3 = ?", answer: "1/2", options: ["1/4", "1/2", "3/4", "5/6"] },
446
+ { question: "4/5 ÷ 2/5 = ?", answer: "2", options: ["1/2", "1", "2", "4"] },
447
+ { question: "1/2 + 1/3 + 1/6 = ?", answer: "1", options: ["2/3", "5/6", "1", "7/6"] }
448
+ ],
449
+ hard: [
450
+ { question: "3 1/2 + 2 3/4 = ?", answer: "25/4", options: ["21/4", "23/4", "25/4", "27/4"] },
451
+ { question: "4 2/3 - 1 5/6 = ?", answer: "17/6", options: ["13/6", "15/6", "17/6", "19/6"] },
452
+ { question: "2 1/4 × 1 1/3 = ?", answer: "3", options: ["2", "2 1/2", "3", "3 1/2"] },
453
+ { question: "3 3/4 ÷ 1 1/2 = ?", answer: "5/2", options: ["3/2", "2", "5/2", "3"] },
454
+ { question: "1/2 + 2/3 - 1/4 = ?", answer: "11/12", options: ["5/12", "7/12", "11/12", "13/12"] }
455
+ ]
456
+ }
457
+ },
458
+ geometry: {
459
+ title: "Геометр",
460
+ icon: "fa-shapes",
461
+ color: "green",
462
+ questions: {
463
+ easy: [
464
+ { question: "3 талтай дүрсийг юу гэж нэрлэдэг вэ?", answer: "Гурвалжин", options: ["Дөрвөлжин", "Гурвалжин", "Тэгш өнцөгт", "Тойрог"] },
465
+ { question: "4 тэнцүү талтай дүрсийг юу гэж нэрлэдэг вэ?", answer: "Квадрат", options: ["Тэгш өнцөгт", "Ромб", "Квадрат", "Параллелограмм"] },
466
+ { question: "Тойргийн голч нь радиусын хэд дахин урт вэ?", answer: "2", options: ["1", "2", "3", "4"] },
467
+ { question: "90 градусын өнцөгтэй гурвалжинг юу гэж нэрлэдэг вэ?", answer: "Тэгш өнцөгт", options: ["Хурц өнцөгт", "Тэгш өнцөгт", "Мохоо өнцөгт", "Тэгш талт"] },
468
+ { question: "5 талтай олон өнцөгтийг юу гэж нэрлэдэг вэ?", answer: "Пентагон", options: ["Тетрагон", "Пентагон", "Гексагон", "Хептагон"] }
469
+ ],
470
+ medium: [
471
+ { question: "Куб хэдэн ирмэгтэй вэ?", answer: "12", options: ["6", "8", "12", "16"] },
472
+ { question: "Тэгш өнцөгт призмийн эзлэхүүнийг хэрхэн олдог вэ?", answer: "Урт × Өргөн × Өндөр", options: ["Урт + Өргөн + Өндөр", "Урт × Өргөн", "Урт × Өргөн × Өндөр", "Урт × Өндөр"] },
473
+ { question: "360 градусын өнцөгтэй дүрсийг юу гэж нэрлэдэг вэ?", answer: "Тойрог", options: ["Гурвалжин", "Дөрвөлжин", "Тэгш өнцөгт", "Тойрог"] },
474
+ { question: "Параллелограммын эсрэг талууд ямар байдаг вэ?", answer: "Зэрэгцээ ба тэнцүү", options: ["Зөвхөн тэнцүү", "Зөвхөн зэрэгцээ", "Зэрэгцээ ба тэнцүү", "Янз бүр"] },
475
+ { question: "Гурвалжны дотоод өнцгүүдийн нийлбэр хэд вэ?", answer: "180°", options: ["90°", "120°", "180°", "360°"] }
476
+ ],
477
+ hard: [
478
+ { question: "Ижил суурьтай, ижил өндөртэй пирамид ба призмийн эзлэхүүний харьцаа хэд вэ?", answer: "1:3", options: ["1:1", "1:2", "1:3", "2:3"] },
479
+ { question: "Тойргийн талбайг πr² томъёогоор олдог бол тойргийн тойргийн уртыг ямар томъёогоор олдог вэ?", answer: "2πr", options: ["πr", "2πr", "πr²", "4πr"] },
480
+ { question: "Тетраэдр хэдэн нүүртэй вэ?", answer: "4", options: ["3", "4", "5", "6"] },
481
+ { question: "Координатын хавтгайд (3,4) ба (7,1) цэгүүдийн хоорондох зайг ол.", answer: "5", options: ["3", "4", "5", "6"] },
482
+ { question: "Тэгш талт гурвалжны өндөр нь 6√3 бол талын урт хэд вэ?", answer: "12", options: ["6", "8", "10", "12"] }
483
+ ]
484
+ }
485
+ }
486
+ }
487
+ };
488
+
489
+ // DOM Elements
490
+ const elements = {
491
+ welcomeSection: document.getElementById('welcome-section'),
492
+ topicSection: document.getElementById('topic-section'),
493
+ difficultySection: document.getElementById('difficulty-section'),
494
+ quizSection: document.getElementById('quiz-section'),
495
+ resultsSection: document.getElementById('results-section'),
496
+ startBtn: document.getElementById('start-btn'),
497
+ topicCards: document.querySelectorAll('.topic-card'),
498
+ difficultyCards: document.querySelectorAll('.difficulty-card'),
499
+ questionContainer: document.getElementById('question-container'),
500
+ question: document.getElementById('question'),
501
+ optionsContainer: document.getElementById('options-container'),
502
+ inputContainer: document.getElementById('input-container'),
503
+ answerInput: document.getElementById('answer-input'),
504
+ submitAnswer: document.getElementById('submit-answer'),
505
+ feedbackContainer: document.getElementById('feedback-container'),
506
+ feedbackIcon: document.getElementById('feedback-icon'),
507
+ feedbackTitle: document.getElementById('feedback-title'),
508
+ feedbackMessage: document.getElementById('feedback-message'),
509
+ backBtn: document.getElementById('back-btn'),
510
+ nextBtn: document.getElementById('next-btn'),
511
+ progressBar: document.getElementById('progress-bar'),
512
+ questionCounter: document.getElementById('question-counter'),
513
+ timerCircle: document.getElementById('timer-circle'),
514
+ timer: document.getElementById('timer'),
515
+ resultCircle: document.getElementById('result-circle'),
516
+ resultPercent: document.getElementById('result-percent'),
517
+ resultTitle: document.getElementById('result-title'),
518
+ resultMessage: document.getElementById('result-message'),
519
+ correctAnswers: document.getElementById('correct-answers'),
520
+ scoreEarned: document.getElementById('score-earned'),
521
+ timeTaken: document.getElementById('time-taken'),
522
+ restartBtn: document.getElementById('restart-btn'),
523
+ newTopicBtn: document.getElementById('new-topic-btn'),
524
+ scoreDisplay: document.getElementById('score'),
525
+ soundBtn: document.getElementById('sound-btn'),
526
+ confettiCanvas: document.getElementById('confetti-canvas'),
527
+ star1: document.getElementById('star-1'),
528
+ star2: document.getElementById('star-2'),
529
+ star3: document.getElementById('star-3')
530
+ };
531
+
532
+ // Event Listeners
533
+ elements.startBtn.addEventListener('click', showTopicSelection);
534
+ elements.topicCards.forEach(card => {
535
+ card.addEventListener('click', () => selectTopic(card.dataset.topic));
536
+ });
537
+ elements.difficultyCards.forEach(card => {
538
+ card.addEventListener('click', () => selectDifficulty(card.dataset.difficulty));
539
+ });
540
+ elements.backBtn.addEventListener('click', goToPreviousQuestion);
541
+ elements.nextBtn.addEventListener('click', goToNextQuestion);
542
+ elements.submitAnswer.addEventListener('click', checkInputAnswer);
543
+ elements.answerInput.addEventListener('keypress', (e) => {
544
+ if (e.key === 'Enter') checkInputAnswer();
545
+ });
546
+ elements.restartBtn.addEventListener('click', restartQuiz);
547
+ elements.newTopicBtn.addEventListener('click', startNewTopic);
548
+ elements.soundBtn.addEventListener('click', toggleSound);
549
+
550
+ // Initialize
551
+ function init() {
552
+ updateScreen('welcome');
553
+ updateScoreDisplay();
554
+ }
555
+
556
+ // Screen Management
557
+ function updateScreen(screen) {
558
+ state.currentScreen = screen;
559
+ elements.welcomeSection.classList.add('hidden');
560
+ elements.topicSection.classList.add('hidden');
561
+ elements.difficultySection.classList.add('hidden');
562
+ elements.quizSection.classList.add('hidden');
563
+ elements.resultsSection.classList.add('hidden');
564
+
565
+ if (screen === 'welcome') {
566
+ elements.welcomeSection.classList.remove('hidden');
567
+ } else if (screen === 'topic') {
568
+ elements.topicSection.classList.remove('hidden');
569
+ } else if (screen === 'difficulty') {
570
+ elements.difficultySection.classList.remove('hidden');
571
+ } else if (screen === 'quiz') {
572
+ elements.quizSection.classList.remove('hidden');
573
+ startQuiz();
574
+ } else if (screen === 'results') {
575
+ elements.resultsSection.classList.remove('hidden');
576
+ showResults();
577
+ }
578
+ }
579
+
580
+ function showTopicSelection() {
581
+ updateScreen('topic');
582
+ }
583
+
584
+ function selectTopic(topic) {
585
+ state.selectedTopic = topic;
586
+ updateScreen('difficulty');
587
+ }
588
+
589
+ function selectDifficulty(difficulty) {
590
+ state.selectedDifficulty = difficulty;
591
+ state.questions = state.topics[state.selectedTopic].questions[state.selectedDifficulty];
592
+ updateScreen('quiz');
593
+ }
594
+
595
+ // Quiz Functions
596
+ function startQuiz() {
597
+ state.currentQuestionIndex = 0;
598
+ state.correctAnswers = 0;
599
+ state.startTime = new Date();
600
+ loadQuestion();
601
+ startTimer();
602
+ }
603
+
604
+ function loadQuestion() {
605
+ const currentQuestion = state.questions[state.currentQuestionIndex];
606
+
607
+ // Update progress
608
+ const progress = ((state.currentQuestionIndex) / state.questions.length) * 100;
609
+ elements.progressBar.style.width = `${progress}%`;
610
+ elements.questionCounter.textContent = `${state.currentQuestionIndex + 1}/${state.questions.length}`;
611
+
612
+ // Show/hide navigation buttons
613
+ elements.backBtn.classList.toggle('hidden', state.currentQuestionIndex === 0);
614
+ elements.nextBtn.textContent = state.currentQuestionIndex === state.questions.length - 1 ? 'Дуусгах' : 'Дараах';
615
+
616
+ // Set question
617
+ elements.question.textContent = currentQuestion.question;
618
+
619
+ // Clear previous feedback
620
+ elements.feedbackContainer.classList.add('hidden');
621
+
622
+ // Check question type and display appropriately
623
+ if (currentQuestion.options) {
624
+ // Multiple choice question
625
+ elements.optionsContainer.classList.remove('hidden');
626
+ elements.inputContainer.classList.add('hidden');
627
+
628
+ // Clear previous options
629
+ elements.optionsContainer.innerHTML = '';
630
+
631
+ // Add new options
632
+ currentQuestion.options.forEach((option, index) => {
633
+ const optionElement = document.createElement('button');
634
+ optionElement.className = 'bg-white hover:bg-gray-100 border border-gray-300 text-gray-800 font-medium py-3 px-4 rounded-lg transition';
635
+ optionElement.textContent = option;
636
+ optionElement.dataset.answer = option;
637
+ optionElement.addEventListener('click', () => selectAnswer(option));
638
+ elements.optionsContainer.appendChild(optionElement);
639
+ });
640
+ } else {
641
+ // Input answer question
642
+ elements.optionsContainer.classList.add('hidden');
643
+ elements.inputContainer.classList.remove('hidden');
644
+ elements.answerInput.value = '';
645
+ elements.answerInput.focus();
646
+ }
647
+ }
648
+
649
+ function selectAnswer(selectedAnswer) {
650
+ const currentQuestion = state.questions[state.currentQuestionIndex];
651
+ const isCorrect = selectedAnswer === currentQuestion.answer;
652
+
653
+ // Disable all options
654
+ const optionButtons = elements.optionsContainer.querySelectorAll('button');
655
+ optionButtons.forEach(button => {
656
+ button.disabled = true;
657
+ if (button.dataset.answer === currentQuestion.answer) {
658
+ button.classList.add('bg-green-100', 'border-green-500');
659
+ } else if (button.dataset.answer === selectedAnswer && !isCorrect) {
660
+ button.classList.add('bg-red-100', 'border-red-500');
661
+ }
662
+ });
663
+
664
+ showFeedback(isCorrect, currentQuestion.answer);
665
+ }
666
+
667
+ function checkInputAnswer() {
668
+ const userAnswer = elements.answerInput.value.trim();
669
+ const currentQuestion = state.questions[state.currentQuestionIndex];
670
+ const isCorrect = userAnswer === currentQuestion.answer;
671
+
672
+ showFeedback(isCorrect, currentQuestion.answer);
673
+ }
674
+
675
+ function showFeedback(isCorrect, correctAnswer) {
676
+ if (isCorrect) {
677
+ state.correctAnswers++;
678
+ state.score += 10 * (state.timer / 5); // More points for faster answers
679
+ updateScoreDisplay();
680
+
681
+ elements.feedbackContainer.className = 'bg-green-100 border border-green-400 text-green-700 p-4 rounded-lg mb-6';
682
+ elements.feedbackIcon.className = 'fas fa-check-circle text-green-500 text-2xl mt-1 mr-3';
683
+ elements.feedbackTitle.textContent = 'Зөв байна!';
684
+ elements.feedbackMessage.textContent = 'Та маш сайн!';
685
+
686
+ playSound('correct');
687
+ } else {
688
+ elements.feedbackContainer.className = 'bg-red-100 border border-red-400 text-red-700 p-4 rounded-lg mb-6';
689
+ elements.feedbackIcon.className = 'fas fa-times-circle text-red-500 text-2xl mt-1 mr-3';
690
+ elements.feedbackTitle.textContent = 'Буруу байна!';
691
+ elements.feedbackMessage.textContent = `Зөв хариулт: ${correctAnswer}`;
692
+
693
+ playSound('wrong');
694
+ }
695
+
696
+ elements.feedbackContainer.classList.remove('hidden');
697
+ stopTimer();
698
+ }
699
+
700
+ function goToPreviousQuestion() {
701
+ if (state.currentQuestionIndex > 0) {
702
+ state.currentQuestionIndex--;
703
+ loadQuestion();
704
+ resetTimer();
705
+ }
706
+ }
707
+
708
+ function goToNextQuestion() {
709
+ if (state.currentQuestionIndex < state.questions.length - 1) {
710
+ state.currentQuestionIndex++;
711
+ loadQuestion();
712
+ resetTimer();
713
+ } else {
714
+ finishQuiz();
715
+ }
716
+ }
717
+
718
+ function finishQuiz() {
719
+ stopTimer();
720
+ updateScreen('results');
721
+ }
722
+
723
+ function showResults() {
724
+ const percentage = Math.round((state.correctAnswers / state.questions.length) * 100);
725
+ const endTime = new Date();
726
+ const timeTaken = Math.floor((endTime - state.startTime) / 1000);
727
+
728
+ // Animate result circle
729
+ const circle = elements.resultCircle;
730
+ const radius = circle.r.baseVal.value;
731
+ const circumference = 2 * Math.PI * radius;
732
+ const offset = circumference - (percentage / 100) * circumference;
733
+
734
+ circle.style.strokeDashoffset = offset;
735
+ circle.style.strokeDasharray = circumference;
736
+
737
+ // Animate percentage counter
738
+ let counter = 0;
739
+ const interval = setInterval(() => {
740
+ if (counter >= percentage) {
741
+ clearInterval(interval);
742
+ } else {
743
+ counter++;
744
+ elements.resultPercent.textContent = `${counter}%`;
745
+ }
746
+ }, 20);
747
+
748
+ // Set result text
749
+ elements.correctAnswers.textContent = state.correctAnswers;
750
+ elements.scoreEarned.textContent = Math.floor(state.score);
751
+ elements.timeTaken.textContent = `${timeTaken}с`;
752
+
753
+ // Set result title based on performance
754
+ if (percentage >= 80) {
755
+ elements.resultTitle.textContent = 'Гайхалтай!';
756
+ elements.resultTitle.className = 'text-3xl font-bold text-green-600 mb-2';
757
+ animateStars();
758
+ triggerConfetti();
759
+ playSound('success');
760
+ } else if (percentage >= 50) {
761
+ elements.resultTitle.textContent = 'Сайн байна!';
762
+ elements.resultTitle.className = 'text-3xl font-bold text-blue-600 mb-2';
763
+ animateStars(2);
764
+ playSound('applause');
765
+ } else {
766
+ elements.resultTitle.textContent = 'Дахиж оролдоно уу!';
767
+ elements.resultTitle.className = 'text-3xl font-bold text-yellow-600 mb-2';
768
+ animateStars(1);
769
+ playSound('try-again');
770
+ }
771
+ }
772
+
773
+ function animateStars(count = 3) {
774
+ elements.star1.classList.remove('text-yellow-300', 'bounce');
775
+ elements.star2.classList.remove('text-yellow-300', 'bounce');
776
+ elements.star3.classList.remove('text-yellow-300', 'bounce');
777
+
778
+ setTimeout(() => {
779
+ if (count >= 1) {
780
+ elements.star1.classList.add('text-yellow-300', 'bounce');
781
+ }
782
+ if (count >= 2) {
783
+ setTimeout(() => {
784
+ elements.star2.classList.add('text-yellow-300', 'bounce');
785
+ }, 200);
786
+ }
787
+ if (count >= 3) {
788
+ setTimeout(() => {
789
+ elements.star3.classList.add('text-yellow-300', 'bounce');
790
+ }, 400);
791
+ }
792
+ }, 100);
793
+ }
794
+
795
+ function triggerConfetti() {
796
+ elements.confettiCanvas.classList.remove('hidden');
797
+ const confettiSettings = {
798
+ target: 'confetti-canvas',
799
+ max: 150,
800
+ size: 1.5,
801
+ animate: true,
802
+ props: ['circle', 'square', 'triangle', 'line'],
803
+ colors: [[255,0,0],[0,255,0],[0,0,255],[255,255,0],[0,255,255],[255,0,255]],
804
+ clock: 25,
805
+ rotate: true,
806
+ start_from_edge: true,
807
+ respawn: true
808
+ };
809
+ const confetti = new ConfettiGenerator(confettiSettings);
810
+ confetti.render();
811
+
812
+ setTimeout(() => {
813
+ confetti.clear();
814
+ elements.confettiCanvas.classList.add('hidden');
815
+ }, 5000);
816
+ }
817
+
818
+ // Timer Functions
819
+ function startTimer() {
820
+ state.timer = 30;
821
+ updateTimerDisplay();
822
+ state.timerInterval = setInterval(() => {
823
+ state.timer--;
824
+ updateTimerDisplay();
825
+
826
+ if (state.timer <= 0) {
827
+ stopTimer();
828
+ showFeedback(false, state.questions[state.currentQuestionIndex].answer);
829
+ }
830
+ }, 1000);
831
+ }
832
+
833
+ function stopTimer() {
834
+ if (state.timerInterval) {
835
+ clearInterval(state.timerInterval);
836
+ state.timerInterval = null;
837
+ }
838
+ }
839
+
840
+ function resetTimer() {
841
+ stopTimer();
842
+ startTimer();
843
+ }
844
+
845
+ function updateTimerDisplay() {
846
+ elements.timer.textContent = state.timer;
847
+
848
+ // Update timer circle
849
+ const percentage = (state.timer / 30) * 100;
850
+ const circle = elements.timerCircle;
851
+ const radius = circle.r.baseVal.value;
852
+ const circumference = 2 * Math.PI * radius;
853
+ const offset = circumference - (percentage / 100) * circumference;
854
+
855
+ circle.style.strokeDashoffset = offset;
856
+ circle.style.strokeDasharray = circumference;
857
+
858
+ // Change color based on time left
859
+ if (state.timer <= 10) {
860
+ circle.classList.remove('stroke-blue-600');
861
+ circle.classList.add('stroke-red-600');
862
+ } else {
863
+ circle.classList.remove('stroke-red-600');
864
+ circle.classList.add('stroke-blue-600');
865
+ }
866
+ }
867
+
868
+ // Score Functions
869
+ function updateScoreDisplay() {
870
+ elements.scoreDisplay.textContent = Math.floor(state.score);
871
+ }
872
+
873
+ // Navigation Functions
874
+ function restartQuiz() {
875
+ state.score = 0;
876
+ updateScoreDisplay();
877
+ updateScreen('quiz');
878
+ }
879
+
880
+ function startNewTopic() {
881
+ updateScreen('topic');
882
+ }
883
+
884
+ // Sound Functions
885
+ function toggleSound() {
886
+ state.soundEnabled = !state.soundEnabled;
887
+ if (state.soundEnabled) {
888
+ elements.soundBtn.innerHTML = '<i class="fas fa-volume-up"></i>';
889
+ playSound('toggle');
890
+ } else {
891
+ elements.soundBtn.innerHTML = '<i class="fas fa-volume-mute"></i>';
892
+ }
893
+ }
894
+
895
+ function playSound(type) {
896
+ if (!state.soundEnabled) return;
897
+
898
+ const audio = new Audio();
899
+ audio.volume = 0.3;
900
+
901
+ switch (type) {
902
+ case 'correct':
903
+ audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-correct-answer-tone-2870.mp3';
904
+ break;
905
+ case 'wrong':
906
+ audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-wrong-answer-fail-notification-946.mp3';
907
+ break;
908
+ case 'success':
909
+ audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-achievement-bell-600.mp3';
910
+ break;
911
+ case 'applause':
912
+ audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-winning-chimes-2015.mp3';
913
+ break;
914
+ case 'try-again':
915
+ audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-retro-arcade-lose-2027.mp3';
916
+ break;
917
+ case 'toggle':
918
+ audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-modern-click-box-check-1120.mp3';
919
+ break;
920
+ default:
921
+ return;
922
+ }
923
+
924
+ audio.play().catch(e => console.log('Audio play failed:', e));
925
+ }
926
+
927
+ // Initialize Confetti Generator class (simplified)
928
+ class ConfettiGenerator {
929
+ constructor(settings) {
930
+ this.settings = settings;
931
+ this.canvas = document.getElementById(settings.target);
932
+ this.ctx = this.canvas.getContext('2d');
933
+ this.particles = [];
934
+ this.animationId = null;
935
+ this.canvas.width = window.innerWidth;
936
+ this.canvas.height = window.innerHeight;
937
+ }
938
+
939
+ render() {
940
+ this.createParticles();
941
+ this.animate();
942
+ }
943
+
944
+ createParticles() {
945
+ for (let i = 0; i < this.settings.max; i++) {
946
+ this.particles.push(this.createParticle());
947
+ }
948
+ }
949
+
950
+ createParticle() {
951
+ const color = this.settings.colors[Math.floor(Math.random() * this.settings.colors.length)];
952
+ return {
953
+ x: Math.random() * this.canvas.width,
954
+ y: this.settings.start_from_edge ? 0 : Math.random() * this.canvas.height,
955
+ r: Math.random() * this.settings.size + 1,
956
+ d: Math.random() * this.settings.max + 1,
957
+ color: `rgb(${color[0]}, ${color[1]}, ${color[2]})`,
958
+ shape: this.settings.props[Math.floor(Math.random() * this.settings.props.length)],
959
+ tilt: Math.floor(Math.random() * 10) - 10,
960
+ tiltAngle: Math.random() * 0.1,
961
+ tiltAngleIncrement: Math.random() * 0.07
962
+ };
963
+ }
964
+
965
+ animate() {
966
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
967
+
968
+ for (let i = 0; i < this.particles.length; i++) {
969
+ const p = this.particles[i];
970
+
971
+ this.ctx.beginPath();
972
+ this.ctx.fillStyle = p.color;
973
+
974
+ switch (p.shape) {
975
+ case 'circle':
976
+ this.ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2, false);
977
+ break;
978
+ case 'square':
979
+ this.ctx.rect(p.x - p.r, p.y - p.r, p.r * 2, p.r * 2);
980
+ break;
981
+ case 'triangle':
982
+ this.ctx.moveTo(p.x, p.y - p.r);
983
+ this.ctx.lineTo(p.x + p.r, p.y + p.r);
984
+ this.ctx.lineTo(p.x - p.r, p.y + p.r);
985
+ break;
986
+ case 'line':
987
+ this.ctx.moveTo(p.x - p.r, p.y);
988
+ this.ctx.lineTo(p.x + p.r, p.y);
989
+ this.ctx.lineWidth = 2;
990
+ break;
991
+ }
992
+
993
+ this.ctx.fill();
994
+
995
+ // Update particle position
996
+ p.y += Math.cos(p.d) + 1 + p.r / 2;
997
+ p.x += Math.sin(0) * 2;
998
+ p.tiltAngle += p.tiltAngleIncrement;
999
+ p.tilt = Math.sin(p.tiltAngle) * 15;
1000
+
1001
+ // Reset particle if it's out of view
1002
+ if (p.y > this.canvas.height) {
1003
+ if (this.settings.respawn) {
1004
+ this.particles[i] = this.createParticle();
1005
+ } else {
1006
+ this.particles.splice(i, 1);
1007
+ i--;
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ this.animationId = requestAnimationFrame(() => this.animate());
1013
+ }
1014
+
1015
+ clear() {
1016
+ cancelAnimationFrame(this.animationId);
1017
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
1018
+ this.particles = [];
1019
+ }
1020
+ }
1021
+
1022
+ // Start the app
1023
+ init();
1024
+ </script>
1025
+ <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=Batzuul/math-3-class" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
1026
+ </html>