startTest method

Future<void> startTest()

Implementation

Future<void> startTest() async {
  widget.eventLogger.instructionEnded();
  widget.eventLogger.testStarted();
  setState(() {
    activityStatus = ActivityStatus.Test;
  });
  await Future<dynamic>.delayed(const Duration(seconds: 2));
  for (String letter in mocaLetterList) {
    if (!mounted) break;
    await player
        .setAsset('../packages/cognition_package/assets/sounds/$letter.mp3');
    await player.play();

    updateLetter(letter);
    await Future<dynamic>.delayed(const Duration(milliseconds: 1000));
    if (letterIndex < 29) letterIndex += 1;
  }
  updateLetter('');
  if (mounted) {
    int score = errors < 2 ? 1 : 0;
    widget.onResultChange({'amount of errors': errors, 'score': score});
    widget.eventLogger.testEnded();
    if (widget.activity.includeResults) {
      widget.eventLogger.resultsShown();
      setState(() {
        activityStatus = ActivityStatus.Result;
      });
    }
  }
}