From 52f86729d09c9a6182de7bdf445d1fb9bc60e327 Mon Sep 17 00:00:00 2001 From: Jacky Sun Date: Tue, 10 Sep 2024 13:48:50 -0700 Subject: [PATCH] update quiz entry code for some localization bugs --- libs/blocks/quiz-entry/quiz-entry.js | 4 +++- libs/blocks/quiz-entry/quizoption.js | 9 +++++---- libs/blocks/quiz-entry/utils.js | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libs/blocks/quiz-entry/quiz-entry.js b/libs/blocks/quiz-entry/quiz-entry.js index 6c9c9394ba..61b3b8545f 100644 --- a/libs/blocks/quiz-entry/quiz-entry.js +++ b/libs/blocks/quiz-entry/quiz-entry.js @@ -3,6 +3,7 @@ import { getQuizEntryData, handleNext, handleSelections } from './utils.js'; import { mlField, getMLResults } from './mlField.js'; import { GetQuizOption } from './quizoption.js'; import { quizPopover, getSuggestions } from './quizPopover.js'; +import { getConfig } from '../../utils/utils.js'; export const locationWrapper = { redirect: (url) => { @@ -343,7 +344,8 @@ const App = ({ if (!dataLoaded || !selectedQuestion) return null; - return html`
+ const { locale } = getConfig(); + return html`
${quizLists.strings[selectedQuestion.questions].heading}
${quizLists.strings[selectedQuestion.questions]['sub-head']}
diff --git a/libs/blocks/quiz-entry/quizoption.js b/libs/blocks/quiz-entry/quizoption.js index bb3f88bf15..5771d6ff92 100644 --- a/libs/blocks/quiz-entry/quizoption.js +++ b/libs/blocks/quiz-entry/quizoption.js @@ -1,5 +1,6 @@ import { html, useState, useEffect } from '../../deps/htm-preact.js'; import { getSwipeDistance, getSwipeDirection } from '../carousel/carousel.js'; +import { removeLeftToRightMark } from '../quiz/utils.js'; export const OptionCard = ({ text, title, image, icon, iconTablet, iconDesktop, options, @@ -17,13 +18,13 @@ export const OptionCard = ({ const getIconHtml = () => html`
- ${iconDesktop && html``} - ${iconTablet && html``} - + ${iconDesktop && html``} + ${iconTablet && html``} +
`; - const imageHtml = image ? html`
` : null; + const imageHtml = image ? html`
` : null; const titleHtml = title ? html`

${title}

` : null; const textHtml = text ? html`

${text}

` : null; diff --git a/libs/blocks/quiz-entry/utils.js b/libs/blocks/quiz-entry/utils.js index dfca985432..787b4ee79a 100644 --- a/libs/blocks/quiz-entry/utils.js +++ b/libs/blocks/quiz-entry/utils.js @@ -1,4 +1,4 @@ -import { getNormalizedMetadata } from '../quiz/utils.js'; +import { getNormalizedMetadata, getLocalizedURL } from '../quiz/utils.js'; export async function fetchJson(path) { const response = await fetch(path); @@ -104,8 +104,8 @@ export const handleSelections = (prevSelections, selectedQuestion, selections) = export async function getQuizEntryData(el) { const blockData = getNormalizedMetadata(el); - const dataPath = blockData.data.text; - const quizPath = blockData.quiz.text; + const dataPath = getLocalizedURL(blockData.data.text); + const quizPath = getLocalizedURL(blockData.quiz.text); const maxQuestions = Number(blockData.maxquestions?.text) || 10; const analyticsType = blockData.analyticstype?.text; const analyticsQuiz = blockData.analyticsquiz?.text;