chore: shuffle practice tokens before selecting the ones to include (#4097)

This commit is contained in:
ggurdin 2025-09-23 09:40:21 -04:00 committed by GitHub
parent 2ca92dea87
commit c8e67a5c89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View file

@ -32,7 +32,7 @@ class PracticeMatchActivity {
final String choiceContent = matchEntry.value.firstWhere(
(element) => !usedForms.contains(element),
orElse: () => throw Exception(
"No unique form available for construct ${matchEntry.key}",
"No unique form available for construct ${matchEntry.key.form}",
),
);

View file

@ -160,10 +160,24 @@ class PracticeSelection {
return [];
}
final List<PangeaToken> activityTokens = [];
tokens.shuffle();
for (final t in tokens) {
if (activityTokens.length >= _maxQueueLength) {
break;
}
if (!activityTokens.any(
(token) =>
token.text.content.toLowerCase() == t.text.content.toLowerCase(),
)) {
activityTokens.add(t);
}
}
return [
PracticeTarget(
activityType: activityType,
tokens: tokens.take(_maxQueueLength).shuffled().toList(),
tokens: activityTokens,
userL2: _userL2,
),
];