Test Your Web Accessibility Knowledge!
++ Put your web accessibility skills to the test with our quick quiz! +
+ +diff --git a/IMG/1c50e360-893f-4a77-8523-445ac92ee031.jpg b/IMG/1c50e360-893f-4a77-8523-445ac92ee031.jpg new file mode 100644 index 0000000..10c5787 Binary files /dev/null and b/IMG/1c50e360-893f-4a77-8523-445ac92ee031.jpg differ diff --git a/IMG/944faf04-56af-4b26-8775-09174491bd62.jpg b/IMG/944faf04-56af-4b26-8775-09174491bd62.jpg new file mode 100644 index 0000000..2042922 Binary files /dev/null and b/IMG/944faf04-56af-4b26-8775-09174491bd62.jpg differ diff --git a/IMG/97e866db-9ce7-42ba-a3af-122746ac226f.jpg b/IMG/97e866db-9ce7-42ba-a3af-122746ac226f.jpg new file mode 100644 index 0000000..a18324d Binary files /dev/null and b/IMG/97e866db-9ce7-42ba-a3af-122746ac226f.jpg differ diff --git a/README.md b/README.md index 57e6d16..af65a50 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Web Accessibility Project -A basic web server template focused on web accessibility practices. +A web accessibility quiz built to use and test web accessibility practices. -### Installation +Team: Therese, Darius, Christina -1. Fork this repository by clicking the "Fork" button at the top right of the GitHub repository page. +### Deployed site -2. Clone your forked repository +accessibility-quiz-wind-3.netlify.app diff --git a/about.html b/about.html deleted file mode 100644 index 5adbad6..0000000 --- a/about.html +++ /dev/null @@ -1,10 +0,0 @@ - - -
- - -This is the starting point.
+ Skip to Quiz + ++ Put your web accessibility skills to the test with our quick quiz! +
+ ++ Meet the team behind the quiz! We're passionate about web + accessibility and dedicated to creating resources that promote a more + inclusive internet for all. +
+
+ + Therese is a front-end developer who’s passionate about building + accessible, user-centric designs that make the web easier to + navigate for everyone. +
+
+ + Darius specialises in front-end development, crafting clean, + intuitive user interfaces that ensure an inclusive experience + across all devices and platforms +
+
+ + Christina focuses on creating responsive, accessible web + experiences, working to ensure that every user, regardless of + ability, can enjoy seamless interaction with websites. +
++ Answer the following questions using space to select an option, then + click the submit button once you're done. You can only select one + answer per question. +
+ ++ Answer the following questions, then click the submit button once you're + done. You can only select one answer per question. +
+ + `; + + quizForm = document.getElementById("quiz-form"); + const nextBtn = document.querySelector(".next-btn"); + const prevBtn = document.querySelector(".prev-btn"); + const submitBtn = document.querySelector(".submit-btn"); + + const displayCurrentQuestion = () => { + const currentQuizQuestion = quizQuestions[currentQuestionIndex]; + + let quizAnswers = [ + { label: currentQuizQuestion.altAnswerOne, value: "wrong" }, + { label: currentQuizQuestion.altAnswerTwo, value: "wrong" }, + { label: currentQuizQuestion.correctAnswer, value: "correct" }, + { label: currentQuizQuestion.altAnswerThree, value: "wrong" }, + ]; + + quizAnswers = quizAnswers.sort(() => Math.random() - 0.5); + + const quizContainer = document.getElementById("quiz-container"); + + quizContainer.innerHTML = ` ++ +
+ + `; + + const quizInputs = document.querySelectorAll( + `input[name="q${currentQuizQuestion.questionNumber}"]` + ); + + quizInputs.forEach((input) => { + input.addEventListener("change", (e) => { + saveAnswer(currentQuestionIndex, e.target.value); + updateNextButtonState(); + }); + }); + + const warningMessage = document.getElementById("warning-message"); + const announcer = document.getElementById("announcer"); + + const updateNextButtonState = () => { + const questionAnswered = Array.from(quizInputs).some( + (input) => input.checked + ); + nextBtn.disabled = !questionAnswered; + + if (!questionAnswered) { + warningMessage.textContent = + "Please select an answer before proceeding."; + } else { + warningMessage.textContent = ""; + } + }; + + updateNextButtonState(); + + // if (currentQuestionIndex === 0 && quizInputs.length > 0) { + // quizInputs[0].focus(); + // } + + if (currentQuestionIndex === 0) { + prevBtn.textContent = "No previous questions"; + prevBtn.disabled = true; + } else { + prevBtn.textContent = "Previous question"; + prevBtn.disabled = false; + } + + if (currentQuestionIndex === quizQuestions.length - 1) { + nextBtn.textContent = "No more questions"; + announcer.textContent = "This is the final question."; + submitBtn.classList.remove("hidden"); + nextBtn.disabled = true; + submitBtn.disabled = false; + } else { + nextBtn.textContent = "Next question"; + submitBtn.classList.add("hidden"); + submitBtn.disabled = true; + } + }; + + displayCurrentQuestion(); + + nextBtn.addEventListener("click", () => { + if (currentQuestionIndex < quizQuestions.length - 1) { + currentQuestionIndex++; + displayCurrentQuestion(); + const quizInputs = document.querySelectorAll(`.quiz-input`); + if (quizInputs.length > 0) { + quizInputs[0].focus(); + }; + prevBtn.disabled = false; + } else if (currentQuestionIndex === quizQuestions.length - 1) { + nextBtn.disabled = true; + } + }); + + prevBtn.addEventListener("click", () => { + if (currentQuestionIndex > 0) { + currentQuestionIndex--; + displayCurrentQuestion(); + } + }); + + quizForm.addEventListener("submit", (e) => { + e.preventDefault(); + displayQuizResults(); + }); +}; + +// QUIZ RESULTS +const displayQuizResults = () => { + const correctAnswers = answers.filter((answer) => answer === "correct"); + + const result = `${correctAnswers.length} / ${answers.length}`; + + let resultText; + + if (correctAnswers.length >= 5 && correctAnswers.length <= 7) { + resultText = "Almsot there, try again!"; + } else if (correctAnswers.length <= 4) { + resultText = "Not quite there, try again!"; + } else { + resultText = "Great job!"; + } + + quizSection.innerHTML = `${resultText} You got ${result}!
+You have finished the quiz, your results are now displayed.
+