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

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

@ -4,7 +4,7 @@ class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server //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://erptstapp.srca.org.sa"; // SRCA server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT 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 = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; 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(" ") : ""; 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 { extension EmailValidator on String {
Widget get toWidget => Text(this); Widget get toWidget => Text(this);

@ -51,6 +51,7 @@ class QuestionModel {
json['questionOptions'].forEach((v) { json['questionOptions'].forEach((v) {
questionOptions!.add(QuestionOptions.fromJson(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(); getCorrectAnswerAndUpdateAnswerColor();
} }
if (totalCurrentQuestionTime == currentGapTime) { if (totalCurrentQuestionTime - currentGapTime == -2) {
updateCardStatusToAnswer(); updateCardStatusToAnswer();
scheduleMicrotask(() async { // scheduleMicrotask(() async {
if (AppState().getIsDemoMarathon || isUserOutOfGame) { // if (AppState().getIsDemoMarathon || isUserOutOfGame) {
await callNextQuestionApi(); // await callNextQuestionApi();
} else { // } else {
await callSubmitOptionApi().then((bool value) async { // await callSubmitOptionApi().then((bool value) async {
updateIsUserOutOfGame = !value; // updateIsUserOutOfGame = !value;
await callNextQuestionApi(); // await callNextQuestionApi();
}); // });
} // }
}); // });
if (currentQuestionNumber == (AppState().getIsDemoMarathon ? demoMarathonDetailModel.totalQuestions! : marathonDetailModel.totalQuestions!)) { if (currentQuestionNumber == (AppState().getIsDemoMarathon ? demoMarathonDetailModel.totalQuestions! : marathonDetailModel.totalQuestions!)) {
isGettingQualifiers = true; isGettingQualifiers = true;
@ -253,7 +253,7 @@ class MarathonProvider extends ChangeNotifier {
return; return;
} else { } else {
if (totalCurrentQuestionTime != currentGapTime) { if (totalCurrentQuestionTime - currentGapTime != -2) {
totalCurrentQuestionTime--; totalCurrentQuestionTime--;
} }
} }
@ -414,10 +414,31 @@ class MarathonProvider extends ChangeNotifier {
void getCorrectAnswerAndUpdateAnswerColor() { void getCorrectAnswerAndUpdateAnswerColor() {
if (selectedOptionIndex != null) { if (selectedOptionIndex != null) {
if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) { scheduleMicrotask(() async {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.correct, selectedOptionIndex!); if (AppState().getIsDemoMarathon) {
} else { if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) {
updateCurrentQuestionOptionStatus(QuestionsOptionStatus.wrong, selectedOptionIndex!); 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; 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!) { if (currentQuestion.questionOptions![selectedOptionIndex!].isCorrectOption!) {
updateQuestionCardStatus(QuestionCardStatus.correctAnswer); updateQuestionCardStatus(QuestionCardStatus.correctAnswer);
updateAnswerStatusesList(QuestionCardStatus.correctAnswer); updateAnswerStatusesList(QuestionCardStatus.correctAnswer);
@ -435,10 +465,15 @@ class MarathonProvider extends ChangeNotifier {
updateQuestionCardStatus(QuestionCardStatus.wrongAnswer); updateQuestionCardStatus(QuestionCardStatus.wrongAnswer);
updateAnswerStatusesList(QuestionCardStatus.wrongAnswer); updateAnswerStatusesList(QuestionCardStatus.wrongAnswer);
} }
} else { return;
updateQuestionCardStatus(QuestionCardStatus.skippedAnswer); }
updateAnswerStatusesList(QuestionCardStatus.skippedAnswer); if (!isUserOutOfGame) {
updateQuestionCardStatus(QuestionCardStatus.correctAnswer);
updateAnswerStatusesList(QuestionCardStatus.correctAnswer);
return;
} }
updateQuestionCardStatus(QuestionCardStatus.wrongAnswer);
updateAnswerStatusesList(QuestionCardStatus.wrongAnswer);
} }
void resetValues() async { void resetValues() async {

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

@ -201,6 +201,7 @@ class CountdownTimerForDetailScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CountdownTimer( return CountdownTimer(
// endTime: dummyTime,
endTime: timeToMarathon, endTime: timeToMarathon,
onEnd: null, onEnd: null,
widgetBuilder: (BuildContext context, CurrentRemainingTime? time) { 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/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.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/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/main.dart';
@ -428,14 +429,17 @@ class MarathonBanner extends StatelessWidget {
letterSpacing: -0.4, letterSpacing: -0.4,
), ),
), ),
Text( Flexible(
AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "", child: Text(
style: TextStyle( (AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "").trimString(15),
fontStyle: FontStyle.italic, overflow: TextOverflow.ellipsis,
fontSize: isTablet ? 30 : 19, style: TextStyle(
fontWeight: FontWeight.bold, fontStyle: FontStyle.italic,
color: MyColors.white.withOpacity(0.83), fontSize: isTablet ? 30 : 19,
height: 32 / 22, fontWeight: FontWeight.bold,
color: MyColors.white.withOpacity(0.83),
height: 32 / 22,
),
), ),
), ),
isTablet ? 10.height : 3.height, isTablet ? 10.height : 3.height,

@ -53,14 +53,24 @@ class MarathonDetailsCard extends StatelessWidget {
? Row( ? Row(
children: <Widget>[ children: <Widget>[
"${LocaleKeys.prize.tr()} ".toText16(color: MyColors.grey77Color, isBold: true), "${LocaleKeys.prize.tr()} ".toText16(color: MyColors.grey77Color, isBold: true),
Row( Expanded(
children: marathonDetailModel.sponsors!.first.sponsorPrizes! child: SizedBox(
.map( height: 30,
(SponsorPrizes prizes) => child: ListView.builder(
"${AppState().isArabic(context) ? prizes.marathonPrizeAr : prizes.marathonPrizeAr}".toText16(color: MyColors.greenColor, isBold: true).paddingOnly(right: 5), scrollDirection: Axis.horizontal,
) shrinkWrap: true,
.toList(), 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(), : const SizedBox(),

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

Loading…
Cancel
Save