Сценарий для учителя
+-
+
- Нажмите «Начать викторину» и выводите вопросы на экран. +
- Дайте детям 20–30 секунд на обсуждение. +
- Выберите вариант ответа, затем нажмите «Показать ответ». +
- В конце покажите итоги и обсудите факты. +
diff --git a/assets/css/custom.css b/assets/css/custom.css
index 789132e..eeac63a 100644
--- a/assets/css/custom.css
+++ b/assets/css/custom.css
@@ -1,403 +1,189 @@
+:root {
+ color-scheme: light;
+ --bg: #f8fafc;
+ --surface: #ffffff;
+ --border: #e2e8f0;
+ --text: #0f172a;
+ --muted: #64748b;
+ --accent: #1f2937;
+ --accent-soft: #e5e7eb;
+}
+
+* {
+ box-sizing: border-box;
+}
+
body {
- background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
- background-size: 400% 400%;
- animation: gradient 15s ease infinite;
- color: #212529;
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
- font-size: 14px;
- margin: 0;
- min-height: 100vh;
+ font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
+ background: var(--bg);
+ color: var(--text);
+ letter-spacing: -0.01em;
}
-.main-wrapper {
- display: flex;
- align-items: center;
- justify-content: center;
- min-height: 100vh;
- width: 100%;
- padding: 20px;
- box-sizing: border-box;
- position: relative;
- z-index: 1;
+a {
+ color: inherit;
}
-@keyframes gradient {
- 0% {
- background-position: 0% 50%;
- }
- 50% {
- background-position: 100% 50%;
- }
- 100% {
- background-position: 0% 50%;
- }
+.hero-card,
+.quiz-card,
+.info-card {
+ background: var(--surface);
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ padding: 2rem;
+ box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}
-.chat-container {
- width: 100%;
- max-width: 600px;
- background: rgba(255, 255, 255, 0.85);
- border: 1px solid rgba(255, 255, 255, 0.3);
- border-radius: 20px;
- display: flex;
- flex-direction: column;
- height: 85vh;
- box-shadow: 0 20px 40px rgba(0,0,0,0.2);
- backdrop-filter: blur(15px);
- -webkit-backdrop-filter: blur(15px);
- overflow: hidden;
+.stat-stack {
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ background: #f9fafb;
}
-.chat-header {
+.score-badge {
+ background: #f9fafb;
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ padding: 0.75rem 1rem;
+ min-width: 140px;
+ text-align: center;
+}
+
+.question-area {
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 1.5rem;
+ background: #f8fafc;
+}
+
+.option-list {
+ margin: 0;
+ padding: 0;
+ display: grid;
+ gap: 0.75rem;
+}
+
+.option-item {
+ border: 1px solid var(--border);
+ background: #ffffff;
+ border-radius: 10px;
+ padding: 0.85rem 1rem;
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ font-weight: 600;
+ cursor: pointer;
+ transition: 0.2s ease;
+}
+
+.option-item:hover {
+ border-color: #94a3b8;
+ transform: translateY(-1px);
+}
+
+.option-item-selected {
+ border-color: #2563eb;
+ background: #eff6ff;
+}
+
+.option-item-correct {
+ border-color: #16a34a;
+ background: #f0fdf4;
+}
+
+.option-item-wrong {
+ border-color: #dc2626;
+ background: #fef2f2;
+}
+
+.option-index {
+ width: 36px;
+ height: 36px;
+ border-radius: 8px;
+ background: var(--accent-soft);
+ color: var(--accent);
+ display: grid;
+ place-items: center;
+ font-weight: 700;
+}
+
+.answer-pill {
+ background: #111827;
+ color: #fff;
+ border-radius: 999px;
+ padding: 0.25rem 0.75rem;
+ font-size: 0.75rem;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+}
+
+.answer-figure {
+ width: 100%;
+ max-width: 360px;
+}
+
+.answer-image,
+.summary-image {
+ width: 100%;
+ height: auto;
+ border-radius: 10px;
+ border: 1px solid var(--border);
+ object-fit: cover;
+}
+
+.summary-image {
+ margin-bottom: 0.75rem;
+ aspect-ratio: 16 / 9;
+}
+
+.summary-list {
+ display: grid;
+ gap: 1rem;
+}
+
+.summary-item {
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ padding: 1rem;
+ background: #ffffff;
+}
+
+.summary-item p {
+ margin-bottom: 0.35rem;
+}
+
+.btn-primary {
+ background: #111827;
+ border-color: #111827;
+}
+
+.btn-primary:hover,
+.btn-primary:focus {
+ background: #0f172a;
+ border-color: #0f172a;
+}
+
+.btn-dark {
+ background: #1f2937;
+ border-color: #1f2937;
+}
+
+.btn-dark:hover,
+.btn-dark:focus {
+ background: #111827;
+ border-color: #111827;
+}
+
+code {
+ background: #f1f5f9;
+ padding: 0.1rem 0.35rem;
+ border-radius: 6px;
+}
+
+@media (max-width: 767px) {
+ .hero-card,
+ .quiz-card,
+ .info-card {
padding: 1.5rem;
- border-bottom: 1px solid rgba(0, 0, 0, 0.05);
- background: rgba(255, 255, 255, 0.5);
- font-weight: 700;
- font-size: 1.1rem;
- display: flex;
- justify-content: space-between;
- align-items: center;
+ }
}
-
-.chat-messages {
- flex: 1;
- overflow-y: auto;
- padding: 1.5rem;
- display: flex;
- flex-direction: column;
- gap: 1.25rem;
-}
-
-/* Custom Scrollbar */
-::-webkit-scrollbar {
- width: 6px;
-}
-
-::-webkit-scrollbar-track {
- background: transparent;
-}
-
-::-webkit-scrollbar-thumb {
- background: rgba(255, 255, 255, 0.3);
- border-radius: 10px;
-}
-
-::-webkit-scrollbar-thumb:hover {
- background: rgba(255, 255, 255, 0.5);
-}
-
-.message {
- max-width: 85%;
- padding: 0.85rem 1.1rem;
- border-radius: 16px;
- line-height: 1.5;
- font-size: 0.95rem;
- box-shadow: 0 4px 15px rgba(0,0,0,0.05);
- animation: fadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
-}
-
-@keyframes fadeIn {
- from { opacity: 0; transform: translateY(20px) scale(0.95); }
- to { opacity: 1; transform: translateY(0) scale(1); }
-}
-
-.message.visitor {
- align-self: flex-end;
- background: linear-gradient(135deg, #212529 0%, #343a40 100%);
- color: #fff;
- border-bottom-right-radius: 4px;
-}
-
-.message.bot {
- align-self: flex-start;
- background: #ffffff;
- color: #212529;
- border-bottom-left-radius: 4px;
-}
-
-.chat-input-area {
- padding: 1.25rem;
- background: rgba(255, 255, 255, 0.5);
- border-top: 1px solid rgba(0, 0, 0, 0.05);
-}
-
-.chat-input-area form {
- display: flex;
- gap: 0.75rem;
-}
-
-.chat-input-area input {
- flex: 1;
- border: 1px solid rgba(0, 0, 0, 0.1);
- border-radius: 12px;
- padding: 0.75rem 1rem;
- outline: none;
- background: rgba(255, 255, 255, 0.9);
- transition: all 0.3s ease;
-}
-
-.chat-input-area input:focus {
- border-color: #23a6d5;
- box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.2);
-}
-
-.chat-input-area button {
- background: #212529;
- color: #fff;
- border: none;
- padding: 0.75rem 1.5rem;
- border-radius: 12px;
- cursor: pointer;
- font-weight: 600;
- transition: all 0.3s ease;
-}
-
-.chat-input-area button:hover {
- background: #000;
- transform: translateY(-2px);
- box-shadow: 0 5px 15px rgba(0,0,0,0.2);
-}
-
-/* Background Animations */
-.bg-animations {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: 0;
- overflow: hidden;
- pointer-events: none;
-}
-
-.blob {
- position: absolute;
- width: 500px;
- height: 500px;
- background: rgba(255, 255, 255, 0.2);
- border-radius: 50%;
- filter: blur(80px);
- animation: move 20s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
-}
-
-.blob-1 {
- top: -10%;
- left: -10%;
- background: rgba(238, 119, 82, 0.4);
-}
-
-.blob-2 {
- bottom: -10%;
- right: -10%;
- background: rgba(35, 166, 213, 0.4);
- animation-delay: -7s;
- width: 600px;
- height: 600px;
-}
-
-.blob-3 {
- top: 40%;
- left: 30%;
- background: rgba(231, 60, 126, 0.3);
- animation-delay: -14s;
- width: 450px;
- height: 450px;
-}
-
-@keyframes move {
- 0% { transform: translate(0, 0) rotate(0deg) scale(1); }
- 33% { transform: translate(150px, 100px) rotate(120deg) scale(1.1); }
- 66% { transform: translate(-50px, 200px) rotate(240deg) scale(0.9); }
- 100% { transform: translate(0, 0) rotate(360deg) scale(1); }
-}
-
-.header-link {
- font-size: 14px;
- color: #fff;
- text-decoration: none;
- background: rgba(0, 0, 0, 0.2);
- padding: 0.5rem 1rem;
- border-radius: 8px;
- transition: all 0.3s ease;
-}
-
-.header-link:hover {
- background: rgba(0, 0, 0, 0.4);
- text-decoration: none;
-}
-
-/* Admin Styles */
-.admin-container {
- max-width: 900px;
- margin: 3rem auto;
- padding: 2.5rem;
- background: rgba(255, 255, 255, 0.85);
- backdrop-filter: blur(20px);
- -webkit-backdrop-filter: blur(20px);
- border-radius: 24px;
- box-shadow: 0 20px 50px rgba(0,0,0,0.15);
- border: 1px solid rgba(255, 255, 255, 0.4);
- position: relative;
- z-index: 1;
-}
-
-.admin-container h1 {
- margin-top: 0;
- color: #212529;
- font-weight: 800;
-}
-
-.table {
- width: 100%;
- border-collapse: separate;
- border-spacing: 0 8px;
- margin-top: 1.5rem;
-}
-
-.table th {
- background: transparent;
- border: none;
- padding: 1rem;
- color: #6c757d;
- font-weight: 600;
- text-transform: uppercase;
- font-size: 0.75rem;
- letter-spacing: 1px;
-}
-
-.table td {
- background: #fff;
- padding: 1rem;
- border: none;
-}
-
-.table tr td:first-child { border-radius: 12px 0 0 12px; }
-.table tr td:last-child { border-radius: 0 12px 12px 0; }
-
-.form-group {
- margin-bottom: 1.25rem;
-}
-
-.form-group label {
- display: block;
- margin-bottom: 0.5rem;
- font-weight: 600;
- font-size: 0.9rem;
-}
-
-.form-control {
- width: 100%;
- padding: 0.75rem 1rem;
- border: 1px solid rgba(0, 0, 0, 0.1);
- border-radius: 12px;
- background: #fff;
- transition: all 0.3s ease;
- box-sizing: border-box;
-}
-
-.form-control:focus {
- outline: none;
- border-color: #23a6d5;
- box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.1);
-}
-
-.header-container {
- display: flex;
- justify-content: space-between;
- align-items: center;
-}
-
-.header-links {
- display: flex;
- gap: 1rem;
-}
-
-.admin-card {
- background: rgba(255, 255, 255, 0.6);
- padding: 2rem;
- border-radius: 20px;
- border: 1px solid rgba(255, 255, 255, 0.5);
- margin-bottom: 2.5rem;
- box-shadow: 0 10px 30px rgba(0,0,0,0.05);
-}
-
-.admin-card h3 {
- margin-top: 0;
- margin-bottom: 1.5rem;
- font-weight: 700;
-}
-
-.btn-delete {
- background: #dc3545;
- color: white;
- border: none;
- padding: 0.25rem 0.5rem;
- border-radius: 4px;
- cursor: pointer;
-}
-
-.btn-add {
- background: #212529;
- color: white;
- border: none;
- padding: 0.5rem 1rem;
- border-radius: 4px;
- cursor: pointer;
- margin-top: 1rem;
-}
-
-.btn-save {
- background: #0088cc;
- color: white;
- border: none;
- padding: 0.8rem 1.5rem;
- border-radius: 12px;
- cursor: pointer;
- font-weight: 600;
- width: 100%;
- transition: all 0.3s ease;
-}
-
-.webhook-url {
- font-size: 0.85em;
- color: #555;
- margin-top: 0.5rem;
-}
-
-.history-table-container {
- overflow-x: auto;
- background: rgba(255, 255, 255, 0.4);
- padding: 1rem;
- border-radius: 12px;
- border: 1px solid rgba(255, 255, 255, 0.3);
-}
-
-.history-table {
- width: 100%;
-}
-
-.history-table-time {
- width: 15%;
- white-space: nowrap;
- font-size: 0.85em;
- color: #555;
-}
-
-.history-table-user {
- width: 35%;
- background: rgba(255, 255, 255, 0.3);
- border-radius: 8px;
- padding: 8px;
-}
-
-.history-table-ai {
- width: 50%;
- background: rgba(255, 255, 255, 0.5);
- border-radius: 8px;
- padding: 8px;
-}
-
-.no-messages {
- text-align: center;
- color: #777;
-}
\ No newline at end of file
diff --git a/assets/images/quiz/q01-minsk.jpg b/assets/images/quiz/q01-minsk.jpg
new file mode 100644
index 0000000..be3a59c
Binary files /dev/null and b/assets/images/quiz/q01-minsk.jpg differ
diff --git a/assets/images/quiz/q02-flag.jpg b/assets/images/quiz/q02-flag.jpg
new file mode 100644
index 0000000..a7ccb04
Binary files /dev/null and b/assets/images/quiz/q02-flag.jpg differ
diff --git a/assets/images/quiz/q03-lake.jpg b/assets/images/quiz/q03-lake.jpg
new file mode 100644
index 0000000..ef9f610
Binary files /dev/null and b/assets/images/quiz/q03-lake.jpg differ
diff --git a/assets/images/quiz/q04-bison.jpg b/assets/images/quiz/q04-bison.jpg
new file mode 100644
index 0000000..91a7d82
Binary files /dev/null and b/assets/images/quiz/q04-bison.jpg differ
diff --git a/assets/images/quiz/q05-forest.jpg b/assets/images/quiz/q05-forest.jpg
new file mode 100644
index 0000000..9138bb2
Binary files /dev/null and b/assets/images/quiz/q05-forest.jpg differ
diff --git a/assets/images/quiz/q06-vitebsk.jpg b/assets/images/quiz/q06-vitebsk.jpg
new file mode 100644
index 0000000..054fd1b
Binary files /dev/null and b/assets/images/quiz/q06-vitebsk.jpg differ
diff --git a/assets/images/quiz/q07-cimbaly.jpg b/assets/images/quiz/q07-cimbaly.jpg
new file mode 100644
index 0000000..c69c274
Binary files /dev/null and b/assets/images/quiz/q07-cimbaly.jpg differ
diff --git a/assets/images/quiz/q08-castle.jpg b/assets/images/quiz/q08-castle.jpg
new file mode 100644
index 0000000..9f93874
Binary files /dev/null and b/assets/images/quiz/q08-castle.jpg differ
diff --git a/assets/images/quiz/q09-river.jpg b/assets/images/quiz/q09-river.jpg
new file mode 100644
index 0000000..6c18918
Binary files /dev/null and b/assets/images/quiz/q09-river.jpg differ
diff --git a/assets/images/quiz/q10-ornament.jpg b/assets/images/quiz/q10-ornament.jpg
new file mode 100644
index 0000000..7d49dc5
Binary files /dev/null and b/assets/images/quiz/q10-ornament.jpg differ
diff --git a/assets/images/quiz/q11-polotsk.jpg b/assets/images/quiz/q11-polotsk.jpg
new file mode 100644
index 0000000..f5947b1
Binary files /dev/null and b/assets/images/quiz/q11-polotsk.jpg differ
diff --git a/assets/images/quiz/q12-kozinaki.jpg b/assets/images/quiz/q12-kozinaki.jpg
new file mode 100644
index 0000000..d93237d
Binary files /dev/null and b/assets/images/quiz/q12-kozinaki.jpg differ
diff --git a/assets/js/main.js b/assets/js/main.js
index d349598..b54e9a1 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -1,39 +1,254 @@
-document.addEventListener('DOMContentLoaded', () => {
- const chatForm = document.getElementById('chat-form');
- const chatInput = document.getElementById('chat-input');
- const chatMessages = document.getElementById('chat-messages');
+const quizData = [
+ {
+ question: "Столица Беларуси — это…",
+ options: ["Гродно", "Минск", "Витебск", "Гомель"],
+ answer: 1,
+ fact: "Минск — самый большой город страны и её главный культурный центр.",
+ imagePath: "assets/images/quiz/q01-minsk.jpg",
+ imageAlt: "Панорама Минска"
+ },
+ {
+ question: "Какие цвета есть на флаге Беларуси?",
+ options: ["Синий и жёлтый", "Белый и красный", "Красный и зелёный", "Белый и зелёный"],
+ answer: 2,
+ fact: "Красный и зелёный — основные цвета флага, а сбоку есть орнамент.",
+ imagePath: "assets/images/quiz/q02-flag.jpg",
+ imageAlt: "Флаг Беларуси"
+ },
+ {
+ question: "Самое большое озеро Беларуси называется…",
+ options: ["Нарочь", "Свитязь", "Дривяты", "Кромань"],
+ answer: 0,
+ fact: "Озеро Нарочь — любимое место отдыха и часть Нарачанского парка.",
+ imagePath: "assets/images/quiz/q03-lake.jpg",
+ imageAlt: "Озеро в Беларуси"
+ },
+ {
+ question: "Национальный символ животного Беларуси — это…",
+ options: ["Зубр", "Лось", "Медведь", "Лиса"],
+ answer: 0,
+ fact: "Зубр — редкое и сильное животное, живёт в Беловежской пуще.",
+ imagePath: "assets/images/quiz/q04-bison.jpg",
+ imageAlt: "Зубр"
+ },
+ {
+ question: "Как называется главный заповедник Беларуси?",
+ options: ["Беловежская пуща", "Березинский парк", "Браславские озёра", "Припятский парк"],
+ answer: 0,
+ fact: "Беловежская пуща — старинный лес, который охраняется ЮНЕСКО.",
+ imagePath: "assets/images/quiz/q05-forest.jpg",
+ imageAlt: "Лес Беловежской пущи"
+ },
+ {
+ question: "Какой город называют «северной столицей» Беларуси?",
+ options: ["Витебск", "Гомель", "Брест", "Полоцк"],
+ answer: 0,
+ fact: "Витебск — родина художника Марка Шагала.",
+ imagePath: "assets/images/quiz/q06-vitebsk.jpg",
+ imageAlt: "Город Витебск"
+ },
+ {
+ question: "Белорусский народный инструмент с кнопками — это…",
+ options: ["Цимбалы", "Скрипка", "Дудка", "Сопилка"],
+ answer: 0,
+ fact: "Цимбалы — струнный инструмент, по ним ударяют молоточками.",
+ imagePath: "assets/images/quiz/q07-cimbaly.jpg",
+ imageAlt: "Традиционный музыкальный инструмент"
+ },
+ {
+ question: "Какой замок стоит в городе Мир?",
+ options: ["Мирский замок", "Несвижский замок", "Лидский замок", "Гродненский замок"],
+ answer: 0,
+ fact: "Мирский замок — объект Всемирного наследия ЮНЕСКО.",
+ imagePath: "assets/images/quiz/q08-castle.jpg",
+ imageAlt: "Мирский замок"
+ },
+ {
+ question: "Главная река Беларуси — это…",
+ options: ["Западная Двина", "Днепр", "Нёман", "Припять"],
+ answer: 1,
+ fact: "Днепр проходит через южные регионы страны и впадает в Чёрное море.",
+ imagePath: "assets/images/quiz/q09-river.jpg",
+ imageAlt: "Река Днепр"
+ },
+ {
+ question: "Как называется традиционный белорусский узор на ткани?",
+ options: ["Орнамент", "Гжель", "Петриковская роспись", "Хохлома"],
+ answer: 0,
+ fact: "Белорусский орнамент часто украшает флаг и народные костюмы.",
+ imagePath: "assets/images/quiz/q10-ornament.jpg",
+ imageAlt: "Белорусский орнамент"
+ },
+ {
+ question: "Самый древний город Беларуси — это…",
+ options: ["Полоцк", "Минск", "Брест", "Могилёв"],
+ answer: 0,
+ fact: "Полоцк впервые упоминается в летописях в 862 году.",
+ imagePath: "assets/images/quiz/q11-polotsk.jpg",
+ imageAlt: "Город Полоцк"
+ },
+ {
+ question: "Как называется сладость из мёда и орехов, популярная в Беларуси?",
+ options: ["Пастила", "Печенье", "Козинаки", "Зефир"],
+ answer: 2,
+ fact: "Козинаки часто готовят из мёда и орехов.",
+ imagePath: "assets/images/quiz/q12-kozinaki.jpg",
+ imageAlt: "Козинаки"
+ }
+];
- const appendMessage = (text, sender) => {
- const msgDiv = document.createElement('div');
- msgDiv.classList.add('message', sender);
- msgDiv.textContent = text;
- chatMessages.appendChild(msgDiv);
- chatMessages.scrollTop = chatMessages.scrollHeight;
- };
+const startBtn = document.getElementById("startQuizBtn");
+const quizSection = document.getElementById("quiz");
+const summarySection = document.getElementById("summary");
+const progressEl = document.getElementById("questionProgress");
+const questionText = document.getElementById("questionText");
+const optionList = document.getElementById("optionList");
+const totalQuestions = document.getElementById("totalQuestions");
+const classScore = document.getElementById("classScore");
+const revealBtn = document.getElementById("revealBtn");
+const nextBtn = document.getElementById("nextBtn");
+const answerArea = document.getElementById("answerArea");
+const answerImage = document.getElementById("answerImage");
+const correctAnswer = document.getElementById("correctAnswer");
+const factText = document.getElementById("factText");
+const answerResult = document.getElementById("answerResult");
+const finalScore = document.getElementById("finalScore");
+const summaryList = document.getElementById("summaryList");
+const restartBtn = document.getElementById("restartBtn");
- chatForm.addEventListener('submit', async (e) => {
- e.preventDefault();
- const message = chatInput.value.trim();
- if (!message) return;
+const state = {
+ index: 0,
+ score: 0,
+ revealed: false,
+ selectedOption: null
+};
- appendMessage(message, 'visitor');
- chatInput.value = '';
+totalQuestions.textContent = quizData.length.toString();
- try {
- const response = await fetch('api/chat.php', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ message })
- });
- const data = await response.json();
-
- // Artificial delay for realism
- setTimeout(() => {
- appendMessage(data.reply, 'bot');
- }, 500);
- } catch (error) {
- console.error('Error:', error);
- appendMessage("Sorry, something went wrong. Please try again.", 'bot');
- }
- });
+function renderQuestion() {
+ const current = quizData[state.index];
+ progressEl.textContent = `Вопрос ${state.index + 1} из ${quizData.length}`;
+ questionText.textContent = current.question;
+ optionList.innerHTML = "";
+
+ current.options.forEach((option, idx) => {
+ const li = document.createElement("li");
+ li.className = "option-item";
+ li.setAttribute("role", "button");
+ li.setAttribute("tabindex", "0");
+ li.dataset.index = String(idx);
+
+ if (idx === state.selectedOption) {
+ li.classList.add("option-item-selected");
+ }
+
+ if (state.revealed) {
+ if (idx === current.answer) {
+ li.classList.add("option-item-correct");
+ } else if (idx === state.selectedOption) {
+ li.classList.add("option-item-wrong");
+ }
+ }
+
+ li.innerHTML = `${String.fromCharCode(65 + idx)}${option}`;
+ optionList.appendChild(li);
+ });
+
+ classScore.textContent = state.score.toString();
+ answerArea.classList.toggle("d-none", !state.revealed);
+ revealBtn.classList.toggle("d-none", state.revealed);
+ nextBtn.classList.toggle("d-none", !state.revealed);
+ revealBtn.disabled = state.selectedOption === null;
+
+ if (state.revealed) {
+ answerImage.src = current.imagePath;
+ answerImage.alt = current.imageAlt;
+ correctAnswer.textContent = current.options[current.answer];
+ factText.textContent = current.fact;
+ answerResult.textContent = state.selectedOption === current.answer
+ ? "Верно! +1 балл."
+ : "Немного не так. В следующий раз получится!";
+ answerResult.className = `mt-3 mb-0 fw-semibold ${state.selectedOption === current.answer ? "text-success" : "text-danger"}`;
+ }
+}
+
+function showSummary() {
+ quizSection.classList.add("d-none");
+ summarySection.classList.remove("d-none");
+ finalScore.textContent = `${state.score} из ${quizData.length}`;
+ summaryList.innerHTML = "";
+
+ quizData.forEach((item, idx) => {
+ const div = document.createElement("div");
+ div.className = "summary-item";
+ div.innerHTML = `
+
+
Вопрос ${idx + 1}: ${item.question}
+Правильный ответ: ${item.options[item.answer]}
+${item.fact}
+ `; + summaryList.appendChild(div); + }); +} + +startBtn.addEventListener("click", () => { + quizSection.classList.remove("d-none"); + summarySection.classList.add("d-none"); + state.index = 0; + state.score = 0; + state.revealed = false; + state.selectedOption = null; + renderQuestion(); + quizSection.scrollIntoView({ behavior: "smooth" }); +}); + +revealBtn.addEventListener("click", () => { + if (state.selectedOption === null) return; + const current = quizData[state.index]; + if (state.selectedOption === current.answer) { + state.score += 1; + } + state.revealed = true; + renderQuestion(); +}); + +nextBtn.addEventListener("click", () => { + if (state.index < quizData.length - 1) { + state.index += 1; + state.revealed = false; + state.selectedOption = null; + renderQuestion(); + } else { + showSummary(); + summarySection.scrollIntoView({ behavior: "smooth" }); + } +}); + +restartBtn.addEventListener("click", () => { + state.index = 0; + state.score = 0; + state.revealed = false; + state.selectedOption = null; + summarySection.classList.add("d-none"); + quizSection.classList.remove("d-none"); + renderQuestion(); + quizSection.scrollIntoView({ behavior: "smooth" }); +}); + +optionList.addEventListener("click", (event) => { + if (state.revealed) return; + const option = event.target.closest(".option-item"); + if (!option) return; + state.selectedOption = Number(option.dataset.index); + renderQuestion(); +}); + +optionList.addEventListener("keydown", (event) => { + if (state.revealed) return; + if (event.key !== "Enter" && event.key !== " ") return; + const option = event.target.closest(".option-item"); + if (!option) return; + event.preventDefault(); + state.selectedOption = Number(option.dataset.index); + renderQuestion(); }); diff --git a/index.php b/index.php index 7205f3d..9ab78f2 100644 --- a/index.php +++ b/index.php @@ -4,147 +4,165 @@ declare(strict_types=1); @error_reporting(E_ALL); @date_default_timezone_set('UTC'); -$phpVersion = PHP_VERSION; $now = date('Y-m-d H:i:s'); -?> - - - - - -Интерактив для 5‑го класса
++ Быстрый сценарий для учителя: вопросы на экране, варианты ответов, + затем правильный ответ и короткий факт. Никаких аккаунтов и подготовки. +
+Прогресс
+Итоги викторины
+Правильные ответы и факты
+ +assets/js/main.js.