From 8e7ed3fd80964f1f27ab3c41d5a95c3fc4057aa2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 14:59:29 +0000 Subject: [PATCH 1/2] Initial plan From 515b54107784a07771265ec413ad3259556ddd1c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 15:10:17 +0000 Subject: [PATCH 2/2] Add GuessTheNumber question type with models, UI components and tests Co-authored-by: fortunkam <1851394+fortunkam@users.noreply.github.com> --- .../Client/GuessTheNumberQuestion.razor | 56 +++++++++++++++++++ .../Client/Shared/Client/QuestionPicker.razor | 4 ++ .../Shared/Edit/GuessTheNumberQuestion.razor | 45 +++++++++++++++ .../Shared/Edit/QuestionTypePickerModal.razor | 10 ++++ .../Client/Shared/Edit/RootComponent.razor | 13 +++++ .../Present/GuessTheNumberQuestion.razor | 44 +++++++++++++++ .../Shared/Present/QuestionPicker.razor | 4 ++ .../ClientQuestionSerializationTests.cs | 25 +++++++++ .../JsonSerializationTests.cs | 9 +++ QuizExperiment.Models/Client/ClientAnswer.cs | 1 + .../Client/ClientGuessTheNumberAnswer.cs | 37 ++++++++++++ .../Client/ClientGuessTheNumberQuestion.cs | 15 +++++ .../Client/ClientQuestion.cs | 1 + .../GuessTheNumberQuestion.cs | 44 +++++++++++++++ .../PolymorphicQuestionConverter.cs | 4 ++ QuizExperiment.Models/Question.cs | 1 + 16 files changed, 313 insertions(+) create mode 100644 QuizExperiment.Admin/Client/Shared/Client/GuessTheNumberQuestion.razor create mode 100644 QuizExperiment.Admin/Client/Shared/Edit/GuessTheNumberQuestion.razor create mode 100644 QuizExperiment.Admin/Client/Shared/Present/GuessTheNumberQuestion.razor create mode 100644 QuizExperiment.Models/Client/ClientGuessTheNumberAnswer.cs create mode 100644 QuizExperiment.Models/Client/ClientGuessTheNumberQuestion.cs create mode 100644 QuizExperiment.Models/GuessTheNumberQuestion.cs diff --git a/QuizExperiment.Admin/Client/Shared/Client/GuessTheNumberQuestion.razor b/QuizExperiment.Admin/Client/Shared/Client/GuessTheNumberQuestion.razor new file mode 100644 index 0000000..234f953 --- /dev/null +++ b/QuizExperiment.Admin/Client/Shared/Client/GuessTheNumberQuestion.razor @@ -0,0 +1,56 @@ +@using QuizExperiment.Models.Client + +@{ + if(Question != null) + { +
+

@Question.Title

+
+
+

Enter a number between @Question.MinValue and @Question.MaxValue

+ + +
+
+
+ } +} + +@code { + + [Parameter] + public ClientGuessTheNumberQuestion? Question { get; set; } + + [Parameter] + public EventCallback OnAnswerSubmit { get; set; } + + private int? userGuess; + + private bool IsValidGuess() + { + if (!userGuess.HasValue || Question == null) return false; + return userGuess.Value >= Question.MinValue && userGuess.Value <= Question.MaxValue; + } + + private async Task SubmitAnswer() + { + if (!IsValidGuess()) return; + + var answer = new ClientGuessTheNumberAnswer + { + Answer = userGuess!.Value + }; + await OnAnswerSubmit.InvokeAsync(answer); + } + +} diff --git a/QuizExperiment.Admin/Client/Shared/Client/QuestionPicker.razor b/QuizExperiment.Admin/Client/Shared/Client/QuestionPicker.razor index ca39148..ec59ce5 100644 --- a/QuizExperiment.Admin/Client/Shared/Client/QuestionPicker.razor +++ b/QuizExperiment.Admin/Client/Shared/Client/QuestionPicker.razor @@ -19,6 +19,10 @@ { } + else if(Question is ClientGuessTheNumberQuestion guessTheNumberQuestion) + { + + } else {

Unsupported question type.

diff --git a/QuizExperiment.Admin/Client/Shared/Edit/GuessTheNumberQuestion.razor b/QuizExperiment.Admin/Client/Shared/Edit/GuessTheNumberQuestion.razor new file mode 100644 index 0000000..705614b --- /dev/null +++ b/QuizExperiment.Admin/Client/Shared/Edit/GuessTheNumberQuestion.razor @@ -0,0 +1,45 @@ +@using QuizModels = QuizExperiment.Models +@using System.Text.Json +@inject HttpClient Http + +@if (Question is not null) +{ + var guessTheNumberQuestion = Question as QuizModels.GuessTheNumberQuestion; + if (guessTheNumberQuestion is not null) + { + +
+ + + + + + + + + + + + + +
ANSWER RANGE
+ + + + + +
+ + +
+
+ } +} + +@code { + [Parameter] + public QuizModels.Question? Question { get; set; } +} diff --git a/QuizExperiment.Admin/Client/Shared/Edit/QuestionTypePickerModal.razor b/QuizExperiment.Admin/Client/Shared/Edit/QuestionTypePickerModal.razor index d4e0edc..d6c150e 100644 --- a/QuizExperiment.Admin/Client/Shared/Edit/QuestionTypePickerModal.razor +++ b/QuizExperiment.Admin/Client/Shared/Edit/QuestionTypePickerModal.razor @@ -28,6 +28,12 @@ Type the Answer +
+ +