diff --git a/packages/core/lib/data/models/question_dto.dart b/packages/core/lib/data/models/question_dto.dart index d84ede1b7..3ee37b0ac 100644 --- a/packages/core/lib/data/models/question_dto.dart +++ b/packages/core/lib/data/models/question_dto.dart @@ -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: diff --git a/packages/core/test/data/models/question_dto_test.dart b/packages/core/test/data/models/question_dto_test.dart index f227735ef..f174419c7 100644 --- a/packages/core/test/data/models/question_dto_test.dart +++ b/packages/core/test/data/models/question_dto_test.dart @@ -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', () { diff --git a/packages/exams/lib/providers/custom_exam_courses_provider.dart b/packages/exams/lib/providers/custom_exam_courses_provider.dart index fb124fed9..de17baef8 100644 --- a/packages/exams/lib/providers/custom_exam_courses_provider.dart +++ b/packages/exams/lib/providers/custom_exam_courses_provider.dart @@ -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'; @@ -8,6 +9,12 @@ part 'custom_exam_courses_provider.g.dart'; class CustomExamCourses extends _$CustomExamCourses { @override FutureOr> 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 diff --git a/packages/exams/lib/providers/custom_exam_courses_provider.g.dart b/packages/exams/lib/providers/custom_exam_courses_provider.g.dart index 61334c43f..ad6ea6fd9 100644 --- a/packages/exams/lib/providers/custom_exam_courses_provider.g.dart +++ b/packages/exams/lib/providers/custom_exam_courses_provider.g.dart @@ -6,7 +6,7 @@ part of 'custom_exam_courses_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$customExamCoursesHash() => r'78f98f9280dde682376bc98faf87079f22e4d493'; +String _$customExamCoursesHash() => r'd427e1dffa61913929a124719db640ff7138e9ff'; /// See also [CustomExamCourses]. @ProviderFor(CustomExamCourses)