Build a twoโmode console appโTeacher and Studentโthat creates, manages, and runs quizzes, using Spectre.Console for all user interaction.
New in this version
- Teacher Mode can disable / enable or delete existing quizzes.
- Optional timeโlimited questions feature worth +50 bonus points.
- Objective
- Functional Requirements
- NonโFunctional Requirements
- Folder Structure
- Data Model (Mermaid)
- Sample Quiz JSON
- Console I/Oย Samples
- Edge Cases
- Spectre.Console Usage Requirements
- Task Breakdown
- Evaluation Rubric
- Sequence Diagrams
Create a console application that lets:
-
Teachers
- Build quizzes (MCQ, True/False, Short Answer).
- Enable/disable quizzes (disabled quizzes are hidden from students).
- Delete quizzes with confirmation.
-
Students
- Load an active quiz.
- Answer questions via
SelectionPrompt/TextPrompt. - Receive an autoโgraded report, with optional halfโscore logic for questions answered after their time limit.
| Requirement | Detail |
|---|---|
| Main menu | SelectionPrompt: Createย Quiz, Manageย Quizzes, Exit. |
| Create quiz | Enter title & description via TextPrompt. |
| Add questions | MCQ, True/False, Short Answer; repeat until done. |
| MCQ format | Options must be dictionary: "A": "int", etc. Answer stores the key (e.g., "A"). |
| Timeโlimited (optional) | Teacher may set TimeLimitSeconds (โฅโฏ5โฏs). Omit for unlimited. |
| Validation | Reject empty prompts, duplicate option keys, invalid time limits. |
| Summary & save | Show a Table; confirm via ConfirmationPrompt before writing JSON. |
| Manage quizzes | List all JSON files via SelectionPrompt. After selection: Enable/Disable, Delete, View Summary. |
| Delete | Requires two confirmations. |
| Requirement | Detail |
|---|---|
| Quiz list | Show only enabled .json files via SelectionPrompt. |
| Load & header | Display in a Panel. |
| Question flow | โข MCQ / TrueโFalse: SelectionPrompt (arrow keys +โฏEnter).โข Short Answer: TextPrompt. |
| Timeโlimited logic (bonus) | If a question has TimeLimitSeconds, start a countdown.โข Correct within limit โ full point. โข Correct after limit โ ยฝย point. โข No answer or wrong answer โ 0. |
| Scoring | Autoโupdate points (1, 0.5, 0). |
| Report | Table with โ/โ and โฑ icons; overall % and pass/fail (70โฏ% threshold). |
- 100โฏ% Spectre.Console for input/outputโno
Console.ReadLine/WriteLine. - Robust error handling with custom exceptions where appropriate.
- Disabled quizzes must not appear in Student Mode.
QuizApp/
โ
โโโ Program.cs
โโโ Models/
โ โโโ Question.cs
โ โโโ McqQuestion.cs
โ โโโ TrueFalseQuestion.cs
โ โโโ ShortAnswerQuestion.cs
โ โโโ QuizMeta.cs <-- holds Title, Description, IsActive
โ
โโโ Services/
โ โโโ QuizBuilder.cs
โ โโโ QuizManager.cs <-- enable/disable/delete logic
โ โโโ QuizRunner.cs
โ โโโ QuizStorage.cs
โ
โโโ Utilities/
โ โโโ InputHelper.cs
โ
โโโ Data/
โโโ quizzes/
classDiagram
direction TB
class QuizMeta {
+string Title
+string Description
+bool IsActive
+List~Question~ Questions
}
class Question {
+string Prompt
+int? TimeLimitSeconds
+abstract double CheckAnswer(string answer, double elapsedSec)
}
class McqQuestion {
+Dictionary~string,string~ Options
+string AnswerKey
}
class TrueFalseQuestion {
+bool CorrectAnswer
}
class ShortAnswerQuestion {
+string CorrectAnswer
}
QuizMeta *-- Question
Question <|-- McqQuestion
Question <|-- TrueFalseQuestion
Question <|-- ShortAnswerQuestion
{
"Title": "C# Basics",
"Description": "Covers primitive types and control flow.",
"IsActive": true,
"Questions": [
{
"Type": "MCQ",
"Prompt": "Which is a value type in C#?",
"Options": {
"A": "string",
"B": "int",
"C": "object",
"D": "dynamic"
},
"Answer": "B",
"TimeLimitSeconds": 20 // answer in 20โฏs for full credit
},
{
"Type": "TrueFalse",
"Prompt": "The 'var' keyword implies dynamic typing.",
"CorrectAnswer": false
},
{
"Type": "ShortAnswer",
"Prompt": "What keyword defines a constant?",
"CorrectAnswer": "const",
"TimeLimitSeconds": 15
}
]
}[ Manage Existing Quizzes ]
โฏ C# Basics (active)
OOP Review (disabled)
Actions for **C# Basics**
โฏ Disable Quiz
Delete Quiz
View Summary
Back
[ Question 1 of 3 ] โฑ 20s
Which is a value type in C#?
โฏ A: string
B: int
C: object
D: dynamic
(timer counts down; answer after 22โฏs but correct)
โ Time exceeded. Half credit awarded.
- Attempting to start Student Mode when no active quizzes exist.
- Deleting a quiz that is currently disabled.
- Teacher disabling an already disabled quiz.
- Time limit โคโฏ0 or <โฏ5โฏseconds (reject).
- Student presses Esc or closes prompt before answering (treat as wrong).
- Halfโcredit rounding (0.5 increments).
| Purpose | API |
|---|---|
| Main & subโmenus | SelectionPrompt<string>() |
| Confirmations | ConfirmationPrompt() |
| Text input | TextPrompt<string>() |
| Timer display | LiveDisplay, Status(), or custom markup refresh |
| Tables | Table() |
| Panels / headings | Panel(), Rule() |
| Color feedback | Markup() |
| Task | Hours |
|---|---|
| Design models & interfaces | 2 |
| Implement Teacher Mode (create) | 3 |
| Implement Teacher Mode (manage) | 1 |
| Implement Student Mode | 4 |
| JSON save/load layer | 2 |
| Spectre polishing | 2 |
| Edge case handling & tests | 2 |
| Bonus: timeโlimit engine | +2โ3 |
| Area | Points |
|---|---|
| OOP design & readability | 15 |
| Teacher Mode โ create | 15 |
| Teacher Mode โ manage | 10 |
| Student Mode | 15 |
| JSON persistence reliability | 15 |
| Full Spectre.Console usage | 15 |
| Error/edge handling | 15 |
| All mandatory edge cases met | 15 |
| Bonus: timeโlimit questions | +50 |
(Maxโฏ=โฏ150; graders scale to 100ย % for final grade.)
sequenceDiagram
participant T as Teacher
participant App as ConsoleApp
participant FS as FileSystem
T->>App: Launch Teacher Mode
App-->>T: Main menu (Create / Manage)
alt Create Quiz
App-->>T: Prompt meta
loop Add Qs
App-->>T: Select qโtype
T-->>App: Provide details
end
App-->>T: Show summary -> confirm save
T-->>App: Confirm
App->>FS: Write JSON
FS-->>App: OK
else Manage Quiz
App->>FS: List quizzes
FS-->>App: File list
App-->>T: Select quiz
T-->>App: Choose Disable/Delete/View
alt Disable
App->>FS: Toggle IsActive
else Delete
App-->>T: Confirm x2
T-->>App: Confirm
App->>FS: Delete file
end
end
App-->>T: Result message
sequenceDiagram
participant S as Student
participant App as ConsoleApp
participant FS as FileSystem
S->>App: Launch Student Mode
App->>FS: List active quizzes
FS-->>App: Quiz list
App-->>S: Select quiz
S-->>App: Choose
App->>FS: Read JSON
FS-->>App: Quiz data
loop Each question
App-->>S: Show prompt (+timer if set)
App-->>S: SelectionPrompt/TextPrompt
S-->>App: Answer (and elapsed time)
App-->>S: Evaluate โ / โ / โฑยฝ
end
App-->>S: Display final report
The following transcripts demonstrate every realistic branch the user can take in Teacher and Student modes, including success paths, validation errors, confirmation prompts, disabled quizzes, timeโlimited questions, half credit, and โno active quizโ handling.
All prompts are powered by Spectre.Console components (shown inย bold).
A.ย Create a New Quiz (happy path)
โโโโโโโโโโโโโโ TEACHER MODE โโโโโโโโโโโโโโ
โฏ Create Quiz
Manage Quizzes
Exit
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[ Title of new quiz ] (TextPrompt)
> C# Basics
[ Short description ] (TextPrompt)
> Covers primitive types and control flow.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Add questions to โC# Basicsโ
โฏ Add MCQ
Add True/False
Add Short Answer
Finish Quiz
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
(After choosing Add MCQ)
[ Question prompt ] (TextPrompt)
> Which is a value type in C#?
[ Option A ] (TextPrompt)
> string
[ Option B ]
> int
[ Option C ]
> object
[ Option D ]
> dynamic
[ Correct option key ] (SelectionPrompt)
โฏ A
B
C
D
(Teacher moves to B) Enter
[ Time limit in seconds (ENTER for none) ] (TextPrompt)
> 20
โ MCQ added.
(Add True/False, Add Short Answer โฆ)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
All questions entered. Summary:
โโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโ
โ # โ Type โ Prompt โ
โโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ MCQ (20โฏs) โ Which is a value type in C#? โ
โ 2 โ True/False โ 'var' implies dynamic typing. โ
โ 3 โ Short Answer โ Keyword that defines a constant? โ
โโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Save quiz? (ConfirmationPrompt) [y/N]
> y
๐ Writing file โC#ย Basics.jsonโ โฆ done.
[green]Quiz created successfully![/]
B.ย Validation Error โ Duplicate MCQ Option Key
Add MCQ
[ Option A ]
> int
[ Option A ] (again by mistake)
> integer
[red]Duplicate option key โAโ. Option keys must be unique (AโZ).[/]
C.ย Overwrite Existing Quiz โย Decline
Quiz titled โC# Basicsโ already exists.
Overwrite? (ConfirmationPrompt) [y/N]
> n
[grey]File not overwritten. Returning to main menuโฆ[/]
D.ย Manage Quizzes โย Disable, Enable, Delete
โโโโโโโโโโ MANAGE QUIZZES โโโโโโโโโโ
โฏ C# Basics (active)
OOP Review (disabled)
Back
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
(Select โC#ย Basicsโ)
Actions: (SelectionPrompt)
โฏ Disable Quiz
Delete Quiz
View Summary
Back
> Disable Quiz
Confirm disable โC#ย Basicsโ? (ConfirmationPrompt) [y/N]
> y
[green]Quiz disabled.[/]
โโโโโโโโโโ MANAGE QUIZZES โโโโโโโโโโ
C# Basics (disabled)
โฏ OOP Review (disabled)
Back
(Select โOOPย Reviewโ)
Actions:
โฏ Enable Quiz
Delete Quiz
View Summary
Back
> Enable Quiz
[green]Quiz enabled.[/]
(Delete flow)
Actions:
Enable/Disable
โฏ Delete Quiz
Danger! This will permanently delete โC#ย Basicsโ.
Type DELETE to confirm โ
> del
[red]Incorrect confirmation string. Delete aborted.[/]
Type DELETE to confirm โ
> DELETE
Are you absolutely sure? (ConfirmationPrompt) [y/N]
> y
File removed.
E.ย No Active Quizzes
โโโโโโโโโโโโโโ STUDENT MODE โโโโโโโโโโโโโโ
(no active quizzes found)
Ask your teacher to enable at least one quiz.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
F.ย Take Quiz โย Mixed Results + Time Limit Scenarios
โโโโโโโโโโโโโโ STUDENT MODE โโโโโโโโโโโโโโ
Select a quiz: (SelectionPrompt)
โฏ C# Basics
OOP Review
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ C# Basics โ
โ Covers primitive types and control flow. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Press ENTER to beginโฆ
[ Question 1 / 3 | โฑ 20โฏs ]
Which is a value type in C#?
โฏ A: string
B: int
C: object
D: dynamic
(Answer chosen within 12โฏs โ B)
[green]โ Correct![/]
[ Question 2 / 3 ]
'var' implies dynamic typing.
โฏ True
False
(Selected โTrueโ)
[red]โ Incorrect.[/]
[ Question 3 / 3 | โฑ 15โฏs ]
Keyword that defines a constant?
(15โsecond countdown shown with Status spinner)
> const
(Time taken: 19โฏs)
[yellow]โ Time exceeded. Half credit awarded.[/]
โโโโโโโโโโโโโโโโโ RESULTS โโโโโโโโโโโโโโโโโ
โโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโ
โ # โ Question โ Score โ
โโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโค
โ 1 โ value type in C#? โ [green]1.0[/] โ
โ 2 โ 'var' implies dynamic typing. โ [red]0.0[/] โ
โ 3 โ keyword for constant โ [yellow]0.5[/]โ
โโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโ
Total: 1.5 / 3 (50โฏ%) โ [red]Fail[/]
G.ย Invalid Selection Key (Prevented by UI)
Because MCQ and True/False use SelectionPrompt, the user cannot enter
an invalid keyโarrow keys restrict the choice set.
If they press Esc or CTRLโC, you should catch the
OperationCanceledException and treat the answer as wrongย (0โฏpts).
[ Question 1 / 3 ]
Which is a value type in C#?
(ESC pressed)
[grey]No answer selected. Marked as incorrect.[/]
These exhaustive transcripts cover all paths that must be handled in code.
Good luck, and happy coding! ๐
๐ฉโ๐ซ Teacher Mode โ How
QuizBuilderandQuizManagerWork๐ช Entry Point
When the user selects "Teacher Mode" from the main menu:
๐งฉ Role of
QuizBuilderQuizBuilderacts as the controller for Teacher Mode.It routes the teacher to either creating or managing quizzes.
๐งญ Main Menu Prompt
๐๏ธ What
CreateQuiz()DoesInside
QuizBuilder, theCreateQuiz()method:TextPrompt)TextPrompt)QuizMetaobjectTablesummaryConfirmationPromptQuizStorage.Save()to write JSON๐ง What
QuizManager.Run()DoesOnce the teacher selects "Manage Existing Quizzes",
control is passed to
QuizManager:Responsibilities:
Data/quizzes/IsActiveflag)๐ Diagram โ Teacher Mode Lifecycle
flowchart TD A[Start: Teacher Mode Selected] B[QuizBuilder.Run] C[Main Menu: SelectionPrompt] D[CreateQuiz] E[QuizManager.Run] F[Return to Main Menu] A --> B --> C C --> D C --> E C --> F D --> D1[Prompt for title + description] D1 --> D2[Loop: Add Questions] D2 --> D3[Show summary table] D3 --> D4[Confirm and Save as JSON] E --> E1[List all quizzes] E1 --> E2[Select quiz to manage] E2 --> E3[Action: Enable/Disable/Delete/View] E3 --> E4[Perform selected action] E3 --> F๐ฏ Why Split the Logic?
QuizBuilderQuizManagerโ Benefits:
Let me know if you'd like this shown as a Mermaid diagram too!