Line data Source code
1 : import 'package:amadeus_proto/api/routes/exercises.dart';
2 : import 'package:amadeus_proto/exercises/providers/single_choice_provider.dart';
3 :
4 : class NoteFinderProvider extends SingleChoiceProvider {
5 : String _questionImage = "";
6 0 : String get questionImage => _questionImage;
7 0 : set questionImage(String value) {
8 0 : _questionImage = value;
9 0 : notifyListeners();
10 : }
11 :
12 : String _audioPath = "";
13 0 : String get audioPath => _audioPath;
14 0 : set audioPath(String value) {
15 0 : _audioPath = value;
16 0 : notifyListeners();
17 : }
18 :
19 : /// Returns `true` if the all the answers is correct or when [lives] fall to 0
20 0 : @override
21 : bool checkEndGame() {
22 0 : if (exerciseInfo != null && answerQueue.isEmpty) {
23 0 : apiBase.completeExercise(exerciseInfo!.id);
24 : }
25 0 : return (lives == 0 || answerQueue.isEmpty);
26 : }
27 :
28 0 : @override
29 : void initializeData(dynamic data) {
30 0 : final List<String> choicesData = data["choices"].cast<String>();
31 0 : final List<int> indices = List.generate(choicesData.length, (i) => i);
32 :
33 0 : indices.shuffle();
34 0 : answerQueue.addAll(indices);
35 :
36 0 : questions = data["audioPaths"].cast<String>();
37 0 : choices = indices.map((i) => choicesData[i]).toSet().toList();
38 0 : questions = indices.map((i) => questions[i]).toSet().toList();
39 :
40 0 : lives = data["lives"];
41 0 : question = data["question"];
42 0 : answer = answerQueue.first;
43 0 : questionImage = data["questionImage"];
44 0 : isInitialized = true;
45 : }
46 :
47 : // @override
48 : // void reset() {
49 : // isReset = false;
50 : // isInitialized = false;
51 : // lives = 3;
52 : // answer = 0;
53 : // displayDialog = false;
54 : // selectedAnswer = null;
55 : // nextQuestion = false;
56 : // progress = 0;
57 : // correctAnswer = null;
58 : // answerQueue.clear();
59 : // }
60 : }
|