shufle order

This commit is contained in:
gitea
2026-01-31 00:32:48 +01:00
parent 2ea573642d
commit 7ab2eb2ba4
15 changed files with 427 additions and 161 deletions
@@ -68,9 +68,15 @@ class AttemptService {
final answerResults = <AnswerResult>[];
final updatedQuestions = <Question>[];
// Process each question in the attempt
for (final question in attempt.questions) {
final userAnswer = answers[question.id];
// Process each question in the attempt.
// Use the deck's current question state (not the attempt snapshot) so that
// manual "mark as known" during the attempt is preserved when applying results.
for (final questionInAttempt in attempt.questions) {
final currentQuestion = deck.questions
.where((q) => q.id == questionInAttempt.id)
.firstOrNull ?? questionInAttempt;
final userAnswer = answers[currentQuestion.id];
if (userAnswer == null) {
// Question not answered, treat as incorrect
continue;
@@ -89,28 +95,28 @@ class AttemptService {
// Check if answer is correct
// For multiple correct answers: user must select all correct answers and no incorrect ones
final correctIndices = question.correctIndices;
final correctIndices = currentQuestion.correctIndices;
final userSet = userAnswerIndices.toSet();
final correctSet = correctIndices.toSet();
final isCorrect = userSet.length == correctSet.length &&
final isCorrect = userSet.length == correctSet.length &&
userSet.every((idx) => correctSet.contains(idx));
final userMarkedNeedsPractice = overrides[question.id] ?? false;
final userMarkedNeedsPractice = overrides[currentQuestion.id] ?? false;
// Determine status change
final oldIsKnown = question.isKnown;
final oldStreak = question.consecutiveCorrect;
// Determine status change (from current deck state)
final oldIsKnown = currentQuestion.isKnown;
final oldStreak = currentQuestion.consecutiveCorrect;
// Update question
// Update question from current deck state so manual marks are preserved
final updated = userMarkedNeedsPractice
? DeckService.updateQuestionWithManualOverride(
question: question,
question: currentQuestion,
isCorrect: isCorrect,
userMarkedNeedsPractice: true,
config: deck.config,
currentAttemptIndex: deck.currentAttemptIndex,
)
: DeckService.updateQuestionAfterAnswer(
question: question,
question: currentQuestion,
isCorrect: isCorrect,
config: deck.config,
currentAttemptIndex: deck.currentAttemptIndex,