Skip to content
9 changes: 1 addition & 8 deletions app/lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,7 @@
},
"free_text_alphanumeric_error": "Bitte geben Sie nur alphanumerische Zeichen ein",
"free_text_numeric_error": "Bitte geben Sie nur numerische Zeichen ein",
"free_text_custom_error": "Bitte geben Sie nur Zeichen ein, die dem Muster {pattern} entsprechen",
"@free_text_custom_error": {
"placeholders": {
"pattern": {
"type": "String"
}
}
},
"free_text_custom_error": "Bitte geben Sie einen Wert im erforderlichen Format ein",
"app_outdated_message": "Eine neue Version der StudyU App ist verfügbar. Bitte führen Sie eine Aktualisierung durch, um die neuesten Funktionen und Verbesserungen zu erhalten. Vielen Dank für Ihre Unterstützung!",
"update_now": "Jetzt aktualisieren",

Expand Down
9 changes: 1 addition & 8 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,7 @@
},
"free_text_alphanumeric_error": "Please enter only alphanumeric characters",
"free_text_numeric_error": "Please enter only numeric characters",
"free_text_custom_error": "Please enter only characters matching the pattern {pattern}",
"@free_text_custom_error": {
"placeholders": {
"pattern": {
"type": "String"
}
}
},
"free_text_custom_error": "Please enter a value in the required format",
"app_outdated_message": "A new version of the StudyU App is available. Please update to get the latest features and improvements. Thank you for your support!",
"update_now": "Update now",

Expand Down
4 changes: 2 additions & 2 deletions app/lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1235,8 +1235,8 @@ abstract class AppLocalizations {
/// No description provided for @free_text_custom_error.
///
/// In en, this message translates to:
/// **'Please enter only characters matching the pattern {pattern}'**
String free_text_custom_error(String pattern);
/// **'Please enter a value in the required format'**
String get free_text_custom_error;

/// No description provided for @app_outdated_message.
///
Expand Down
6 changes: 2 additions & 4 deletions app/lib/l10n/app_localizations_de.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;

import 'app_localizations.dart';

// ignore_for_file: type=lint
Expand Down Expand Up @@ -639,9 +638,8 @@ class AppLocalizationsDe extends AppLocalizations {
'Bitte geben Sie nur numerische Zeichen ein';

@override
String free_text_custom_error(String pattern) {
return 'Bitte geben Sie nur Zeichen ein, die dem Muster $pattern entsprechen';
}
String get free_text_custom_error =>
'Bitte geben Sie einen Wert im erforderlichen Format ein';

@override
String get app_outdated_message =>
Expand Down
6 changes: 2 additions & 4 deletions app/lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;

import 'app_localizations.dart';

// ignore_for_file: type=lint
Expand Down Expand Up @@ -632,9 +631,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get free_text_numeric_error => 'Please enter only numeric characters';

@override
String free_text_custom_error(String pattern) {
return 'Please enter only characters matching the pattern $pattern';
}
String get free_text_custom_error =>
'Please enter a value in the required format';

@override
String get app_outdated_message =>
Expand Down
7 changes: 7 additions & 0 deletions app/lib/widgets/questionnaire/question_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import 'package:studyu_core/core.dart';

class QuestionContainer extends StatefulWidget {
final Function(Answer, int) onDone;
final Function(int)? onInvalid;
final Question question;
final int index;
final String? taskId;
final GlobalKey? containerKey;

const QuestionContainer({
required this.onDone,
this.onInvalid,
required this.question,
required this.index,
this.taskId,
Expand All @@ -40,6 +42,10 @@ class _QuestionContainerState extends State<QuestionContainer>
widget.onDone(answer, widget.index);
}

void _onInvalid() {
widget.onInvalid?.call(widget.index);
}

QuestionWidget getQuestionBody(BuildContext context) {
switch (widget.question) {
case final ChoiceQuestion choiceQuestion:
Expand Down Expand Up @@ -83,6 +89,7 @@ class _QuestionContainerState extends State<QuestionContainer>
return FreeTextQuestionWidget(
question: freeTextQuestion,
onDone: _onDone,
onInvalid: _onInvalid,
);
case final FitbitQuestion fitbitQuestion:
return FitbitQuestionWidget(
Expand Down
13 changes: 7 additions & 6 deletions app/lib/widgets/questionnaire/questionnaire_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class _QuestionnaireWidgetState extends State<QuestionnaireWidget> {
containerKey: containerKey,
question: question,
onDone: _onQuestionDone,
onInvalid: _onQuestionInvalid,
index: shownQuestions.length,
taskId: widget.taskId,
),
Expand Down Expand Up @@ -140,6 +141,12 @@ class _QuestionnaireWidgetState extends State<QuestionnaireWidget> {
}
}

void _onQuestionInvalid(int index) {
final questionId = shownQuestions[index].question.id;
qs.answers.remove(questionId);
_finishQuestionnaire(null);
}

void _onQuestionDone(Answer answer, int index) {
if (kDebugMode) {
debugPrint(
Expand All @@ -149,12 +156,6 @@ class _QuestionnaireWidgetState extends State<QuestionnaireWidget> {
qs.answers[answer.question] = answer;
final shouldContinue = widget.shouldContinue?.call(qs);

// Check if the questionnaire should not continue
if (shouldContinue == false) {
_finishQuestionnaire(qs);
return;
}

// Check if there are questions whose visibility depend on this question
final hasConditionalDependencies = _isConditionalTarget(answer.question);

Expand Down
Loading
Loading