From 5ce8eb8be15391973d25590778065fffd252a596 Mon Sep 17 00:00:00 2001 From: Ananya Gupta Date: Mon, 17 Jun 2024 16:35:53 +0530 Subject: [PATCH 1/3] styling --- ananya_20233049/index.html | 31 +++++++++++++++++++++++++ ananya_20233049/style.css | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 ananya_20233049/index.html create mode 100644 ananya_20233049/style.css diff --git a/ananya_20233049/index.html b/ananya_20233049/index.html new file mode 100644 index 0000000..62c22aa --- /dev/null +++ b/ananya_20233049/index.html @@ -0,0 +1,31 @@ + + + + + + Quizzer + + + + + + + +
+

Quiz!

+
+

Your Question is:

+
+ + + + +
+ +
+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/style.css b/ananya_20233049/style.css new file mode 100644 index 0000000..bc19395 --- /dev/null +++ b/ananya_20233049/style.css @@ -0,0 +1,46 @@ +*{ + margin:0; + padding:0; + font-family:'Poppins',sans-serif; + box-sizing: border-box; +} +body{ + background:rgb(1, 1, 18); +} +.app{ + background: rgb(215, 213, 213); + width:90%; + max-width:600px; + margin:100px auto 0; + border-radius: 10px; + padding:30px; + +} +.app h1{ + font-weight: 600; + color:blueviolet; + font-size:25px; + border-bottom: 1px solid #333; + padding-bottom: 30px; +} +.quiz{ + padding:20px 0; + +} +.quiz h2{ + font-size:18px; + color: crimson; + font-weight: 600; +} +.btn{ + background: white; + color: grey; + font-weight:500; + width:10%; + border:1px solid grey; + padding:10px; + margin: 10px 0; + text-align: left; + border-radius: 4px; + cursor:pointer; +} From 9dac02bd6496c4bf93be117d9d529e958b0e987c Mon Sep 17 00:00:00 2001 From: Ananya Gupta Date: Tue, 18 Jun 2024 15:20:15 +0530 Subject: [PATCH 2/3] commit --- ananya_20233049/cquiz.html | 31 +++++++++ ananya_20233049/dsa.html | 31 +++++++++ ananya_20233049/dsasc.js | 133 ++++++++++++++++++++++++++++++++++++ ananya_20233049/index.html | 21 +++--- ananya_20233049/python.html | 31 +++++++++ ananya_20233049/pythonsc.js | 133 ++++++++++++++++++++++++++++++++++++ ananya_20233049/script.js | 133 ++++++++++++++++++++++++++++++++++++ ananya_20233049/style.css | 78 +++++++++++++++++++-- 8 files changed, 577 insertions(+), 14 deletions(-) create mode 100644 ananya_20233049/cquiz.html create mode 100644 ananya_20233049/dsa.html create mode 100644 ananya_20233049/dsasc.js create mode 100644 ananya_20233049/python.html create mode 100644 ananya_20233049/pythonsc.js create mode 100644 ananya_20233049/script.js diff --git a/ananya_20233049/cquiz.html b/ananya_20233049/cquiz.html new file mode 100644 index 0000000..b40060a --- /dev/null +++ b/ananya_20233049/cquiz.html @@ -0,0 +1,31 @@ + + + + + + Quiz + + + + + + + +
+

Quiz!

+
+

Your Question is:

+
+ + + + +
+ +
+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/dsa.html b/ananya_20233049/dsa.html new file mode 100644 index 0000000..d0287c0 --- /dev/null +++ b/ananya_20233049/dsa.html @@ -0,0 +1,31 @@ + + + + + + Quiz + + + + + + + +
+

Quiz!

+
+

Your Question is:

+
+ + + + +
+ +
+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/dsasc.js b/ananya_20233049/dsasc.js new file mode 100644 index 0000000..fa97258 --- /dev/null +++ b/ananya_20233049/dsasc.js @@ -0,0 +1,133 @@ +const questions=[ + { + question:"What is a data structure?", + answers:[ + {text:'A programming language',correct:false}, + {text:'A collection of algorithms',correct:false}, + {text:'A way to store and organize data',correct:true}, + {text:'A type of computer hardware',correct:false}, + ] + }, + { + question:" Which data structure is used for implementing recursion?", + answers:[ + {text:'queue',correct:false}, + {text:'stack',correct:true}, + {text:'vector',correct:false}, + {text:'array',correct:false}, + ] + }, + { + question:"The data structure required to check whether an expression contains a balanced parenthesis is?", + answers:[ + {text:'stack',correct:true}, + {text:'queue',correct:false}, + {text:'tree',correct:false}, + {text:'array',correct:false}, + ] + }, + { + question:"What is the value of the postfix expression 6 3 2 4 + – *?", + answers:[ + {text:'74',correct:false}, + {text:'-18',correct:true}, + {text:'-22',correct:false}, + {text:'40',correct:false}, + ] + }, + { + question:"The data structure required for Breadth First Traversal on a graph is?", + answers:[ + {text:'Tree',correct:false}, + {text:'Stack',correct:false}, + {text:'Queue',correct:true}, + {text:'Array',correct:false}, + ] + }, + { + question:"Which of the following is not the type of queue?", + answers:[ + {text:'priority queue',correct:false}, + {text:'circular queue',correct:false}, + {text:'single ended queue',correct:true}, + {text:'ordinary queue',correct:false}, + ] + }, +]; + +const questionElement=document.getElementById("question"); +const answerButton=document.getElementById("answer-buttons"); +const nextButton=document.getElementById("next-btn"); +let curruentQuestionIndex=0; +let score=0; + +function startQuiz(){ + curruentQuestionIndex=0; + score=0; + nextButton.innerHTML="Next"; + showQuestion(); +} + +function showQuestion(){ + resetState(); + let currentques=questions[curruentQuestionIndex]; + let questionno=curruentQuestionIndex+1; + questionElement.innerHTML=questionno +'.'+currentques.question; + currentques.answers.forEach(answer=>{ + const button=document.createElement("button"); + button.innerHTML=answer.text; + button.classList.add("btn"); + answerButton.appendChild(button); + if(answer.correct){ + button.dataset.correct=answer.correct; + } + button.addEventListener("click",selectAnswer); + }); +} +function resetState(){ + nextButton.style.display="none"; + while(answerButton.firstChild){ + answerButton.removeChild(answerButton.firstChild); + } +} +function selectAnswer(e){ + const selectedBtn=e.target; + const isCorrect=selectedBtn.dataset.correct==="true"; + if(isCorrect){ + selectedBtn.classList.add("correct"); + score++; + } + else{ + selectedBtn.classList.add("incorrect"); + } + Array.from(answerButton.children).forEach(button=>{ + if(button.dataset.correct==="true"){ + button.classList.add("correct"); + } + button.disabled=true; + }); + nextButton.style.display="block"; +} +function showScore(){ + resetState(); + questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; + nextButton.innerHTML="Play Again"; + nextButton.style.display="block"; +} +function handleNextButton(){ + curruentQuestionIndex++; + if(curruentQuestionIndex{ + if(curruentQuestionIndex -
-

Quiz!

-
-

Your Question is:

+
+

Welcome to the Quiz!

+
- - - - + + + + + + +
- +
- \ No newline at end of file diff --git a/ananya_20233049/python.html b/ananya_20233049/python.html new file mode 100644 index 0000000..db6c372 --- /dev/null +++ b/ananya_20233049/python.html @@ -0,0 +1,31 @@ + + + + + + Quiz + + + + + + + +
+

Quiz!

+
+

Your Question is:

+
+ + + + +
+ +
+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/pythonsc.js b/ananya_20233049/pythonsc.js new file mode 100644 index 0000000..0f74b1a --- /dev/null +++ b/ananya_20233049/pythonsc.js @@ -0,0 +1,133 @@ +const questions=[ + { + question:" Which type of Programming does Python support?", + answers:[ + {text:'object-oriented programming',correct:false}, + {text:'structured programming',correct:false}, + {text:'functional programming',correct:false}, + {text:'All of the above',correct:true}, + ] + }, + { + question:"Is Python case sensitive when dealing with identifiers?", + answers:[ + {text:'No',correct:false}, + {text:'Yes',correct:true}, + {text:'Machine Dependent',correct:false}, + {text:'None',correct:false}, + ] + }, + { + question:"Is Python code compiled or interpreted?", + answers:[ + {text:'Python code is both compiled and interpreted',correct:true}, + {text:'Python code is neither compiled nor interpreted',correct:false}, + {text:'Python code is only compiled',correct:false}, + {text:'Python code is only interpreted',correct:false}, + ] + }, + { + question:"All keywords in Python are?", + answers:[ + {text:'Capitalized',correct:false}, + {text:'lower case',correct:false}, + {text:'UPPER case',correct:false}, + {text:'None',correct:true}, + ] + }, + { + question:"What does pip stand for python?", + answers:[ + {text:'Pip Installs Python',correct:false}, + {text:'Pip Installs Packages',correct:false}, + {text:'Preferred Installer Program',correct:true}, + {text:'All',correct:false}, + ] + }, + { + question:" Which of the following is the truncation division operator in Python?", + answers:[ + {text:'|',correct:false}, + {text:'*',correct:false}, + {text:'\\\\',correct:true}, + {text:'%',correct:false}, + ] + }, +]; + +const questionElement=document.getElementById("question"); +const answerButton=document.getElementById("answer-buttons"); +const nextButton=document.getElementById("next-btn"); +let curruentQuestionIndex=0; +let score=0; + +function startQuiz(){ + curruentQuestionIndex=0; + score=0; + nextButton.innerHTML="Next"; + showQuestion(); +} + +function showQuestion(){ + resetState(); + let currentques=questions[curruentQuestionIndex]; + let questionno=curruentQuestionIndex+1; + questionElement.innerHTML=questionno +'.'+currentques.question; + currentques.answers.forEach(answer=>{ + const button=document.createElement("button"); + button.innerHTML=answer.text; + button.classList.add("btn"); + answerButton.appendChild(button); + if(answer.correct){ + button.dataset.correct=answer.correct; + } + button.addEventListener("click",selectAnswer); + }); +} +function resetState(){ + nextButton.style.display="none"; + while(answerButton.firstChild){ + answerButton.removeChild(answerButton.firstChild); + } +} +function selectAnswer(e){ + const selectedBtn=e.target; + const isCorrect=selectedBtn.dataset.correct==="true"; + if(isCorrect){ + selectedBtn.classList.add("correct"); + score++; + } + else{ + selectedBtn.classList.add("incorrect"); + } + Array.from(answerButton.children).forEach(button=>{ + if(button.dataset.correct==="true"){ + button.classList.add("correct"); + } + button.disabled=true; + }); + nextButton.style.display="block"; +} +function showScore(){ + resetState(); + questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; + nextButton.innerHTML="Play Again"; + nextButton.style.display="block"; +} +function handleNextButton(){ + curruentQuestionIndex++; + if(curruentQuestionIndex{ + if(curruentQuestionIndex{ + const button=document.createElement("button"); + button.innerHTML=answer.text; + button.classList.add("btn"); + answerButton.appendChild(button); + if(answer.correct){ + button.dataset.correct=answer.correct; + } + button.addEventListener("click",selectAnswer); + }); +} +function resetState(){ + nextButton.style.display="none"; + while(answerButton.firstChild){ + answerButton.removeChild(answerButton.firstChild); + } +} +function selectAnswer(e){ + const selectedBtn=e.target; + const isCorrect=selectedBtn.dataset.correct==="true"; + if(isCorrect){ + selectedBtn.classList.add("correct"); + score++; + } + else{ + selectedBtn.classList.add("incorrect"); + } + Array.from(answerButton.children).forEach(button=>{ + if(button.dataset.correct==="true"){ + button.classList.add("correct"); + } + button.disabled=true; + }); + nextButton.style.display="block"; +} +function showScore(){ + resetState(); + questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; + nextButton.innerHTML="Play Again"; + nextButton.style.display="block"; +} +function handleNextButton(){ + curruentQuestionIndex++; + if(curruentQuestionIndex{ + if(curruentQuestionIndex Date: Tue, 18 Jun 2024 16:15:24 +0530 Subject: [PATCH 3/3] commit --- ananya_20233049/cquiz.html | 2 ++ ananya_20233049/dsa.html | 1 + ananya_20233049/dsasc.js | 9 ++++++--- ananya_20233049/python.html | 1 + ananya_20233049/pythonsc.js | 8 ++++++-- ananya_20233049/script.js | 10 +++++++--- ananya_20233049/style.css | 17 +++++++++++++++-- 7 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ananya_20233049/cquiz.html b/ananya_20233049/cquiz.html index b40060a..7747484 100644 --- a/ananya_20233049/cquiz.html +++ b/ananya_20233049/cquiz.html @@ -21,7 +21,9 @@

Your Question is:

+ +
diff --git a/ananya_20233049/dsa.html b/ananya_20233049/dsa.html index d0287c0..3e83f05 100644 --- a/ananya_20233049/dsa.html +++ b/ananya_20233049/dsa.html @@ -21,6 +21,7 @@

Your Question is:

+
diff --git a/ananya_20233049/dsasc.js b/ananya_20233049/dsasc.js index fa97258..d27d8f0 100644 --- a/ananya_20233049/dsasc.js +++ b/ananya_20233049/dsasc.js @@ -55,12 +55,15 @@ const questions=[ }, ]; + const questionElement=document.getElementById("question"); const answerButton=document.getElementById("answer-buttons"); const nextButton=document.getElementById("next-btn"); let curruentQuestionIndex=0; let score=0; - +function Gotohome(){ + window.location="index.html"; +} function startQuiz(){ curruentQuestionIndex=0; score=0; @@ -106,13 +109,13 @@ function selectAnswer(e){ } button.disabled=true; }); - nextButton.style.display="block"; + nextButton.style.display="inline"; } function showScore(){ resetState(); questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; nextButton.innerHTML="Play Again"; - nextButton.style.display="block"; + nextButton.style.display="inline"; } function handleNextButton(){ curruentQuestionIndex++; diff --git a/ananya_20233049/python.html b/ananya_20233049/python.html index db6c372..6983196 100644 --- a/ananya_20233049/python.html +++ b/ananya_20233049/python.html @@ -21,6 +21,7 @@

Your Question is:

+
diff --git a/ananya_20233049/pythonsc.js b/ananya_20233049/pythonsc.js index 0f74b1a..3aca2a7 100644 --- a/ananya_20233049/pythonsc.js +++ b/ananya_20233049/pythonsc.js @@ -61,6 +61,10 @@ const nextButton=document.getElementById("next-btn"); let curruentQuestionIndex=0; let score=0; +function Gotohome(){ + window.location="index.html"; +} + function startQuiz(){ curruentQuestionIndex=0; score=0; @@ -106,13 +110,13 @@ function selectAnswer(e){ } button.disabled=true; }); - nextButton.style.display="block"; + nextButton.style.display="inline"; } function showScore(){ resetState(); questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; nextButton.innerHTML="Play Again"; - nextButton.style.display="block"; + nextButton.style.display="inline"; } function handleNextButton(){ curruentQuestionIndex++; diff --git a/ananya_20233049/script.js b/ananya_20233049/script.js index 8f9097b..f77f478 100644 --- a/ananya_20233049/script.js +++ b/ananya_20233049/script.js @@ -58,9 +58,12 @@ const questions=[ const questionElement=document.getElementById("question"); const answerButton=document.getElementById("answer-buttons"); const nextButton=document.getElementById("next-btn"); +const backButton=document.getElementById("back"); let curruentQuestionIndex=0; let score=0; - +function Gotohome(){ + window.location="index.html"; +} function startQuiz(){ curruentQuestionIndex=0; score=0; @@ -106,13 +109,13 @@ function selectAnswer(e){ } button.disabled=true; }); - nextButton.style.display="block"; + nextButton.style.display="inline"; } function showScore(){ resetState(); questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; nextButton.innerHTML="Play Again"; - nextButton.style.display="block"; + nextButton.style.display="inline"; } function handleNextButton(){ curruentQuestionIndex++; @@ -130,4 +133,5 @@ nextButton.addEventListener("click",()=>{ startQuiz(); } }); + startQuiz(); diff --git a/ananya_20233049/style.css b/ananya_20233049/style.css index 6153e85..511cb88 100644 --- a/ananya_20233049/style.css +++ b/ananya_20233049/style.css @@ -5,7 +5,7 @@ box-sizing: border-box; } body{ - background:rgb(1, 1, 18); + background:rgb(16, 23, 80); } .index{ background: rgb(215, 213, 213); @@ -18,7 +18,7 @@ body{ .app{ background: rgb(215, 213, 213); width:90%; - max-width:600px; + max-width:500px; margin:100px auto 0; border-radius: 10px; padding:30px; @@ -96,6 +96,18 @@ body{ .btn:disabled{ cursor: no-drop; } +#back{ + background-color:rgb(4,16,55); + color:white; + font-weight: 500; + width:150px; + border:0; + padding: 10px; + margin: 20px auto 0; + border-radius: 5px; + cursor: pointer; + align-self: left; +} #next-btn{ background: rgb(4, 16, 55); color:white; @@ -106,6 +118,7 @@ body{ margin:20px auto 0; border-radius: 5px; cursor:pointer; + align-self: right; display:none; } .correct{