-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathspeaking_test.html
More file actions
546 lines (465 loc) · 19.9 KB
/
speaking_test.html
File metadata and controls
546 lines (465 loc) · 19.9 KB
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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aptis Speaking Test - Giao diện mới</title>
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="icon" href="img/favicon.png" type="image/x-icon">
<style>
/* === CSS ĐÃ CẬP NHẬT CHO GIAO DIỆN MỚI === */
body,
html {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background-color: #f0f2f5;
color: #333;
}
/* Header được thiết kế lại */
.test-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 24px;
background-color: #ffffff;
border-top: 4px solid #d9534f;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
width: 100%;
box-sizing: border-box;
position: sticky;
top: 0;
z-index: 1000;
}
.header-left {
font-weight: bold;
font-size: 1.1em;
color: #d9534f;
}
/* Tiêu đề "Speaking Part X" ở giữa */
.header-center {
font-size: 1.5em;
font-weight: 500;
color: #000;
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.header-right {
font-size: 0.95em;
}
.container {
max-width: 960px;
margin: 20px auto;
padding: 0 24px;
box-sizing: border-box;
}
.test-simulation-wrapper {
background-color: #ffffff;
border: 1px solid #ddd;
border-radius: 8px;
padding: 24px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
min-height: 500px;
position: relative;
}
.test-screen {
display: none;
}
.test-screen.active {
display: block;
}
/* Bỏ khung cho khu vực câu hỏi */
#question-area {
width: 100%;
padding-top: 20px;
text-align: center;
}
.test-image-container {
display: flex;
justify-content: center;
gap: 20px;
margin-bottom: 24px;
}
.test-image-container img {
width: 45%;
max-width: 300px;
height: auto;
border-radius: 6px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.test-question-text {
padding: 16px 0;
margin: 0;
font-size: 1.2em;
line-height: 1.6;
}
.test-part4-questions ul {
list-style-position: inside;
padding: 16px 0;
margin: 0 auto;
font-size: 1.2em;
text-align: left;
max-width: 80%;
}
.test-part4-questions li {
padding-bottom: 12px;
}
/* Footer chứa nút Next và Đồng hồ */
.page-footer {
display: flex;
justify-content: flex-end;
align-items: center;
position: absolute;
bottom: 24px;
right: 24px;
width: calc(100% - 48px);
}
#next-btn {
padding: 12px 30px;
border: none;
border-radius: 5px;
font-size: 1em;
font-weight: 500;
cursor: pointer;
transition: background-color 0.2s ease-in-out;
background-color: #28a745;
color: white;
display: none;
/* Ẩn mặc định */
}
#next-btn:hover {
background-color: #218838;
}
/* Đồng hồ tròn mới */
.circular-timer {
position: relative;
width: 80px;
height: 80px;
margin-left: 20px;
}
.circular-timer svg {
transform: rotate(-90deg);
width: 100%;
height: 100%;
}
.timer-circle {
fill: none;
stroke-width: 8;
}
.timer-background {
stroke: #e6e6e6;
}
.timer-progress {
stroke: #28a745;
stroke-linecap: round;
transition: stroke-dashoffset 1s linear;
}
#timer-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 1.2em;
font-weight: 500;
}
#start-screen,
#end-screen {
text-align: center;
padding: 40px 0;
}
.explanation-box {
border: 1px solid #ddd;
border-radius: 8px;
padding: 20px;
background-color: #f8f9fa;
}
.explanation-box ul {
padding-left: 20px;
}
.explanation-box li {
margin-bottom: 10px;
}
a.action-btn,
a.action-btn-secondary {
text-decoration: none;
}
.action-btn-secondary {
color: #007bff;
display: inline-block;
}
a {
text-decoration: none;
color: black;
}
/* === STYLE MỚI CHO DÒNG CHÚ THÍCH === */
#disclaimer-text {
font-style: italic;
color: #777;
font-size: 0.9em;
margin-top: 20px;
}
/* === CSS MỚI CHO PART 4 STATUS === */
.part4-status {
display: inline-block;
padding: 8px 20px;
border-radius: 50px;
font-weight: bold;
margin-bottom: 20px;
font-size: 1.1em;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.status-prepare {
background-color: #fff3cd;
color: #856404;
border: 1px solid #ffeeba;
}
.status-speaking {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}
</style>
</head>
<body>
<header class="test-header">
<a href="index.html">
<div><i class="fas fa-home"></i>
Aptis practice
</div>
</a>
<div class="header-center" id="part-indicator-header">
Speaking Test
</div>
<div class="header-right" id="question-indicator-header">
</div>
</header>
<div class="container">
<div class="test-simulation-wrapper">
<div id="start-screen" class="test-screen active">
<h1>Mô phỏng bài thi Speaking</h1>
<p>Bài thi sẽ chạy tự động qua 4 phần. Bạn sẽ không thể tạm dừng.<br>Hãy chuẩn bị sẵn micro hoặc điện
thoại để ghi âm lại phần trả lời của bạn.<br>
<strong>Lưu ý:</strong> Bạn sẽ có 3 giây để đọc câu hỏi. Hãy bắt đầu trả lời ngay sau khi bạn nghe
thấy tiếng bíp.
</p>
<div style="margin: 25px 0;">
<p style="margin-bottom: 10px;"><strong>Nghe thử âm thanh bắt đầu:</strong></p>
<audio controls>
<source src="audio/ring.mp3" type="audio/mpeg">
Trình duyệt của bạn không hỗ trợ phát âm thanh.
</audio>
</div>
<button id="start-test-btn"
style="padding: 10px 25px; border: none; border-radius: 5px; font-size: 1em; background-color: #28a745; color: white; cursor: pointer;">Bắt
đầu bài thi</button>
</div>
<div id="test-screen" class="test-screen">
<div id="question-area"></div>
</div>
<!-- Màn hình kết thúc -->
<div id="end-screen" class="test-screen">
<h1>Bài thi đã kết thúc!</h1>
<p>Chúc mừng bạn đã hoàn thành bài thi mô phỏng.</p>
<div class="explanation-box" style="margin-top: 20px; text-align: left;">
<h3>💡 Bước tiếp theo: Tự đánh giá bài làm</h3>
<p>Bây giờ là lúc sử dụng file ghi âm bạn vừa tạo để cải thiện kỹ năng. Hãy làm theo các bước sau:
</p>
<ul>
<li><strong>Bước 1:</strong> Nghe lại file ghi âm của bạn.</li>
<li><strong>Bước 2:</strong> So sánh câu trả lời của bạn với các "Câu trả lời mẫu".</li>
<li><strong>Bước 3 (Nâng cao):</strong> Tải file ghi âm lên các công cụ AI để nhận feedback chi
tiết.</li>
</ul>
</div>
<a href="speaking_test.html" class="action-btn" style="margin-top: 20px;">Làm lại bài thi khác</a>
<a href="index.html" class="action-btn-secondary" style="margin-top: 10px;">Quay về trang chủ</a>
</div>
<!-- Footer mới chứa cả nút Next và đồng hồ -->
<footer class="page-footer" id="test-footer" style="display: none;">
<button id="next-btn">Next</button>
<div class="circular-timer">
<svg viewBox="0 0 36 36">
<path class="timer-circle timer-background"
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"></path>
<path class="timer-circle timer-progress" id="timer-progress-circle"
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"></path>
</svg>
<div id="timer-text">00:00</div>
</div>
</footer>
</div>
</div>
<audio id="start-sound" preload="auto">
<source src="audio/ring.mp3" type="audio/mpeg">
</audio>
<!-- Script của bạn sẽ được tải ở đây -->
<script src="js/data-speaking-test.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const startSound = document.getElementById('start-sound');
const startScreen = document.getElementById('start-screen');
const testScreen = document.getElementById('test-screen');
const endScreen = document.getElementById('end-screen');
const startBtn = document.getElementById('start-test-btn');
const questionArea = document.getElementById('question-area');
const nextBtn = document.getElementById('next-btn');
const testFooter = document.getElementById('test-footer');
const partIndicatorHeader = document.getElementById('part-indicator-header');
const questionIndicatorHeader = document.getElementById('question-indicator-header');
const timerProgressCircle = document.getElementById('timer-progress-circle');
const timerText = document.getElementById('timer-text');
const CIRCLE_LENGTH = timerProgressCircle.getTotalLength();
const shuffle = (array) => array.sort(() => Math.random() - 0.5);
let timerInterval;
let delayTimeout;
let forceNext = () => { };
let questionCounter = 0;
function runSkippableDelay(ms) {
return new Promise(resolve => {
forceNext = () => {
clearTimeout(delayTimeout);
resolve();
};
delayTimeout = setTimeout(resolve, ms);
});
}
function resetTimerDisplay(totalSeconds) {
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
timerText.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
timerProgressCircle.style.transition = 'none';
timerProgressCircle.style.strokeDashoffset = 0;
}
function runTimer(totalSeconds, showNextButton = false) {
return new Promise(resolve => {
let secondsLeft = totalSeconds;
forceNext = () => {
clearInterval(timerInterval);
resolve();
};
nextBtn.style.display = showNextButton ? 'inline-block' : 'none';
const updateDisplay = () => {
const minutes = Math.floor(secondsLeft / 60);
const seconds = secondsLeft % 60;
timerText.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
const progress = secondsLeft / totalSeconds;
const dashoffset = CIRCLE_LENGTH * (1 - progress);
timerProgressCircle.style.strokeDashoffset = dashoffset;
};
resetTimerDisplay(totalSeconds);
setTimeout(() => {
timerProgressCircle.style.transition = `stroke-dashoffset 1s linear`;
}, 100);
updateDisplay();
timerInterval = setInterval(() => {
secondsLeft--;
updateDisplay();
if (secondsLeft < 0) {
forceNext();
}
}, 1000);
});
}
function displayContent(part, task, contentHTML) {
questionCounter++;
partIndicatorHeader.textContent = `Speaking Part ${part}`;
questionArea.innerHTML = contentHTML;
questionIndicatorHeader.textContent = `Question ${questionCounter}`;
}
async function startTest() {
startScreen.classList.remove('active');
testScreen.classList.add('active');
testFooter.style.display = 'flex';
questionCounter = 0;
// Reset/đảm bảo data có sẵn trước khi chạy
if(typeof speakingData === 'undefined') {
alert("Không tìm thấy dữ liệu câu hỏi (speakingData). Vui lòng kiểm tra file js/data-speaking-test.js");
return;
}
await runPart1();
await runPart2();
await runPart3();
await runPart4();
testScreen.classList.remove('active');
endScreen.classList.add('active');
testFooter.style.display = 'none';
partIndicatorHeader.textContent = 'Test Finished';
questionIndicatorHeader.textContent = '';
}
async function runPart1() {
const questions = shuffle([...speakingData.part1]).slice(0, 3);
for (let i = 0; i < questions.length; i++) {
const duration = questions[i].prompt.duration;
displayContent('I', `Question ${i + 1}`, `<p class="test-question-text">${questions[i].prompt.question}</p>`);
resetTimerDisplay(duration);
nextBtn.style.display = 'inline-block';
await runSkippableDelay(3000);
await startSound.play().catch(e => console.error("Audio play failed:", e));
await runTimer(duration, true);
}
}
async function runPart2() {
const topic = shuffle([...speakingData.part2])[0];
const imageHTML = `<div class="test-image-container"><img src="${topic.imageSrc}" alt="Image for Part 2"></div>`;
for (let i = 0; i < topic.tasks.length; i++) {
const task = topic.tasks[i];
const duration = task.duration;
const contentHTML = `${imageHTML}<p class="test-question-text">${task.question}</p>`;
displayContent('II', `Task ${i + 1}`, contentHTML);
resetTimerDisplay(duration);
nextBtn.style.display = 'inline-block';
await runSkippableDelay(3000);
await startSound.play().catch(e => console.error("Audio play failed:", e));
await runTimer(duration, true);
}
}
async function runPart3() {
const topic = shuffle([...speakingData.part3])[0];
const imagesHTML = `<div class="test-image-container">...</div>`;
for (let i = 0; i < topic.tasks.length; i++) {
const task = topic.tasks[i];
const duration = task.duration;
const contentHTML = `${imagesHTML.replace('...', `<img src="${topic.image1Src}" alt="Picture 1"><img src="${topic.image2Src}" alt="Picture 2">`)}<p class="test-question-text">${task.question}</p>`;
displayContent('III', `Task ${i + 1}`, contentHTML);
resetTimerDisplay(duration);
nextBtn.style.display = 'inline-block';
await runSkippableDelay(3000);
await startSound.play().catch(e => console.error("Audio play failed:", e));
await runTimer(duration, true);
}
}
// === CẬP NHẬT PART 4: HIỂN THỊ RÕ THỜI GIAN CHUẨN BỊ VÀ TRẢ LỜI ===
async function runPart4() {
const topic = shuffle([...speakingData.part4])[0];
let questionsHTML = '<ul class="test-part4-questions">';
topic.tasks.forEach(task => { questionsHTML += `<li>${task.question}</li>`; });
questionsHTML += '</ul>';
// 1. Giai đoạn chuẩn bị (1 Phút)
const prepareBadge = '<div class="part4-status status-prepare"><i class="fas fa-pencil-alt"></i> CHUẨN BỊ (1 Phút)</div>';
const prepareContent = prepareBadge + '<br>' + questionsHTML;
displayContent('IV', 'Prepare your answer', prepareContent);
// Cập nhật lại header nhỏ bên phải để người dùng biết đang ở câu nào
questionIndicatorHeader.textContent = `Part 4 - Preparation`;
await runTimer(60, false); // Không hiện nút Next khi đang chuẩn bị
// 2. Giai đoạn trả lời (2 Phút)
await startSound.play().catch(e => console.error("Audio play failed:", e));
const speakingBadge = '<div class="part4-status status-speaking"><i class="fas fa-microphone"></i> TRẢ LỜI (2 Phút)</div>';
const speakingContent = speakingBadge + '<br>' + questionsHTML;
displayContent('IV', 'Answer all questions', speakingContent);
questionIndicatorHeader.textContent = `Part 4 - Speaking`;
await runTimer(120, true);
}
startBtn.addEventListener('click', startTest);
nextBtn.addEventListener('click', () => forceNext());
});
</script>
</body>
</html>