Skip to content

Commit

Permalink
adding max-score in quize button1 and button2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudip200 committed May 12, 2024
1 parent ae1d727 commit 21d0f4f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
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
21 changes: 19 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,25 @@ const quizData = [
const submitButton = document.getElementById("submit");
const difficulty = document.getElementById("difficulty");
const quizcount = document.getElementById("quizcount");
const prev_score= document.getElementById("max-score");


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}`;
}

}
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 +146,7 @@ const quizData = [

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

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

loadQuiz();

loadScore();
submitButton.addEventListener("click", () => {
const answer = getSelected();
if (answer) {
Expand All @@ -161,6 +176,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

0 comments on commit 21d0f4f

Please sign in to comment.