Skip to content

Commit

Permalink
fix: enforce images are present in all skills
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Nov 3, 2023
1 parent 4287619 commit 4b59830
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ New words:
Translation: the woman
Also accepted:
- the female
Images:
- man1
- man2
- man3

Phrases:
- Phrase: La femme dit bonjour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@
},
{
"formInTargetLanguage": "la femme",
"group": "2729f22db5bf",
"id": "bd13dcfe4d22",
"group": "1c08a1db48bf",
"id": "38734148215a",
"meaningInSourceLanguage": "the woman",
"pictures": None,
"pictures": ["man1.jpg", "man2.jpg", "man3.jpg"],
"priority": 0,
"type": "cards",
},
{
"formInTargetLanguage": ["la femme", "la dame"],
"group": "2729f22db5bf",
"id": "19a877a0955d",
"group": "1c08a1db48bf",
"id": "1f9d7215444b",
"phrase": [
{
"definition": """la
Expand All @@ -198,15 +198,15 @@
},
{"definition": "femme", "word": "woman"},
],
"pictures": None,
"pictures": ["man1.jpg", "man2.jpg", "man3.jpg"],
"priority": 1,
"type": "shortInput",
},
{
"answer": "la femme",
"audio": "cabd9d1b9cae7227bd640f6ec302ea9ce0c551e7f94d23a7ff843ced6846c7da",
"group": "2729f22db5bf",
"id": "f91de23ae173",
"group": "1c08a1db48bf",
"id": "0f716658c347",
"meaning": "the woman",
"priority": 1,
"type": "listeningExercise",
Expand Down
7 changes: 5 additions & 2 deletions apps/librelingo_yaml_loader/librelingo_yaml_loader/skill.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@
"type": "array",
"items": {
"type": "string"
}
},
"minItems": 3,
"maxItems": 3
}
},
"required": [
"Word",
"Translation"
"Translation",
"Images"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ New words:
Translation: the woman
Also accepted:
- the female
Images:
- man1
- man2
- man3

Phrases:
- Phrase: La femme dit bonjour
Expand Down
12 changes: 11 additions & 1 deletion apps/librelingo_yaml_loader/tests/test_yaml_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def test_load_course_output_matches_value(fs):
Word(
in_target_language=["la femme", "la dame"],
in_source_language=["the woman", "the female"],
pictures=None,
pictures=["man1", "man2", "man3"],
),
]
assert result.special_characters == [
Expand Down Expand Up @@ -871,6 +871,11 @@ def test_load_skill_complains_about_misspelled_word_in_source_language(load_yaml
{
"Translation": fake_word_value,
"Word": "ola",
"Images": [
"hello1",
"hello2",
"hello3",
],
}
],
}
Expand Down Expand Up @@ -905,6 +910,11 @@ def test_load_skill_complains_about_misspelled_word_in_target_language(load_yaml
{
"Translation": "le asd",
"Word": fake_word_value,
"Images": [
"hello1",
"hello2",
"hello3",
],
}
],
}
Expand Down
10 changes: 7 additions & 3 deletions apps/web/src/components/ChallengeScreen.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@
new Image().src = `images/${imageName}`
}

challenges
.filter(({ type }) => type === "cards")
.map(({ pictures }: CardChallengeType) => pictures.map(preloadImage))
challenges &&
challenges
.filter(({ type }) => type === "cards")
.map(
({ pictures }: CardChallengeType) =>
pictures && pictures.map(preloadImage)
)

$: alternativeChallenges =
currentChallenge &&
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ indent-string=' '
max-line-length=100

# Maximum number of lines in a module.
max-module-lines=1000
max-module-lines=1010

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
Expand Down

0 comments on commit 4b59830

Please sign in to comment.