From 4dc399d311dfdf769cbeedbde0bde5a625de75e5 Mon Sep 17 00:00:00 2001 From: muttaqinrizal Date: Mon, 16 Oct 2023 20:43:52 +0700 Subject: [PATCH] define model quiz --- .idea/.gitignore | 3 ++ .idea/bebras-pandai.iml | 9 +++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ .../presentation/model/answer.dart | 23 +++++++++++ .../presentation/model/aspect.dart | 12 ++++++ .../presentation/model/description.dart | 8 ++++ .../presentation/model/explanation.dart | 11 ++++++ .../presentation/model/options.dart | 12 ++++++ .../presentation/model/questions.dart | 15 ++++++++ .../presentation/model/quiz_exercise.dart | 38 +++++++++++++++++++ .../repositories/quiz_exercise.dart | 1 + 12 files changed, 146 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/bebras-pandai.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 app/lib/features/quiz_exercise/presentation/model/answer.dart create mode 100644 app/lib/features/quiz_exercise/presentation/model/aspect.dart create mode 100644 app/lib/features/quiz_exercise/presentation/model/description.dart create mode 100644 app/lib/features/quiz_exercise/presentation/model/explanation.dart create mode 100644 app/lib/features/quiz_exercise/presentation/model/options.dart create mode 100644 app/lib/features/quiz_exercise/presentation/model/questions.dart create mode 100644 app/lib/features/quiz_exercise/presentation/model/quiz_exercise.dart create mode 100644 app/lib/features/quiz_exercise/presentation/repositories/quiz_exercise.dart diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/bebras-pandai.iml b/.idea/bebras-pandai.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/bebras-pandai.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2604166 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/lib/features/quiz_exercise/presentation/model/answer.dart b/app/lib/features/quiz_exercise/presentation/model/answer.dart new file mode 100644 index 0000000..b924da4 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/model/answer.dart @@ -0,0 +1,23 @@ +import 'aspect.dart'; +import 'explanation.dart'; + +class Answer { + final Aspect aspect; + final List correctAnswer; + final Explanation explanation; + + Answer({ + required this.aspect, + required this.correctAnswer, + required this.explanation, + }); + + factory Answer.fromJson(Map json) { + return Answer( + aspect: Aspect.fromJson(json['aspect'] as Map), + correctAnswer: + json['correctAnswer'].cast>() as List, + explanation: + Explanation.fromJson(json['explanation'] as Map)); + } +} diff --git a/app/lib/features/quiz_exercise/presentation/model/aspect.dart b/app/lib/features/quiz_exercise/presentation/model/aspect.dart new file mode 100644 index 0000000..ca3b765 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/model/aspect.dart @@ -0,0 +1,12 @@ +class Aspect { + final String content; + final String label; + Aspect({required this.content, required this.label}); + + factory Aspect.fromJson(Map json) { + return Aspect( + content: json['content'] as String, + label: json['label'] as String, + ); + } +} diff --git a/app/lib/features/quiz_exercise/presentation/model/description.dart b/app/lib/features/quiz_exercise/presentation/model/description.dart new file mode 100644 index 0000000..e3a2980 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/model/description.dart @@ -0,0 +1,8 @@ +class Description { + final String content; + Description({required this.content}); + + factory Description.fromJson(Map json) { + return Description(content: json['content'] as String); + } +} diff --git a/app/lib/features/quiz_exercise/presentation/model/explanation.dart b/app/lib/features/quiz_exercise/presentation/model/explanation.dart new file mode 100644 index 0000000..3e09924 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/model/explanation.dart @@ -0,0 +1,11 @@ +class Explanation { + final String content; + + Explanation({required this.content}); + + factory Explanation.fromJson(Map json) { + return Explanation( + content: json['content'] as String, + ); + } +} diff --git a/app/lib/features/quiz_exercise/presentation/model/options.dart b/app/lib/features/quiz_exercise/presentation/model/options.dart new file mode 100644 index 0000000..3bd87c2 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/model/options.dart @@ -0,0 +1,12 @@ +class Options { + final String content; + final String id; + Options({required this.content, required this.id}); + + factory Options.fromJson(Map json) { + return Options( + content: json['content'] as String, + id: json['id'] as String, + ); + } +} diff --git a/app/lib/features/quiz_exercise/presentation/model/questions.dart b/app/lib/features/quiz_exercise/presentation/model/questions.dart new file mode 100644 index 0000000..56b4640 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/model/questions.dart @@ -0,0 +1,15 @@ +import 'options.dart'; + +class Question { + final String content; + final List options; + + Question({required this.content, required this.options}); + + factory Question.fromJson(Map json) { + return Question( + content: json['content'] as String, + options: json['options'].cast>() as List, + ); + } +} diff --git a/app/lib/features/quiz_exercise/presentation/model/quiz_exercise.dart b/app/lib/features/quiz_exercise/presentation/model/quiz_exercise.dart new file mode 100644 index 0000000..8c00fc1 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/model/quiz_exercise.dart @@ -0,0 +1,38 @@ +import 'description.dart'; +import 'questions.dart'; + +class QuizExerciseModel { + final String id; + final String country; + final String challengeGroup; + final String title; + final String type; + final String source; + final Description description; + final Question question; + + QuizExerciseModel({ + required this.id, + required this.country, + required this.challengeGroup, + required this.title, + required this.source, + required this.type, + required this.description, + required this.question, + }); + + factory QuizExerciseModel.fromJson(Map json) { + return QuizExerciseModel( + id: json['id'] as String, + country: json['country'] as String, + challengeGroup: json['challenge_group'] as String, + title: json['title'] as String, + source: json['source'] as String, + type: json['type'] as String, + description: + Description.fromJson(json['description'] as Map), + question: Question.fromJson(json['question'] as Map), + ); + } +} diff --git a/app/lib/features/quiz_exercise/presentation/repositories/quiz_exercise.dart b/app/lib/features/quiz_exercise/presentation/repositories/quiz_exercise.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/app/lib/features/quiz_exercise/presentation/repositories/quiz_exercise.dart @@ -0,0 +1 @@ +