Skip to content

Commit

Permalink
Merge pull request #19 from levante-framework/survey-lang-fix
Browse files Browse the repository at this point in the history
Fixing language switching on survey
  • Loading branch information
Zio-4 authored Aug 13, 2024
2 parents 3efb2d3 + 57fb7b9 commit b07238c
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/pages/LEVANTE/UserSurvey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,15 @@ async function getSurvey() {
try {
const response = await axios.get(`https://storage.googleapis.com/road-dashboard/${userType}_survey.json`);
if (userType === 'child') {
const audioLinkMap = await fetchAudioLinks('child-survey');
audioLinks.value = audioLinkMap;
}
const audioLinkMap = await fetchAudioLinks('child-survey');
audioLinks.value = audioLinkMap;
fetchedSurvey.value = response.data;
// Create the survey model with the fetched data
const surveyInstance = new Model(fetchedSurvey.value);
surveyInstance.locale = locale.value;
if (userType === 'child') {
fetchBuffer(getParsedLocale(locale.value));
}
fetchBuffer(getParsedLocale(locale.value));
survey.value = surveyInstance;
survey.value.onTextMarkdown.add(function (survey, options) {
Expand All @@ -119,19 +115,18 @@ async function getSurvey() {
options.html = str;
});
survey.value.onComplete.add(saveResults);
if (userType === 'child') {
survey.value.onAfterRenderPage.add((__, { htmlElement }) => {
const questionElements = htmlElement.querySelectorAll('div[id^=sq_]');
if (currentAudioSource) {
currentAudioSource.stop();
}
questionElements.forEach((el) => {
const playAudioButton = document.getElementById('audio-button-' + el.dataset.name);
showAndPlaceAudioButton(playAudioButton, el);
});
survey.value.onAfterRenderPage.add((__, { htmlElement }) => {
const questionElements = htmlElement.querySelectorAll('div[id^=sq_]');
if (currentAudioSource) {
currentAudioSource.stop();
}
questionElements.forEach((el) => {
const playAudioButton = document.getElementById('audio-button-' + el.dataset.name);
showAndPlaceAudioButton(playAudioButton, el);
});
}
});
} catch (error) {
console.error(error);
}
Expand Down

0 comments on commit b07238c

Please sign in to comment.