I need to store data on multiple levels:
Test 1 > q1, q2, q3... > question: hello, answer: opt 2, opt 1: a, opt 2: b, opt 3: c, opt 4: d
So in actual terms I have multiples tests where in each test you have multiple questions and where each question has multiple options.
how can I add it to firestore and be able to load each test fast as at the moment it is delayed for long with the below code:
for (var i = 1; i < totalquestions + 1; i++) {
await FirebaseFirestore.instance
.collection("users")
.doc(user!.uid)
.collection('Test $no')
.doc(i.toString())
.set(
Map<String, dynamic>.from(
Provider.of<Question>(context, listen: false)
.question[i]!,
),
);
await FirebaseFirestore.instance
.collection("users")
.doc(user.uid)
.collection('Test $no')
.doc(i.toString())
.update(
{
'yourAns':
Provider.of<Question>(context, listen: false)
.answers[i]!
.values
.first
},
);
}