吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1465|回复: 28
收起左侧

[原创工具] 【Python+HTML】题库软件V2

[复制链接]
tianlan001 发表于 2025-5-5 21:34
本帖最后由 tianlan001 于 2025-5-12 21:22 编辑

单位发了一套题库要求背。题库是word格式,包括判断题、单选题和多选题。答案在题目中。
为了方便记忆,自制了一个Web版题库软件。

首先,手动将word拆分成2个word,分别只包含判断题、选择题。
要求:
1、判断题:一道题占用一行,答案可以是(正确)(√)(True)(错误)(×)(False)
2、选择题:每一个选项以大写字母开头,并占用一行。答案也必须是大写字母。自动识别单选题和多选题。
                    多选题答案可以连续,或者以顿号分隔,例(AC)或(A、C)

然后,从word中提取题目数据。Python实现,目前已编译成tkdata.exe
命令行如下。提取的题目数据会保存到data.txt中
[PowerShell] 纯文本查看 复制代码
1
2
3
4
5
6
读取word中的判断题。word中只能包含判断题。每一行为一道题。
  tkdata -pd src.docx
 
读取word中的选择题,自动识别单选和多选。
word中只能包含选择题。要求每一个选项占一行。
  tkdata -xz src.docx


最后,将其拷贝到html相同目录下,双击html用浏览器打开,即可食用。


PS:html也支持填空题、简答题练习。按如下格式,往data.txt中插入填空题、简答题数据即可。

[JavaScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
"填空题": [
        {
                "question": "中国的首都是______,最大的城市是______,XX是______。",
                "answer": ["北京", "上海", "天津"]
        },
        {
                "question": "一年有______个月,其中大月有______个。",
                "answer": ["12", "7"]
        }
],
"简答题": [
        {
                "question": "简述光合作用的过程。",
                "answer": "光合作用是绿色植物通过叶绿体,利用光能,把二氧化碳和水转化成储存着能量的有机物,并释放出氧气的过程。"
        },
        {
                "question": "说明摩擦力的作用。",
                "answer": "摩擦力可以阻碍物体的相对运动或相对运动趋势,它可以使物体减速、停止,也可以帮助物体实现运动,如人走路时依靠鞋底与地面的摩擦力前进。"
        }
]


https://wwqm.lanzouu.com/b00ya73pub
密码:52pj

判断题格式

判断题格式

判断题格式



选择题格式,可包括单选多选

选择题格式,可包括单选多选

选择题格式,可包括单选多选


题目数据提取,保存到data.txt中

题目数据提取

题目数据提取



将data.txt与html放置在同一目录

将data.txt与html放置在同一目录

将data.txt与html放置在同一目录


双击html打开食用

双击html打开食用

双击html打开食用



=========================================================================================
更新 题库V2:
1、tkdata.exe提取word数据,以json格式保存到data.txt中。
2、打开HTML后,选择data.txt加载题目数据。(方便以后切换不同的试卷或题库)
3、增加快捷键:1 2 分别对应√×,123456789对应ABCDEFGHI。空格键或回车键确认,ESC键清空。左右箭头上下翻题。
4、增加保存按钮,保存答题状态。关闭浏览器后,再次打开HTML,自动恢复答题状态。
5、增加重置按钮,清空所有答题状态。
6、离线可用。不需要联网。


V2操作演示

V2操作演示

V2操作演示




2025-05-12更新
调整按钮位置。左侧题目数量较多时,往下滚动页面,左侧顶部三个按钮将不可见,不方便操作,故将左侧顶部三个按钮调整到右侧顶部。

7.png

[HTML] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="lib/tailwindcss3.4.16"></script>
    <link href="lib/Font Awesome Free 6.7.2-all.min.css" rel="stylesheet">
    <title>题库软件</title>
    <style>
        .question-label {
            width: 2.5rem;
            height: 2.5rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin: 0.25rem;
            cursor: pointer;
            transition: background-color 0.3s ease;
            border: 1px solid #ccc;
            border-radius: 0;
        }
 
        .question-label.current {
            background-color: #3b82f6;
            color: white;
            border-radius: 1.5rem;
        }
 
        .question-label.correct {
            background-color: #22c55e;
            color: white;
        }
 
        .question-label.incorrect {
            background-color: #ef4444;
            color: white;
        }
 
        #question-content {
            min-height: 200px;
            max-height: calc(100vh - 120px);
            overflow-y: auto;
        }
 
        input[type="text"],
        textarea {
            border: 1px solid #ccc;
            padding: 0.5rem;
            margin-bottom: 0.5rem;
            height: 2.5rem;
        }
 
        textarea {
            height: 6rem;
        }
 
        input[type="radio"],
        input[type="checkbox"] {
            margin-right: 1rem;
        }
 
        #question-content h2 {
            margin-bottom: 0.5rem;
            font-size: 1.25rem;
        }
 
        #question-content label {
            font-size: 1.25rem;
        }
 
        #question-types > div {
            margin-bottom: 1.5rem;
        }
 
        .file-selection-group {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            margin-bottom: 0.5rem;
        }
 
        .custom-file-input {
            position: relative;
            flex: 1;
            min-width: 120px;
        }
 
        .custom-file-input input[type="file"] {
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0;
            width: 100%;
            height: 100%;
            cursor: pointer;
        }
 
        .custom-file-input label {
            display: block;
            padding: 0.75rem 1rem;
            background-color: #3b82f6;
            color: white;
            border-radius: 0.375rem;
            text-align: center;
            cursor: pointer;
            transition: background-color 0.3s ease;
            height: 100%;
            box-sizing: border-box;
        }
 
        .custom-file-input label:hover {
            background-color: #2563eb;
        }
 
        .custom-file-input label:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
        }
 
        .action-buttons {
            display: flex;
            gap: 0.5rem;
        }
 
        .action-buttons button {
            padding: 0.75rem 1rem;
            background-color: #4f46e5;
            color: white;
            border-radius: 0.375rem;
            cursor: pointer;
            transition: background-color 0.3s ease;
            white-space: nowrap;
        }
 
        .action-buttons button:hover {
            background-color: #4338ca;
        }
 
        .action-buttons button:disabled {
            background-color: #a0aec0;
            cursor: not-allowed;
        }
 
        #save-btn {
            background-color: #22c55e;
        }
 
        #reset-btn {
            background-color: #ef4444;
        }
 
        #selected-file-path {
            padding: 0.75rem 0rem;
            font-size: 1rem;
            color: red;       
        }
 
        #fixed-buttons {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 0.5rem;
        }
 
    </style>
</head>
 
<body class="bg-gray-100">
    <div class="flex h-screen">
        <!-- 左侧题目类型和序号区域 -->
        <div class="w-1/4 bg-white p-4 overflow-y-auto" id="question-types-container">
            <div id="question-types"></div>
        </div>
        <!-- 右侧题目内容区域 -->
        <div class="w-3/4 bg-gray-200 p-4">
            <div id="fixed-buttons">
                <div class="file-selection-group">
                    <div class="custom-file-input">
                        <input type="file" id="question-file-input" accept=".txt,.json">
                        <label for="question-file-input">选择题目数据文件</label>
                    </div>
                    <div class="action-buttons">
                        <button id="save-btn">保存状态</button>
                        <button id="reset-btn">全部重置</button>
                    </div>
                                        <div id="selected-file-path"></div>
                </div>
            </div>
            <div id="question-content" class="bg-white p-4 rounded shadow mb-4 overflow-y-auto" style="white-space: pre-wrap;"></div>
            <div class="flex justify-start space-x-2">
                <button id="confirm-btn" class="bg-blue-500 text-white px-4 py-2 rounded">确定</button>
                <button id="clear-btn" class="bg-yellow-500 text-white px-4 py-2 rounded">清空</button>
                <button id="prev-btn" class="bg-gray-500 text-white px-4 py-2 rounded">上一题</button>
                <button id="next-btn" class="bg-gray-500 text-white px-4 py-2 rounded">下一题</button>
            </div>
        </div>
    </div>
 
    <script>
        let currentType;
        let currentIndex = 0;
        let answered = {};
        let userAnswers = {};
        const confirmBtn = document.getElementById('confirm-btn');
        const clearBtn = document.getElementById('clear-btn');
        const questionTypesContainer = document.getElementById('question-types-container');
        const questionFileInput = document.getElementById('question-file-input');
        const selectedFilePathDiv = document.getElementById('selected-file-path');
        const saveBtn = document.getElementById('save-btn');
        const resetBtn = document.getElementById('reset-btn');
        let questions = {};
        let selectedFilePath = '';
        const SAVE_KEY = 'questionnaire_state';
 
        const savedState = localStorage.getItem(SAVE_KEY);
        if (savedState) {
            const {
                savedQuestions,
                savedCurrentType,
                savedCurrentIndex,
                savedAnswered,
                savedUserAnswers,
                savedFilePath
            } = JSON.parse(savedState);
             
            questions = savedQuestions;
            currentType = savedCurrentType;
            currentIndex = savedCurrentIndex;
            answered = savedAnswered;
            userAnswers = savedUserAnswers;
            selectedFilePath = savedFilePath;
             
            if (selectedFilePath) {
                selectedFilePathDiv.textContent = `已选择文件: ${selectedFilePath}`;
            }
             
            initQuestionTypes();
            showQuestion();
        }
 
        questionFileInput.addEventListener('change', function (event) {
            const file = event.target.files[0];
            if (file) {
                selectedFilePath = file.path || file.name;
                selectedFilePathDiv.textContent = `已选择文件: ${selectedFilePath}`;
                const reader = new FileReader();
                reader.onload = function (e) {
                    try {
                        questions = JSON.parse(e.target.result);
                        currentType = Object.keys(questions)[0];
                        currentIndex = 0;
                        answered = {};
                        userAnswers = {};
                        initQuestionTypes();
                        showQuestion();
                    } catch (error) {
                        alert('解析文件内容时出错,请确保文件内容为有效的 JSON 格式。');
                    }
                };
                reader.readAsText(file);
            } else {
                if (selectedFilePath) {
                    selectedFilePathDiv.textContent = `已选择文件: ${selectedFilePath}`;
                } else {
                    selectedFilePathDiv.textContent = '';
                }
            }
        });
 
        function initQuestionTypes() {
            const questionTypesDiv = document.getElementById('question-types');
            questionTypesDiv.innerHTML = '';
            for (const type in questions) {
                const typeDiv = document.createElement('div');
                typeDiv.innerHTML = `<h3 class="text-lg font-bold mb-2">${type}</h3>`;
                for (let i = 0; i < questions[type].length; i++) {
                    const label = document.createElement('span');
                    label.classList.add('question-label');
                    label.textContent = i + 1;
                    label.dataset.type = type;
                    label.dataset.index = i;
                    label.addEventListener('click', () => {
                        currentType = type;
                        currentIndex = i;
                        showQuestion();
                    });
                    typeDiv.appendChild(label);
                }
                questionTypesDiv.appendChild(typeDiv);
            }
        }
 
        function showQuestion() {
            const questionContentDiv = document.getElementById('question-content');
            questionContentDiv.innerHTML = '';
 
            if (!questions ||!questions[currentType]) {
                return;
            }
 
            const question = questions[currentType][currentIndex];
            const questionTitle = document.createElement('h2');
            questionTitle.textContent = `${currentType}(第 ${currentIndex + 1} 题):${question.question}`;
            questionContentDiv.appendChild(questionTitle);
 
            if (currentType === '单选题' || currentType === '多选题') {
                for (let i = 0; i < question.options.length; i++) {
                    const input = document.createElement('input');
                    input.type = currentType === '单选题'? 'radio' : 'checkbox';
                    input.name = 'option';
                    input.value = String.fromCharCode(65 + i);
                    const label = document.createElement('label');
                    label.textContent = question.options[i];
                    label.addEventListener('click', () => {
                        input.click();
                    });
                    questionContentDiv.appendChild(input);
                    questionContentDiv.appendChild(label);
                    questionContentDiv.appendChild(document.createElement('br'));
 
                    if (userAnswers[`${currentType}-${currentIndex}`]) {
                        if (Array.isArray(userAnswers[`${currentType}-${currentIndex}`])) {
                            input.checked = userAnswers[`${currentType}-${currentIndex}`].includes(input.value);
                        } else {
                            input.checked = userAnswers[`${currentType}-${currentIndex}`] === input.value;
                        }
                    }
                }
            } else if (currentType === '填空题') {
                const blanks = question.question.match(/______/g).length;
                for (let i = 0; i < blanks; i++) {
                    const input = document.createElement('input');
                    input.type = 'text';
                    input.style.width = '100%';
                    input.name = `blank-${i}`;
                    questionContentDiv.appendChild(input);
                    questionContentDiv.appendChild(document.createElement('br'));
 
                    if (userAnswers[`${currentType}-${currentIndex}`] && userAnswers[`${currentType}-${currentIndex}`][i]) {
                        input.value = userAnswers[`${currentType}-${currentIndex}`][i];
                    }
                }
                                const inputs = document.querySelectorAll('input[name^="blank-"]');
                                inputs[0].focus();
            } else if (currentType === '判断题') {
                const trueInput = document.createElement('input');
                trueInput.type = 'radio';
                trueInput.name = 'option';
                trueInput.value = '正确';
                const trueLabel = document.createElement('label');
                trueLabel.textContent = '正确';
                trueLabel.addEventListener('click', () => {
                    trueInput.click();
                });
                const falseInput = document.createElement('input');
                falseInput.type = 'radio';
                falseInput.name = 'option';
                falseInput.value = '错误';
                const falseLabel = document.createElement('label');
                falseLabel.textContent = '错误';
                falseLabel.addEventListener('click', () => {
                    falseInput.click();
                });
                questionContentDiv.appendChild(trueInput);
                questionContentDiv.appendChild(trueLabel);
                questionContentDiv.appendChild(document.createElement('br'));
                questionContentDiv.appendChild(falseInput);
                questionContentDiv.appendChild(falseLabel);
 
                if (userAnswers[`${currentType}-${currentIndex}`]!== undefined) {
                    trueInput.checked = userAnswers[`${currentType}-${currentIndex}`] === '正确';
                    falseInput.checked = userAnswers[`${currentType}-${currentIndex}`] === '错误';
                }
            } else if (currentType === '简答题') {
                const textarea = document.createElement('textarea');
                textarea.style.width = '100%';
                textarea.name = 'answer';
                questionContentDiv.appendChild(textarea);
                                textarea.focus();
 
                if (userAnswers[`${currentType}-${currentIndex}`]) {
                    textarea.value = userAnswers[`${currentType}-${currentIndex}`];
                }
            }
 
            const labels = document.querySelectorAll('.question-label');
            labels.forEach(label => {
                label.classList.remove('current', 'correct', 'incorrect');
                if (label.dataset.type === currentType && parseInt(label.dataset.index) === currentIndex) {
                    label.classList.add('current');
                    const rect = label.getBoundingClientRect();
                    const containerRect = questionTypesContainer.getBoundingClientRect();
                    if (rect.top < containerRect.top || rect.bottom > containerRect.bottom) {
                        label.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
                    }
                }
                if (answered[`${label.dataset.type}-${label.dataset.index}`]!== undefined) {
                    if (answered[`${label.dataset.type}-${label.dataset.index}`]) {
                        label.classList.add('correct');
                    } else {
                        label.classList.add('incorrect');
                    }
                }
            });
 
            if (answered[`${currentType}-${currentIndex}`]!== undefined) {
                const result = answered[`${currentType}-${currentIndex}`];
                const resultDiv = document.createElement('div');
                if (result) {
                    resultDiv.textContent = '回答正确!';
                    resultDiv.classList.add('text-green-500');
                } else {
                    resultDiv.textContent = `回答错误,正确答案是:${Array.isArray(question.answer)? question.answer.join(', ') : question.answer}`;
                    resultDiv.classList.add('text-red-500');
                }
                questionContentDiv.appendChild(resultDiv);
            }
 
        }
 
        function confirmAnswer() {
            const question = questions[currentType][currentIndex];
            let userAnswer;
            if (currentType === '单选题' || currentType === '判断题') {
                const inputs = document.querySelectorAll('input[name="option"]:checked');
                userAnswer = inputs.length > 0? inputs[0].value : null;
            } else if (currentType === '多选题') {
                const inputs = document.querySelectorAll('input[name="option"]:checked');
                userAnswer = [];
                inputs.forEach(input => userAnswer.push(input.value));
            } else if (currentType === '填空题') {
                const inputs = document.querySelectorAll('input[name^="blank-"]');
                userAnswer = [];
                inputs.forEach(input => userAnswer.push(input.value.trim())); // 添加trim()去除空格
            } else if (currentType === '简答题') {
                const textarea = document.querySelector('textarea[name="answer"]');
                userAnswer = textarea.value;
            }
 
            userAnswers[`${currentType}-${currentIndex}`] = userAnswer;
 
            let isCorrect;
            if (Array.isArray(question.answer)) {
                                if (currentType === '填空题') {
                                        isCorrect = true;
                                        for (let i = 0; i < question.answer.length; i++) {
                                                if (userAnswer[i] !== question.answer[i]) {
                                                        isCorrect = false;
                                                        break;
                                                }
                                        }
                                } else {
                                        isCorrect = JSON.stringify(userAnswer.sort()) === JSON.stringify(question.answer.sort());
                                }
            } else {
                isCorrect = userAnswer === question.answer;
            }
 
            answered[`${currentType}-${currentIndex}`] = isCorrect;
 
            const label = document.querySelector(`.question-label[data-type="${currentType}"][data-index="${currentIndex}"]`);
            if (isCorrect) {
                label.classList.add('correct');
                label.classList.remove('incorrect');
            } else {
                label.classList.add('incorrect');
                label.classList.remove('correct');
            }
 
            showQuestion();
 
            // 不论正确与否,都自动切换到下一题
                if (currentIndex < questions[currentType].length - 1) {
                    currentIndex++;
                } else {
                    const types = Object.keys(questions);
                    const currentTypeIndex = types.indexOf(currentType);
                    if (currentTypeIndex < types.length - 1) {
                        currentType = types[currentTypeIndex + 1];
                        currentIndex = 0;
                    }
                }
                showQuestion();
            }
 
        function clearAnswer() {
            userAnswers[`${currentType}-${currentIndex}`] = null;
            answered[`${currentType}-${currentIndex}`] = undefined;
            const label = document.querySelector(`.question-label[data-type="${currentType}"][data-index="${currentIndex}"]`);
            label.classList.remove('correct', 'incorrect');
            showQuestion();
        }
 
        function prevQuestion() {
            if (currentIndex > 0) {
                currentIndex--;
            } else {
                const types = Object.keys(questions);
                const currentTypeIndex = types.indexOf(currentType);
                if (currentTypeIndex > 0) {
                    currentType = types[currentTypeIndex - 1];
                    currentIndex = questions[currentType].length - 1;
                }
            }
            showQuestion();
        }
 
        function nextQuestion() {
            if (currentIndex < questions[currentType].length - 1) {
                currentIndex++;
            } else {
                const types = Object.keys(questions);
                const currentTypeIndex = types.indexOf(currentType);
                if (currentTypeIndex < types.length - 1) {
                    currentType = types[currentTypeIndex + 1];
                    currentIndex = 0;
                }
            }
            showQuestion();
        }
 
        function saveState() {
            if (!questions || Object.keys(questions).length === 0) {
                alert('请先选择题目数据文件');
                return;
            }
             
            const state = {
                savedQuestions: questions,
                savedCurrentType: currentType,
                savedCurrentIndex: currentIndex,
                savedAnswered: answered,
                savedUserAnswers: userAnswers,
                savedFilePath: selectedFilePath
            };
             
            localStorage.setItem(SAVE_KEY, JSON.stringify(state));
            alert('答题状态已保存!');
        }
 
        function resetAll() {
            if (!questions || Object.keys(questions).length === 0) {
                alert('请先选择题目数据文件');
                return;
            }
             
            if (confirm('确定要清空所有答案,恢复初始状态吗?')) {
                currentIndex = 0;
                answered = {};
                userAnswers = {};
                 
                const labels = document.querySelectorAll('.question-label');
                labels.forEach(label => {
                    label.classList.remove('current', 'correct', 'incorrect');
                });
                   
                localStorage.removeItem(SAVE_KEY);
                                 
                currentType = Object.keys(questions)[0];
                currentIndex = 0;
                showQuestion();
            }
        }
 
        document.addEventListener('keydown', function (event) {
                if (Object.keys(questions).length > 0) {
                    if ((event.key === 'Enter' || event.code === 'Space') && (currentType === '判断题' || currentType === '单选题' || currentType === '多选题')) {
                        event.preventDefault(); // 阻止默认行为
                        confirmAnswer();
                    } else if ((event.key === 'Enter') && (currentType === '填空题' || currentType === '简答题')) {
                        event.preventDefault(); // 阻止默认行为
                        confirmAnswer();
                    } else if (event.key === 'Escape') {
                        event.preventDefault();
                        clearAnswer();
                    } else if (currentType === '判断题' && (event.key === '1' || event.key === '2')) {
                        event.preventDefault();
                        const option = event.key === '1'? '正确' : '错误';
                        const inputs = document.querySelectorAll('input[name="option"]');
                        inputs.forEach(input => {
                            if (input.value === option) {
                                input.checked = true;
                            }
                        });
                    } else if ((currentType === '单选题' || currentType === '多选题') && /^[1-9]$/.test(event.key)) {
                        event.preventDefault();
                        const index = parseInt(event.key) - 1;
                        const option = String.fromCharCode(65 + index);
                        const inputs = document.querySelectorAll('input[name="option"]');
                        inputs.forEach(input => {
                            if (input.value === option) {
                                if (currentType === '单选题') {
                                    inputs.forEach(inp => inp.checked = false);
                                }
                                input.checked =!input.checked;
                            }
                        });
                    }
                }
 
                if (event.key === 'ArrowLeft') {
                    event.preventDefault();
                    prevQuestion();
                } else if (event.key === 'ArrowRight') {
                    event.preventDefault();
                    nextQuestion();
                }
        });
 
        confirmBtn.addEventListener('click', confirmAnswer);
        clearBtn.addEventListener('click', clearAnswer);
        const prevBtn = document.getElementById('prev-btn');
        prevBtn.addEventListener('click', prevQuestion);
        const nextBtn = document.getElementById('next-btn');
        nextBtn.addEventListener('click', nextQuestion);
        saveBtn.addEventListener('click', saveState);
        resetBtn.addEventListener('click', resetAll);
    </script>
</body>
 
</html>

免费评分

参与人数 5吾爱币 +13 热心值 +5 收起 理由
yaont + 1 + 1 谢谢@Thanks!
caoxuexin + 1 + 1 谢谢@Thanks!
yuppy34 + 1 + 1 谢谢@Thanks!
linglong2013 + 3 + 1 思路非常棒!谢谢分享
风之暇想 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

价值投机 发表于 2025-5-8 12:26
多谢楼主分享
 楼主| tianlan001 发表于 2025-5-8 13:07
ElEzUs 发表于 2025-5-8 08:20
支持一道题题目和一个答案分别占用多行吗?

题目可以多行,选项不支持多行
nyboy0377 发表于 2025-5-7 18:08
xghjf000 发表于 2025-5-7 19:01
数学公式能使用吗?
 楼主| tianlan001 发表于 2025-5-7 20:26
xghjf000 发表于 2025-5-7 19:01
数学公式能使用吗?

我没有考虑公式,不知道可不可以。您是想怎么使用公式?
单位要背的题库全是文字形式。
xghjf000 发表于 2025-5-8 07:12
tianlan001 发表于 2025-5-7 20:26
我没有考虑公式,不知道可不可以。您是想怎么使用公式?
单位要背的题库全是文字形式。

数学题呀?里面有公式
ElEzUs 发表于 2025-5-8 08:20
支持一道题题目和一个答案分别占用多行吗?
zpwz 发表于 2025-5-8 10:09
感谢分享,如果能是任何格式的,就更好了
zpwz 发表于 2025-5-8 10:17
运行tkdata.exe后,找不到data.txt
94altman 发表于 2025-5-8 10:24
下载测试一下
caoxino 发表于 2025-5-8 10:39
能统计用户吗?可以在内网老师然后统计用户成绩吗?
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-22 08:18

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表