Remove redundant code
This commit is contained in:
@@ -410,72 +410,6 @@ exports.createProgressWithIncorrect = functions.https.onCall((data, context) =>
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Processes a response to a question in a vocab set.
|
||||
* @param {string} progressId The ID of the progress file to retrieve the prompt from.
|
||||
* @return {string} item The term/definition prompt for the next question.
|
||||
* @return {string} sound The file ID for the next question's sound file. Null if language is switched.
|
||||
*//*
|
||||
exports.getPrompt = functions.https.onCall((data, context) => {
|
||||
// const uid = context.auth.uid;
|
||||
const uid = "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3";
|
||||
|
||||
const progressId = data;
|
||||
|
||||
const progressDocId = db
|
||||
.collection("progress").doc(progressId);
|
||||
|
||||
return db.runTransaction((transaction) => {
|
||||
return transaction.get(progressDocId).then((progressDoc) => {
|
||||
if (uid !== progressDoc.data().uid) {
|
||||
throw new functions.https.HttpsError("permission-denied", "Wrong user's progress");
|
||||
} else if (progressDoc.data().progress >= progressDoc.data().questions.length) {
|
||||
throw new functions.https.HttpsError("permission-denied", "Progress already completed")
|
||||
} else {
|
||||
nextIndex = progressDoc.data().progress;
|
||||
nextVocabId = progressDoc.data().questions[nextIndex];
|
||||
|
||||
if (progressDoc.data().switch_language) {
|
||||
const promptDocId = progressDocId
|
||||
.collection("definitions").doc(nextVocabId);
|
||||
const sound = null;
|
||||
|
||||
return transaction.get(promptDocId).then((promptDoc) => {
|
||||
return {
|
||||
item: promptDoc.data().item,
|
||||
sound: sound,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const promptDocId = progressDocId
|
||||
.collection("terms").doc(nextVocabId);
|
||||
|
||||
return transaction.get(promptDocId).then((promptDoc) => {
|
||||
const sound = promptDoc.data().sound;
|
||||
return {
|
||||
item: promptDoc.data().item,
|
||||
sound: sound,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});*/
|
||||
|
||||
/**
|
||||
* Checks whether two arrays have the same members.
|
||||
* @param {array} arr1 The first array to compare.
|
||||
* @param {array} arr2 The second array to compare.
|
||||
* @return {boolean} Whether or not the two arrays have the same members.
|
||||
*/
|
||||
function arraysHaveSameMembers(arr1, arr2) {
|
||||
const set1 = new Set(arr1);
|
||||
const set2 = new Set(arr2);
|
||||
return arr1.every(item => set2.has(item)) &&
|
||||
arr2.every(item => set1.has(item));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes characters from terms & definitions that should be ignored.
|
||||
* @param {string} item The term/definition to remove the characters that should be ignored from.
|
||||
|
||||
Reference in New Issue
Block a user