questionOf function

Question questionOf(
  1. TheoryCard card,
  2. TheoryTopic topic
)

A pergunta da rodada, do cartão card do tópico topic.

Implementation

Question questionOf(TheoryCard card, TheoryTopic topic) {
  final chordOptions =
      card.options.isNotEmpty && card.options.every((o) => o.chord != null);
  // A partitura da pergunta vai como MusicXML (o `round.musicxml` da rodada).
  final score = card.score;
  final scoreBytes = score == null
      ? null
      : Uint8List.fromList(utf8.encode(score));
  return Question(
    prompt: card.prompt,
    answers: [for (final option in card.options) option.label],
    correct: card.correct,
    expectedPitch: card.pitch,
    anyOctave: card.pitch != null,
    playChord: card.playChord,
    chords: card.chords,
    answerChords: chordOptions
        ? [for (final option in card.options) option.chord!]
        : const [],
    explanation: card.explanation,
    scoreBytes: scoreBytes,
    scoreFileName: scoreBytes == null ? null : 'round.musicxml',
    topic: topic.wire,
  );
}