08.10.2026 - Fixes adding calc, quiz from lesson, added search in portfolio
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
let score = 0;
|
||||
let currentQuestionIndex = 0;
|
||||
let shuffledQuestions = [];
|
||||
|
||||
let questions = [
|
||||
{
|
||||
question: "Mit wie vielen Jahren kam der erste Kontakt mit Technik?",
|
||||
answers: ["Mit zehn Jahren", "Mit sechs Jahren", "Mit vierzehn Jahren"],
|
||||
correctAnswer: 1,
|
||||
},
|
||||
{
|
||||
question: "Welche Art von Skripten entstand als erstes?",
|
||||
answers: ["Boot-Skripte", "PowerShell-Skripte", "Bash-Skripte"],
|
||||
correctAnswer: 0,
|
||||
},
|
||||
{
|
||||
question: "Mit welchem Thema fing das Programmieren richtig an?",
|
||||
answers: ["Mit Spieleprogrammierung", "Mit Datensicherung", "Mit Webseiten"],
|
||||
correctAnswer: 1,
|
||||
},
|
||||
{
|
||||
question: "Welche Datei führte Windows 95 beim Start automatisch aus?",
|
||||
answers: ["config.sys", "win.ini", "Autostart.bat"],
|
||||
correctAnswer: 2,
|
||||
},
|
||||
{
|
||||
question: "Was konnte das erste Backup-Skript zusätzlich zum reinen Kopieren?",
|
||||
answers: ["Es verschlüsselte die Dateien", "Es verschickte eine Benachrichtigung", "Es erkannte die zuletzt vergebene Nummer und zählte fortlaufend weiter"],
|
||||
correctAnswer: 2,
|
||||
},
|
||||
{
|
||||
question: "Welche Schule folgte nach der Pflichtschule?",
|
||||
answers: ["Eine Fachschule für Elektronik und EDV", "Eine Handelsakademie", "Eine HTL für Maschinenbau"],
|
||||
correctAnswer: 0,
|
||||
},
|
||||
{
|
||||
question: "Welche Lehre bot den ersten Weg in die Arbeitswelt?",
|
||||
answers: ["Die Lehre als IT-Techniker", "Die Tischlerlehre", "Die Lehre als Elektrotechniker"],
|
||||
correctAnswer: 1,
|
||||
},
|
||||
{
|
||||
question: "In welcher Sprache entstanden die ersten Webseiten, bevor PHP dazukam?",
|
||||
answers: ["In JavaScript", "In HTML", "In Python"],
|
||||
correctAnswer: 1,
|
||||
},
|
||||
{
|
||||
question: "Mit welchen Programmiersprachen wurde bisher gearbeitet?",
|
||||
answers: ["Java, C# und C++", "Ruby, Go und Rust", "Swift, Kotlin und Dart"],
|
||||
correctAnswer: 0,
|
||||
},
|
||||
{
|
||||
question: "Worauf läuft der eigene Git-Server?",
|
||||
answers: ["Auf einem Raspberry Pi", "Bei einem Cloud-Anbieter", "Auf einer eigenen Synology"],
|
||||
correctAnswer: 2,
|
||||
},
|
||||
{
|
||||
question: "Wofür dienen die Server bei Hetzner zusätzlich zu Webseiten und Backends?",
|
||||
answers: ["Als Runner für GitLab und GitHub", "Als Mailserver", "Als Spieleserver"],
|
||||
correctAnswer: 0,
|
||||
},
|
||||
];
|
||||
|
||||
function shuffleArray(questionArray)
|
||||
{
|
||||
let newArray = [questionArray.length];
|
||||
let rng = getRandomNumber(questionArray.length);
|
||||
for(i = 0; i < questionArray.length; i++)
|
||||
{
|
||||
do
|
||||
{
|
||||
rng = getRandomNumber(questionArray.length);
|
||||
}
|
||||
while(newArray.includes(questionArray[rng]));
|
||||
newArray[i] = questionArray[rng]
|
||||
}
|
||||
|
||||
return newArray;
|
||||
}
|
||||
|
||||
function getRandomNumber(maxValue){
|
||||
return Math.floor(Math.random() * maxValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function resetQuiz(){
|
||||
document.getElementById("result").hidden = true;
|
||||
currentQuestionIndex = 0;
|
||||
score = 0;
|
||||
shuffledQuestions = shuffleArray(questions);
|
||||
showQuestions();
|
||||
document.getElementById("quiz-container").hidden = false;
|
||||
}
|
||||
|
||||
|
||||
function showQuestions() {
|
||||
|
||||
let btn = document.getElementById("resultBtn");
|
||||
if (currentQuestionIndex >= shuffledQuestions.length) {
|
||||
document.getElementById("quiz-container").hidden = true;
|
||||
document.getElementById("result").hidden = false;
|
||||
document.getElementById("score").textContent = score;
|
||||
|
||||
btn.hidden = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let currentQuestion = shuffledQuestions[currentQuestionIndex];
|
||||
|
||||
|
||||
document.getElementById("question").textContent = currentQuestion.question;
|
||||
|
||||
let answersDiv = document.getElementById("answers");
|
||||
answersDiv.innerHTML = "";
|
||||
|
||||
currentQuestion.answers.forEach((answer, index ) => {
|
||||
let answerBtn = document.createElement("button");
|
||||
answerBtn.className = "btn btn-outline-primary";
|
||||
answerBtn.textContent = answer;
|
||||
answerBtn.onclick = () => checkAnswer(index, currentQuestion.correctAnswer);
|
||||
answersDiv.appendChild(answerBtn);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function checkAnswer(selectedIndex, indexOfCorrectAnswer) {
|
||||
|
||||
if(selectedIndex === indexOfCorrectAnswer){
|
||||
score++;
|
||||
}
|
||||
|
||||
currentQuestionIndex++;
|
||||
showQuestions();
|
||||
}
|
||||
|
||||
shuffledQuestions = shuffleArray(questions);
|
||||
showQuestions();
|
||||
|
||||
if(isEvening() === true)
|
||||
{
|
||||
document.getElementById("quiz-container").classList.add("night");
|
||||
document.getElementById("result").classList.add("night");
|
||||
}
|
||||
Reference in New Issue
Block a user