1123 multiple options are highlighted and cant move to the next item (#1124)

* once user has selected correct choice, disable further interaction

* if not include tts on click, don't play tts on correct choice selected

* fix range error when logging warning about having multiple 'other' categories
pull/1544/head
ggurdin 11 months ago committed by GitHub
parent ceea63b3a2
commit 2397c8f78d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -60,11 +60,16 @@ class ChoicesArrayState extends State<ChoicesArray> {
} }
void enableInteractions() { void enableInteractions() {
if (_hasSelectedCorrectChoice) return;
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) setState(() => interactionDisabled = false); if (mounted) setState(() => interactionDisabled = false);
}); });
} }
bool get _hasSelectedCorrectChoice =>
widget.choices?.any((choice) => choice.isGold && choice.color != null) ??
false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);

@ -48,10 +48,14 @@ class ConstructListModel {
/// Given a list of new construct uses, update the map of construct /// Given a list of new construct uses, update the map of construct
/// IDs to ConstructUses and re-sort the list of ConstructUses /// IDs to ConstructUses and re-sort the list of ConstructUses
void updateConstructs(List<OneConstructUse> newUses) { void updateConstructs(List<OneConstructUse> newUses) {
try {
_updateConstructMap(newUses); _updateConstructMap(newUses);
_updateConstructList(); _updateConstructList();
_updateCategoriesToUses(); _updateCategoriesToUses();
_updateMetrics(); _updateMetrics();
} catch (err, s) {
ErrorHandler.logError(e: "Failed to update analytics: $err", s: s);
}
} }
int _sortConstructs(ConstructUses a, ConstructUses b) { int _sortConstructs(ConstructUses a, ConstructUses b) {
@ -126,12 +130,14 @@ class ConstructListModel {
ErrorHandler.logError( ErrorHandler.logError(
e: "More than one 'other' category in groupedByCategory", e: "More than one 'other' category in groupedByCategory",
data: { data: {
"others": others "others": others.map((entry) {
.map( List<String> useKeys =
(entry) => entry.value.map((uses) => uses.id.string).toList();
("${entry.key}: ${entry.value.map((uses) => uses.id.string).toList().sublist(0, 10)}"), if (useKeys.length > 10) {
) useKeys = useKeys.sublist(0, 10);
.toList(), }
("${entry.key}: $useKeys");
}).toList(),
}, },
); );
} }

@ -81,30 +81,30 @@ class MultipleChoiceActivityState extends State<MultipleChoiceActivity> {
final bool isCorrect = final bool isCorrect =
widget.currentActivity.content.isCorrect(value, index); widget.currentActivity.content.isCorrect(value, index);
// If the activity is not set to include TTS on click, and the choice is correct, speak the target tokens // // If the activity is not set to include TTS on click, and the choice is correct, speak the target tokens
// We have to check if tokens // // We have to check if tokens
if (!widget.currentActivity.activityType.includeTTSOnClick && // if (!widget.currentActivity.activityType.includeTTSOnClick &&
isCorrect && // isCorrect &&
mounted) { // mounted) {
// should be set by now but just in case we make a mistake // // should be set by now but just in case we make a mistake
if (widget.practiceCardController.currentActivity?.targetTokens == null) { // if (widget.practiceCardController.currentActivity?.targetTokens == null) {
debugger(when: kDebugMode); // debugger(when: kDebugMode);
ErrorHandler.logError( // ErrorHandler.logError(
e: "Missing target tokens in multiple choice activity", // e: "Missing target tokens in multiple choice activity",
data: { // data: {
"currentActivity": widget.practiceCardController.currentActivity, // "currentActivity": widget.practiceCardController.currentActivity,
}, // },
); // );
} else { // } else {
tts.tryToSpeak( // tts.tryToSpeak(
PangeaToken.reconstructText( // PangeaToken.reconstructText(
widget.practiceCardController.currentActivity!.targetTokens!, // widget.practiceCardController.currentActivity!.targetTokens!,
), // ),
context, // context,
null, // null,
); // );
} // }
} // }
if (currentRecordModel?.hasTextResponse(value) ?? false) { if (currentRecordModel?.hasTextResponse(value) ?? false) {
return; return;

Loading…
Cancel
Save