in frontend/frontend-flutter/lib/main.dart [2914:2962]
void SaveImportedQuestionsToFirestore(
List<List<dynamic>> questionList) async {
int count = 0;
print('Main: SaveImportedQuestionsToFirestore() : START');
print(
'Main: SaveImportedQuestionsToFirestore() : questionList = $questionList');
if (questionList.length > 0) {
try {
//Delete all former questions for that user
var querySnapshot = await db!
.collection("${TextToDocParameter.imported_questions}")
.where("user_id", isEqualTo: TextToDocParameter.userID)
.get();
for (var docSnapshot in querySnapshot.docs) {
db.collection("imported_questions").doc('${docSnapshot.id}').delete();
}
//create new questions to be stored on Firestore
for (int i = 0; i < questionList.length; i++) {
List list = questionList[i];
print('Main: SaveImportedQuestionsToFirestore() : List = $List');
Map<String, dynamic> questionMap = {};
questionMap['user_grouping'] = list[0];
questionMap['scenario'] = list[1];
questionMap['question'] = list[2];
questionMap['user_id'] = TextToDocParameter.userID;
if (list.length == 4)
questionMap['main_question'] = list[3];
else
questionMap['main_question'] = "Y";
questionMap['order'] = count++;
db
.collection("imported_questions")
.doc("question$i")
.set(questionMap);
}
} catch (e) {
print('Main: SaveImportedQuestionsToFirestore() : EXCEPTION : e = $e');
}
}
}