Compare commits
No commits in common. "471cbef217bd9a9b46c9df9b1e491eabd1dbb560" and "acafc4fe79f8b0179258af71ac1e0d0f10bc6923" have entirely different histories.
471cbef217
...
acafc4fe79
|
@ -17,7 +17,7 @@ export default function MinimalPairs({
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h5 className="my-3" onClick={() => setOpened((x) => !x)}>
|
<h5 className="my-3" onClick={() => setOpened((x) => !x)}>
|
||||||
{opened ? "▼" : "▶"} Browse Pairs
|
{opened ? "▼" : "▶"} View Pairs
|
||||||
</h5>
|
</h5>
|
||||||
<SmoothCollapse expanded={opened}>
|
<SmoothCollapse expanded={opened}>
|
||||||
{section.pairs.map((pairs, i) => (
|
{section.pairs.map((pairs, i) => (
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
const minimalPairsSection = [
|
|
||||||
"t and T",
|
|
||||||
"d and D",
|
|
||||||
"r and R",
|
|
||||||
"n and N",
|
|
||||||
"a and aa",
|
|
||||||
"ay and uy",
|
|
||||||
"ay and e",
|
|
||||||
"ee and e",
|
|
||||||
] as const;
|
|
||||||
export type MinimalPairsSection = (typeof minimalPairsSection)[number];
|
|
|
@ -11,23 +11,12 @@ import psmd from "../../lib/psmd";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
import MinimalPairs from "./MinimalPairs.tsx";
|
import MinimalPairs from "./MinimalPairs.tsx";
|
||||||
import minimalPairs from "./minimal-pairs.ts";
|
import minimalPairs from "./minimal-pairs.ts";
|
||||||
import {
|
|
||||||
minimalPairsT,
|
|
||||||
minimalPairsD,
|
|
||||||
minimalPairsR,
|
|
||||||
minimalPairsN,
|
|
||||||
minimalPairsAa,
|
|
||||||
minimalPairsAyUy,
|
|
||||||
minimalPairsAyE,
|
|
||||||
minimalPairsEeE,
|
|
||||||
} from "../../games/games";
|
|
||||||
import GameDisplay from "../../games/GameDisplay";
|
|
||||||
|
|
||||||
There are certain sounds in Pashto that are quite difficult for some learners to distinguish.
|
There are certain sounds in Pashto that are quite difficult for some learners to distinguish.
|
||||||
|
|
||||||
For example, English speakers have a very hard time hearing the difference between the dental <InlinePs opts={opts} ps={{ p: "ت", f: "t" }}/> and retroflex <InlinePs opts={opts} ps={{ p: "ټ", f: "T" }}/>. Some of the vowels like <InlinePs opts={opts} ps={{ p: "ي", f: "ee" }}/> and <InlinePs opts={opts} ps={{ p: "ې", f: "e" }}/> can also be very tricky to distinguish.
|
For example, English speakers have a very hard time hearing the difference between the dental <InlinePs opts={opts} ps={{ p: "ت", f: "t" }}/> and retroflex <InlinePs opts={opts} ps={{ p: "ټ", f: "T" }}/>. Some of the vowels like <InlinePs opts={opts} ps={{ p: "ي", f: "ee" }}/> and <InlinePs opts={opts} ps={{ p: "ې", f: "e" }}/> can also be very tricky to distinguish.
|
||||||
|
|
||||||
Here are some examples of words that vary by these different sounds. Listen to them to train your ear to the difference, and then use the games to see if you can hear the difference yourself.
|
Here are some examples of words that vary by these different sounds. Listen to them to train your ear to the difference, and then use the games to see if you can hear the difference yourself. (Games coming soon! 🚧)
|
||||||
|
|
||||||
## ت - t and ټ - T
|
## ت - t and ټ - T
|
||||||
|
|
||||||
|
@ -36,8 +25,6 @@ Here are some examples of words that vary by these different sounds. Listen to t
|
||||||
section={minimalPairs.find((x) => x.title === "t and T")}
|
section={minimalPairs.find((x) => x.title === "t and T")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsT} />
|
|
||||||
|
|
||||||
## د - d and ډ - D
|
## د - d and ډ - D
|
||||||
|
|
||||||
<MinimalPairs
|
<MinimalPairs
|
||||||
|
@ -45,8 +32,6 @@ Here are some examples of words that vary by these different sounds. Listen to t
|
||||||
section={minimalPairs.find((x) => x.title === "d and D")}
|
section={minimalPairs.find((x) => x.title === "d and D")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsD} />
|
|
||||||
|
|
||||||
## ر - r and ړ - R
|
## ر - r and ړ - R
|
||||||
|
|
||||||
<MinimalPairs
|
<MinimalPairs
|
||||||
|
@ -54,8 +39,6 @@ Here are some examples of words that vary by these different sounds. Listen to t
|
||||||
section={minimalPairs.find((x) => x.title === "r and R")}
|
section={minimalPairs.find((x) => x.title === "r and R")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsR} />
|
|
||||||
|
|
||||||
## ن - n and ڼ - N
|
## ن - n and ڼ - N
|
||||||
|
|
||||||
<MinimalPairs
|
<MinimalPairs
|
||||||
|
@ -63,8 +46,6 @@ Here are some examples of words that vary by these different sounds. Listen to t
|
||||||
section={minimalPairs.find((x) => x.title === "n and N")}
|
section={minimalPairs.find((x) => x.title === "n and N")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsN} />
|
|
||||||
|
|
||||||
## ه - a and ا - aa
|
## ه - a and ا - aa
|
||||||
|
|
||||||
<MinimalPairs
|
<MinimalPairs
|
||||||
|
@ -72,8 +53,6 @@ Here are some examples of words that vary by these different sounds. Listen to t
|
||||||
section={minimalPairs.find((x) => x.title === "a and aa")}
|
section={minimalPairs.find((x) => x.title === "a and aa")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsAa} />
|
|
||||||
|
|
||||||
## ی - ay and ۍ - uy
|
## ی - ay and ۍ - uy
|
||||||
|
|
||||||
<MinimalPairs
|
<MinimalPairs
|
||||||
|
@ -81,8 +60,6 @@ Here are some examples of words that vary by these different sounds. Listen to t
|
||||||
section={minimalPairs.find((x) => x.title === "ay and uy")}
|
section={minimalPairs.find((x) => x.title === "ay and uy")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsAyUy} />
|
|
||||||
|
|
||||||
## ی - ay and ې - e
|
## ی - ay and ې - e
|
||||||
|
|
||||||
<MinimalPairs
|
<MinimalPairs
|
||||||
|
@ -90,13 +67,9 @@ Here are some examples of words that vary by these different sounds. Listen to t
|
||||||
section={minimalPairs.find((x) => x.title === "ay and e")}
|
section={minimalPairs.find((x) => x.title === "ay and e")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsAyE} />
|
|
||||||
|
|
||||||
## ي - ee and ې - e
|
## ي - ee and ې - e
|
||||||
|
|
||||||
<MinimalPairs
|
<MinimalPairs
|
||||||
opts={opts}
|
opts={opts}
|
||||||
section={minimalPairs.find((x) => x.title === "ee and e")}
|
section={minimalPairs.find((x) => x.title === "ee and e")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<GameDisplay record={minimalPairsEeE} />
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useRef, useEffect, memo } from "react";
|
import { useState, useRef, useEffect } from "react";
|
||||||
import { CountdownCircleTimer } from "react-countdown-circle-timer";
|
import { CountdownCircleTimer } from "react-countdown-circle-timer";
|
||||||
import Reward, { RewardElement } from "react-rewards";
|
import Reward, { RewardElement } from "react-rewards";
|
||||||
import Link from "../components/Link";
|
import Link from "../components/Link";
|
||||||
|
@ -25,7 +25,7 @@ type GameState<Question> = (
|
||||||
}
|
}
|
||||||
) & {
|
) & {
|
||||||
numberComplete: number;
|
numberComplete: number;
|
||||||
current: Question | undefined;
|
current: Question;
|
||||||
timerKey: number;
|
timerKey: number;
|
||||||
strikes: number;
|
strikes: number;
|
||||||
justStruck: boolean;
|
justStruck: boolean;
|
||||||
|
@ -74,13 +74,10 @@ function GameCore<Question>({
|
||||||
timeLimit: number;
|
timeLimit: number;
|
||||||
amount: number;
|
amount: number;
|
||||||
}) {
|
}) {
|
||||||
// TODO STOP THE DOUBLE POOL DIPPING !!!
|
|
||||||
// POSSIBLE SOLUTION - allow question to be undefined... then use useEffect
|
|
||||||
// to grab the first question
|
|
||||||
const initialState: GameState<Question> = {
|
const initialState: GameState<Question> = {
|
||||||
mode: "intro",
|
mode: "intro",
|
||||||
numberComplete: 0,
|
numberComplete: 0,
|
||||||
current: undefined,
|
current: getQuestion(),
|
||||||
timerKey: 0,
|
timerKey: 0,
|
||||||
strikes: 0,
|
strikes: 0,
|
||||||
justStruck: false,
|
justStruck: false,
|
||||||
|
@ -94,10 +91,6 @@ function GameCore<Question>({
|
||||||
useState<GameState<Question>>(initialState);
|
useState<GameState<Question>>(initialState);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
parent.current && autoAnimate(parent.current);
|
parent.current && autoAnimate(parent.current);
|
||||||
setStateDangerous((s) => ({
|
|
||||||
...s,
|
|
||||||
current: getQuestion(),
|
|
||||||
}));
|
|
||||||
}, [parent]);
|
}, [parent]);
|
||||||
|
|
||||||
const gameReducer = (
|
const gameReducer = (
|
||||||
|
@ -180,7 +173,6 @@ function GameCore<Question>({
|
||||||
if (action.type === "quit") {
|
if (action.type === "quit") {
|
||||||
return {
|
return {
|
||||||
...initialState,
|
...initialState,
|
||||||
current: getQuestion(),
|
|
||||||
timerKey: gs.timerKey + 1,
|
timerKey: gs.timerKey + 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -380,7 +372,7 @@ function GameCore<Question>({
|
||||||
<ActionButtons />
|
<ActionButtons />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{gameRunning && state.current && (
|
{gameRunning && (
|
||||||
<Display
|
<Display
|
||||||
question={state.current}
|
question={state.current}
|
||||||
callback={(correct) =>
|
callback={(correct) =>
|
||||||
|
@ -402,7 +394,7 @@ function GameCore<Question>({
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{state.showAnswer && state.mode === "practice" && state.current && (
|
{state.showAnswer && state.mode === "practice" && (
|
||||||
<div className="my-2">
|
<div className="my-2">
|
||||||
<div className="my-1">
|
<div className="my-1">
|
||||||
<DisplayCorrectAnswer question={state.current} />
|
<DisplayCorrectAnswer question={state.current} />
|
||||||
|
@ -431,25 +423,24 @@ function GameCore<Question>({
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{(state.mode === "timeout" || state.mode === "fail") &&
|
{(state.mode === "timeout" || state.mode === "fail") && (
|
||||||
state.current && (
|
<div className="mb-4">
|
||||||
<div className="mb-4">
|
<h4 className="mt-4">
|
||||||
<h4 className="mt-4">
|
{failMessage({
|
||||||
{failMessage({
|
numberComplete: state.numberComplete,
|
||||||
numberComplete: state.numberComplete,
|
amount,
|
||||||
amount,
|
type: state.mode,
|
||||||
type: state.mode,
|
})}
|
||||||
})}
|
</h4>
|
||||||
</h4>
|
<div>The correct answer was:</div>
|
||||||
<div>The correct answer was:</div>
|
<div className="my-2">
|
||||||
<div className="my-2">
|
<DisplayCorrectAnswer question={state.current} />
|
||||||
<DisplayCorrectAnswer question={state.current} />
|
|
||||||
</div>
|
|
||||||
<div className="my-3">
|
|
||||||
<ActionButtons />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
<div className="my-3">
|
||||||
|
<ActionButtons />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Reward>
|
</Reward>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,6 @@ import VerbGame from "./sub-cores/VerbGame";
|
||||||
import GenderGame from "./sub-cores/GenderGame";
|
import GenderGame from "./sub-cores/GenderGame";
|
||||||
import PluralNounGame from "./sub-cores/PluralNounGame";
|
import PluralNounGame from "./sub-cores/PluralNounGame";
|
||||||
import UnisexNounGame from "./sub-cores/UnisexNounGame";
|
import UnisexNounGame from "./sub-cores/UnisexNounGame";
|
||||||
import MinimalPairsGame from "./sub-cores/MinimalPairsGame";
|
|
||||||
import EquativeSituations from "./sub-cores/EquativeSituations";
|
import EquativeSituations from "./sub-cores/EquativeSituations";
|
||||||
import VerbSituations from "./sub-cores/VerbSituations";
|
import VerbSituations from "./sub-cores/VerbSituations";
|
||||||
import EquativeIdentify from "./sub-cores/EquativeIdentify";
|
import EquativeIdentify from "./sub-cores/EquativeIdentify";
|
||||||
|
@ -14,64 +13,6 @@ import PerfectVerbsIntransitive from "./sub-cores/PerfectGame";
|
||||||
import NPAdjWriting from "./sub-cores/NPAdjGame";
|
import NPAdjWriting from "./sub-cores/NPAdjGame";
|
||||||
import EPAdjGame from "./sub-cores/EPAdjGame";
|
import EPAdjGame from "./sub-cores/EPAdjGame";
|
||||||
|
|
||||||
// MINIMAL PAIRS
|
|
||||||
export const minimalPairsT = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - t and T",
|
|
||||||
id: "minimal-pairs-t",
|
|
||||||
link: "/writing/minimal-pairs/#ت---t-and-ټ---t",
|
|
||||||
level: "t and T",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
export const minimalPairsD = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - d and D",
|
|
||||||
id: "minimal-pairs-d",
|
|
||||||
link: "/writing/minimal-pairs/#د---d-and-ډ---d",
|
|
||||||
level: "d and D",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
export const minimalPairsR = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - r and R",
|
|
||||||
id: "minimal-pairs-r",
|
|
||||||
link: "/writing/minimal-pairs/#ر---r-and-ړ---r",
|
|
||||||
level: "r and R",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
export const minimalPairsN = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - n and N",
|
|
||||||
id: "minimal-pairs-n",
|
|
||||||
link: "/writing/aiilmmn - pairs / #ن-- - n - and - ڼ-- - n",
|
|
||||||
level: "n and N",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
export const minimalPairsAa = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - a and aa",
|
|
||||||
id: "minimal-pairs-aa",
|
|
||||||
link: "/writing/minimal-pairs/#ه---a-and-ا---aa",
|
|
||||||
level: "a and aa",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
export const minimalPairsAyUy = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - ay and uy",
|
|
||||||
id: "minimal-pairs-ay-uy",
|
|
||||||
link: "/writing/minimal-pairs/#ی---ay-and-ۍ---uy",
|
|
||||||
level: "ay and uy",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
export const minimalPairsAyE = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - ay and e",
|
|
||||||
id: "minimal-pairs-ay-e",
|
|
||||||
link: "/writing/minimal-pairs/#ی---ay-and-ې---e",
|
|
||||||
level: "ay and e",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
export const minimalPairsEeE = makeGameRecord({
|
|
||||||
title: "Minimal Pairs - ee and e",
|
|
||||||
id: "minimal-pairs-ee-e",
|
|
||||||
link: "ي - ee and ې - e",
|
|
||||||
level: "ee and e",
|
|
||||||
SubCore: MinimalPairsGame,
|
|
||||||
});
|
|
||||||
|
|
||||||
// NOUNS
|
// NOUNS
|
||||||
export const nounGenderGame1 = makeGameRecord({
|
export const nounGenderGame1 = makeGameRecord({
|
||||||
title: "Identify Noun Genders - Level 1",
|
title: "Identify Noun Genders - Level 1",
|
||||||
|
@ -502,19 +443,6 @@ export const npWithAdjectivesInSandwiches = makeGameRecord({
|
||||||
});
|
});
|
||||||
|
|
||||||
const games: { chapter: string; items: GameRecord[] }[] = [
|
const games: { chapter: string; items: GameRecord[] }[] = [
|
||||||
{
|
|
||||||
chapter: "Minimal Pairs",
|
|
||||||
items: [
|
|
||||||
minimalPairsT,
|
|
||||||
minimalPairsD,
|
|
||||||
minimalPairsR,
|
|
||||||
minimalPairsN,
|
|
||||||
minimalPairsAa,
|
|
||||||
minimalPairsAyUy,
|
|
||||||
minimalPairsAyE,
|
|
||||||
minimalPairsEeE,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
chapter: "Nouns",
|
chapter: "Nouns",
|
||||||
items: [nounGenderGame1, nounGenderGame2, unisexNounGame, pluralNounGame],
|
items: [nounGenderGame1, nounGenderGame2, unisexNounGame, pluralNounGame],
|
||||||
|
|
|
@ -1,206 +0,0 @@
|
||||||
import GameCore from "../GameCore";
|
|
||||||
import {
|
|
||||||
Types as T,
|
|
||||||
defaultTextOptions as opts,
|
|
||||||
randFromArray,
|
|
||||||
removeAccents,
|
|
||||||
} from "@lingdocs/ps-react";
|
|
||||||
import minimalPairs from "../../content/writing/minimal-pairs";
|
|
||||||
import { makePool } from "../../lib/pool";
|
|
||||||
import { useEffect, useRef } from "react";
|
|
||||||
import { MinimalPairsSection } from "../../content/writing/minimal-pairs-type";
|
|
||||||
|
|
||||||
// is it removing from the pool properly ? or is it a problem with strict mode doing double?
|
|
||||||
|
|
||||||
const amount = 20;
|
|
||||||
type EntryWF = { f: string; entry: T.DictionaryEntry };
|
|
||||||
type MinimalPair = [EntryWF, EntryWF];
|
|
||||||
type Question = {
|
|
||||||
pair: MinimalPair;
|
|
||||||
selected: 0 | 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function MinimalPairsGame({
|
|
||||||
level,
|
|
||||||
id,
|
|
||||||
link,
|
|
||||||
inChapter,
|
|
||||||
}: {
|
|
||||||
inChapter: boolean;
|
|
||||||
level: MinimalPairsSection;
|
|
||||||
id: string;
|
|
||||||
link: string;
|
|
||||||
}) {
|
|
||||||
const getPair = makePool<MinimalPair>(
|
|
||||||
// @ts-ignore
|
|
||||||
minimalPairs.find((x) => x.title === level)?.pairs || []
|
|
||||||
);
|
|
||||||
function getQuestion(): Question {
|
|
||||||
const pair = getPair();
|
|
||||||
const selected: 0 | 1 = randFromArray([0, 1]);
|
|
||||||
return { pair, selected };
|
|
||||||
}
|
|
||||||
function Display({ question, callback }: QuestionDisplayProps<Question>) {
|
|
||||||
const audioRef = useRef<HTMLAudioElement>();
|
|
||||||
useEffect(() => {
|
|
||||||
if (audioRef && audioRef.current) {
|
|
||||||
audioRef.current.play();
|
|
||||||
}
|
|
||||||
}, [question]);
|
|
||||||
const selected = getSelected(question);
|
|
||||||
const audioSrc = getAudioSrc(selected);
|
|
||||||
function playAudio() {
|
|
||||||
if (audioRef && audioRef.current) {
|
|
||||||
audioRef.current.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function check(guess: 0 | 1) {
|
|
||||||
return () => callback(question.selected === guess);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<audio
|
|
||||||
src={audioSrc}
|
|
||||||
// @ts-expect-error // typing not playing nice here
|
|
||||||
ref={audioRef}
|
|
||||||
/>
|
|
||||||
<div>
|
|
||||||
<button className="btn btn-lg btn-primary mt-3" onClick={playAudio}>
|
|
||||||
<i className="fas fa-play" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<PairButtons
|
|
||||||
renderButton={(n) => (
|
|
||||||
<WordButton
|
|
||||||
entry={question.pair[n]}
|
|
||||||
handleClick={check(n)}
|
|
||||||
type="guess"
|
|
||||||
hideAccents={true}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Instructions() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h5>Listen and identify the correct word in a minimal pair</h5>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function DisplayCorrectAnswer({ question }: { question: Question }) {
|
|
||||||
const audioRef0 = useRef<HTMLAudioElement>();
|
|
||||||
const audioRef1 = useRef<HTMLAudioElement>();
|
|
||||||
const [audioSrc0, audioSrc1] = question.pair.map(getAudioSrc);
|
|
||||||
const playAudio = (n: 0 | 1) => () => {
|
|
||||||
const audio = n === 0 ? audioRef0 : audioRef1;
|
|
||||||
audio.current?.play();
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<audio
|
|
||||||
src={audioSrc0}
|
|
||||||
// @ts-expect-error // typing not playing nice here
|
|
||||||
ref={audioRef0}
|
|
||||||
preload="auto"
|
|
||||||
/>
|
|
||||||
<audio
|
|
||||||
src={audioSrc1}
|
|
||||||
// @ts-expect-error // typing not playing nice here
|
|
||||||
ref={audioRef1}
|
|
||||||
preload="auto"
|
|
||||||
/>
|
|
||||||
<PairButtons
|
|
||||||
renderButton={(n) => (
|
|
||||||
<WordButton
|
|
||||||
entry={question.pair[n]}
|
|
||||||
handleClick={playAudio(n)}
|
|
||||||
key={`answer-${n}`}
|
|
||||||
type={question.selected === n ? "correct" : "incorrect"}
|
|
||||||
hideAccents={false}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<GameCore
|
|
||||||
inChapter={inChapter}
|
|
||||||
studyLink={link}
|
|
||||||
getQuestion={getQuestion}
|
|
||||||
id={id}
|
|
||||||
Display={Display}
|
|
||||||
DisplayCorrectAnswer={DisplayCorrectAnswer}
|
|
||||||
amount={amount}
|
|
||||||
timeLimit={90}
|
|
||||||
Instructions={Instructions}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function PairButtons({
|
|
||||||
renderButton,
|
|
||||||
}: {
|
|
||||||
renderButton: (n: 0 | 1) => JSX.Element;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="mt-4 d-flex justify-content-center"
|
|
||||||
style={{ margin: "0 auto", gap: "2.5rem" }}
|
|
||||||
>
|
|
||||||
{([0, 1] as const).map(renderButton)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function WordButton({
|
|
||||||
entry,
|
|
||||||
handleClick,
|
|
||||||
type,
|
|
||||||
hideAccents,
|
|
||||||
}: {
|
|
||||||
entry: EntryWF;
|
|
||||||
handleClick: () => void;
|
|
||||||
type: "guess" | "correct" | "incorrect";
|
|
||||||
hideAccents: boolean;
|
|
||||||
}) {
|
|
||||||
const btnColor =
|
|
||||||
type === "guess" ? "light" : type === "correct" ? "success" : "danger";
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
className={`btn btn-lg btn-${btnColor} mr-3`}
|
|
||||||
style={{ minWidth: "8rem" }}
|
|
||||||
onClick={handleClick}
|
|
||||||
>
|
|
||||||
<div className="d-flex justify-content-around">
|
|
||||||
{type === "guess" ? null : (
|
|
||||||
<div className="mr-3 d-flex flex-column justify-content-around">
|
|
||||||
<i className={`fas fa-${type === "correct" ? "check" : "times"}`} />
|
|
||||||
<i className="fas fa-play" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div>
|
|
||||||
<div>{hideAccents ? removeAccents(entry.f) : entry.f}</div>
|
|
||||||
<div>{entry.entry.p}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAudioSrc(entry: EntryWF): string {
|
|
||||||
const tag = entry.entry.a === 1 ? "" : "f";
|
|
||||||
return `https://storage.lingdocs.com/audio/${entry.entry.ts}${tag}.mp3`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSelected(question: Question): {
|
|
||||||
f: string;
|
|
||||||
entry: T.DictionaryEntry;
|
|
||||||
} {
|
|
||||||
return question.pair[question.selected];
|
|
||||||
}
|
|
|
@ -6,7 +6,7 @@ import equal from "fast-deep-equal";
|
||||||
* @param poolBase an array of things you want to use as the pool to pick from
|
* @param poolBase an array of things you want to use as the pool to pick from
|
||||||
* @param removalLaxity If set, thery will be a n% chance that the pick will NOT
|
* @param removalLaxity If set, thery will be a n% chance that the pick will NOT
|
||||||
* be removed after use. Defaults to 0, meaning that every time an item is picked
|
* be removed after use. Defaults to 0, meaning that every time an item is picked
|
||||||
* it is removed from the pool. 100 means that items will never be removed from the pool.
|
* it is removed from the. 100 means that items will never be removed from the pool.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function makePool<P>(poolBase: P[], removalLaxity = 0): () => P {
|
export function makePool<P>(poolBase: P[], removalLaxity = 0): () => P {
|
||||||
|
|
Loading…
Reference in New Issue