playWith/packages/games/quiz/lib/model/quiz_model.dart
2025-11-25 17:25:16 +09:00

108 lines
3.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

enum QuizType { text, image } // 문제 유형
class QuizItem {
final QuizType type;
final String question; // 질문 텍스트
final String answer; // 정답
final List<String> options; // 보기 (객관식용, 없으면 주관식/OX)
QuizItem({
required this.type,
required this.question,
required this.answer,
required this.options,
});
Map<String, dynamic> toJson() => {
'type': type.name,
'question': question,
'answer': answer,
'options': options,
};
factory QuizItem.fromJson(Map<String, dynamic> json) {
return QuizItem(
type: json['type'] == 'image' ? QuizType.image : QuizType.text,
question: json['question'],
answer: json['answer'],
options: List<String>.from(json['options'] ?? []),
);
}
}
class QuizSet {
static List<QuizItem> getDummy10() {
return [
// 1. [OX] 기본
QuizItem(
type: QuizType.text,
question: "사과는 영어로 Apple이다.",
answer: "O",
options: ["O", "X"],
),
// 2. [OX] 상식
QuizItem(
type: QuizType.text,
question: "북극곰의 피부색은 흰색이다.",
answer: "X", // 검은색임
options: ["O", "X"],
),
// 3. [OX] 생물
QuizItem(
type: QuizType.text,
question: "돌고래는 '어류(물고기)'다.",
answer: "X", // 포유류
options: ["O", "X"],
),
// 4. [4지선다] 역사
QuizItem(
type: QuizType.text,
question: "임진왜란이 일어난 해는?",
answer: "1592년",
options: ["1392년", "1492년", "1592년", "1950년"],
),
// 5. [4지선다] 넌센스
QuizItem(
type: QuizType.text,
question: "왕이 넘어지면?",
answer: "킹콩",
options: ["왕콩", "킹콩", "전하", "꽈당"],
),
// 6. [주관식/음성] 속담 (보기를 줘서 터치도 가능하게 함)
QuizItem(
type: QuizType.text,
question: "가는 말이 고와야 [ ? ]가 곱다.",
answer: "오는 말",
options: ["오는 말", "가는 발", "너의 말", "우리 말"],
),
// 7. [수학] 연산
QuizItem(
type: QuizType.text,
question: "5 + 5 × 5 = ?",
answer: "30",
options: ["25", "30", "50", "10"],
),
// 8. [상식] 수도 맞추기
QuizItem(
type: QuizType.text,
question: "미국의 수도는 어디일까요?",
answer: "워싱턴 D.C.",
options: ["뉴욕", "LA", "워싱턴 D.C.", "시카고"],
),
// 9. [넌센스]
QuizItem(
type: QuizType.text,
question: "세상에서 가장 뜨거운 바다는?",
answer: "열바다",
options: ["불바다", "열바다", "사랑해", "동해"],
),
// 10. [OX] 마지막
QuizItem(
type: QuizType.text,
question: "개발자님은 이 앱을 완성할 수 있다!",
answer: "O",
options: ["O", "X"],
),
];
}
}