Skip to content

Commit 5acfdea

Browse files
feat: add quiz question type, show questions
1 parent 2003488 commit 5acfdea

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

src/components/tutorial-quiz.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
import { Cinzel } from "next/font/google";
2+
import { useState } from "react";
3+
import { helloWorldQuiz } from "@/data/quizzes/01-hello-world";
24
const cinzel = Cinzel({ subsets: ["latin"], weight: ["700"] });
35
export default function TutorialQuiz() {
6+
const [questionNumber, setQuestionNumber] = useState<number>(0);
7+
const currentQuestion = helloWorldQuiz.questions[questionNumber];
8+
49
return (
510
<div className="mt-12 p-8 border-2 border-amber-800/50 rounded-xl bg-amber-50/50 shadow-inner shadow-amber-900/20">
611
<h2 className={`text-3xl font-bold text-center mb-6 text-amber-900 ${cinzel.className}`}>
712
Test Your Knowledge, Initiate
813
</h2>
14+
15+
{/* Question Card */}
16+
<div className="space-y-6">
17+
<div className="bg-amber-200/50 p-6 rounded-lg border border-amber-800/30">
18+
<h3 className="text-xl font-semibold text-amber-950 mb-4">
19+
{currentQuestion.questionText}
20+
</h3>
21+
</div>
22+
</div>
923
</div>
1024
);
1125
}

src/data/quizzes/01-hello-world.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { QuizData } from "@/lib/types/types";
2+
3+
export const helloWorldQuiz: QuizData = {
4+
title: "The Oracle's First Greeting",
5+
questions: [
6+
{
7+
questionText: "What is the primary purpose of a 'Hello World' program?",
8+
options: [
9+
"To summon a digital dragon",
10+
"To verify that your coding environment is set up correctly",
11+
"To hack into the mainframe",
12+
"To write a poem for the computer",
13+
],
14+
correctAnswer: "To verify that your coding environment is set up correctly",
15+
},
16+
{
17+
questionText:
18+
"True or False: 'Hello World' is only used in one specific programming language.",
19+
options: ["True", "False"],
20+
correctAnswer: "False",
21+
},
22+
{
23+
questionText: "Which of the following is a common command to display text?",
24+
options: ["print", "shout", "whisper", "cast_spell"],
25+
correctAnswer: "print",
26+
},
27+
],
28+
};

src/lib/types/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type Question = {
2+
questionText: string;
3+
options: string[];
4+
correctAnswer: string;
5+
};
6+
7+
export type QuizData = {
8+
title: string;
9+
questions: Question[];
10+
};

0 commit comments

Comments
 (0)