From 4bb3c8e4c9b40da615d2621cb200daa022eda996 Mon Sep 17 00:00:00 2001 From: Mirza Widihananta Date: Sat, 11 Nov 2023 07:13:02 +0700 Subject: [PATCH 1/3] fix: able to read double value in duration_minute --- .../presentation/bloc/quiz_exercise_cubit.dart | 2 +- app/lib/models/weekly_quiz.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart b/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart index c88e777..b288e88 100644 --- a/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart +++ b/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart @@ -85,7 +85,7 @@ class QuizExerciseCubit extends Cubit { if (duration == null) { throw Exception('Duration for selected Challenge Group not found'); } - remainingDuration = duration * 60; + remainingDuration = (duration * 60.0).toInt(); timer = Timer.periodic(const Duration(seconds: 1), (timer) { if (state is! QuizExerciseShow) { timer.cancel(); diff --git a/app/lib/models/weekly_quiz.dart b/app/lib/models/weekly_quiz.dart index 81aba14..0f69f98 100644 --- a/app/lib/models/weekly_quiz.dart +++ b/app/lib/models/weekly_quiz.dart @@ -5,7 +5,7 @@ class WeeklyQuiz extends Equatable { final String id; final String title; final String created_at; - final Map duration_minute; + final Map duration_minute; final String end_at; final Map max_attempts; final Map> problems; @@ -32,8 +32,8 @@ class WeeklyQuiz extends Equatable { id: id, title: json['title'] as String, created_at: json['created_at'] as String, - duration_minute: (json['duration_minute'] as Map) - .map((key, value) => MapEntry(key, value as int)), + duration_minute: (json['duration_minute'] as Map).map( + (key, value) => MapEntry(key, (value as num?)?.toDouble() ?? -1.0)), end_at: json['end_at'] as String, max_attempts: (json['max_attempts'] as Map) .map((key, value) => MapEntry(key, value as int)), From ef7fd46f51830356079a550b585d14a34c4b4394 Mon Sep 17 00:00:00 2001 From: Mirza Widihananta Date: Sat, 11 Nov 2023 07:15:37 +0700 Subject: [PATCH 2/3] fix: count blank as incorrect in result page --- .../quiz_result/presentation/pages/quiz_result_page.dart | 2 +- .../features/quiz_start/presentation/pages/quiz_start_page.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lib/features/quiz_result/presentation/pages/quiz_result_page.dart b/app/lib/features/quiz_result/presentation/pages/quiz_result_page.dart index c327c89..06640c6 100644 --- a/app/lib/features/quiz_result/presentation/pages/quiz_result_page.dart +++ b/app/lib/features/quiz_result/presentation/pages/quiz_result_page.dart @@ -56,7 +56,7 @@ class _QuizResultPageState extends State { children: [ Text('Total Nilai: ${state.attempt.score}'), Text( - 'benar: ${state.attempt.totalCorrect}, salah: ${state.attempt.totalIncorrect}'), + 'benar: ${state.attempt.totalCorrect}, salah: ${state.attempt.totalIncorrect + state.attempt.totalBlank}'), const Text('MANTAP!!!') ], ), diff --git a/app/lib/features/quiz_start/presentation/pages/quiz_start_page.dart b/app/lib/features/quiz_start/presentation/pages/quiz_start_page.dart index f88ac31..22aebdf 100644 --- a/app/lib/features/quiz_start/presentation/pages/quiz_start_page.dart +++ b/app/lib/features/quiz_start/presentation/pages/quiz_start_page.dart @@ -74,7 +74,7 @@ class _QuizStartPageState extends State { Text( 'Alokasi waktu: ${state.quiz.duration_minute[state.participation.challenge_group]} menit'), Text( - 'Sisa coba lagi ${state.participation.quiz_max_attempts - state.participation.attempts.length} / ${state.participation.quiz_max_attempts}'), + 'Sisa coba lagi: ${state.participation.quiz_max_attempts - state.participation.attempts.length} dari ${state.participation.quiz_max_attempts} kesempatan'), const SizedBox( height: 10, ), From 348fd2268e698db867b54bca7efd51384ba9225a Mon Sep 17 00:00:00 2001 From: Mirza Widihananta Date: Sat, 11 Nov 2023 07:24:46 +0700 Subject: [PATCH 3/3] fix: lower case correct_answers before comparison --- .../quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart b/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart index b288e88..478c306 100644 --- a/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart +++ b/app/lib/features/quiz_exercise/presentation/bloc/quiz_exercise_cubit.dart @@ -176,6 +176,7 @@ class QuizExerciseCubit extends Cubit { if (currentProblem.type == 'SHORT_ANSWER' && currentProblem.answer.correctAnswer + .map((answer) => answer.toLowerCase()) .contains(shortAnswer.trim().toLowerCase())) { verdict = 'CORRECT'; }