Added the Sequence Number in Question Options and Removed isCorrectOption

merge-requests/135/head
Faiz Hashmi 3 years ago
parent 10ef069a06
commit 7f02dff689

@ -27,7 +27,7 @@
"titleEn": "2",
"titleAr": "2",
"questionId": "b8f10b10-221c-495d-b99b-6a8094892549",
"sequence": 2,
"sequence": 3,
"image": "null",
"isCorrectOption": true
},
@ -36,7 +36,7 @@
"titleEn": "3",
"titleAr": "3",
"questionId": "b8f10b10-221c-495d-b99b-6a8094892549",
"sequence": 3,
"sequence": 2,
"image": "null",
"isCorrectOption": false
},
@ -79,7 +79,7 @@
"titleEn": "Argentina",
"titleAr": "Argentina",
"questionId": "0d60d55f-4067-48f9-9ace-b6309c6a7cf0",
"sequence": 2,
"sequence": 4,
"image": "null",
"isCorrectOption": true
},
@ -97,7 +97,7 @@
"titleEn": "France",
"titleAr": "France",
"questionId": "0d60d55f-4067-48f9-9ace-b6309c6a7cf0",
"sequence": 4,
"sequence": 2,
"image": "null",
"isCorrectOption": false
}

@ -11,16 +11,13 @@ class DemoMarathonRepo {
Future<MarathonDetailModel> getDemoMarathonDetails() async {
String response = await rootBundle.loadString('assets/json/demo_upcoming_marathon');
var json = jsonDecode(response);
logger.i("json in getDemoMarathonDetails: $json");
MarathonDetailModel marathonDetailModel = MarathonDetailModel.fromJson(json);
return marathonDetailModel;
}
Future<QuestionModel> getDemoNextQuestion({required int currentQuestionNumber}) async {
print("currentNumber: $currentQuestionNumber");
String response = await rootBundle.loadString('assets/json/demo_questions_marathon');
List json = jsonDecode(response);
logger.i("json in getDemoNextQuestion: $json");
QuestionModel currentQuestion = QuestionModel.fromJson(json.elementAt(currentQuestionNumber));
return currentQuestion;

@ -4,7 +4,7 @@ class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server
// static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
// static String baseUrl = "https://hmgwebservices.com"; // Live server
// static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

@ -13,6 +13,15 @@ extension CapExtension on String {
String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : "";
}
extension TrimString on String {
String trimString(int minThreshold) {
if (length > minThreshold) {
return "${substring(0, 10)}...${substring(length - 4, length)}";
}
return this;
}
}
extension EmailValidator on String {
Widget get toWidget => Text(this);

@ -51,6 +51,7 @@ class QuestionModel {
json['questionOptions'].forEach((v) {
questionOptions!.add(QuestionOptions.fromJson(v));
});
questionOptions!.sort((QuestionOptions a, QuestionOptions b) => a.sequence!.compareTo(b.sequence!));
}
}

@ -221,19 +221,19 @@ class MarathonProvider extends ChangeNotifier {
getCorrectAnswerAndUpdateAnswerColor();
}
if (totalCurrentQuestionTime == currentGapTime) {
if (totalCurrentQuestionTime - currentGapTime == -2) {
updateCardStatusToAnswer();
scheduleMicrotask(() async {
if (AppState().getIsDemoMarathon || isUserOutOfGame) {
await callNextQuestionApi();
} else {
await callSubmitOptionApi().then((bool value) async {
updateIsUserOutOfGame = !value;
await callNextQuestionApi();
});
}
});
// scheduleMicrotask(() async {
// if (AppState().getIsDemoMarathon || isUserOutOfGame) {
// await callNextQuestionApi();
// } else {
// await callSubmitOptionApi().then((bool value) async {
// updateIsUserOutOfGame = !value;
// await callNextQuestionApi();
// });
// }
// });
if (currentQuestionNumber == (AppState().getIsDemoMarathon ? demoMarathonDetailModel.totalQuestions! : marathonDetailModel.totalQuestions!)) {
isGettingQualifiers = true;
@ -253,7 +253,7 @@ class MarathonProvider extends ChangeNotifier {
return;
} else {
if (totalCurrentQuestionTime != currentGapTime) {
if (totalCurrentQuestionTime - currentGapTime != -2) {
totalCurrentQuestionTime--;
}
}
@ -414,10 +414,31 @@ class MarathonProvider extends ChangeNotifier {
void getCorrectAnswerAndUpdateAnswerColor() {
if (selectedOptionIndex != null) {
if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.correct, selectedOptionIndex!);
} else {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.wrong, selectedOptionIndex!);
scheduleMicrotask(() async {
if (AppState().getIsDemoMarathon) {
if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.correct, selectedOptionIndex!);
} else {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.wrong, selectedOptionIndex!);
}
} else {
await callSubmitOptionApi().then((bool value) async {
updateIsUserOutOfGame = !value;
if (value) {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.correct, selectedOptionIndex!);
} else {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.wrong, selectedOptionIndex!);
}
});
}
});
} else {
if (!AppState().getIsDemoMarathon) {
scheduleMicrotask(() async {
await callSubmitOptionApi().then((bool value) async {
updateIsUserOutOfGame = !value;
});
});
}
}
}
@ -427,7 +448,16 @@ class MarathonProvider extends ChangeNotifier {
return;
}
if (selectedOptionIndex != null) {
scheduleMicrotask(() async {
await callNextQuestionApi();
});
if (selectedOptionIndex == null) {
updateQuestionCardStatus(QuestionCardStatus.skippedAnswer);
updateAnswerStatusesList(QuestionCardStatus.skippedAnswer);
return;
}
if (AppState().getIsDemoMarathon) {
if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) {
updateQuestionCardStatus(QuestionCardStatus.correctAnswer);
updateAnswerStatusesList(QuestionCardStatus.correctAnswer);
@ -435,10 +465,15 @@ class MarathonProvider extends ChangeNotifier {
updateQuestionCardStatus(QuestionCardStatus.wrongAnswer);
updateAnswerStatusesList(QuestionCardStatus.wrongAnswer);
}
} else {
updateQuestionCardStatus(QuestionCardStatus.skippedAnswer);
updateAnswerStatusesList(QuestionCardStatus.skippedAnswer);
return;
}
if (!isUserOutOfGame) {
updateQuestionCardStatus(QuestionCardStatus.correctAnswer);
updateAnswerStatusesList(QuestionCardStatus.correctAnswer);
return;
}
updateQuestionCardStatus(QuestionCardStatus.wrongAnswer);
updateAnswerStatusesList(QuestionCardStatus.wrongAnswer);
}
void resetValues() async {

@ -15,13 +15,13 @@ import 'package:video_player/video_player.dart';
class SponsorVideoScreen extends StatelessWidget {
const SponsorVideoScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
MarathonProvider provider = context.watch<MarathonProvider>();
return WillPopScope(
onWillPop: () {
provider.videoController.dispose();
provider.videoController.pause();
provider.disposeVideoPlayer();
provider.sponsorsSecondsCounter = 0;
provider.totalSponsorVideoSeconds = 0;
provider.timerForSponsorVideo.cancel();
@ -52,11 +52,12 @@ class SponsorVideoScreen extends StatelessWidget {
child: provider.totalSponsorVideoSeconds == 0
? InkWell(
onTap: () {
provider.videoController.dispose();
Navigator.pushReplacementNamed(context, AppRoutes.marathonIntroScreen);
provider.videoController.pause();
provider.disposeVideoPlayer();
provider.sponsorsSecondsCounter = 0;
provider.totalSponsorVideoSeconds = 0;
provider.timerForSponsorVideo.cancel();
Navigator.pushReplacementNamed(context, AppRoutes.marathonIntroScreen);
},
child: const Icon(Icons.close, size: 12),
)
@ -73,11 +74,12 @@ class SponsorVideoScreen extends StatelessWidget {
alignment: Alignment.topLeft,
child: InkWell(
onTap: () {
provider.videoController.dispose();
Navigator.pushReplacementNamed(context, AppRoutes.marathonIntroScreen);
provider.videoController.pause();
provider.disposeVideoPlayer();
provider.sponsorsSecondsCounter = 0;
provider.totalSponsorVideoSeconds = 0;
provider.timerForSponsorVideo.cancel();
Navigator.pushReplacementNamed(context, AppRoutes.marathonIntroScreen);
},
child: Container(
decoration: BoxDecoration(color: MyColors.white, borderRadius: BorderRadius.circular(15)),

@ -201,6 +201,7 @@ class CountdownTimerForDetailScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CountdownTimer(
// endTime: dummyTime,
endTime: timeToMarathon,
onEnd: null,
widgetBuilder: (BuildContext context, CurrentRemainingTime? time) {

@ -11,6 +11,7 @@ import 'package:mohem_flutter_app/classes/decorations_helper.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/main.dart';
@ -428,14 +429,17 @@ class MarathonBanner extends StatelessWidget {
letterSpacing: -0.4,
),
),
Text(
AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "",
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: isTablet ? 30 : 19,
fontWeight: FontWeight.bold,
color: MyColors.white.withOpacity(0.83),
height: 32 / 22,
Flexible(
child: Text(
(AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "").trimString(15),
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: isTablet ? 30 : 19,
fontWeight: FontWeight.bold,
color: MyColors.white.withOpacity(0.83),
height: 32 / 22,
),
),
),
isTablet ? 10.height : 3.height,

@ -53,14 +53,24 @@ class MarathonDetailsCard extends StatelessWidget {
? Row(
children: <Widget>[
"${LocaleKeys.prize.tr()} ".toText16(color: MyColors.grey77Color, isBold: true),
Row(
children: marathonDetailModel.sponsors!.first.sponsorPrizes!
.map(
(SponsorPrizes prizes) =>
"${AppState().isArabic(context) ? prizes.marathonPrizeAr : prizes.marathonPrizeAr}".toText16(color: MyColors.greenColor, isBold: true).paddingOnly(right: 5),
)
.toList(),
),
Expanded(
child: SizedBox(
height: 30,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: marathonDetailModel.sponsors!.first.sponsorPrizes!.length,
itemBuilder: (BuildContext context, int index) {
SponsorPrizes prizes = marathonDetailModel.sponsors!.first.sponsorPrizes![index];
return Container(
decoration: BoxDecoration(color: MyColors.backgroundColor, borderRadius: BorderRadius.circular(100), border: Border.all(color: MyColors.grey57Color.withOpacity(0.1))),
child: "${AppState().isArabic(context) ? prizes.marathonPrizeAr : prizes.marathonPrizeEn}"
.toText16(color: MyColors.greenColor, isBold: true)
.paddingOnly(left: 5, right: 5),
).paddingOnly(left: 5);
}),
),
)
],
)
: const SizedBox(),

@ -57,7 +57,7 @@ class MarathonProgressContainer extends StatelessWidget {
? getDemoMarathonerText()
: "${provider.totalMarathoners} ${provider.totalMarathoners == 1 ? LocaleKeys.marathoner.tr() : LocaleKeys.marathoners.tr()}".toText14(),
provider.questionCardStatus == QuestionCardStatus.question
? "00:${(provider.totalCurrentQuestionTime - provider.currentGapTime) < 10 ? "0${provider.totalCurrentQuestionTime - provider.currentGapTime}" : provider.totalCurrentQuestionTime - provider.currentGapTime}"
? "00:${provider.totalCurrentQuestionTime - provider.currentGapTime < 0 ? "00" : (provider.totalCurrentQuestionTime - provider.currentGapTime) < 10 ? "0${provider.totalCurrentQuestionTime - provider.currentGapTime}" : provider.totalCurrentQuestionTime - provider.currentGapTime}"
.toText18(color: provider.totalCurrentQuestionTime - provider.currentGapTime < 5 ? MyColors.redColor : MyColors.black)
: const SizedBox(),
],

Loading…
Cancel
Save