fix: Second play, now displays the form
This commit is contained in:
parent
94d30121d4
commit
40079e1145
@ -36,6 +36,7 @@ function quizz(req, res) {
|
||||
res.json({ species, audio }).send();
|
||||
debug("Quizz sent");
|
||||
quizzController.cacheQuizz(); // Prepare the next question in advance.
|
||||
debug("New quizz cached");
|
||||
})
|
||||
.catch(error => {
|
||||
debug("Faced error while generating quizz");
|
||||
|
@ -22,9 +22,10 @@ async function getQuizzCached(region, locale, size) {
|
||||
}
|
||||
|
||||
async function cacheQuizz(region, locale, size) {
|
||||
let quizz = generateQuizz(region, locale, size);
|
||||
let quizz = await generateQuizz(region, locale, size);
|
||||
let key = quizzKey(region, locale, size);
|
||||
cache.push(key, quizz);
|
||||
return quizz;
|
||||
}
|
||||
|
||||
async function generateQuizz(region, locale, size) {
|
||||
@ -66,10 +67,6 @@ async function generateQuizz(region, locale, size) {
|
||||
|
||||
async function getSpeciesSelection(region, number) {
|
||||
const regionCode = region;
|
||||
// const { lat, lng } = coordinates;
|
||||
// const region = await getRegion(lat, lng);
|
||||
// const regionCode = await getRegionCode(region);
|
||||
// const regionCode = region.country_code;
|
||||
const speciesList = await getSpeciesList(regionCode);
|
||||
const speciesSelection = choices(speciesList, number);
|
||||
debug("Species proposals:", speciesSelection)
|
||||
|
@ -15,6 +15,8 @@ let resultSciName = document.querySelector('.game-results-step .species .sci');
|
||||
|
||||
const API_VERSION = "0";
|
||||
|
||||
let region = 'FR';
|
||||
|
||||
function geolocationStep() {
|
||||
if (map != undefined)
|
||||
geolocationHandler();
|
||||
@ -25,20 +27,16 @@ function geolocationStep() {
|
||||
function regionCoder() {
|
||||
// Start by disallowing geolocation step
|
||||
gameMapStep.classList.add('none');
|
||||
// Then allow the quizz step
|
||||
gameQuizzStep.classList.remove('none');
|
||||
|
||||
// Retrieve coordinates from former done geolocation (TODO: fix the need of cookie)
|
||||
const coordinates = getCoordinates();
|
||||
let [lat, lon] = coordinates;
|
||||
client.getRegion(lat, lon).then(data => {
|
||||
let { region } = data;
|
||||
console.log(region);
|
||||
quizzStep(region);
|
||||
region = data.region;
|
||||
quizzStep();
|
||||
});
|
||||
}
|
||||
|
||||
function quizzStep(region) {
|
||||
function quizzStep() {
|
||||
client.getQuizz(region)
|
||||
.then(quizz => {
|
||||
displayQuizz(quizz);
|
||||
@ -51,6 +49,7 @@ function quizzStep(region) {
|
||||
function displayQuizz(quizz) {
|
||||
audio.src = quizz.audio;
|
||||
audio.classList.remove("none"); // Display the audio controls
|
||||
gameQuizzStep.classList.remove("none");
|
||||
audio.play();
|
||||
proposals.innerHTML = "";
|
||||
quizz.species.forEach(sp => {
|
||||
|
Loading…
Reference in New Issue
Block a user