Repository: fniessink/toisto (language: python)

Issue:
Hints are shown while not necessary or not shown when necessary
- [ ] Gender hint is unncessary:

```console
Translate into Finnish (male):
hij schreef
> hän kirjoitti
✅ Correct.

Translate into Finnish (male):
hij at
> hän söi
✅ Correct.
```

- [x] Country hint should be shown but is not:

```console
Listen and write in Finnish:
> Suomi
✅ Correct.
Meaning "Finland".
```

- [ ] Country hint should not be shown but is:

```console
Translate into Finnish (country):
Finland
> Suomi
✅ Correct.

Translate into Dutch (country):
Suomi
> Finland
✅ Correct.
```


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21fa9b5b..14f8292c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 ### Fixed
 
 - Fixed a few typo's.
+- Show notes for listening quizzes. Fixes [#351](https://github.com/fniessink/toisto/issues/351).
 
 ### Added
 
diff --git a/src/toisto/model/quiz/quiz.py b/src/toisto/model/quiz/quiz.py
index 11c45a9a..972a5a98 100644
--- a/src/toisto/model/quiz/quiz.py
+++ b/src/toisto/model/quiz/quiz.py
@@ -157,7 +157,7 @@ def is_blocked_by(self, quizzes: Quizzes) -> bool:
 
     def _instruction_note(self) -> str:
         """Return the instruction note, if applicable."""
-        note_applicable = self.question_language != self.answer_language or "answer" in self.quiz_types
+        note_applicable = self.question_language != self.answer_language or {"answer", "listen"} & set(self.quiz_types)
         instruction_note = self.notes[0] if self.notes else ""
         return f" ({instruction_note})" if (note_applicable and instruction_note) else ""
 


Test patch:
diff --git a/tests/toisto/model/quiz/test_quiz.py b/tests/toisto/model/quiz/test_quiz.py
index b3fe472e..e6c39044 100644
--- a/tests/toisto/model/quiz/test_quiz.py
+++ b/tests/toisto/model/quiz/test_quiz.py
@@ -129,13 +129,18 @@ def test_question_note_is_not_shown_when_question_and_answer_language_are_the_sa
         quiz = self.create_quiz(self.concept, "fi", "fi", "Hän on;female", ["He ovat"], "pluralize")
         self.assertEqual("Give the [underline]plural[/underline] in Finnish", quiz.instruction())
 
-    def test_question_note_is_shown_when_question_language_equals_answer_language_but_quiz_type_is_answer(self):
-        """Test that a note is not shown when the question and answer languages are the same."""
-        quiz = self.create_quiz(self.concept, "fi", "fi", "Onko hän Bob?", ["On", "Ei"], "answer")
-        self.assertEqual("Answer the question in Finnish", quiz.instruction())
+    def test_question_note_is_shown_when_question_language_equals_answer_language_and_quiz_type_is_listen(self):
+        """Test that a note is shown when the question and answer languages are the same and the quiz type is listen."""
+        quiz = self.create_quiz(self.concept, "fi", "fi", "Suomi;country", ["Finland"], "listen")
+        self.assertEqual("Listen and write in Finnish (country)", quiz.instruction())
+
+    def test_question_note_is_shown_when_question_language_equals_answer_language_and_quiz_type_is_answer(self):
+        """Test that a note is shown when the question and answer languages are the same and the quiz type is answer."""
+        quiz = self.create_quiz(self.concept, "fi", "fi", "Onko hän Bob?;positive or negative", ["On", "Ei"], "answer")
+        self.assertEqual("Answer the question in Finnish (positive or negative)", quiz.instruction())
 
     def test_question_note_is_ignored_in_answer(self):
-        """Test that a note can be added to the question."""
+        """Test that a note in the answer is ignored."""
         quiz = self.create_quiz(self.concept, "en", "nl", "Jij bent", ["You are;singular"])
         self.assertEqual("You are", quiz.answer)
         self.assertEqual(("You are",), quiz.answers)