@@ -159,6 +159,12 @@ export class ExpoQuiz2025Component implements OnInit, OnDestroy {
159159 showResultsModal : boolean = false ;
160160 showLeaderboardModal : boolean = false ;
161161
162+ // Feedback state
163+ showFeedback : boolean = false ;
164+ isAnswerCorrect : boolean = false ;
165+ feedbackMessage : string = '' ;
166+ currentCorrectAnswer : number | null = null ;
167+
162168 // Modal data
163169 incorrectAnswers : any [ ] = [ ] ;
164170 playerName : string = '' ;
@@ -262,10 +268,34 @@ export class ExpoQuiz2025Component implements OnInit, OnDestroy {
262268
263269 private resetQuizState ( ) : void {
264270 this . selectedAnswer = null ;
271+ this . showFeedback = false ;
272+ this . isAnswerCorrect = false ;
273+ this . feedbackMessage = '' ;
274+ this . currentCorrectAnswer = null ;
265275 }
266276
267277 selectAnswer ( answerIndex : number ) : void {
278+ // Don't allow changing answer while feedback is showing
279+ if ( this . showFeedback ) return ;
280+
268281 this . selectedAnswer = answerIndex ;
282+
283+ // Check if answer is correct
284+ const correctAnswer = this . quizData [ this . currentQuiz ! ] . questions [ this . currentQuestion ] . correct ;
285+ this . currentCorrectAnswer = correctAnswer ;
286+ this . isAnswerCorrect = ( answerIndex === correctAnswer ) ;
287+
288+ // Set feedback message
289+ if ( this . isAnswerCorrect ) {
290+ const messages = [ '🎉 Correct!' , '✨ Well done!' , '🌟 Excellent!' , '👏 Great job!' , '💯 Perfect!' ] ;
291+ this . feedbackMessage = messages [ Math . floor ( Math . random ( ) * messages . length ) ] ;
292+ } else {
293+ const messages = [ '❌ Incorrect' , '🤔 Not quite' , '💭 Try again next time' , '📚 Keep learning' ] ;
294+ this . feedbackMessage = messages [ Math . floor ( Math . random ( ) * messages . length ) ] ;
295+ }
296+
297+ // Show feedback
298+ this . showFeedback = true ;
269299 }
270300
271301 nextQuestion ( ) : void {
@@ -283,6 +313,10 @@ export class ExpoQuiz2025Component implements OnInit, OnDestroy {
283313 // Move to next question
284314 this . currentQuestion ++ ;
285315 this . selectedAnswer = null ;
316+ this . showFeedback = false ;
317+ this . isAnswerCorrect = false ;
318+ this . feedbackMessage = '' ;
319+ this . currentCorrectAnswer = null ;
286320 }
287321
288322 finishQuiz ( ) : void {
@@ -297,8 +331,8 @@ export class ExpoQuiz2025Component implements OnInit, OnDestroy {
297331 this . score ++ ;
298332 }
299333
300- // Show answers modal first
301- this . showAnswers ( ) ;
334+ // Go directly to results, skip the answers modal
335+ this . showResults ( ) ;
302336 }
303337
304338 private showAnswers ( ) : void {
@@ -414,12 +448,10 @@ export class ExpoQuiz2025Component implements OnInit, OnDestroy {
414448
415449 // Mark name as submitted and clear input
416450 this . nameSubmitted = true ;
417- const playerName = this . playerName . trim ( ) ;
418451 this . playerName = '' ;
419452
420- // Show success message
421- const quizName = this . currentQuiz === 'food' ? 'Global Food Quiz' : 'SNOMED CT International Quiz' ;
422- alert ( `Great job, ${ playerName } ! Your score has been added to the ${ quizName } leaderboard!` ) ;
453+ // Trigger flash animation by adding/removing class
454+ // The leaderboard will update with real-time data and the new entry will flash
423455 } catch ( error ) {
424456 console . error ( 'Error adding to leaderboard:' , error ) ;
425457 alert ( 'Sorry, there was an error saving your score. Please try again.' ) ;
0 commit comments