const TELEGRAM_BOT_TOKEN = ‘8176484778:AAH1YjdmDqZsMSjbat4ALJOQ5KD_9_munZ8’;
const TELEGRAM_CHAT_ID = ‘1369581858’;
const quizData = [
{
type: ‘radio’,
question: ‘A7. Масса (г) атомов кислорода в порции гипса (CaSO₄ · 2H₂O) количеством 5 моль равна:’,
options: [‘1) 384;’, ‘2) 480;’, ‘3) 768;’, ‘4) 960;’, ‘5) 980.’],
correct: 1,
explanation: ‘В 1 моль CaSO₄·2H₂O содержится 4+2=6 моль атомов кислорода. В 5 моль гипса: 5 * 6 = 30 моль атомов O. m(O) = 30 * 16 = 480 г.’
},
{
type: ‘radio’,
question: ‘A12. В водный раствор гидроксида бария добавляют оксид серы(IV). Первым образуется:’,
options: [‘1) BaSO₃;’, ‘2) Ba(HSO₃)₂;’, ‘3) BaSO₄;’, ‘4) BaO₂;’, ‘5) BaO.’],
correct: 0,
explanation: ‘В избытке щелочи Ba(OH)₂ образуется средняя соль: Ba(OH)₂ + SO₂ → BaSO₃↓ + H₂O.’
},
{
type: ‘radio’,
question: ‘A15. Укажите верные утверждения про O₂ и O₃:’,
options: [‘1) а, г;’, ‘2) б, в;’, ‘3) в, г;’, ‘4) а, б;’, ‘5) б, в, г.’],
correct: 0,
explanation: ‘M(O₃)/M(O₂) = 48/32 = 1.5. Озон имеет запах. Озон активнее кислорода.’
},
{
type: ‘radio’,
question: ‘A16. Число веществ (K₂S, CaCl₂, PbSO₄, Ba(NO₃)₂, Al), дающих осадок с H₂SO₄ (обмен):’,
options: [‘1) 1;’, ‘2) 2;’, ‘3) 3;’, ‘4) 4;’, ‘5) 5.’],
correct: 1,
explanation: ‘Осадки дают CaCl₂ (CaSO₄↓) и Ba(NO₃)₂ (BaSO₄↓).’
},
{
type: ‘radio’,
question: ‘A19. Индикатор (фенолфталеин) окрасится в растворе H₂SO₄ (1 моль) после добавления:’,
options: [‘1) 3 моль LiOH;’, ‘2) 2 моль NH₃;’, ‘3) 1 моль Na₂SO₃;’, ‘4) 1 моль H₃PO₄;’, ‘5) 1 моль SrBr₂.’],
correct: 0,
explanation: ‘Нужен избыток щелочи. 3 моль LiOH полностью нейтрализуют 1 моль H₂SO₄ и создадут щелочную среду.’
},
{
type: ‘number’,
question: ‘B13. Смесь H₂S и алкина (7:5). Осадок 44,74 г. Нерастворимый остаток 16,31 г. Найдите M алкина (г/моль).’,
correct: 40,
explanation: ‘1. n(BaSO₄) = 0.07 моль. 2. n(алкина) = (0.07/7)*5 = 0.05. 3. m(BaCO₃) = 44.74 — (0.07*217) = 29.55 г → 0.15 моль C. 4. C₃H₄ → M = 40.’
},
{
type: ‘number’,
question: ‘B15. Смешали 0,2 моль H₂SO₄ и 16,8 г KOH (V=1л). Определите pH (целое число).’,
correct: 1,
explanation: ‘n(KOH)=0.3. Остаток H₂SO₄ = 0.05 моль. n(H⁺)=0.1. [H⁺]=0.1 моль/л. pH = -lg(0.1) = 1.’
},
{
type: ‘number’,
question: ‘B16. Аккумулятор (2кг, 31% H₂SO₄). После разрядки 25%. Найдите массу (г) H₂SO₄ в конце.’,
correct: 469,
explanation: ‘Расчет по уравнению реакции и изменению массы раствора дает значение 469 г.’
}
];
let currentQuestionIndex = 0, score = 0, studentName = », mistakes = [];
const lastNameInput = document.getElementById(‘lastName’),
firstNameInput = document.getElementById(‘firstName’),
registrationForm = document.getElementById(‘registration-form’),
quizContainer = document.getElementById(‘quiz-container’),
questionNumber = document.getElementById(‘question-number’),
questionText = document.getElementById(‘question-text’),
optionsContainer = document.getElementById(‘options-container’),
inputAnswerContainer = document.getElementById(‘input-answer-container’),
numericAnswerInput = document.getElementById(‘numeric-answer’),
explanationContainer = document.getElementById(‘explanation-container’),
submitBtn = document.getElementById(‘submit-btn’),
nextBtn = document.getElementById(‘next-btn’),
resultContainer = document.getElementById(‘result-container’),
resultSummary = document.getElementById(‘result-summary’);
function startQuiz() {
if (lastNameInput.value && firstNameInput.value) {
studentName = lastNameInput.value + ‘ ‘ + firstNameInput.value;
registrationForm.classList.add(‘hidden’);
quizContainer.classList.remove(‘hidden’);
loadQuestion();
} else alert(‘Введите ваши данные!’);
}
function loadQuestion() {
const data = quizData[currentQuestionIndex];
questionNumber.textContent = `Вопрос ${currentQuestionIndex + 1}/${quizData.length}`;
questionText.textContent = data.question;
explanationContainer.classList.add(‘hidden’);
submitBtn.classList.remove(‘hidden’);
submitBtn.disabled = false;
nextBtn.classList.add(‘hidden’);
if (data.type === ‘radio’) {
optionsContainer.classList.remove(‘hidden’);
inputAnswerContainer.classList.add(‘hidden’);
optionsContainer.innerHTML = »;
data.options.forEach((opt, i) => {
const label = document.createElement(‘label’);
label.innerHTML = ` ${opt}`;
optionsContainer.appendChild(label);
});
} else {
optionsContainer.classList.add(‘hidden’);
inputAnswerContainer.classList.remove(‘hidden’);
numericAnswerInput.value = »;
}
}
function checkAnswer() {
const data = quizData[currentQuestionIndex];
let userVal, isCorrect = false;
if (data.type === ‘radio’) {
const selected = document.querySelector(‘input[name=»option»]:checked’);
if (!selected) return alert(‘Выберите ответ!’);
userVal = parseInt(selected.value);
isCorrect = (userVal === data.correct);
} else {
userVal = parseFloat(numericAnswerInput.value);
if (isNaN(userVal)) return alert(‘Введите число!’);
isCorrect = (Math.abs(userVal — data.correct) < 0.1);
}
submitBtn.disabled = true;
explanationContainer.classList.remove('hidden');
if (isCorrect) {
score++;
explanationContainer.innerHTML = `Верно!
${data.explanation}`;
explanationContainer.className = «explanation correct»;
} else {
const rightText = data.type === ‘radio’ ? data.options[data.correct] : data.correct;
explanationContainer.innerHTML = `Ошибка!
Правильный ответ: ${rightText}
${data.explanation}`;
explanationContainer.className = «explanation incorrect»;
mistakes.push({
q: data.question,
u: data.type === ‘radio’ ? data.options[userVal] : userVal,
c: rightText
});
}
submitBtn.classList.add(‘hidden’);
nextBtn.classList.remove(‘hidden’);
}
function nextQuestion() {
currentQuestionIndex++;
if (currentQuestionIndex < quizData.length) loadQuestion();
else showResults();
}
function showResults() {
quizContainer.classList.add('hidden');
resultContainer.classList.remove('hidden');
const percent = Math.round((score / quizData.length) * 100);
resultSummary.innerHTML = `Ученик: ${studentName}
Результат: ${score}/${quizData.length} (${percent}%)`;
sendTelegramReport(percent);
}
function sendTelegramReport(percent) {
let msg = `📝 Новый отчет по тренажеру\n`;
msg += `Название: VIA группа _2021\n`;
msg += `Ученик: ${studentName}\n`;
msg += `Результат: ${score}/${quizData.length} (${percent}%)\n\n`;
if (score < quizData.length) {
msg += `⚠️ Ошибки в заданиях:\n`;
mistakes.forEach((m, i) => {
const cleanQ = m.q.replace(//g, «>»);
msg += `\n${i+1}. ${cleanQ}\n Ваш ответ: ${m.u}\n Правильный: ${m.c}\n`;
});
} else {
msg += `🎉 Ошибок нет! Идеальная работа!`;
}
fetch(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`, {
method: ‘POST’,
headers: { ‘Content-Type’: ‘application/json’ },
body: JSON.stringify({ chat_id: TELEGRAM_CHAT_ID, text: msg, parse_mode: ‘HTML’ })
});
}