diff --git a/lib/pages/practice/PracticeDatabase.dart b/lib/pages/practice/PracticeDatabase.dart index a56b8ec..164912d 100644 --- a/lib/pages/practice/PracticeDatabase.dart +++ b/lib/pages/practice/PracticeDatabase.dart @@ -71,7 +71,20 @@ class PracticeDatabase { static Future> getStats() async { var db = await getDatabase(); - List> answers = await db.rawQuery('''SELECT * FROM AnswersView;'''); + List> answers = await db.rawQuery(''' + SELECT + type, + SUM(correct = 1) AS correct, + SUM(correct = 0) AS incorrect, + ( + (SUM(correct = 1)*1.0) / + (SUM(correct = 0) + SUM(correct = 1)) + ) as ratio + FROM + AnswersView + GROUP BY + type; + '''); print(answers); var first = answers.first; print(first["practice_id"]);