Skip to content

Commit

Permalink
define model quiz
Browse files Browse the repository at this point in the history
  • Loading branch information
muttaqinrizal committed Oct 16, 2023
1 parent 2d1ec00 commit 4dc399d
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/bebras-pandai.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions app/lib/features/quiz_exercise/presentation/model/answer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'aspect.dart';
import 'explanation.dart';

class Answer {
final Aspect aspect;
final List<dynamic> correctAnswer;
final Explanation explanation;

Answer({
required this.aspect,
required this.correctAnswer,
required this.explanation,
});

factory Answer.fromJson(Map<String, dynamic> json) {
return Answer(
aspect: Aspect.fromJson(json['aspect'] as Map<String, dynamic>),
correctAnswer:
json['correctAnswer'].cast<Map<String, dynamic>>() as List<dynamic>,
explanation:
Explanation.fromJson(json['explanation'] as Map<String, dynamic>));
}
}
12 changes: 12 additions & 0 deletions app/lib/features/quiz_exercise/presentation/model/aspect.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Aspect {
final String content;
final String label;
Aspect({required this.content, required this.label});

factory Aspect.fromJson(Map<String, dynamic> json) {
return Aspect(
content: json['content'] as String,
label: json['label'] as String,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Description {
final String content;
Description({required this.content});

factory Description.fromJson(Map<String, dynamic> json) {
return Description(content: json['content'] as String);
}
}
11 changes: 11 additions & 0 deletions app/lib/features/quiz_exercise/presentation/model/explanation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Explanation {
final String content;

Explanation({required this.content});

factory Explanation.fromJson(Map<String, dynamic> json) {
return Explanation(
content: json['content'] as String,
);
}
}
12 changes: 12 additions & 0 deletions app/lib/features/quiz_exercise/presentation/model/options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Options {
final String content;
final String id;
Options({required this.content, required this.id});

factory Options.fromJson(Map<String, dynamic> json) {
return Options(
content: json['content'] as String,
id: json['id'] as String,
);
}
}
15 changes: 15 additions & 0 deletions app/lib/features/quiz_exercise/presentation/model/questions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'options.dart';

class Question {
final String content;
final List<Options> options;

Question({required this.content, required this.options});

factory Question.fromJson(Map<String, dynamic> json) {
return Question(
content: json['content'] as String,
options: json['options'].cast<Map<String, dynamic>>() as List<Options>,
);
}
}
Original file line number Diff line number Diff line change
@@ -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<String, dynamic> 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<String, dynamic>),
question: Question.fromJson(json['question'] as Map<String, dynamic>),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 4dc399d

Please sign in to comment.