Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Saving Max Score of Quizzes #230

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Pages/Quizes/tests/button-1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ <h1>P Block</h1>
<!-- Quiz section -->

<div class="quiz-wrapper">
<div class="max-wrapper">
<div id="max-score"></div>
</div>

<div class="quiz-container" id="quiz">

Expand Down
24 changes: 22 additions & 2 deletions Pages/Quizes/tests/button-1/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,28 @@ const quizData = [
const submitButton = document.getElementById("submit");
const difficulty = document.getElementById("difficulty");
const quizcount = document.getElementById("quizcount");
const prev_score= document.getElementById("max-score");
const max_wrapper= document.getElementsByClassName("max-wrapper")[0]


let currentQuiz = 0;
let score = 0;
const weak_topics=[];
const loadScore=()=>{
const score= localStorage.getItem('btn-1-max');
if(score){
prev_score.innerHTML=`Max score <br>${score}`;
}else{
max_wrapper.style.display='none'
}

}
const storeMax=(score)=>{
const maxscore = localStorage.getItem('btn-1-max');
if (score>maxscore){
localStorage.setItem('btn-1-max',score)
}
}

const deselectAnswers = () => {
answerElements.forEach((answer) => (answer.checked = false));
Expand All @@ -132,6 +149,7 @@ const quizData = [

const loadQuiz = () => {
deselectAnswers();

const currentQuizData = quizData[currentQuiz];
questionElement.innerText = currentQuizData.question;
a_text.innerText = currentQuizData.a;
Expand All @@ -143,7 +161,7 @@ const quizData = [
};

loadQuiz();

loadScore();
submitButton.addEventListener("click", () => {
const answer = getSelected();
if (answer) {
Expand All @@ -161,6 +179,8 @@ const quizData = [
<h2>You answered ${score}/${quizData.length} questions correctly</h2>
<button onclick="history.go(0)">Play Again</button>
`
storeMax(score);
loadScore();

var temp;
for (i = 0; i < weak_topics.length; i++) {
Expand Down
17 changes: 17 additions & 0 deletions Pages/Quizes/tests/button-1/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,23 @@ ul {
margin-left: 1.5vw;
}
/* footer */
.max-wrapper{
background-color:#F0F1FF;
border-radius: 50%;
width:100px;
height:100px;
display: flex;
justify-content:center;
align-items: center;
border : 7px solid #242969;
margin-bottom: 20px;
padding: 5px;
}
#max-score{
font-family: 'Poppins', sans-serif;
font-weight: bold;
text-align: center;
}



Expand Down
4 changes: 3 additions & 1 deletion Pages/Quizes/tests/button-2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ <h1>Scalars & Vectors</h1>
<!-- Quiz section -->

<div class="quiz-wrapper">

<div class="max-wrapper">
<div id="max-score"></div>
</div>
<div class="quiz-container" id="quiz">

<div class="quiz-header">
Expand Down
21 changes: 21 additions & 0 deletions Pages/Quizes/tests/button-2/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ const quizData = [
const submitButton = document.getElementById("submit");
const difficulty = document.getElementById("difficulty");
const quizcount = document.getElementById("quizcount");
const prev_score= document.getElementById("max-score");
const max_wrapper= document.getElementsByClassName('max-wrapper')[0];

const loadScore=()=>{
const score= localStorage.getItem('btn-2-max');
if(score){
prev_score.innerHTML=`Max score <br>${score}`;
}else{
max_wrapper.style.display='none'
}

}
const storeMax=(score)=>{
const maxscore = localStorage.getItem('btn-2-max');
if (score>maxscore){
localStorage.setItem('btn-2-max',score)
}
}


let currentQuiz = 0;
Expand Down Expand Up @@ -142,6 +160,7 @@ const quizData = [
};

loadQuiz();
loadScore();

submitButton.addEventListener("click", () => {
const answer = getSelected();
Expand All @@ -160,6 +179,8 @@ const quizData = [
<h2>You answered ${score}/${quizData.length} questions correctly</h2>
<button onclick="history.go(0)">Play Again</button>
`
storeMax(score);
loadScore();
var temp;
for (i = 0; i < weak_topics.length; i++) {
if(i===0){
Expand Down
18 changes: 18 additions & 0 deletions Pages/Quizes/tests/button-2/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,27 @@ ul {
.recommendations h3{
margin-left: 1.5vw;
}
.max-wrapper{
background-color:#F0F1FF;
border-radius: 50%;
width:100px;
height:100px;
display: flex;
justify-content:center;
align-items: center;
border : 7px solid #242969;
margin-bottom: 20px;
padding: 5px;
}
#max-score{
font-family: 'Poppins', sans-serif;
font-weight: bold;
text-align: center;
}

/* footer */


footer{

bottom: 0;
Expand Down
3 changes: 3 additions & 0 deletions Pages/Quizes/tests/button-3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ <h1>Respiration In Plants</h1>
<!-- Quiz section -->

<div class="quiz-wrapper">
<div class="max-wrapper">
<div id="max-score"></div>
</div>

<div class="quiz-container" id="quiz">

Expand Down
21 changes: 21 additions & 0 deletions Pages/Quizes/tests/button-3/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,28 @@ const quizData = [
const submitButton = document.getElementById("submit");
const difficulty = document.getElementById("difficulty");
const quizcount = document.getElementById("quizcount");
const prev_score= document.getElementById("max-score");
const max_wrapper= document.getElementsByClassName("max-wrapper")[0]


let currentQuiz = 0;
let score = 0;
const weak_topics=[];
const loadScore=()=>{
const score= localStorage.getItem('btn-3-max');
if(score){
prev_score.innerHTML=`Max score <br>${score}`;
}else{
max_wrapper.style.display='none'
}

}
const storeMax=(score)=>{
const maxscore = localStorage.getItem('btn-3-max');
if (score>maxscore){
localStorage.setItem('btn-3-max',score)
}
}

const deselectAnswers = () => {
answerElements.forEach((answer) => (answer.checked = false));
Expand All @@ -128,6 +145,7 @@ const quizData = [
});
return answer;
};


const loadQuiz = () => {
deselectAnswers();
Expand All @@ -142,6 +160,7 @@ const quizData = [
};

loadQuiz();
loadScore();

submitButton.addEventListener("click", () => {
const answer = getSelected();
Expand All @@ -160,6 +179,8 @@ const quizData = [
<h2>You answered ${score}/${quizData.length} questions correctly</h2>
<button onclick="history.go(0)">Play Again</button>
`
storeMax(score);
loadScore();
var temp;
for (i = 0; i < weak_topics.length; i++) {
if(i===0){
Expand Down
17 changes: 17 additions & 0 deletions Pages/Quizes/tests/button-3/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,23 @@ ul {
.recommendations h3{
margin-left: 1.5vw;
}
.max-wrapper{
background-color:#F0F1FF;
border-radius: 50%;
width:100px;
height:100px;
display: flex;
justify-content:center;
align-items: center;
border : 7px solid #242969;
margin-bottom: 20px;
padding: 5px;
}
#max-score{
font-family: 'Poppins', sans-serif;
font-weight: bold;
text-align: center;
}
/* footer */

footer{
Expand Down
3 changes: 3 additions & 0 deletions Pages/Quizes/tests/button-4/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ <h1>Newton Laws of Motion</h1>
<!-- Quiz section -->

<div class="quiz-wrapper">
<div class="max-wrapper">
<div id="max-score"></div>
</div>

<div class="quiz-container" id="quiz">

Expand Down
20 changes: 20 additions & 0 deletions Pages/Quizes/tests/button-4/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,28 @@ const quizData = [
const submitButton = document.getElementById("submit");
const difficulty = document.getElementById("difficulty");
const quizcount = document.getElementById("quizcount");
const prev_score= document.getElementById("max-score");
const max_wrapper= document.getElementsByClassName("max-wrapper")[0]


let currentQuiz = 0;
let score = 0;
const weak_topics=[];
const loadScore=()=>{
const score= localStorage.getItem('btn-4-max');
if(score){
prev_score.innerHTML=`Max score <br>${score}`;
}else{
max_wrapper.style.display='none'
}

}
const storeMax=(score)=>{
const maxscore = localStorage.getItem('btn-4-max');
if (score>maxscore){
localStorage.setItem('btn-4-max',score)
}
}

const deselectAnswers = () => {
answerElements.forEach((answer) => (answer.checked = false));
Expand All @@ -142,6 +159,7 @@ const quizData = [
};

loadQuiz();
loadScore();

submitButton.addEventListener("click", () => {
const answer = getSelected();
Expand All @@ -160,6 +178,8 @@ const quizData = [
<h2>You answered ${score}/${quizData.length} questions correctly</h2>
<button onclick="history.go(0)">Play Again</button>
`
storeMax(score);
loadScore();
var temp;
for (i = 0; i < weak_topics.length; i++) {
if(i===0){
Expand Down
17 changes: 17 additions & 0 deletions Pages/Quizes/tests/button-4/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,23 @@ ul {
.recommendations h3{
margin-left: 1.5vw;
}
.max-wrapper{
background-color:#F0F1FF;
border-radius: 50%;
width:100px;
height:100px;
display: flex;
justify-content:center;
align-items: center;
border : 7px solid #242969;
margin-bottom: 20px;
padding: 5px;
}
#max-score{
font-family: 'Poppins', sans-serif;
font-weight: bold;
text-align: center;
}
/* footer */

footer{
Expand Down
3 changes: 3 additions & 0 deletions Pages/Quizes/tests/button-5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ <h1>Thermodynamics</h1>
<!-- Quiz section -->

<div class="quiz-wrapper">
<div class="max-wrapper">
<div id="max-score"></div>
</div>

<div class="quiz-container" id="quiz">

Expand Down
20 changes: 20 additions & 0 deletions Pages/Quizes/tests/button-5/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ const quizData = [
const submitButton = document.getElementById("submit");
const difficulty = document.getElementById("difficulty");
const quizcount = document.getElementById("quizcount");
const prev_score= document.getElementById("max-score");
const max_wrapper= document.getElementsByClassName("max-wrapper")[0]
const loadScore=()=>{
const score= localStorage.getItem('btn-5-max');
if(score){
prev_score.innerHTML=`Max score <br>${score}`;
}else{
max_wrapper.style.display='none'
}

}
const storeMax=(score)=>{
const maxscore = localStorage.getItem('btn-5-max');
if (score>maxscore){
localStorage.setItem('btn-5-max',score)
}
}


let currentQuiz = 0;
Expand Down Expand Up @@ -142,6 +159,7 @@ const quizData = [
};

loadQuiz();
loadScore();

submitButton.addEventListener("click", () => {
const answer = getSelected();
Expand All @@ -160,6 +178,8 @@ const quizData = [
<h2>You answered ${score}/${quizData.length} questions correctly</h2>
<button onclick="history.go(0)">Play Again</button>
`
storeMax(score);
loadScore();
var temp;
for (i = 0; i < weak_topics.length; i++) {
if(i===0){
Expand Down
Loading
Loading