Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/quiz list #173

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading