Spaces:
Running

File size: 51,371 Bytes
d410619
74d9416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d410619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74d9416
 
68e6c78
 
30619c7
68e6c78
 
30619c7
68e6c78
 
74d9416
30619c7
68e6c78
 
30619c7
 
68e6c78
 
2018902
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68e6c78
74d9416
68e6c78
 
 
2018902
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68e6c78
74d9416
68e6c78
30619c7
 
68e6c78
2018902
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68e6c78
74d9416
 
 
2018902
74d9416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68e6c78
74d9416
104f101
d410619
74d9416
 
 
d410619
74d9416
 
 
d410619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68e6c78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2018902
104f101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d410619
 
 
 
 
 
 
 
 
 
 
 
74d9416
 
d410619
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test Yaratish - TestMaster Pro</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gray-50 min-h-screen">
    <header-component></header-component>
    
    <main class="container mx-auto px-4 py-8">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-xl shadow-lg p-6 mb-8">
                <h1 class="text-3xl font-bold text-gray-800 mb-2">Test Yaratish</h1>
                <p class="text-gray-600">Javoblarni kiriting va test kodingizni oling</p>
            </div>

            <div id="auth-required-message" class="bg-yellow-50 border border-yellow-200 rounded-lg p-6 mb-8 hidden">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i data-feather="alert-triangle" class="text-yellow-500 w-5 h-5"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-sm font-medium text-yellow-800">Avtorizatsiya talab qilinadi</h3>
                        <div class="mt-2 text-sm text-yellow-700">
                            <p>Test yaratish uchun tizimga kirishingiz kerak.</p>
                        </div>
                        <div class="mt-4">
                            <button id="login-to-create-btn" class="btn btn-primary">
                                Kirish
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div id="test-form" class="bg-white rounded-xl shadow-lg p-6 hidden">
                <div class="mb-8">
                    <h2 class="text-xl font-semibold text-gray-800 mb-4">Test Javoblari</h2>
                    <!-- Tab Navigation -->
                    <div class="flex border-b border-gray-200 mb-6">
                        <button class="tab-button py-2 px-4 font-medium text-blue-600 border-b-2 border-blue-600" data-tab="multiple-choice">
                            Tanlovli savollar
                        </button>
                        <button class="tab-button py-2 px-4 font-medium text-gray-500 hover:text-gray-700" data-tab="written">
                            Ochiq savollar
                        </button>
                    </div>
<!-- Tab Content -->
                    <div class="tab-content">
                        <!-- Multiple Choice Questions (1-35) -->
                        <div id="multiple-choice-tab" class="tab-pane">
<!-- Questions 1-32 (ABCD) -->
                            <div class="mb-8">
                                <h3 class="font-medium text-gray-700 mb-3">Savollar 1-32 (A, B, C, D variantlardan birini tanlang)</h3>
                                <div class="grid grid-cols-2 sm:grid-cols-4 md:grid-cols-6 gap-3" id="q1-32-grid"><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">1</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="1" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="1" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="1" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="1" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">2</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="2" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="2" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="2" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="2" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">3</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="3" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="3" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="3" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="3" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">4</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="4" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="4" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="4" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="4" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">5</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="5" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="5" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="5" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="5" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">6</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="6" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="6" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="6" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="6" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">7</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="7" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="7" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="7" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="7" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">8</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="8" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="8" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="8" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="8" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">9</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="9" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="9" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="9" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="9" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">10</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="10" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="10" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="10" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="10" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">11</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="11" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="11" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="11" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="11" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">12</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="12" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="12" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="12" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="12" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">13</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="13" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="13" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="13" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="13" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">14</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="14" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="14" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="14" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="14" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">15</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="15" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="15" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="15" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="15" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">16</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="16" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="16" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="16" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="16" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">17</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="17" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="17" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="17" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="17" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">18</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="18" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="18" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="18" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="18" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">19</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="19" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="19" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="19" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="19" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">20</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="20" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="20" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="20" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="20" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">21</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="21" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="21" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="21" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="21" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">22</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="22" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="22" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="22" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="22" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">23</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="23" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="23" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="23" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="23" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">24</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="24" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="24" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="24" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="24" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">25</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="25" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="25" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="25" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="25" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">26</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="26" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="26" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="26" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="26" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">27</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="27" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="27" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="27" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="27" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">28</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="28" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="28" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="28" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="28" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">29</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="29" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="29" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="29" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="29" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">30</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="30" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="30" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="30" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="30" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">31</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="31" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="31" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="31" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="31" data-answer="D">D</button>
                    </div>
                </div><div class="flex flex-col items-center">
                    <span class="text-sm font-medium text-gray-700 mb-2">32</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="32" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="32" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="32" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="32" data-answer="D">D</button>
                    </div>
                </div></div>
                            </div>

                            <!-- Questions 33-35 (ABCDEF) -->
                            <div class="mb-8">
                                <h3 class="font-medium text-gray-700 mb-3">Savollar 33-35 (A, B, C, D, E, F variantlardan birini tanlang)</h3>
                                <div class="grid grid-cols-1 sm:grid-cols-3 gap-3" id="q33-35-grid"><div class="flex flex-col">
                    <span class="text-sm font-medium text-gray-700 mb-2">33</span>
                    <div class="grid grid-cols-3 gap-2">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="33" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="33" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="33" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="33" data-answer="D">D</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="33" data-answer="E">E</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="33" data-answer="F">F</button>
                    </div>
                </div><div class="flex flex-col">
                    <span class="text-sm font-medium text-gray-700 mb-2">34</span>
                    <div class="grid grid-cols-3 gap-2">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="34" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="34" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="34" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="34" data-answer="D">D</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="34" data-answer="E">E</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="34" data-answer="F">F</button>
                    </div>
                </div><div class="flex flex-col">
                    <span class="text-sm font-medium text-gray-700 mb-2">35</span>
                    <div class="grid grid-cols-3 gap-2">
                        <button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="35" data-answer="A">A</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="35" data-answer="B">B</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="35" data-answer="C">C</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="35" data-answer="D">D</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="35" data-answer="E">E</button><button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" data-question="35" data-answer="F">F</button>
                    </div>
                </div></div>
                            </div>
                        </div>
                        <!-- Written Answers (36-45) -->
                        <div id="written-tab" class="tab-pane hidden">
<div>
                                <h3 class="font-medium text-gray-700 mb-3">Savollar 36-45 (Javoblarni yozing)</h3>
                                <div class="space-y-4" id="q36-45-inputs"><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">36.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="36">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">37.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="37">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">38.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="38">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">39.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="39">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">40.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="40">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">41.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="41">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">42.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="42">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">43.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="43">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">44.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="44">
                </div><div class="flex items-center">
                    <span class="w-10 text-gray-700 font-medium">45.</span>
                    <input type="text" class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Javobni kiriting" data-question="45">
                </div></div>
                            </div>
                        </div>
                    </div>
                </div>
<div class="flex flex-wrap gap-4">
                    <button id="generate-code-btn" class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-lg transition-colors">
                        Test Kodini Yaratish
                    </button>
                    <button id="finish-test-btn" class="bg-red-600 hover:bg-red-700 text-white font-medium py-3 px-6 rounded-lg transition-colors hidden">
                        Testni Tugatish
                    </button>
                </div>

                <div id="result-section" class="mt-8 hidden">
                    <div class="bg-green-50 border border-green-200 rounded-lg p-6">
                        <h3 class="text-xl font-semibold text-green-800 mb-2">Test Muvaffaqiyatli Yaratildi!</h3>
                        <p class="text-green-700 mb-4">Test kodingiz:</p>
                        <div class="text-4xl font-bold text-green-600 mb-4" id="test-code-display"></div>
                        <p class="text-green-700">Bu kod orqali foydalanuvchilar testni ishlashi mumkin.</p>
                    </div>
                </div>
            </div>
</div>
    </main>
<footer-component></footer-component>
    <auth-modal></auth-modal>

    <script src="components/header.js"></script>
    <script src="components/footer.js"></script>
    <script src="components/auth-modal.js"></script>
    <script src="script.js"></script>
    <script>
        feather.replace();
        
        // Check if user is logged in
        const user = JSON.parse(localStorage.getItem('telegramUser'));
        const authMessage = document.getElementById('auth-required-message');
        const testForm = document.getElementById('test-form');
        const loginBtn = document.getElementById('login-to-create-btn');
        
        if (!user) {
            authMessage.classList.remove('hidden');
            testForm.classList.add('hidden');
            
            loginBtn.addEventListener('click', () => {
                document.querySelector('auth-modal').openModal();
            });
        } else {
            authMessage.classList.add('hidden');
            testForm.classList.remove('hidden');
            // Initialize the test creation form
            initializeTestCreationForm();
        }
        // Tab switching functionality
        document.querySelectorAll('.tab-button').forEach(button => {
            button.addEventListener('click', () => {
                // Remove active classes
                document.querySelectorAll('.tab-button').forEach(btn => {
                    btn.classList.remove('text-blue-600', 'border-b-2', 'border-blue-600');
                    btn.classList.add('text-gray-500', 'hover:text-gray-700');
                });
                
                // Add active classes to clicked button
                button.classList.remove('text-gray-500', 'hover:text-gray-700');
                button.classList.add('text-blue-600', 'border-b-2', 'border-blue-600');
                
                // Hide all tab panes
                document.querySelectorAll('.tab-pane').forEach(pane => {
                    pane.classList.add('hidden');
                });
                
                // Show the corresponding tab pane
                const tabId = button.getAttribute('data-tab');
                document.getElementById(`${tabId}-tab`).classList.remove('hidden');
            });
        });
            // Initialize the test creation form when user is authenticated
        function initializeTestCreationForm() {
            // Questions 1-32 (ABCD)
            const q1_32Grid = document.getElementById('q1-32-grid');
            q1_32Grid.innerHTML = '';
            
            for (let i = 1; i <= 32; i++) {
                const questionGroup = document.createElement('div');
                questionGroup.className = 'flex flex-col items-center';
                questionGroup.innerHTML = `
                    <span class="text-sm font-medium text-gray-700 mb-2">${i}</span>
                    <div class="grid grid-cols-2 gap-2 w-full">
                        ${['A', 'B', 'C', 'D'].map(letter => 
                            `<button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" 
                                    data-question="${i}" data-answer="${letter}">${letter}</button>`
                        ).join('')}
                    </div>
                `;
                q1_32Grid.appendChild(questionGroup);
            }

            // Questions 33-35 (ABCDEF)
            const q33_35Grid = document.getElementById('q33-35-grid');
            q33_35Grid.innerHTML = '';
            
            for (let i = 33; i <= 35; i++) {
                const questionGroup = document.createElement('div');
                questionGroup.className = 'flex flex-col';
                questionGroup.innerHTML = `
                    <span class="text-sm font-medium text-gray-700 mb-2">${i}</span>
                    <div class="grid grid-cols-3 gap-2">
                        ${['A', 'B', 'C', 'D', 'E', 'F'].map(letter => 
                            `<button class="answer-btn py-2 px-3 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 transition-colors" 
                                    data-question="${i}" data-answer="${letter}">${letter}</button>`
                        ).join('')}
                    </div>
                `;
                q33_35Grid.appendChild(questionGroup);
            }

            // Questions 36-45 (Written Answers)
            const q36_45Inputs = document.getElementById('q36-45-inputs');
            q36_45Inputs.innerHTML = '';
            
            for (let i = 36; i <= 45; i++) {
                const inputGroup = document.createElement('div');
                inputGroup.className = 'flex items-center';
                inputGroup.innerHTML = `
                    <span class="w-10 text-gray-700 font-medium">${i}.</span>
                    <input type="text" 
                           class="flex-1 ml-2 border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" 
                           placeholder="Javobni kiriting" 
                           data-question="${i}">
                `;
                q36_45Inputs.appendChild(inputGroup);
            }

            // Add event listeners for answer buttons
            document.querySelectorAll('.answer-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const question = this.dataset.question;
                    const answer = this.dataset.answer;
                    
                    // Remove selected class from all buttons in this group
                    this.parentElement.querySelectorAll('.answer-btn').forEach(b => {
                        b.classList.remove('bg-blue-100', 'border-blue-500', 'text-blue-700');
                        b.classList.add('border-gray-300', 'text-gray-700');
                    });
                    
                    // Add selected class to clicked button
                    this.classList.remove('border-gray-300', 'text-gray-700');
                    this.classList.add('bg-blue-100', 'border-blue-500', 'text-blue-700');
                    
                    // Store the answer
                    window.testAnswers = window.testAnswers || {};
                    window.testAnswers[question] = answer;
                });
            });
            
            // Add event listeners for text inputs
            document.querySelectorAll('input[data-question]').forEach(input => {
                input.addEventListener('input', function() {
                    const question = this.dataset.question;
                    const answer = this.value.trim();
                    window.testAnswers = window.testAnswers || {};
                    window.testAnswers[question] = answer;
                });
            });

            // Generate code button
            document.getElementById('generate-code-btn').addEventListener('click', function() {
                // Validate that all questions have answers
                let isValid = true;
                for (let i = 1; i <= 45; i++) {
                    if (!window.testAnswers || !window.testAnswers[i]) {
                        isValid = false;
                        break;
                    }
                }
                
                if (!isValid) {
                    alert('Iltimos, barcha savollarga javob bering!');
                    return;
                }
                
                // Generate test code
                const code = Math.floor(10 + Math.random() * 90).toString();
                window.currentTestCode = code;
                
                // Save test to storage
                let userTests = JSON.parse(localStorage.getItem('userTests')) || [];
                const test = {
                    code: code,
                    answers: window.testAnswers,
                    createdAt: new Date().toISOString(),
                    isActive: true,
                    participants: []
                };
                userTests.push(test);
                localStorage.setItem('userTests', JSON.stringify(userTests));
                
                // Show result section
                document.getElementById('test-code-display').textContent = code;
                document.getElementById('result-section').classList.remove('hidden');
                document.getElementById('finish-test-btn').classList.remove('hidden');
            });
            
            // Finish test button
            document.getElementById('finish-test-btn').addEventListener('click', function() {
                if (window.currentTestCode) {
                    let userTests = JSON.parse(localStorage.getItem('userTests')) || [];
                    const testIndex = userTests.findIndex(t => t.code === window.currentTestCode);
                    if (testIndex !== -1) {
                        userTests[testIndex].isActive = false;
                        localStorage.setItem('userTests', JSON.stringify(userTests));
                        alert(`Test ${window.currentTestCode} muvaffaqiyatli tugatildi!`);
                        // Reset form
                        document.querySelectorAll('.answer-btn').forEach(btn => {
                            btn.classList.remove('bg-blue-100', 'border-blue-500', 'text-blue-700');
                            btn.classList.add('border-gray-300', 'text-gray-700');
                        });
                        document.querySelectorAll('input[data-question]').forEach(input => {
                            input.value = '';
                        });
                        document.getElementById('result-section').classList.add('hidden');
                        document.getElementById('finish-test-btn').classList.add('hidden');
                        window.testAnswers = {};
                        window.currentTestCode = null;
                    }
                }
            });
        }
// Listen for auth state changes
        window.addEventListener('authStateChange', () => {
            const newUser = JSON.parse(localStorage.getItem('telegramUser'));
            if (newUser) {
                authMessage.classList.add('hidden');
                testForm.classList.remove('hidden');
                // Initialize the test creation form
                initializeTestCreationForm();
            } else {
                authMessage.classList.remove('hidden');
                testForm.classList.add('hidden');
            }
        });
    </script>
</body>
</html>