chore: match vocab lemma irrespective of case, use static message in activity stats dropdown (#4205)
This commit is contained in:
parent
dabfb54ee8
commit
01b9059cbe
2 changed files with 6 additions and 43 deletions
|
|
@ -5298,5 +5298,6 @@
|
|||
"directMessageBotDesc": "Talking to humans is more fun but... AI is always ready!",
|
||||
"inviteYourFriends": "Invite your friends",
|
||||
"playWithAI": "Play with AI for now",
|
||||
"courseStartDesc": "Pangea Bot is ready to go anytime!\n\n...but learning is better with friends!"
|
||||
"courseStartDesc": "Pangea Bot is ready to go anytime!\n\n...but learning is better with friends!",
|
||||
"activityDropdownDesc": "When you’re done with this activity, click below"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,18 +62,9 @@ class ActivityStatsMenuState extends State<ActivityStatsMenu> {
|
|||
|
||||
Set<String>? get _usedVocab => analytics?.constructs[room.client.userID!]
|
||||
?.constructsOfType(ConstructTypeEnum.vocab)
|
||||
.map((id) => id.lemma)
|
||||
.map((id) => id.lemma.toLowerCase())
|
||||
.toSet();
|
||||
|
||||
double get _percentVocabComplete {
|
||||
final vocabList = room.activityPlan?.vocab.map((v) => v.lemma) ?? [];
|
||||
if (vocabList.isEmpty || _usedVocab == null) {
|
||||
return 0;
|
||||
}
|
||||
return _usedVocab!.intersection(vocabList.toSet()).length /
|
||||
vocabList.length;
|
||||
}
|
||||
|
||||
Future<void> _updateUsedVocab() async {
|
||||
final analytics = await room.getActivityAnalytics();
|
||||
if (mounted) {
|
||||
|
|
@ -139,7 +130,6 @@ class ActivityStatsMenuState extends State<ActivityStatsMenu> {
|
|||
final bool activityComplete = room.activityIsFinished;
|
||||
bool shouldShowEndForAll = true;
|
||||
bool shouldShowImDone = true;
|
||||
String message = "";
|
||||
|
||||
if (!room.isRoomAdmin) {
|
||||
shouldShowEndForAll = false;
|
||||
|
|
@ -154,34 +144,6 @@ class ActivityStatsMenuState extends State<ActivityStatsMenu> {
|
|||
//activity is finished, no buttons
|
||||
shouldShowImDone = false;
|
||||
shouldShowEndForAll = false;
|
||||
message = L10n.of(context).activityComplete;
|
||||
} else {
|
||||
//activity is ongoing
|
||||
if (_getCompletedRolesCount() == 0 ||
|
||||
(_getAssignedRolesCount() == 1) && (_isBotParticipant() == true)) {
|
||||
//IF nobodys done or you're only playing with the bot,
|
||||
//Then it should show tips about your progress and nudge you to continue/end
|
||||
if ((_percentVocabComplete < .7) && (_usedVocab?.length ?? 0) < 50) {
|
||||
message = L10n.of(context).haventChattedMuch;
|
||||
} else {
|
||||
message = L10n.of(context).haveChatted;
|
||||
}
|
||||
} else {
|
||||
//user is in group with other users OR someone has wrapped up
|
||||
if (userComplete) {
|
||||
//user is done but group is ongoing, no buttons
|
||||
message = L10n.of(context).userDoneAndWaiting(
|
||||
_getCompletedRolesCount(),
|
||||
_getAssignedRolesCount(),
|
||||
);
|
||||
} else {
|
||||
//user is not done, buttons are present
|
||||
message = L10n.of(context).othersDoneAndWaiting(
|
||||
_getCompletedRolesCount(),
|
||||
_getAssignedRolesCount(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Positioned(
|
||||
|
|
@ -237,8 +199,8 @@ class ActivityStatsMenuState extends State<ActivityStatsMenu> {
|
|||
vocab: v,
|
||||
langCode:
|
||||
room.activityPlan!.req.targetLanguage,
|
||||
isUsed:
|
||||
(_usedVocab ?? {}).contains(v.lemma),
|
||||
isUsed: (_usedVocab ?? {})
|
||||
.contains(v.lemma.toLowerCase()),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
@ -247,7 +209,7 @@ class ActivityStatsMenuState extends State<ActivityStatsMenu> {
|
|||
],
|
||||
),
|
||||
Text(
|
||||
message,
|
||||
L10n.of(context).activityDropdownDesc,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 16.0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue