Skip to content

Commit

Permalink
feat(#451): basic free text question data model
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Jul 20, 2023
1 parent 17ef604 commit f545171
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/lib/src/models/questionnaire/question.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ abstract class Question<V> {
ScaleQuestion.questionType: (json) => ScaleQuestion.fromJson(json),
AnnotatedScaleQuestion.questionType: (json) => AnnotatedScaleQuestion.fromJson(json),
VisualAnalogueQuestion.questionType: (json) => VisualAnalogueQuestion.fromJson(json),
FreeTextQuestion.questionType: (json) => FreeTextQuestion.fromJson(json),
};
static const String keyType = 'type';
String type;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:json_annotation/json_annotation.dart';

import 'package:studyu_core/core.dart';

part 'free_text_question.g.dart';

@JsonSerializable()
class FreeTextQuestion extends Question<String> {
static const String questionType = 'freeText';

FreeTextQuestion(): super(questionType);

FreeTextQuestion.withId(): super.withId(questionType);

factory FreeTextQuestion.fromJson(Map<String, dynamic> json) => _$FreeTextQuestionFromJson(json);
@override
Map<String, dynamic> toJson() => _$FreeTextQuestionToJson(this);

Answer<String> constructAnswer(String response) => Answer.forQuestion(this, response);
}

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

1 change: 1 addition & 0 deletions core/lib/src/models/questionnaire/questions/questions.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export 'annotated_scale_question.dart';
export 'boolean_question.dart';
export 'choice_question.dart';
export 'free_text_question.dart';
export 'scale_question.dart';
export 'slider_question.dart';
export 'visual_analogue_question.dart';

0 comments on commit f545171

Please sign in to comment.