develop #1
|
@ -19,7 +19,7 @@ class PlayQuizMultiplayerController extends GetxController {
|
|||
final Rx<ButtonType> buttonType = ButtonType.disabled.obs;
|
||||
|
||||
final fillInAnswerController = TextEditingController();
|
||||
bool? selectedTOFAns;
|
||||
RxBool isASentAns = false.obs;
|
||||
|
||||
late final String sessionCode;
|
||||
late final bool isAdmin;
|
||||
|
@ -51,11 +51,15 @@ class PlayQuizMultiplayerController extends GetxController {
|
|||
_socketService.questionUpdate.listen((data) {
|
||||
buttonType.value = ButtonType.disabled;
|
||||
fillInAnswerController.clear();
|
||||
isASentAns.value = false;
|
||||
|
||||
final model = MultiplayerQuestionModel.fromJson(Map<String, dynamic>.from(data));
|
||||
currentQuestion.value = model;
|
||||
// questions.add(model);
|
||||
fillInAnswerController.clear(); // reset tiap soal baru
|
||||
fillInAnswerController.clear();
|
||||
});
|
||||
|
||||
_socketService.quizDone.listen((_) {
|
||||
isDone.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -87,6 +91,7 @@ class PlayQuizMultiplayerController extends GetxController {
|
|||
questionIndex: question.questionIndex,
|
||||
answer: answer,
|
||||
);
|
||||
isASentAns.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class PlayQuizMultiplayerView extends GetView<PlayQuizMultiplayerController> {
|
|||
elevation: 0,
|
||||
centerTitle: true,
|
||||
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),
|
||||
),
|
||||
),
|
||||
|
@ -27,6 +27,9 @@ class PlayQuizMultiplayerView extends GetView<PlayQuizMultiplayerController> {
|
|||
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();
|
||||
}),
|
||||
);
|
||||
|
@ -105,7 +108,7 @@ class PlayQuizMultiplayerView extends GetView<PlayQuizMultiplayerController> {
|
|||
}
|
||||
|
||||
Widget _buildTrueFalseButton(String label, bool value) {
|
||||
final isSelected = controller.selectedTOFAns = value;
|
||||
final isSelected = controller.selectedAnswer.value == value.toString();
|
||||
|
||||
return Container(
|
||||
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