generate method

  1. @override
Future<QuestionRound> generate(
  1. NameNoteSpec spec,
  2. CourseFiles files,
  3. Random rng, {
  4. RoundTurn? turn,
})
override

Assíncrono porque alguns tipos leem um file: da pasta do curso. turn é a rodada na sessão (EX05: o play-score com keys: e cycle: escolhe o tom por ela); quem não usa, ignora.

Implementation

@override
Future<QuestionRound> generate(
  NameNoteSpec spec,
  CourseFiles files,
  Random rng, {
  RoundTurn? turn,
}) async {
  final notes = notesOf(spec.notes, rng, key: spec.key);
  final source = fromMusicXml(
    notesScore(notes, clef: spec.clef, key: spec.key),
  );
  final choices = spec.choices;
  return QuestionRound(
    [
      for (var i = 0; i < notes.length; i++)
        Question(
          answers: choices,
          correct: choices.indexOf(notes[i].step),
          highlightId: roundNoteId(i),
        ),
    ],
    scoreBytes: source.bytes,
    fileName: source.fileName,
  );
}