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
@@ -76,6 +76,20 @@ class Deck {
return (knownCount / questions.length) * 100.0;
}
/// Progress percentage including partial credit: each question contributes
/// 1.0 if known, otherwise (consecutiveCorrect / requiredConsecutiveCorrect)
/// capped at 1.0. Averaged over all questions * 100.
double get progressPercentage {
if (questions.isEmpty) return 0.0;
final required = config.requiredConsecutiveCorrect;
final sum = questions.fold<double>(0.0, (sum, q) {
if (q.isKnown) return sum + 1.0;
final partial = (q.consecutiveCorrect / required).clamp(0.0, 1.0);
return sum + partial;
});
return (sum / questions.length) * 100.0;
}
/// Number of completed attempts.
int get attemptCount => attemptHistory.length;
@@ -19,6 +19,10 @@ class DeckConfig {
/// If false, known questions will be excluded from attempts.
final bool includeKnownInAttempts;
/// Whether to shuffle answer order for each question in an attempt.
/// When true, answer options appear in random order each attempt.
final bool shuffleAnswerOrder;
/// Optional time limit for attempts in seconds.
/// If null, no time limit is enforced.
final int? timeLimitSeconds;
@@ -30,6 +34,7 @@ class DeckConfig {
this.priorityDecreaseOnCorrect = 2,
this.immediateFeedbackEnabled = true,
this.includeKnownInAttempts = false,
this.shuffleAnswerOrder = true,
this.timeLimitSeconds,
});
@@ -41,6 +46,7 @@ class DeckConfig {
int? priorityDecreaseOnCorrect,
bool? immediateFeedbackEnabled,
bool? includeKnownInAttempts,
bool? shuffleAnswerOrder,
int? timeLimitSeconds,
}) {
return DeckConfig(
@@ -55,6 +61,7 @@ class DeckConfig {
immediateFeedbackEnabled ?? this.immediateFeedbackEnabled,
includeKnownInAttempts:
includeKnownInAttempts ?? this.includeKnownInAttempts,
shuffleAnswerOrder: shuffleAnswerOrder ?? this.shuffleAnswerOrder,
timeLimitSeconds: timeLimitSeconds ?? this.timeLimitSeconds,
);
}
@@ -70,6 +77,7 @@ class DeckConfig {
priorityDecreaseOnCorrect == other.priorityDecreaseOnCorrect &&
immediateFeedbackEnabled == other.immediateFeedbackEnabled &&
includeKnownInAttempts == other.includeKnownInAttempts &&
shuffleAnswerOrder == other.shuffleAnswerOrder &&
timeLimitSeconds == other.timeLimitSeconds;
@override
@@ -80,6 +88,7 @@ class DeckConfig {
priorityDecreaseOnCorrect.hashCode ^
immediateFeedbackEnabled.hashCode ^
includeKnownInAttempts.hashCode ^
shuffleAnswerOrder.hashCode ^
(timeLimitSeconds?.hashCode ?? 0);
}