Skip to content

Commit

Permalink
Merge pull request #173 from ia-toki/fix/quiz-list
Browse files Browse the repository at this point in the history
Fix/quiz list
  • Loading branch information
gmochid authored Apr 22, 2024
2 parents 91249c0 + 0731669 commit ae6839d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class _QuizDownloadPageState extends State<QuizDownloadPage> {
@override
Widget build(BuildContext context) {
return BebrasScaffold(
body: Container(
body: SizedBox(
height: double.infinity,
child: Stack(
children: [
Expand All @@ -66,10 +66,9 @@ class _QuizDownloadPageState extends State<QuizDownloadPage> {
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(
margin: const EdgeInsets.only(
top: 15,
),
child: Row(
Expand All @@ -84,7 +83,7 @@ class _QuizDownloadPageState extends State<QuizDownloadPage> {
Container(
alignment: Alignment.center,
child: const Text(
'Latihan Minggu Depan',
'Latihan Mingguan',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18,
Expand All @@ -104,37 +103,40 @@ class _QuizDownloadPageState extends State<QuizDownloadPage> {
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<QuizRegistrationCubit, QuizRegistrationState>(
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<QuizRegistrationCubit,
QuizRegistrationState>(
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();
},
),
),
),
),
Expand Down
17 changes: 16 additions & 1 deletion app/lib/services/quiz_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,24 @@ class QuizService {
Future<void> 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<dynamic>) {
Expand Down

0 comments on commit ae6839d

Please sign in to comment.