Skip to content

Commit 99b32f2

Browse files
committed
added Quiz
1 parent efad31d commit 99b32f2

File tree

15 files changed

+1677
-41
lines changed

15 files changed

+1677
-41
lines changed

Component/AppBar.razor

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,13 @@
2626

2727
<!-- Right Section -->
2828
<div class="flex items-center space-x-1 sm:space-x-2">
29-
<!-- Stats -->
30-
<div class="hidden sm:flex items-center space-x-2 md:space-x-4 text-sm text-white">
31-
<div class="text-center bg-white/20 backdrop-blur-sm rounded-2xl px-2 sm:px-4 py-1 sm:py-2 cartoon-rounded border border-white/30">
32-
@if (StateService.IsLoading || !StateService.CurrentVideos.Any())
33-
{
34-
<div class="h-4 sm:h-5 bg-white/30 rounded w-6 sm:w-8 mx-auto mb-1 skeleton"></div>
35-
<div class="text-xs text-white font-comic font-semibold drop-shadow-md">Episodes</div>
36-
}
37-
else
38-
{
39-
<div class="font-bold text-white font-cartoon text-sm sm:text-lg drop-shadow-lg">@StateService.CurrentVideos.Count()</div>
40-
<div class="text-xs text-white font-comic font-semibold drop-shadow-md">Episodes</div>
41-
}
42-
</div>
43-
</div>
29+
<!-- Quiz Button -->
30+
<button @onclick="GoToQuiz"
31+
class="hidden sm:flex items-center space-x-2 bg-cartoon-yellow text-amber-800 rounded-xl px-3 py-2 font-bold font-comic hover:bg-cartoon-orange transition-colors cartoon-rounded">
32+
<span class="text-lg">🧠</span>
33+
<span class="text-sm">Quiz</span>
34+
</button>
35+
4436
</div>
4537
</div>
4638
</div>
@@ -56,6 +48,11 @@
5648
{
5749
nav.NavigateTo("stickers");
5850
}
51+
52+
void GoToQuiz()
53+
{
54+
nav.NavigateTo("quiz");
55+
}
5956

6057
protected override void OnInitialized()
6158
{

Component/Footer.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177

178178
void GoToSearch()
179179
{
180-
nav.NavigateTo("search");
180+
nav.NavigateTo("Search/");
181181
}
182182

183183
protected override void OnInitialized()

Model/QuizQuestion.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace TomAndJerry.Model
2+
{
3+
public class QuizQuestion
4+
{
5+
public int Id { get; set; }
6+
public string Question { get; set; } = string.Empty;
7+
public List<string> Options { get; set; } = new List<string>();
8+
public int CorrectAnswerIndex { get; set; }
9+
public string Explanation { get; set; } = string.Empty;
10+
public string Category { get; set; } = "general";
11+
public string Difficulty { get; set; } = "easy";
12+
public string ImagePath { get; set; } = string.Empty;
13+
public DateTime CreatedAt { get; set; } = DateTime.Now;
14+
}
15+
}

Model/QuizResult.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace TomAndJerry.Model
2+
{
3+
public class QuizResult
4+
{
5+
public int TotalQuestions { get; set; }
6+
public int CorrectAnswers { get; set; }
7+
public int WrongAnswers { get; set; }
8+
public double ScorePercentage { get; set; }
9+
public TimeSpan TimeTaken { get; set; }
10+
public List<QuizAnswer> Answers { get; set; } = new List<QuizAnswer>();
11+
public DateTime CompletedAt { get; set; } = DateTime.Now;
12+
public string Grade { get; set; } = string.Empty;
13+
public string Message { get; set; } = string.Empty;
14+
}
15+
16+
public class QuizAnswer
17+
{
18+
public int QuestionId { get; set; }
19+
public string Question { get; set; } = string.Empty;
20+
public string SelectedAnswer { get; set; } = string.Empty;
21+
public string CorrectAnswer { get; set; } = string.Empty;
22+
public bool IsCorrect { get; set; }
23+
public string Explanation { get; set; } = string.Empty;
24+
}
25+
}

Pages/Home.razor

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
@using TomAndJerry.Services
33
@using TomAndJerry.Model
44
@using TomAndJerry.Component
5+
@using TomAndJerry.Utils
56
@inject NavigationManager nav
67
@inject IVideoService VideoService
78
@inject IStateService StateService
89
@inject IJSRuntime JSRuntime
910
@inject IStickerService StickerService
11+
@inject IRandomFactsService RandomFactsService
1012
<PageTitle>Home - Tom & Jerry</PageTitle>
1113

1214
<div class="min-h-screen cartoon-bg">
@@ -130,6 +132,10 @@
130132
class="px-6 sm:px-8 py-3 sm:py-4 bg-soft-blue text-amber-800 rounded-2xl hover:bg-cartoon-yellow transition-colors font-bold font-comic text-base sm:text-lg border-2 border-amber-800 shadow-lg hover:shadow-xl transform hover:-translate-y-1">
131133
📺 View All
132134
</button>
135+
<button @onclick="GoToQuiz"
136+
class="px-6 sm:px-8 py-3 sm:py-4 bg-cartoon-pink text-white rounded-2xl hover:bg-cartoon-red transition-colors font-bold font-comic text-base sm:text-lg border-2 border-white/30 shadow-lg hover:shadow-xl transform hover:-translate-y-1">
137+
🧠 Take Quiz
138+
</button>
133139
<button @onclick="ShowRandomFact"
134140
class="px-6 py-4 bg-cartoon-yellow/20 backdrop-blur-sm text-white rounded-2xl hover:bg-cartoon-yellow/30 transition-all font-bold font-comic text-lg border-2 border-cartoon-yellow/30">
135141
💡 Random Fact
@@ -427,6 +433,11 @@
427433
await ScrollToSection("sticker-gallery");
428434
}
429435

436+
private void GoToQuiz()
437+
{
438+
nav.NavigateTo("quiz");
439+
}
440+
430441
private void RefreshStickers()
431442
{
432443
// This will trigger a refresh of the sticker gallery
@@ -457,22 +468,7 @@
457468

458469
private async Task ShowRandomFact()
459470
{
460-
string[] facts = {
461-
"Tom & Jerry won 7 Academy Awards for Best Animated Short Film!",
462-
"The original creators were William Hanna and Joseph Barbera, who later founded Hanna-Barbera.",
463-
"Tom's full name is Thomas Cat, and Jerry's full name is Gerald Mouse.",
464-
"The show was originally called 'Puss Gets the Boot' before becoming Tom & Jerry.",
465-
"Over 160 episodes were produced between 1940 and 1958.",
466-
"Tom & Jerry has been translated into over 30 languages worldwide.",
467-
"The characters rarely speak - most communication is through actions and expressions.",
468-
"Tom & Jerry was one of the first cartoons to use limited animation techniques.",
469-
"The show has been rebooted multiple times with different animation styles.",
470-
"Tom & Jerry merchandise has generated billions in revenue over the decades."
471-
};
472-
473-
var random = new Random();
474-
var fact = facts[random.Next(facts.Length)];
475-
471+
var fact = RandomFactsService.GetRandomFact();
476472
await snackbar.ShowAsync("🎭 Fun Fact", fact, "💡", SnackbarType.Info, 6000);
477473
}
478474

0 commit comments

Comments
 (0)