From f3c29183cc1120e2b005998a4f9606bbabbe1996 Mon Sep 17 00:00:00 2001 From: Muktazam Hasbi Ashidiqi Date: Tue, 16 Apr 2024 16:57:45 +0700 Subject: [PATCH 1/3] fix: scrollable list quiz --- .../pages/quiz_download_page.dart | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart b/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart index 3de6f95..691a645 100644 --- a/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart +++ b/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart @@ -51,7 +51,7 @@ class _QuizDownloadPageState extends State { @override Widget build(BuildContext context) { return BebrasScaffold( - body: Container( + body: SizedBox( height: double.infinity, child: Stack( children: [ @@ -66,10 +66,9 @@ class _QuizDownloadPageState extends State { ), ), child: Column( - crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - margin: EdgeInsets.only( + margin: const EdgeInsets.only( top: 15, ), child: Row( @@ -104,37 +103,40 @@ class _QuizDownloadPageState extends State { bottom: 0, child: Container( padding: const EdgeInsets.symmetric(horizontal: 20), - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( - topLeft: Radius.circular(42.0), - topRight: Radius.circular(42.0), + topLeft: Radius.circular(42), + topRight: Radius.circular(42), ), ), - child: - BlocConsumer( - listener: (context, state) { - if (state is QuizRegistrationSuccess) { - // return PermissionToDownloadQuiz(); // onClickDownload: _downloadQuiz); - } - }, - builder: (context, state) { - if (state is QuizRegistrationLoading) { - return const Center( - child: CircularProgressIndicator(), - ); - } - if (state is QuizRegistrationFailed) { - return buildQuizRegistrationHeader(Text(state.error)); - } - if (state is QuizRegistrationSuccess) { - return buildQuizRegistrationHeader( - state.weeklyQuizzes.isEmpty - ? buildQuizRegistrationEmpty() - : buildQuizRegistrationList(state)); - } - return Container(); - }, + clipBehavior: Clip.antiAlias, + child: SingleChildScrollView( + child: BlocConsumer( + listener: (context, state) { + if (state is QuizRegistrationSuccess) { + // return PermissionToDownloadQuiz(); // onClickDownload: _downloadQuiz); + } + }, + builder: (context, state) { + if (state is QuizRegistrationLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } + if (state is QuizRegistrationFailed) { + return buildQuizRegistrationHeader(Text(state.error)); + } + if (state is QuizRegistrationSuccess) { + return buildQuizRegistrationHeader( + state.weeklyQuizzes.isEmpty + ? buildQuizRegistrationEmpty() + : buildQuizRegistrationList(state)); + } + return Container(); + }, + ), ), ), ), From 609599b906286afd6e1e989b1bd5d35c9e9284fe Mon Sep 17 00:00:00 2001 From: Muktazam Hasbi Ashidiqi Date: Wed, 17 Apr 2024 09:50:13 +0700 Subject: [PATCH 2/3] fix: check participation before registering to a quiz --- app/lib/services/quiz_service.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/lib/services/quiz_service.dart b/app/lib/services/quiz_service.dart index 1f737c0..ee789b0 100644 --- a/app/lib/services/quiz_service.dart +++ b/app/lib/services/quiz_service.dart @@ -40,9 +40,24 @@ class QuizService { Future registerParticipant(String week, String level) async { final levelLowerCase = level.toLowerCase(); final snapshot = await db.collection('configuration').doc(week).get(); + + final checkParticipation = await db + .collection('weekly_quiz_participation') + .where( + 'quiz_id', + isEqualTo: snapshot['id'], + ) + .where( + 'user_uid', + isEqualTo: currentUserUID, + ) + .get(); + if (checkParticipation.docs.isNotEmpty) { + return; + } + final registeredUserSnapshot = await db.collection('registered_user').doc(currentUserUID).get(); - // background task untuk fetch task untuk sesuai minggu dan level // yang akan didaftarkan agar bisa dipakai offline // for (final taskId in snapshot['tasks'][level] as List) { From 0731669d9e66f62363206f3ae803a926f28e0075 Mon Sep 17 00:00:00 2001 From: Muktazam Hasbi Ashidiqi Date: Thu, 18 Apr 2024 14:00:26 +0700 Subject: [PATCH 3/3] fix: change lahitan minggu depan to latihan mingguan --- .../quiz_download/presentation/pages/quiz_download_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart b/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart index 691a645..0b3389a 100644 --- a/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart +++ b/app/lib/features/quiz_download/presentation/pages/quiz_download_page.dart @@ -83,7 +83,7 @@ class _QuizDownloadPageState extends State { Container( alignment: Alignment.center, child: const Text( - 'Latihan Minggu Depan', + 'Latihan Mingguan', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 18,