28 lines
855 B
Dart
28 lines
855 B
Dart
|
|
import 'dart:convert';
|
||
|
|
|
||
|
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||
|
|
import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
|
||
|
|
|
||
|
|
extension TestModelExtension on TestQuestionModel {
|
||
|
|
AbstractTestQuestion toQuestionTestBody() {
|
||
|
|
final json = jsonDecode(body);
|
||
|
|
switch (questionType) {
|
||
|
|
case TestQuestionType.simple:
|
||
|
|
return SimpleTestQuestionBody.fromJson(json)..id = id;
|
||
|
|
case TestQuestionType.input_buttons:
|
||
|
|
return InputButtonsTestQuestionBody.fromJson(json)..id = id;
|
||
|
|
case TestQuestionType.matrix:
|
||
|
|
throw UnimplementedError();
|
||
|
|
case TestQuestionType.match:
|
||
|
|
throw UnimplementedError();
|
||
|
|
case TestQuestionType.undefined:
|
||
|
|
throw UnimplementedError();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// TestQuestionBody(
|
||
|
|
// questionType: questionType,
|
||
|
|
// id: id,
|
||
|
|
// body: body,
|
||
|
|
// );
|
||
|
|
}
|