@@ -95,13 +95,10 @@ const BubbleSortQuiz = () => {
9595 const [ showResult , setShowResult ] = useState ( false ) ;
9696 const [ quizCompleted , setQuizCompleted ] = useState ( false ) ;
9797 const [ answers , setAnswers ] = useState ( Array ( questions . length ) . fill ( null ) ) ;
98- const [ showExplanation , setShowExplanation ] = useState ( false ) ;
9998 const [ showIntro , setShowIntro ] = useState ( true ) ;
10099 const [ showSuccessAnimation , setShowSuccessAnimation ] = useState ( false ) ;
101- const [ penaltyApplied , setPenaltyApplied ] = useState ( false ) ;
102100
103101 const handleAnswerSelect = ( optionIndex ) => {
104- if ( selectedAnswer !== null ) return ;
105102 setSelectedAnswer ( optionIndex ) ;
106103 const newAnswers = [ ...answers ] ;
107104 newAnswers [ currentQuestion ] = optionIndex ;
@@ -111,18 +108,10 @@ const BubbleSortQuiz = () => {
111108 const handleNextQuestion = ( ) => {
112109 if ( selectedAnswer === null ) return ;
113110
114- if ( showExplanation && ! penaltyApplied ) {
115- setScore ( ( prevScore ) => Math . max ( 0 , prevScore - 0.5 ) ) ;
116- setPenaltyApplied ( true ) ;
117- }
118-
119111 if ( selectedAnswer === questions [ currentQuestion ] . correctAnswer ) {
120112 setScore ( score + 1 ) ;
121113 }
122114
123- setShowExplanation ( false ) ;
124- setPenaltyApplied ( false ) ;
125-
126115 if ( currentQuestion < questions . length - 1 ) {
127116 setCurrentQuestion ( currentQuestion + 1 ) ;
128117 setSelectedAnswer ( null ) ;
@@ -137,7 +126,6 @@ const BubbleSortQuiz = () => {
137126 } ;
138127
139128 const handlePreviousQuestion = ( ) => {
140- setShowExplanation ( false ) ;
141129 setCurrentQuestion ( currentQuestion - 1 ) ;
142130 setSelectedAnswer ( answers [ currentQuestion - 1 ] ) ;
143131 } ;
@@ -149,9 +137,7 @@ const BubbleSortQuiz = () => {
149137 setShowResult ( false ) ;
150138 setQuizCompleted ( false ) ;
151139 setAnswers ( Array ( questions . length ) . fill ( null ) ) ;
152- setShowExplanation ( false ) ;
153140 setShowIntro ( true ) ;
154- setPenaltyApplied ( false ) ;
155141 } ;
156142
157143 const calculateWeakAreas = ( ) => {
@@ -332,29 +318,7 @@ const BubbleSortQuiz = () => {
332318 ) ) }
333319 </ div >
334320
335- { selectedAnswer !== null && (
336- < div className = "mb-6" >
337- < button
338- onClick = { ( ) => setShowExplanation ( ! showExplanation ) }
339- className = "text-sm flex items-center text-blue-600 dark:text-blue-400 hover:underline mb-2"
340- >
341- < FaInfoCircle className = "mr-1" />
342- { showExplanation ? "Hide Explanation" : "Show Explanation" }
343- </ button >
344- < AnimatePresence >
345- { showExplanation && (
346- < motion . div
347- initial = { { opacity : 0 , height : 0 } }
348- animate = { { opacity : 1 , height : "auto" } }
349- exit = { { opacity : 0 , height : 0 } }
350- className = "p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg text-sm overflow-hidden"
351- >
352- { questions [ currentQuestion ] . explanation }
353- </ motion . div >
354- ) }
355- </ AnimatePresence >
356- </ div >
357- ) }
321+
358322 </ motion . div >
359323
360324 < div className = "flex justify-between" >
0 commit comments