chanind / hanzi-writer

Chinese character stroke order animations and practice quizzes
https://hanziwriter.org
MIT License
3.57k stars 557 forks source link

feat: add onCancel option to quizzes #316

Open vherrmann opened 6 months ago

vherrmann commented 6 months ago

With this pr I want to add the callback onCancel to the options of quiz objects. This callback is executed whenever the quiz is cancelled. I gave it the same type as onComplete:

  onCancel?: (summary: { character: string; totalMistakes: number }) => void;

All tests have passed on my machine.

codecov-commenter commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.42%. Comparing base (4ec4eda) to head (3de527f).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #316 +/- ## ========================================== + Coverage 96.41% 96.42% +0.01% ========================================== Files 32 32 Lines 1144 1148 +4 Branches 212 213 +1 ========================================== + Hits 1103 1107 +4 Misses 37 37 Partials 4 4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

vherrmann commented 6 months ago

I have just noticed that the even though quiz.cancel() is executed on animateCharacter it is not on e.g. showCharacter. Therefore this pr may not be that reasonable after all (since the feature would work in unexpected ways).