From e3faf41b83084e5647775a45a819ce912906217a Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Tue, 10 Nov 2020 17:45:32 +0100 Subject: [PATCH] Working percentage correct stats coming from the sqlite database, now to display them (and test the whole thing...) --- lib/pages/practice/PracticeDatabase.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/pages/practice/PracticeDatabase.dart b/lib/pages/practice/PracticeDatabase.dart index ef33531..f156d0b 100644 --- a/lib/pages/practice/PracticeDatabase.dart +++ b/lib/pages/practice/PracticeDatabase.dart @@ -135,7 +135,7 @@ class PracticeDatabase { correct, incorrect, total, - correct / total AS ratio + (correct / total) * 100 AS ratio FROM AnswersCorrectByTypeViewAll UNION ALL @@ -145,7 +145,7 @@ class PracticeDatabase { correct, incorrect, total, - correct / total AS ratio + (correct / total) * 100 AS ratio FROM AnswersCorrectByTypeView7d UNION ALL @@ -155,21 +155,25 @@ class PracticeDatabase { correct, incorrect, total, - correct / total AS ratio + (correct / total) * 100 AS ratio FROM AnswersCorrectByTypeView30d; '''); print(answers); var stats = getEmtpyStats(); - + for(var stat in answers){ + var typeRange = "${stat['range']} ${stat['type']}"; + stats[typeRange] = (stat['ratio'] as double).roundToDouble(); + } print(stats); } - static Map getEmtpyStats(){ - Map emptyStats = Map(); + static Map getEmtpyStats(){ + Map emptyStats = Map(); ["All", "30d", "7d"].forEach((range) => { PracticeType.values.forEach((type) { - emptyStats["$range ${type.toString().split(".").last}"] = 0; + var typeRange = "$range ${type.toString().split(".").last}"; + emptyStats[typeRange] = 0; }) }); return emptyStats;