|
1 | 1 | <script lang="typescript">
|
2 | 2 | import sound from "../media/sound"
|
3 |
| - import DeckChallenge from "./DeckChallenge" |
4 |
| - import OptionChallenge from "./OptionChallenge" |
5 |
| - import ShortInputChallenge from "./ShortInputChallenge" |
6 |
| - import ListeningChallenge from "./ListeningChallenge" |
7 |
| - import ChipsChallenge from "./ChipsChallenge" |
8 |
| - import FanfareScreen from "./FanfareScreen" |
9 |
| - import ProgressBar from "./ProgressBar" |
| 3 | + import DeckChallenge from "./DeckChallenge/index.svelte" |
| 4 | + import OptionChallenge from "./OptionChallenge/index.svelte" |
| 5 | + import ShortInputChallenge from "./ShortInputChallenge.svelte" |
| 6 | + import ListeningChallenge from "./ListeningChallenge.svelte" |
| 7 | + import ChipsChallenge from "./ChipsChallenge/index.svelte" |
| 8 | + import FanfareScreen from "./FanfareScreen.svelte" |
| 9 | + import ProgressBar from "./ProgressBar.svelte" |
10 | 10 | import shuffle from "lodash.shuffle"
|
11 | 11 | import { fade, scale } from "svelte/transition"
|
12 | 12 | // TODO: deal with this ignore comment
|
|
22 | 22 | export let skillId
|
23 | 23 | export let expectedNumberOfChallenges
|
24 | 24 |
|
25 |
| - let challenges = sortChallengeGroups( |
| 25 | + type CardChallengeType = { |
| 26 | + id: string, |
| 27 | + type: "cards", |
| 28 | + pictures: Array<string> |
| 29 | + } |
| 30 | +
|
| 31 | + type ListeningChallengeType = { |
| 32 | + id: string, |
| 33 | + type: "listeningExercise", |
| 34 | + } |
| 35 | +
|
| 36 | + type OptionsChallengeType = { |
| 37 | + id: string, |
| 38 | + type: "options", |
| 39 | + } |
| 40 | +
|
| 41 | + type ShortInputChallengeType = { |
| 42 | + id: string, |
| 43 | + type: "shortInput", |
| 44 | + } |
| 45 | +
|
| 46 | + type ChipsChallengeType = { |
| 47 | + id: string, |
| 48 | + type: "chips", |
| 49 | + } |
| 50 | +
|
| 51 | + type ChallengeType = |
| 52 | + | CardChallengeType |
| 53 | + | ListeningChallengeType |
| 54 | + | OptionsChallengeType |
| 55 | + | ShortInputChallengeType |
| 56 | + | ChipsChallengeType |
| 57 | +
|
| 58 | + let challenges: Array<ChallengeType> = sortChallengeGroups( |
26 | 59 | shuffle(rawChallenges),
|
27 | 60 | expectedNumberOfChallenges
|
28 | 61 | )
|
|
38 | 71 | skipped: 0,
|
39 | 72 | }
|
40 | 73 |
|
41 |
| - const preloadImage = (imageName) => { |
| 74 | + const preloadImage = (imageName: string) => { |
42 | 75 | if (typeof Image === "undefined") return
|
43 | 76 | new Image().src = `images/${imageName}`
|
44 | 77 | }
|
45 | 78 |
|
46 | 79 | challenges
|
47 |
| - .filter(({ type }) => type === "card") |
48 |
| - .map(({ pictures }) => pictures.map(preloadImage)) |
| 80 | + .filter(({ type }) => type === "cards") |
| 81 | + .map(({ pictures }: CardChallengeType) => pictures.map(preloadImage)) |
49 | 82 |
|
50 | 83 | $: alternativeChallenges =
|
51 | 84 | currentChallenge &&
|
52 | 85 | rawChallenges.filter(({ id }) => id !== currentChallenge.id)
|
53 | 86 |
|
54 |
| - $: registerResult = (isCorrect) => { |
| 87 | + $: registerResult = (isCorrect: boolean) => { |
55 | 88 | if (isCorrect) {
|
56 | 89 | stats.correct++
|
57 | 90 | skipAllChallenges = skipAllChallengesFunc
|
|
0 commit comments