lss9566 commited on
Commit
6471abd
·
verified ·
1 Parent(s): 8142ae5

Upload 2 files

Browse files
Files changed (1) hide show
  1. simple_quiz.html +98 -85
simple_quiz.html CHANGED
@@ -5,6 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>인적자원관리 퀴즈</title>
7
  <style>
 
8
  body {
9
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
10
  line-height: 1.6;
@@ -13,11 +14,12 @@
13
  color: #1a202c;
14
  min-height: 100vh;
15
  padding: 20px;
 
16
  }
17
  .container {
18
- max-width: 800px;
19
  margin: 0 auto;
20
- padding: 0 20px;
21
  }
22
  .quiz-header {
23
  background: rgba(255, 255, 255, 0.95);
@@ -30,7 +32,7 @@
30
  text-align: center;
31
  }
32
  .quiz-title {
33
- font-size: 28px;
34
  font-weight: 700;
35
  margin: 0 0 15px 0;
36
  background: linear-gradient(135deg, #667eea, #764ba2);
@@ -41,29 +43,30 @@
41
  .card {
42
  background: rgba(255, 255, 255, 0.95);
43
  backdrop-filter: blur(20px);
44
- border-radius: 20px;
45
- padding: 30px;
46
- margin: 20px 0;
47
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
48
  border: 1px solid rgba(255, 255, 255, 0.2);
49
  }
50
  .question-text {
51
- font-size: 18px;
52
  font-weight: 500;
53
  line-height: 1.7;
54
- margin-bottom: 25px;
55
  color: #2d3748;
56
  }
57
  .choice {
58
  display: block;
59
  border: 2px solid #e2e8f0;
60
  border-radius: 12px;
61
- padding: 16px 20px;
62
- margin: 12px 0;
63
  background: white;
64
  cursor: pointer;
65
  transition: all 0.3s ease;
66
  font-weight: 500;
 
67
  color: #4a5568;
68
  width: 100%;
69
  text-align: left;
@@ -84,10 +87,10 @@
84
  color: white;
85
  border: none;
86
  border-radius: 12px;
87
- padding: 12px 24px;
88
  cursor: pointer;
89
  font-weight: 500;
90
- font-size: 14px;
91
  transition: all 0.3s ease;
92
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
93
  margin: 10px 5px;
@@ -104,11 +107,12 @@
104
  background: rgba(255, 255, 255, 0.9);
105
  backdrop-filter: blur(10px);
106
  border-radius: 15px;
107
- padding: 15px 25px;
108
- margin-bottom: 20px;
109
  display: flex;
110
  justify-content: space-between;
111
  align-items: center;
 
112
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
113
  border: 1px solid rgba(255, 255, 255, 0.3);
114
  }
@@ -119,12 +123,24 @@
119
  .score-display {
120
  background: linear-gradient(135deg, #48bb78, #38a169);
121
  color: white;
122
- padding: 8px 16px;
123
  border-radius: 20px;
124
  font-weight: 600;
125
  font-size: 14px;
126
  box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
127
  }
 
 
 
 
 
 
 
 
 
 
 
 
128
  </style>
129
  </head>
130
  <body>
@@ -232,105 +248,102 @@
232
  const btn = document.createElement('button');
233
  btn.className = 'choice';
234
  btn.textContent = (i + 1) + '. ' + c;
235
-
236
- if (!st.revealed) {
237
- btn.onclick = () => select(c);
238
- if (st.selected === c) btn.classList.add('selected');
239
- } else {
240
  btn.disabled = true;
 
241
  if (normalize(c) === normalize(q.answer)) {
242
- btn.style.backgroundColor = '#c6f6d5';
243
  btn.style.borderColor = '#48bb78';
244
- }
245
- if (st.selected === c && !st.correct) {
246
- btn.style.backgroundColor = '#fed7d7';
247
- btn.style.borderColor = '#f56565';
248
  }
249
  }
 
 
 
 
 
250
  card.appendChild(btn);
251
  });
252
  }
253
 
254
- if (st.revealed) {
255
- const resultDiv = document.createElement('div');
256
- resultDiv.style.cssText = 'margin-top: 20px; padding: 15px; border-radius: 10px; text-align: center; font-weight: 600;';
257
- if (st.correct) {
258
- resultDiv.textContent = '정답입니다! ✅';
259
- resultDiv.style.backgroundColor = '#c6f6d5';
260
- resultDiv.style.color = '#22543d';
261
- } else {
262
- resultDiv.textContent = '틀렸습니다! ❌';
263
- resultDiv.style.backgroundColor = '#fed7d7';
264
- resultDiv.style.color = '#742a2a';
265
- }
266
- card.appendChild(resultDiv);
267
 
268
- const answerDiv = document.createElement('div');
269
- answerDiv.style.cssText = 'margin-top: 10px; padding: 10px; background: #f7fafc; border-radius: 8px;';
270
- const answerIndex = q.choices.findIndex(choice => normalize(choice) === normalize(q.answer));
271
- answerDiv.innerHTML = `<strong>정답:</strong> ${answerIndex + 1}`;
272
- card.appendChild(answerDiv);
273
- }
 
 
 
 
 
 
 
274
 
275
  quiz.appendChild(card);
276
 
277
- // 상태 업데이트
278
- document.getElementById('status').textContent = `문항 ${idx + 1}/${questions.length}`;
279
  document.getElementById('score-text').textContent = `${score}/${questions.length}`;
280
-
281
- const prevBtn = document.getElementById('prev');
282
- const nextBtn = document.getElementById('next');
283
- prevBtn.disabled = idx === 0;
284
- nextBtn.textContent = st.revealed ? (idx === questions.length - 1 ? '완료' : '다음 →') : '다음 →';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  }
286
 
287
  function restart() {
288
  idx = 0;
289
  score = 0;
290
- state.clear();
291
  finished = false;
292
  render();
293
  }
294
 
295
- // 이벤트 리스너
296
- document.getElementById('prev').onclick = () => {
297
- if (finished) return;
298
  if (idx > 0) {
299
- idx--;
300
  render();
301
  }
302
- };
303
-
304
- document.getElementById('next').onclick = () => {
305
- if (finished) {
306
- restart();
307
- return;
308
- }
309
-
310
- const st = getState(idx);
311
- if (!st.revealed) {
312
- if (st.selected == null) {
313
- alert('먼저 답을 선택하세요.');
314
- return;
315
- }
316
- st.revealed = true;
317
- if (st.correct && !st.scored) {
318
- score++;
319
- st.scored = true;
320
- }
321
  render();
322
- } else {
323
- if (idx < questions.length - 1) {
324
- idx++;
325
- render();
326
- } else {
327
- finished = true;
328
- render();
329
- }
330
  }
331
- };
332
 
333
- // 초기 렌더링
334
  render();
335
  </script>
336
  </body>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>인적자원관리 퀴즈</title>
7
  <style>
8
+ * , *::before, *::after { box-sizing: border-box; }
9
  body {
10
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
11
  line-height: 1.6;
 
14
  color: #1a202c;
15
  min-height: 100vh;
16
  padding: 20px;
17
+ overflow-x: hidden;
18
  }
19
  .container {
20
+ max-width: 720px;
21
  margin: 0 auto;
22
+ padding: 0 16px;
23
  }
24
  .quiz-header {
25
  background: rgba(255, 255, 255, 0.95);
 
32
  text-align: center;
33
  }
34
  .quiz-title {
35
+ font-size: clamp(22px, 6vw, 28px);
36
  font-weight: 700;
37
  margin: 0 0 15px 0;
38
  background: linear-gradient(135deg, #667eea, #764ba2);
 
43
  .card {
44
  background: rgba(255, 255, 255, 0.95);
45
  backdrop-filter: blur(20px);
46
+ border-radius: 16px;
47
+ padding: 24px;
48
+ margin: 16px 0;
49
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
50
  border: 1px solid rgba(255, 255, 255, 0.2);
51
  }
52
  .question-text {
53
+ font-size: clamp(16px, 4.5vw, 18px);
54
  font-weight: 500;
55
  line-height: 1.7;
56
+ margin-bottom: 20px;
57
  color: #2d3748;
58
  }
59
  .choice {
60
  display: block;
61
  border: 2px solid #e2e8f0;
62
  border-radius: 12px;
63
+ padding: 14px 16px;
64
+ margin: 10px 0;
65
  background: white;
66
  cursor: pointer;
67
  transition: all 0.3s ease;
68
  font-weight: 500;
69
+ font-size: clamp(16px, 5vw, 18px);
70
  color: #4a5568;
71
  width: 100%;
72
  text-align: left;
 
87
  color: white;
88
  border: none;
89
  border-radius: 12px;
90
+ padding: 12px 20px;
91
  cursor: pointer;
92
  font-weight: 500;
93
+ font-size: 15px;
94
  transition: all 0.3s ease;
95
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
96
  margin: 10px 5px;
 
107
  background: rgba(255, 255, 255, 0.9);
108
  backdrop-filter: blur(10px);
109
  border-radius: 15px;
110
+ padding: 12px 18px;
111
+ margin-bottom: 16px;
112
  display: flex;
113
  justify-content: space-between;
114
  align-items: center;
115
+ gap: 8px;
116
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
117
  border: 1px solid rgba(255, 255, 255, 0.3);
118
  }
 
123
  .score-display {
124
  background: linear-gradient(135deg, #48bb78, #38a169);
125
  color: white;
126
+ padding: 8px 14px;
127
  border-radius: 20px;
128
  font-weight: 600;
129
  font-size: 14px;
130
  box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
131
  }
132
+
133
+ /* Mobile optimizations */
134
+ @media (max-width: 480px) {
135
+ body { padding: 8px; }
136
+ .container { padding: 0 6px; max-width: 100%; }
137
+ .quiz-header { padding: 18px; border-radius: 16px; }
138
+ .card { padding: 16px; border-radius: 14px; }
139
+ .question-text { margin-bottom: 16px; }
140
+ .choice { padding: 14px 16px; margin: 8px 0; font-size: clamp(17px, 5.4vw, 19px); }
141
+ .status-bar { flex-direction: column; align-items: stretch; text-align: center; }
142
+ .btn { padding: 12px 18px; font-size: 15px; }
143
+ }
144
  </style>
145
  </head>
146
  <body>
 
248
  const btn = document.createElement('button');
249
  btn.className = 'choice';
250
  btn.textContent = (i + 1) + '. ' + c;
251
+ btn.onclick = () => select(c);
252
+
253
+ const stNow = getState(idx);
254
+ if (stNow.revealed) {
 
255
  btn.disabled = true;
256
+ btn.style.cursor = 'default';
257
  if (normalize(c) === normalize(q.answer)) {
 
258
  btn.style.borderColor = '#48bb78';
259
+ btn.style.background = 'linear-gradient(135deg, #f0fff4, #ebf8ff)';
260
+ btn.style.color = '#2f855a';
 
 
261
  }
262
  }
263
+
264
+ if (stNow.selected === c) {
265
+ btn.classList.add('selected');
266
+ }
267
+
268
  card.appendChild(btn);
269
  });
270
  }
271
 
272
+ const btnWrap = document.createElement('div');
273
+ btnWrap.style.textAlign = 'center';
274
+ btnWrap.style.marginTop = '12px';
 
 
 
 
 
 
 
 
 
 
275
 
276
+ const submitBtn = document.createElement('button');
277
+ submitBtn.className = 'btn';
278
+ submitBtn.textContent = '정답 확인';
279
+ submitBtn.onclick = () => reveal();
280
+
281
+ const nextBtn = document.createElement('button');
282
+ nextBtn.className = 'btn';
283
+ nextBtn.textContent = '다음 문항';
284
+ nextBtn.onclick = () => gotoNext();
285
+
286
+ btnWrap.appendChild(submitBtn);
287
+ btnWrap.appendChild(nextBtn);
288
+ card.appendChild(btnWrap);
289
 
290
  quiz.appendChild(card);
291
 
292
+ // 상태 갱신
293
+ document.getElementById('status').textContent = `문항 ${idx+1}/${questions.length}`;
294
  document.getElementById('score-text').textContent = `${score}/${questions.length}`;
295
+
296
+ // 버튼 상태
297
+ document.getElementById('prev').disabled = (idx === 0);
298
+ document.getElementById('next').disabled = (idx >= questions.length - 1);
299
+ }
300
+
301
+ function reveal() {
302
+ const st = getState(idx);
303
+ if (st.revealed) return;
304
+ const q = questions[idx];
305
+ if (st.selected == null) return;
306
+ st.revealed = true;
307
+ if (!st.scored && st.correct) {
308
+ score += 1;
309
+ st.scored = true;
310
+ }
311
+ render();
312
+ }
313
+
314
+ function gotoNext() {
315
+ if (idx < questions.length - 1) {
316
+ idx += 1;
317
+ render();
318
+ } else {
319
+ finished = true;
320
+ render();
321
+ }
322
  }
323
 
324
  function restart() {
325
  idx = 0;
326
  score = 0;
327
+ state = new Map();
328
  finished = false;
329
  render();
330
  }
331
 
332
+ // 하단 버튼
333
+ document.getElementById('prev').addEventListener('click', () => {
 
334
  if (idx > 0) {
335
+ idx -= 1;
336
  render();
337
  }
338
+ });
339
+ document.getElementById('next').addEventListener('click', () => {
340
+ if (idx < questions.length - 1) {
341
+ idx += 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  render();
 
 
 
 
 
 
 
 
343
  }
344
+ });
345
 
346
+ // 초기 렌더
347
  render();
348
  </script>
349
  </body>