feat: adjust play quiz multiplayer
This commit is contained in:
parent
e060f32593
commit
053c7db78c
|
@ -19,7 +19,7 @@ class PlayQuizMultiplayerController extends GetxController {
|
||||||
final Rx<ButtonType> buttonType = ButtonType.disabled.obs;
|
final Rx<ButtonType> buttonType = ButtonType.disabled.obs;
|
||||||
|
|
||||||
final fillInAnswerController = TextEditingController();
|
final fillInAnswerController = TextEditingController();
|
||||||
bool? selectedTOFAns;
|
RxBool isASentAns = false.obs;
|
||||||
|
|
||||||
late final String sessionCode;
|
late final String sessionCode;
|
||||||
late final bool isAdmin;
|
late final bool isAdmin;
|
||||||
|
@ -51,11 +51,15 @@ class PlayQuizMultiplayerController extends GetxController {
|
||||||
_socketService.questionUpdate.listen((data) {
|
_socketService.questionUpdate.listen((data) {
|
||||||
buttonType.value = ButtonType.disabled;
|
buttonType.value = ButtonType.disabled;
|
||||||
fillInAnswerController.clear();
|
fillInAnswerController.clear();
|
||||||
|
isASentAns.value = false;
|
||||||
|
|
||||||
final model = MultiplayerQuestionModel.fromJson(Map<String, dynamic>.from(data));
|
final model = MultiplayerQuestionModel.fromJson(Map<String, dynamic>.from(data));
|
||||||
currentQuestion.value = model;
|
currentQuestion.value = model;
|
||||||
// questions.add(model);
|
fillInAnswerController.clear();
|
||||||
fillInAnswerController.clear(); // reset tiap soal baru
|
});
|
||||||
|
|
||||||
|
_socketService.quizDone.listen((_) {
|
||||||
|
isDone.value = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +91,7 @@ class PlayQuizMultiplayerController extends GetxController {
|
||||||
questionIndex: question.questionIndex,
|
questionIndex: question.questionIndex,
|
||||||
answer: answer,
|
answer: answer,
|
||||||
);
|
);
|
||||||
|
isASentAns.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class PlayQuizMultiplayerView extends GetView<PlayQuizMultiplayerController> {
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: Text(
|
title: Text(
|
||||||
"Soal ${(controller.currentQuestion.value?.questionIndex ?? 0) + 1}/10",
|
"Soal ${(controller.currentQuestion.value?.questionIndex ?? 0)}/10",
|
||||||
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
|
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -27,6 +27,9 @@ class PlayQuizMultiplayerView extends GetView<PlayQuizMultiplayerController> {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (controller.isASentAns.value) {
|
||||||
|
return const Center(child: Text("you already answer, please wait until the duration is done"));
|
||||||
|
}
|
||||||
return _buildQuestionView();
|
return _buildQuestionView();
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -105,7 +108,7 @@ class PlayQuizMultiplayerView extends GetView<PlayQuizMultiplayerController> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTrueFalseButton(String label, bool value) {
|
Widget _buildTrueFalseButton(String label, bool value) {
|
||||||
final isSelected = controller.selectedTOFAns = value;
|
final isSelected = controller.selectedAnswer.value == value.toString();
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
|
@ -152,4 +155,14 @@ class PlayQuizMultiplayerView extends GetView<PlayQuizMultiplayerController> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Widget _buildProgressBar() {
|
||||||
|
// final question = controller.currentQuestion;
|
||||||
|
// return LinearProgressIndicator(
|
||||||
|
// value: controller.timeLeft.value / question.duration,
|
||||||
|
// minHeight: 8,
|
||||||
|
// backgroundColor: Colors.grey[300],
|
||||||
|
// valueColor: const AlwaysStoppedAnimation<Color>(Color(0xFF2563EB)),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue