|
|
|
|
@ -31,6 +31,11 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
String? selectedOptionId;
|
|
|
|
|
int? totalQualifiers;
|
|
|
|
|
|
|
|
|
|
//TODO: THIS BUG NEEDS TO BE FIXED. NOT DONE YET
|
|
|
|
|
String? gapTimeImage;
|
|
|
|
|
String? gapTimeText;
|
|
|
|
|
int? gapTimeType;
|
|
|
|
|
|
|
|
|
|
bool iAmWinner = false;
|
|
|
|
|
bool isPrivilegedWithMarathon = false;
|
|
|
|
|
|
|
|
|
|
@ -178,16 +183,21 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
updateCardStatusToAnswer();
|
|
|
|
|
|
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
|
await callSubmitOptionApi().then((bool value) async {
|
|
|
|
|
if (value) {
|
|
|
|
|
await callNextQuestionApi();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totalCurrentQuestionTime == 0) {
|
|
|
|
|
gapTimeImage = currentQuestion.gapImage;
|
|
|
|
|
gapTimeText = currentQuestion.gapText;
|
|
|
|
|
gapTimeType = currentQuestion.gapType;
|
|
|
|
|
updateCardData();
|
|
|
|
|
if (currentQuestionNumber == marathonDetailModel.totalQuestions!) {
|
|
|
|
|
if (currentQuestionNumber - 1 == marathonDetailModel.totalQuestions!) {
|
|
|
|
|
callGetQualifiersApi();
|
|
|
|
|
updateQuestionCardStatus(QuestionCardStatus.findingWinner);
|
|
|
|
|
timer.cancel();
|
|
|
|
|
@ -242,7 +252,6 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
selectedWinners = await MarathonApiClient().getSelectedWinner(marathonId: marathonDetailModel.id!);
|
|
|
|
|
if (selectedWinners != null) {
|
|
|
|
|
selectedWinners!.removeWhere((WinnerModel element) {
|
|
|
|
|
print("matching : ${AppState().memberInformationList!.eMPLOYEENUMBER} with ${element.employeeId}");
|
|
|
|
|
if (element.employeeId == AppState().memberInformationList!.eMPLOYEENUMBER) {
|
|
|
|
|
iAmWinner = true;
|
|
|
|
|
return true;
|
|
|
|
|
@ -251,18 +260,18 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
print("selectedWinners Length : ${selectedWinners!.length}");
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: here I need to add a logic where I should call this function for Api but for the 1st question it should behave differently
|
|
|
|
|
// TODO: Verify the callings!!!
|
|
|
|
|
Future<void> callNextQuestionApi() async {
|
|
|
|
|
if (currentQuestionNumber < marathonDetailModel.totalQuestions!) {
|
|
|
|
|
if (currentQuestionNumber == 0) {
|
|
|
|
|
Utils.showLoading(AppRoutes.navigatorKey.currentContext!);
|
|
|
|
|
currentQuestion = (await MarathonApiClient().getNextQuestion(questionId: null, marathonId: marathonDetailModel.id!))!;
|
|
|
|
|
gapTimeImage = currentQuestion.gapImage;
|
|
|
|
|
gapTimeText = currentQuestion.gapText;
|
|
|
|
|
gapTimeType = currentQuestion.gapType;
|
|
|
|
|
if (Utils.isLoading) {
|
|
|
|
|
Utils.hideLoading(AppRoutes.navigatorKey.currentContext!);
|
|
|
|
|
}
|
|
|
|
|
@ -283,6 +292,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
selectedOptionIndex = null;
|
|
|
|
|
currentQuestionNumber++;
|
|
|
|
|
|
|
|
|
|
cardContentList.add(const CardContent());
|
|
|
|
|
totalCurrentQuestionTime = currentQuestion.questionTime! + currentQuestion.nextQuestGap!;
|
|
|
|
|
currentGapTime = currentQuestion.nextQuestGap!;
|
|
|
|
|
@ -293,7 +303,7 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
void populateQuestionStatusesList() {
|
|
|
|
|
if (marathonDetailModel.totalQuestions != null) {
|
|
|
|
|
for (int i = 0; i < marathonDetailModel.totalQuestions! - 1; i++) {
|
|
|
|
|
for (int i = 0; i < marathonDetailModel.totalQuestions!; i++) {
|
|
|
|
|
answerStatusesList.add(QuestionCardStatus.question);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -422,9 +432,6 @@ class MarathonProvider extends ChangeNotifier {
|
|
|
|
|
Navigator.pushReplacementNamed(context, AppRoutes.marathonWaitingScreen);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
print("error in onJoinMarathonPressed: ${e.toString()}");
|
|
|
|
|
}
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.confirmDialog(context, e.toString());
|
|
|
|
|
}
|
|
|
|
|
|