tweaking criteria for determining existing activity
This commit is contained in:
parent
653ee5f75f
commit
51bff65a8b
3 changed files with 22 additions and 13 deletions
|
|
@ -27,19 +27,17 @@ class TargetTokensAndActivityType {
|
|||
return false;
|
||||
}
|
||||
|
||||
// check that the activity matches at least one construct in the target tokens
|
||||
// TODO - this is complicated so we need to verify it works
|
||||
// maybe we just verify that the target span of the activity is the same as the target span of the target
|
||||
final allTokenConstructs =
|
||||
tokens.map((t) => t.constructs).expand((e) => e).toList();
|
||||
for (final c in allTokenConstructs) {
|
||||
if (activity.tgtConstructs.any((tc) => tc == c.id)) {
|
||||
debugPrint('found existing activity');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// This is kind of complicated
|
||||
// if it's causing problems,
|
||||
// maybe we just verify that the target span of the activity is the same as the target span of the target?
|
||||
final List<ConstructIdentifier> allTokenConstructs = tokens
|
||||
.map((t) => t.constructs)
|
||||
.expand((e) => e)
|
||||
.map((c) => c.id)
|
||||
.where(activityType.constructFilter)
|
||||
.toList();
|
||||
|
||||
return false;
|
||||
return listEquals(activity.tgtConstructs, allTokenConstructs);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart';
|
||||
|
||||
enum ActivityTypeEnum { wordMeaning, wordFocusListening, hiddenWordListening }
|
||||
|
||||
|
|
@ -68,4 +70,14 @@ extension ActivityTypeExtension on ActivityTypeEnum {
|
|||
];
|
||||
}
|
||||
}
|
||||
|
||||
/// Filters out constructs that are not relevant to the activity type
|
||||
bool Function(ConstructIdentifier) get constructFilter {
|
||||
switch (this) {
|
||||
case ActivityTypeEnum.wordMeaning:
|
||||
case ActivityTypeEnum.wordFocusListening:
|
||||
case ActivityTypeEnum.hiddenWordListening:
|
||||
return (id) => id.type == ConstructTypeEnum.vocab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ class WordAudioButtonState extends State<WordAudioButton> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint('build WordAudioButton');
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.play_arrow_outlined),
|
||||
isSelected: _isPlaying,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue