Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/core/lib/data/models/question_dto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ class QuestionDto {
'S' => 'shortAnswer',
'N' => 'numerical',
'E' => 'essay',
final String t when t.contains('Numerical') || t.contains('NAT') =>
'numerical',
final String t
when t.contains('Multiple Choice') || t.contains('MCQ') =>
'singleSelect',
final String t
when t.contains('Multiple Select') || t.contains('MSQ') =>
'multipleSelect',
_ => 'singleSelect',
},
subject:
Expand Down
20 changes: 20 additions & 0 deletions packages/core/test/data/models/question_dto_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ void main() {
);
},
);

test('parses verbose string types correctly', () {
final natQuestion = QuestionDto.fromJson({
'id': '1',
'type': 'NAT, Numerical Answer Type',
});
expect(natQuestion.type, 'numerical');

final mcqQuestion = QuestionDto.fromJson({
'id': '2',
'type': 'MCQ, Multiple Choice Type',
});
expect(mcqQuestion.type, 'singleSelect');

final msqQuestion = QuestionDto.fromJson({
'id': '3',
'type': 'MSQ, Multiple Select Type',
});
expect(msqQuestion.type, 'multipleSelect');
});
});

group('AnswerDto', () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'package:core/data/data.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../repositories/custom_exam_repository.dart';
Expand All @@ -8,6 +9,12 @@ part 'custom_exam_courses_provider.g.dart';
class CustomExamCourses extends _$CustomExamCourses {
@override
FutureOr<List<CourseDto>> build() async {
final link = ref.keepAlive();
final timer = Timer(const Duration(minutes: 5), () {
link.close();
});
ref.onDispose(() => timer.cancel());

final repository = ref.watch(customExamRepositoryProvider);

// Fetch courses with allow_custom_test=true
Expand Down

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