39 lines
978 B
Dart
39 lines
978 B
Dart
|
|
import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
|
||
|
|
import 'package:mnemo_cards_backend/tests/test_model.dart';
|
||
|
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||
|
|
|
||
|
|
extension TestModelExtension on TestModel {
|
||
|
|
TestDto toDto({
|
||
|
|
List<AbstractTestQuestion>? questions,
|
||
|
|
TestStatisticsDto? statistics,
|
||
|
|
}) {
|
||
|
|
final dtoQuestions =
|
||
|
|
questions ?? this.questions.map((e) => e.toQuestionTestBody()).toList();
|
||
|
|
return TestDto(
|
||
|
|
id: id.toString(),
|
||
|
|
questions: dtoQuestions,
|
||
|
|
name: name,
|
||
|
|
color: color,
|
||
|
|
cover: cover,
|
||
|
|
version: version,
|
||
|
|
time: time,
|
||
|
|
timeSubtitle: timeSubtitle,
|
||
|
|
statistics: statistics,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
extension TestDtoExtension on TestDto {
|
||
|
|
TestModel toEmptyModel() {
|
||
|
|
return TestModel(
|
||
|
|
id: int.tryParse(id ?? ''),
|
||
|
|
name: name,
|
||
|
|
color: color,
|
||
|
|
cover: cover,
|
||
|
|
version: version,
|
||
|
|
time: time,
|
||
|
|
timeSubtitle: timeSubtitle,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|