You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.1 KiB
86 lines
3.1 KiB
/// Configuration for a practice deck.
|
|
class DeckConfig {
|
|
/// Number of consecutive correct answers required to mark a question as known.
|
|
final int requiredConsecutiveCorrect;
|
|
|
|
/// Default number of questions to include in an attempt.
|
|
final int defaultAttemptSize;
|
|
|
|
/// Priority points to add when a question is answered incorrectly.
|
|
final int priorityIncreaseOnIncorrect;
|
|
|
|
/// Priority points to subtract when a question is answered correctly.
|
|
final int priorityDecreaseOnCorrect;
|
|
|
|
/// Whether to provide immediate feedback after each answer.
|
|
final bool immediateFeedbackEnabled;
|
|
|
|
/// Whether to include known questions in attempts.
|
|
/// If false, known questions will be excluded from attempts.
|
|
final bool includeKnownInAttempts;
|
|
|
|
/// Optional time limit for attempts in seconds.
|
|
/// If null, no time limit is enforced.
|
|
final int? timeLimitSeconds;
|
|
|
|
const DeckConfig({
|
|
this.requiredConsecutiveCorrect = 3,
|
|
this.defaultAttemptSize = 10,
|
|
this.priorityIncreaseOnIncorrect = 5,
|
|
this.priorityDecreaseOnCorrect = 2,
|
|
this.immediateFeedbackEnabled = true,
|
|
this.includeKnownInAttempts = false,
|
|
this.timeLimitSeconds,
|
|
});
|
|
|
|
/// Creates a copy of this config with the given fields replaced.
|
|
DeckConfig copyWith({
|
|
int? requiredConsecutiveCorrect,
|
|
int? defaultAttemptSize,
|
|
int? priorityIncreaseOnIncorrect,
|
|
int? priorityDecreaseOnCorrect,
|
|
bool? immediateFeedbackEnabled,
|
|
bool? includeKnownInAttempts,
|
|
int? timeLimitSeconds,
|
|
}) {
|
|
return DeckConfig(
|
|
requiredConsecutiveCorrect:
|
|
requiredConsecutiveCorrect ?? this.requiredConsecutiveCorrect,
|
|
defaultAttemptSize: defaultAttemptSize ?? this.defaultAttemptSize,
|
|
priorityIncreaseOnIncorrect:
|
|
priorityIncreaseOnIncorrect ?? this.priorityIncreaseOnIncorrect,
|
|
priorityDecreaseOnCorrect:
|
|
priorityDecreaseOnCorrect ?? this.priorityDecreaseOnCorrect,
|
|
immediateFeedbackEnabled:
|
|
immediateFeedbackEnabled ?? this.immediateFeedbackEnabled,
|
|
includeKnownInAttempts:
|
|
includeKnownInAttempts ?? this.includeKnownInAttempts,
|
|
timeLimitSeconds: timeLimitSeconds ?? this.timeLimitSeconds,
|
|
);
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is DeckConfig &&
|
|
runtimeType == other.runtimeType &&
|
|
requiredConsecutiveCorrect == other.requiredConsecutiveCorrect &&
|
|
defaultAttemptSize == other.defaultAttemptSize &&
|
|
priorityIncreaseOnIncorrect == other.priorityIncreaseOnIncorrect &&
|
|
priorityDecreaseOnCorrect == other.priorityDecreaseOnCorrect &&
|
|
immediateFeedbackEnabled == other.immediateFeedbackEnabled &&
|
|
includeKnownInAttempts == other.includeKnownInAttempts &&
|
|
timeLimitSeconds == other.timeLimitSeconds;
|
|
|
|
@override
|
|
int get hashCode =>
|
|
requiredConsecutiveCorrect.hashCode ^
|
|
defaultAttemptSize.hashCode ^
|
|
priorityIncreaseOnIncorrect.hashCode ^
|
|
priorityDecreaseOnCorrect.hashCode ^
|
|
immediateFeedbackEnabled.hashCode ^
|
|
includeKnownInAttempts.hashCode ^
|
|
(timeLimitSeconds?.hashCode ?? 0);
|
|
}
|
|
|