-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyQuiz.html
More file actions
446 lines (382 loc) · 14.7 KB
/
myQuiz.html
File metadata and controls
446 lines (382 loc) · 14.7 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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Known Test</title>
<link rel="stylesheet" href="tmp.css">
<style>
/* Font 설정 */
@font-face {
font-family: 'SBAggroB';
src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_2108@1.1/SBAggroB.woff') format('woff');
font-weight: normal;
font-style: normal;
}
/* CSS 변수 설정 */
:root {
--primary-color: black;
--secondary-color: black;
--background-color: #f5f5f5;
--container-width: 600px;
}
body {
font-family: 'SBAggroB', Arial, sans-serif;
margin: 0;
padding: 0;
background-color: var(--background-color);
overflow-x: hidden;
/* 가로 스크롤 방지 */
}
h1 {
text-align: center;
color: var(--primary-color);
margin: 20px 0;
}
.container {
max-width: var(--container-width);
margin: 20px auto;
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.hidden {
display: none;
}
/* 버튼 스타일 */
.button {
background-color: var(--primary-color);
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 4px;
font-size: 16px;
margin-top: 20px;
/* 버튼 간격 추가 */
transition: background-color 0.3s ease;
}
.button:hover {
background-color: var(--secondary-color);
}
/* 질문 및 입력 스타일 */
.question {
margin-bottom: 20px;
}
input[type="text"],
textarea {
width: 100%;
padding: 15px;
margin-top: 15px;
/* 입력 요소 간격 추가 */
border: 1px solid #ccc;
border-radius: 4px;
font-size: 18px;
/* 입력 글씨 크기 증가 */
box-sizing: border-box;
}
textarea {
resize: none;
}
/* 결과 섹션 스타일 */
#result-section h2 {
color: var(--primary-color);
border-bottom: 2px solid var(--primary-color);
padding-bottom: 10px;
}
#incorrect-answers p {
margin: 10px 0;
padding: 10px;
background-color: #ffecec;
border: 1px solid #ffcccc;
border-radius: 4px;
}
#incorrect-answers strong {
color: var(--primary-color);
}
</style>
<script>
function showCategory() {
// 모든 FAQ 섹션을 숨김
let sections = document.querySelectorAll('.faq-section');
sections.forEach(section => section.style.display = 'none');
// 선택된 카테고리의 FAQ 섹션을 표시
let selectedCategory = document.getElementById('category-select').value;
let selectedSection = document.getElementById(selectedCategory);
if (selectedSection) {
selectedSection.style.display = 'block';
}
}
// 페이지 로드 시 기본적으로 '일반' 카테고리 보이기
window.onload = function () {
showCategory();
};
function searchFAQ(category) {
let searchInput = document.getElementById(category + '-search').value.toLowerCase(); // 검색 입력값
let faqList = document.getElementById(category + '-list'); // 해당 분야의 FAQ 리스트
let faqItems = faqList.getElementsByClassName('faq-item'); // FAQ 항목들
// 각 FAQ 항목을 검색어와 비교
for (let i = 0; i < faqItems.length; i++) {
let itemText = faqItems[i].textContent || faqItems[i].innerText; // 질문과 답변 텍스트
if (itemText.toLowerCase().indexOf(searchInput) > -1) {
faqItems[i].style.display = ''; // 검색어가 포함된 항목은 보이게
} else {
faqItems[i].style.display = 'none'; // 검색어가 포함되지 않은 항목은 숨김
}
}
}
// 질문 옆 버튼 클릭 시 답변 토글
document.addEventListener('DOMContentLoaded', () => {
const toggleButtons = document.querySelectorAll('.toggle-btn');
toggleButtons.forEach(button => {
button.addEventListener('click', () => {
const faqItem = button.closest('.faq-item'); // 버튼이 포함된 FAQ 항목
const answer = faqItem.querySelector('.faq-answer'); // 해당 항목의 답변
if (answer.style.display === 'block') {
// 답변 숨기기
answer.style.display = 'none';
button.textContent = '+'; // 버튼 텍스트 변경
} else {
// 답변 보이기
answer.style.display = 'block';
button.textContent = '-'; // 버튼 텍스트 변경
}
});
});
});
const content = [
{ title: "공지사항 ", url: "events.html" },
{ title: "자료집", url: "resources.html" },
{ title: "FAQ 페이지", url: "FAQ_Board.html" },
{ title: "홈페이지", url: "index.html" },
{ title: "소모임 소개", url: "club.html" },
{ title: "운영국", url: "team/team_1.html" },
{ title: "홍보국", url: "team/team_2.html" },
{ title: "기획국", url: "team/team_3.html" },
{ title: "Plan_manager", url: "Plan_manager.html" },
];
function searchContent() {
const query = document.getElementById('search-bar').value.toLowerCase();
const resultsContainer = document.getElementById('search-results');
resultsContainer.innerHTML = '';
if (query.trim() === '') {
resultsContainer.style.display = 'none';
return;
}
const results = content.filter(item => item.title.toLowerCase().includes(query));
if (results.length > 0) {
resultsContainer.style.display = 'block';
resultsContainer.innerHTML = results.map(item =>
`<p><a href="${item.url}" style="text-decoration: none; color: black;">${item.title}</a></p>`
).join('');
} else {
resultsContainer.style.display = 'block';
resultsContainer.innerHTML = '<p>검색 결과가 없습니다.</p>';
}
// 3초 후 검색 결과 숨기기
setTimeout(() => {
resultsContainer.style.display = 'none';
}, 1000);
}
document.addEventListener('DOMContentLoaded', () => {
const searchBar = document.getElementById('search-bar');
searchBar.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
event.preventDefault(); // 기본 동작 방지
searchContent();
}
});
});
</script>
</head>
<body>
<header>
<div class="logo">
<a href="index.html"> <!-- 이미지를 링크로 감싸기 -->
<img src="image/광운대학교.png" alt="Kwangwoon University Logo">
</a>
<h1>컴퓨터정보공학부 학생회</h1>
</div>
<div class="search-container">
<input type="text" id="search-bar" placeholder="검색...">
<span class="search-icon" onclick="searchContent()">⌕</span>
<nav class="menu-links">
<a href="index.html">홈페이지</a>
<a href="resources.html">자료집</a>
<a href="events.html">공지사항</a>
<a href="FAQ_Board.html">FAQ</a>
</nav>
<div id="search-results"></div>
</div>
</header>
<div class="navigation">
<a href="resources.html" class="back-arrow"><</a>
<h1>Known Test</h1>
</div>
<div class="container">
<div id="add-question-section">
<h2>새로운 문제 추가</h2>
<label for="new-question">문제:</label><br>
<textarea id="new-question" rows="3"></textarea><br>
<label for="new-answer">정답:</label><br>
<input type="text" id="new-answer"><br>
<button class="button" onclick="addQuestion()">문제 추가</button>
</div>
<div id="quiz-section" class="hidden">
<h2>퀴즈 풀기</h2>
<div id="quiz"></div>
<button class="button" onclick="startQuiz()">퀴즈 시작</button>
</div>
<div id="result-section" class="hidden">
<h2>결과</h2>
<p id="result-summary"></p>
<div id="incorrect-answers"></div>
<button class="button" onclick="resetToMain()">메인 화면으로 돌아가기</button>
</div>
</div>
<script>
const questionsAndAnswers = [];
let currentQuestionIndex = 0;
let score = 0;
let incorrectAnswers = [];
function addQuestion() {
const question = document.getElementById('new-question').value.trim();
const answer = document.getElementById('new-answer').value.trim();
if (question && answer) {
questionsAndAnswers.push({ question, answer });
alert('문제가 성공적으로 추가되었습니다!');
document.getElementById('new-question').value = '';
document.getElementById('new-answer').value = '';
if (questionsAndAnswers.length === 1) {
document.getElementById('quiz-section').classList.remove('hidden');
}
} else {
alert('문제와 정답을 모두 입력해주세요.');
}
}
function startQuiz() {
if (questionsAndAnswers.length === 0) {
alert('추가된 문제가 없습니다. 문제를 추가해주세요.');
return;
}
currentQuestionIndex = 0;
score = 0;
incorrectAnswers = [];
document.getElementById('add-question-section').classList.add('hidden');
document.getElementById('quiz-section').classList.remove('hidden');
showQuestion();
}
function showQuestion() {
const quizDiv = document.getElementById('quiz');
quizDiv.innerHTML = '';
document.getElementById('result-section').classList.add('hidden');
const { question } = questionsAndAnswers[currentQuestionIndex];
const questionElement = document.createElement('div');
questionElement.className = 'question';
questionElement.innerHTML = `<strong>문제 ${currentQuestionIndex + 1}:</strong> ${question}`;
const input = document.createElement('input');
input.type = 'text';
input.id = 'user-answer';
const button = document.createElement('button');
button.className = 'button';
button.textContent = '정답 제출';
button.onclick = checkAnswer;
quizDiv.appendChild(questionElement);
quizDiv.appendChild(input);
quizDiv.appendChild(button);
quizDiv.classList.remove('hidden');
}
function checkAnswer() {
const userAnswer = document.getElementById('user-answer').value.trim();
const correctAnswer = questionsAndAnswers[currentQuestionIndex].answer;
if (userAnswer.toLowerCase() === correctAnswer.toLowerCase()) {
score++;
alert('정답입니다!');
} else {
alert(`오답입니다! 정답: ${correctAnswer}`);
incorrectAnswers.push({
question: questionsAndAnswers[currentQuestionIndex].question,
correctAnswer,
userAnswer,
});
}
currentQuestionIndex++;
if (currentQuestionIndex < questionsAndAnswers.length) {
showQuestion();
} else {
showResults();
}
}
function showResults() {
document.getElementById('quiz').classList.add('hidden');
const resultSection = document.getElementById('result-section');
const resultSummary = document.getElementById('result-summary');
resultSummary.textContent = `총 점수: ${score} / ${questionsAndAnswers.length}`;
const incorrectDiv = document.getElementById('incorrect-answers');
incorrectDiv.innerHTML = '';
if (incorrectAnswers.length > 0) {
const title = document.createElement('h3');
title.textContent = '틀린 문제';
incorrectDiv.appendChild(title);
incorrectAnswers.forEach((item, index) => {
const questionText = document.createElement('p');
questionText.innerHTML = `<strong>문제 ${index + 1}:</strong> ${item.question}<br><strong>사용자 답변:</strong> ${item.userAnswer}<br><strong>정답:</strong> ${item.correctAnswer}`;
incorrectDiv.appendChild(questionText);
});
}
resultSection.classList.remove('hidden');
}
function resetToMain() {
document.getElementById('add-question-section').classList.remove('hidden');
document.getElementById('quiz-section').classList.add('hidden');
document.getElementById('result-section').classList.add('hidden');
}
</script>
<div class="side-bar">
<div class="links">
<ul>
<li><a href="login.html" style="color:white; text-decoration:none;">로그아웃</a></li>
<li><a href="index.html" style="color:white; text-decoration:none;">홈페이지</a></li>
<li><a href="resources.html" style="color:white; text-decoration:none;">자료집</a></li>
<li><a href="events.html" style="color:white; text-decoration:none;">공지사항</a></li>
<li><a href="club.html" style="color:white; text-decoration:none;">소모임 소개</a></li>
<li><a href="introduce_2.html" style="color:white; text-decoration:none;">학과 소개</a></li>
<li><a href="FAQ_Board.html" style="color:white; text-decoration:none;">FAQ</a></li>
<li><a href="Plan_manager.html" style="color:white; text-decoration:none;">Plan Manager</a></li>
</ul>
</div>
<div class="footer-links">
<a href="https://www.kw.ac.kr" target="_blank">광운대학교 홈페이지</a>
<a href="https://sw.kw.ac.kr" target="_blank">인융대 홈페이지</a>
</div>
</div>
<!-- 푸터 -->
<footer>
<div class="footer-left"></div>
<div class="footer-right">
<!-- 첫 번째 아이콘: 카카오톡 -->
<div class="icon-wrapper">
<a href="https://open.kakao.com/o/gDFOk91g" target="_blank">
<img src="image/메세지.png" alt="카카오톡 아이콘" class="footer-icon"
style="width: 60px; height: 50px; transition: transform 0.2s ease;">
</a>
<div class="tooltip">카카오톡 채팅방으로 이동합니다.</div>
</div>
<!-- 두 번째 아이콘: 인스타그램 -->
<div class="icon-wrapper">
<a href="https://www.instagram.com/kw_cie/" target="_blank">
<img src="image/인스타그램.png" alt="인스타그램 아이콘" class="footer-icon"
style="width: 60px; height: 50px; transition: transform 0.2s ease;">
</a>
<div class="tooltip">인스타그램 페이지로 이동합니다.</div>
</div>
<!-- 텍스트 영역 -->
<div class="text">
<p>김재용(회장): 010-5651-4415</p>
<p>최우진(부회장): 010-4907-7802</p>
</div>
</div>
</footer>
</body>
</html>