Skip to content

Commit

Permalink
Merge pull request #233 from Pratik2401/main
Browse files Browse the repository at this point in the history
feat: Add explanation to incorrect questions and disable radio buttons while reviewing answers #155
  • Loading branch information
JAYESHBATRA authored May 15, 2024
2 parents 3b7f56d + dd286e7 commit 8ad94cc
Show file tree
Hide file tree
Showing 19 changed files with 1,279 additions and 813 deletions.
33 changes: 24 additions & 9 deletions Pages/Quizes/tests/button-1/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const quizData = [
c: "F < O < Cl",
d: "Cl < O < F",
correct: "b",
explanation: "Electron affinity is the energy released when an electron is added to a neutral atom to form a negative ion. Among oxygen (O), fluorine (F), and chlorine (Cl), fluorine has the highest electron affinity due to its smaller atomic size and higher effective nuclear charge. Thus, the correct order is O < F < Cl.",
topic: "Electron Affinity",
difficulty: "Easy",
},
Expand All @@ -18,17 +19,18 @@ const quizData = [
c: "Pyrophosphate",
d: "Phosphite",
correct: "a",
explanation: "The formation of a yellow precipitate upon the addition of aqueous silver nitrate indicates the presence of chloride ions. Orthophosphate ions (PO₄³⁻) do not react with silver nitrate, whereas chloride ions (Cl⁻) do, forming a yellow precipitate of silver chloride (AgCl).",
topic: "Group 11",
difficulty: "Hard",
},

{
question: "How many S-S bonds are there in tetrathionate ion ?",
a: "2",
b: "3",
c: "4",
d: "5",
correct: "c",
explanation: "The tetrathionate ion (S₄O₆²⁻) consists of four sulfur atoms bonded to each other with three S-S bonds and two S=O bonds. Therefore, the number of S-S bonds in the tetrathionate ion is 3.",
topic: "Molecular Structure",
difficulty: "Hard",
},
Expand All @@ -39,6 +41,7 @@ const quizData = [
c: "Oxygen",
d: "Hydrogen",
correct: "c",
explanation: "When ozone (O₃) reacts with hydrogen sulfide (H₂S), oxygen gas (O₂) is released. The reaction can be represented as follows: O₃ + H₂S -> O₂ + H₂O.",
topic: "Group 1",
difficulty: "Medium",
},
Expand All @@ -49,6 +52,7 @@ const quizData = [
c: "Si",
d: "Sn",
correct: "c",
explanation: "Boron shows a diagonal relationship with silicon (Si). Diagonal relationships occur between elements in different periods that have similar properties, despite being in different groups. Boron and silicon have similar properties due to their comparable sizes and similar electronegativities.",
topic: "Diagonal Relationship",
difficulty: "Easy",
},
Expand All @@ -59,6 +63,7 @@ const quizData = [
c: "sulphur",
d: "zinc",
correct: "b",
explanation: "Catenation is the ability of an element to form bonds with itself to form chains or rings. Carbon (C) exhibits the maximum catenation property among the given options. This is due to its ability to form strong covalent bonds with other carbon atoms, leading to the formation of long chains and complex structures.",
topic: "Catenation",
difficulty: "Easy",
},
Expand All @@ -69,6 +74,7 @@ const quizData = [
c: "Si",
d: "Sn",
correct: "c",
explanation: "Boron shows a diagonal relationship with silicon (Si). Diagonal relationships occur between elements in different periods that have similar properties, despite being in different groups. Boron and silicon have similar properties due to their comparable sizes and similar electronegativities.",
topic: "Chemical Composition",
difficulty: "Medium",
},
Expand All @@ -79,6 +85,7 @@ const quizData = [
c: "3",
d: "4",
correct: "c",
explanation: "Cyclic metaphosphoric acid (HPO₃)ₙ does not have any P-O-P bonds because it consists of cyclic phosphate units linked by P-O-H bonds. Therefore, the correct answer is 0.",
topic: "Chemical Bonding",
difficulty: "Medium",
},
Expand All @@ -90,6 +97,7 @@ const quizData = [
c: "Nitrogen dioxide",
d: "Dinitrogen tetroxide",
correct: "b",
explanation: "On heating ammonium nitrate (NH₄NO₃) at 250°C, nitrous oxide (N₂O) is released. The decomposition of ammonium nitrate at this temperature yields nitrous oxide, water, and dinitrogen monoxide.",
topic: "Nitrogen Oxides",
difficulty: "Easy",
},
Expand All @@ -100,11 +108,13 @@ const quizData = [
c: "sp3d3",
d: "sp3",
correct: "b",
explanation: "The hybridization of sulfur in sulfur hexafluoride (SF₆) is sp³d². In SF₆, sulfur forms six σ bonds with the fluorine atoms, and its electron configuration involves one 3s, three 3p, and two 3d orbitals.",
topic: "Hybridization",
difficulty: "Hard",
},
];


const quiz = document.getElementById("quiz");
const answerElements = document.querySelectorAll(".answer");
const questionElement = document.getElementById("question");
Expand All @@ -123,15 +133,20 @@ const deselectAnswers = () => {
answerElements.forEach((answer) => (answer.checked=false));
};

const explanationElement = document.getElementById("explanation");

const loadQuiz = () => {
deselectAnswers();
const currentQuizData = quizData[currentQuiz];
questionElement.innerText = currentQuizData.question;
a_text.innerText = currentQuizData.a;
b_text.innerText = currentQuizData.b;
c_text.innerText = currentQuizData.c;
d_text.innerText = currentQuizData.d;
difficulty.innerText = currentQuizData.difficulty;
deselectAnswers();
const currentQuizData = quizData[currentQuiz];
questionElement.innerText = currentQuizData.question;
a_text.innerText = currentQuizData.a;
b_text.innerText = currentQuizData.b;
c_text.innerText = currentQuizData.c;
d_text.innerText = currentQuizData.d;
difficulty.innerText = currentQuizData.difficulty;

// Update explanation text
explanationElement.innerText = currentQuizData.explanation;
};

loadQuiz();
Expand Down
13 changes: 9 additions & 4 deletions Pages/Quizes/tests/button-1/solutions.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ <h2 id="question">Question is loading...</h2>

<ul class="quiz-ul">
<li>
<input type="radio" name="answer" id="a" class="answer" />
<input type="radio" name="answer" id="a" class="answer" disabled/>
<label for="a" id="a_text">Answer...</label>
</li>
<li>
<input type="radio" name="answer" id="b" class="answer" />
<input type="radio" name="answer" id="b" class="answer" disabled/>
<label for="b" id="b_text">Answer...</label>
</li>
<li>
<input type="radio" name="answer" id="c" class="answer" />
<input type="radio" name="answer" id="c" class="answer" disabled/>
<label for="c" id="c_text">Answer...</label>
</li>
<li>
<input type="radio" name="answer" id="d" class="answer" />
<input type="radio" name="answer" id="d" class="answer" disabled />
<label for="d" id="d_text">Answer...</label>
</li>
<div class="">
Expand All @@ -75,7 +75,12 @@ <h3>
Correct Answer
</h3>
<h4 id="answer">Answer</h4>
<div class="explanation">
<h3>Explanation</h3>
<p id="explanation">Explanation goes here...</p>
</div>
</div>

<button id="next">Next Question</button>
</div>
</div>
Expand Down
13 changes: 8 additions & 5 deletions Pages/Quizes/tests/button-2/solution.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,30 @@ <h2 id="question">Question is loading...</h2>

<ul class="quiz-ul">
<li>
<input type="radio" name="answer" id="a" class="answer" />
<input type="radio" name="answer" id="a" class="answer" disabled/>
<label for="a" id="a_text">Answer...</label>
</li>
<li>
<input type="radio" name="answer" id="b" class="answer" />
<input type="radio" name="answer" id="b" class="answer" disabled/>
<label for="b" id="b_text">Answer...</label>
</li>
<li>
<input type="radio" name="answer" id="c" class="answer" />
<input type="radio" name="answer" id="c" class="answer" disabled/>
<label for="c" id="c_text">Answer...</label>
</li>
<li>
<input type="radio" name="answer" id="d" class="answer" />
<input type="radio" name="answer" id="d" class="answer" disabled/>
<label for="d" id="d_text">Answer...</label>
</li>
<div class="">
<h3>

Correct Answer
</h3>
<h4 id="answer">Answer</h4>
</div>
<div class="explanation">
<h3>Explanation</h3>
<p id="explanation">Explanation goes here...</p>
</div>
<button id="next">Next Question</button>
</div>
Expand Down
Loading

0 comments on commit 8ad94cc

Please sign in to comment.