-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2540591
commit 8f891db
Showing
13 changed files
with
106 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const achievements = require("../data/achievements"); | ||
const getSpecificAchievement = require("../data/getSpecificAchievement"); | ||
|
||
async function CategoryCorrectCount(user, locale) { | ||
const count = user.fields.CorrectCount; | ||
const userId = user.fields.RecordId; | ||
switch (count) { | ||
case 1: return await getSpecificAchievement(achievements.CORRECT_ANSWERS_1, userId, locale); | ||
case 5: return await getSpecificAchievement(achievements.CORRECT_ANSWERS_5, userId, locale); | ||
case 10: return await getSpecificAchievement(achievements.CORRECT_ANSWERS_10, userId, locale); | ||
case 25: return await getSpecificAchievement(achievements.CORRECT_ANSWERS_25, userId, locale); | ||
case 50: return await getSpecificAchievement(achievements.CORRECT_ANSWERS_50, userId, locale); | ||
case 100: return await getSpecificAchievement(achievements.CORRECT_ANSWERS_100, userId, locale); | ||
default: return undefined; | ||
} | ||
} | ||
|
||
module.exports = CategoryCorrectCount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
const AchievementCount = require("./AchievementCount"); | ||
const AnswerCount = require("./AnswerCount"); | ||
const CategoryCorrectCount = require("./CategoryCorrectCount"); | ||
const CorrectCount = require("./CorrectCount"); | ||
const SessionCount = require("./SessionCount"); | ||
|
||
module.exports = { | ||
AchievementCount, | ||
AnswerCount, | ||
CategoryCorrectCount, | ||
CorrectCount, | ||
SessionCount | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const helper = require("../helper"); | ||
const fetch = require("node-fetch"); | ||
const keys = require("../keys"); | ||
|
||
async function getSpecificCategory(categoryId) { | ||
const url = `https://api.airtable.com/v0/${keys.airtable_base_data}/Category?api_key=${keys.airtable_api_key}&filterByFormula=AND(RecordId%3D"${encodeURIComponent(categoryId)}")`; | ||
const options = { | ||
method: "GET", | ||
}; | ||
//console.log(`FULL PATH ${url}`); | ||
|
||
return fetch(url, options) | ||
.then((res) => res.json()) | ||
.then((r) => { | ||
//console.log({r}); | ||
const item = helper.getRandomItem(r.records); | ||
return item; | ||
}); | ||
} | ||
|
||
module.exports = getSpecificCategory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const data = require("../data"); | ||
const helper = require("../helper"); | ||
|
||
async function UserEventHandler(handlerInput) { | ||
const categoryId = handlerInput.requestEnvelope.request.arguments[0]; | ||
const question = await data.getRandomQuestion(categoryId, helper.getLocale(handlerInput)); | ||
return await data.askQuestion(question, handlerInput, data); | ||
} | ||
|
||
module.exports = UserEventHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters