Skip to content

Commit

Permalink
fix: check participation before registering to a quiz
Browse files Browse the repository at this point in the history
  • Loading branch information
reorr committed Apr 17, 2024
1 parent af59311 commit e117969
Showing 1 changed file with 16 additions and 1 deletion.
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 e117969

Please sign in to comment.