File size: 8,045 Bytes
e337ee1 456e1a2 e337ee1 | 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 |
// Translation dictionary
const translations = {
en: {
// English translations
},
ru: {
"C++ Code Crusaders Adventure": "C++ Код Крестоносцы Приключение",
"Embark on an epic journey to master the fundamentals of C++ programming!": "Отправьтесь в эпическое путешествие, чтобы освоить основы программирования на C++!",
"Getting Started": "Начало работы",
"Learn the basic syntax, variables, and data types in C++.": "Изучите базовый синтаксис, переменные и типы данных в C++.",
"Start Learning": "Начать обучение",
"Control Structures": "Управляющие конструкции",
"Master loops, conditionals, and program flow control.": "Освойте циклы, условия и управление потоком программы.",
"Functions & OOP": "Функции и ООП",
"Discover functions, classes, and object-oriented programming.": "Откройте для себя функции, классы и объектно-ориентированное программирование.",
"Ready to Test Your Knowledge?": "Готовы проверить свои знания?",
"After completing all lessons, challenge yourself with our interactive quiz to reinforce what you've learned!": "После завершения всех уроков проверьте себя с помощью нашего интерактивного теста, чтобы закрепить полученные знания!",
"Take the Quiz": "Пройти тест",
"Progress:": "Прогресс:",
"Back": "Назад",
"Mark Complete": "Отметить завершенным",
"Next:": "Далее:",
"Submit Quiz": "Отправить тест",
"Quiz Results": "Результаты теста",
"Excellent work! You've mastered the C++ fundamentals!": "Отличная работа! Вы освоили основы C++!",
"Good job! You have a solid understanding of C++ basics.": "Хорошая работа! У вас прочные знания основ C++.",
"Not bad! Review the lessons to improve your understanding.": "Неплохо! Повторите уроки для лучшего понимания.",
"Keep practicing! Review the lessons and try again.": "Продолжайте практиковаться! Повторите уроки и попробуйте снова.",
"Home": "Главная",
"Review": "Повторить",
"Conditional Statements": "Условные операторы",
"Control structures allow you to control the flow of execution in your program based on certain conditions.": "Управляющие конструкции позволяют контролировать поток выполнения программы на основе определенных условий.",
"If-Else Statements": "Операторы If-Else",
"Switch Statements": "Оператор Switch",
"Loops": "Циклы",
"For Loop": "Цикл For",
"While Loop": "Цикл While",
"Functions in C++": "Функции в C++",
"Functions allow you to group code into reusable blocks. They can take parameters and return values.": "Функции позволяют группировать код в повторно используемые блоки. Они могут принимать параметры и возвращать значения.",
"Function Example": "Пример функции",
"Object-Oriented Programming": "Объектно-ориентированное программирование",
"C++ supports object-oriented programming with classes and objects.": "C++ поддерживает объектно-ориентированное программирование с классами и объектами.",
"Class Example": "Пример класса",
"Inheritance Example": "Пример наследования",
"1. What is the correct syntax to output \"Hello World\" in C++?": "1. Какой правильный синтаксис для вывода \"Hello World\" в C++?",
"2. Which of the following is NOT a valid C++ data type?": "2. Какой из следующих типов данных НЕ является допустимым в C++?",
"3. What is the correct way to create a for loop in C++?": "3. Как правильно создать цикл for в C++?",
"4. How do you declare a function in C++ that doesn't return any value?": "4. Как объявить функцию в C++, которая не возвращает значение?",
"5. Which keyword is used to create a class in C++?": "5. Какое ключевое слово используется для создания класса в C++?",
"Correct! Well done!": "Правильно! Отличная работа!",
"Incorrect. Try again!": "Неверно. Попробуйте еще раз!"
}
};
// Shared JavaScript functionality
document.addEventListener('DOMContentLoaded', function() {
// Set language
const lang = localStorage.getItem('lang') || 'en';
document.documentElement.lang = lang;
// Apply translations
if (lang === 'ru') {
const elements = document.querySelectorAll('[data-translate]');
elements.forEach(el => {
const key = el.dataset.translate;
if (translations.ru[key]) {
el.textContent = translations.ru[key];
}
});
}
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Progress tracking
if (localStorage.getItem('cppProgress')) {
const progress = JSON.parse(localStorage.getItem('cppProgress'));
updateProgressBars(progress);
}
});
function updateProgressBars(progress) {
const progressBars = document.querySelectorAll('.progress-fill');
progressBars.forEach(bar => {
const section = bar.dataset.section;
if (progress[section]) {
bar.style.width = `${progress[section]}%`;
}
});
}
function markSectionComplete(section) {
let progress = localStorage.getItem('cppProgress') ? JSON.parse(localStorage.getItem('cppProgress')) : {};
progress[section] = 100;
localStorage.setItem('cppProgress', JSON.stringify(progress));
updateProgressBars(progress);
}
// Quiz functionality
function checkAnswer(questionId, correctAnswer) {
const selectedOption = document.querySelector(`input[name="${questionId}"]:checked`);
if (!selectedOption) return false;
const feedbackElement = document.getElementById(`feedback-${questionId}`);
if (selectedOption.value === correctAnswer) {
feedbackElement.textContent = "Correct! Well done!";
feedbackElement.className = "text-green-600 mt-2";
return true;
} else {
feedbackElement.textContent = "Incorrect. Try again!";
feedbackElement.className = "text-red-600 mt-2";
return false;
}
}
function calculateQuizScore() {
const questions = document.querySelectorAll('.quiz-question');
let correctAnswers = 0;
questions.forEach(question => {
const questionId = question.id;
const correctAnswer = question.dataset.correctAnswer;
if (checkAnswer(questionId, correctAnswer)) {
correctAnswers++;
}
});
const scorePercentage = Math.round((correctAnswers / questions.length) * 100);
return scorePercentage;
} |