changed messages since update back to 10, re-enabled getting tokens after accepting matching in IGC, and allowed saving of initial empty analytics event
This commit is contained in:
parent
c6d3f36805
commit
e6fa2b1b4b
5 changed files with 64 additions and 131 deletions
|
|
@ -186,7 +186,7 @@ class Choreographer {
|
|||
// this may be unnecessary now that tokens are not used
|
||||
// to allow click of words in the input field and we're getting this at the end
|
||||
// TODO - turn it off and tested that this is fine
|
||||
// igc.justGetTokensAndAddThemToIGCTextData();
|
||||
igc.justGetTokensAndAddThemToIGCTextData();
|
||||
|
||||
// we set editType to keyboard here because that is the default for it
|
||||
// and we want to make sure that the next change is treated as a keyboard change
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ import 'package:fluffychat/pangea/choreographer/controllers/span_data_controller
|
|||
import 'package:fluffychat/pangea/models/igc_text_data_model.dart';
|
||||
import 'package:fluffychat/pangea/models/pangea_match_model.dart';
|
||||
import 'package:fluffychat/pangea/repo/igc_repo.dart';
|
||||
import 'package:fluffychat/pangea/repo/tokens_repo.dart';
|
||||
import 'package:fluffychat/pangea/widgets/igc/span_card.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../models/span_card_model.dart';
|
||||
import '../../utils/error_handler.dart';
|
||||
|
|
@ -32,12 +34,6 @@ class IgcController {
|
|||
try {
|
||||
if (choreographer.currentText.isEmpty) return clear();
|
||||
|
||||
// the error spans are going to be reloaded, so clear the cache
|
||||
// @ggurdin: Why is this separate from the clear() call?
|
||||
// Also, if the spans are equal according the to the equals method, why not reuse the cached span data?
|
||||
// It seems this would save some calls if the user makes some tiny changes to the text that don't
|
||||
// change the matches at all.
|
||||
spanDataController.clearCache();
|
||||
debugPrint('getIGCTextData called with ${choreographer.currentText}');
|
||||
debugPrint(
|
||||
'getIGCTextData called with tokensOnly = $onlyTokensAndLanguageDetection',
|
||||
|
|
@ -87,61 +83,61 @@ class IgcController {
|
|||
}
|
||||
}
|
||||
|
||||
// Future<void> justGetTokensAndAddThemToIGCTextData() async {
|
||||
// try {
|
||||
// if (igcTextData == null) {
|
||||
// debugger(when: kDebugMode);
|
||||
// choreographer.getLanguageHelp();
|
||||
// return;
|
||||
// }
|
||||
// igcTextData!.loading = true;
|
||||
// choreographer.startLoading();
|
||||
// if (igcTextData!.originalInput != choreographer.textController.text) {
|
||||
// debugger(when: kDebugMode);
|
||||
// ErrorHandler.logError(
|
||||
// m: "igcTextData fullText does not match current text",
|
||||
// s: StackTrace.current,
|
||||
// data: igcTextData!.toJson(),
|
||||
// );
|
||||
// }
|
||||
Future<void> justGetTokensAndAddThemToIGCTextData() async {
|
||||
try {
|
||||
if (igcTextData == null) {
|
||||
debugger(when: kDebugMode);
|
||||
choreographer.getLanguageHelp();
|
||||
return;
|
||||
}
|
||||
igcTextData!.loading = true;
|
||||
choreographer.startLoading();
|
||||
if (igcTextData!.originalInput != choreographer.textController.text) {
|
||||
debugger(when: kDebugMode);
|
||||
ErrorHandler.logError(
|
||||
m: "igcTextData fullText does not match current text",
|
||||
s: StackTrace.current,
|
||||
data: igcTextData!.toJson(),
|
||||
);
|
||||
}
|
||||
|
||||
// if (choreographer.l1LangCode == null ||
|
||||
// choreographer.l2LangCode == null) {
|
||||
// debugger(when: kDebugMode);
|
||||
// ErrorHandler.logError(
|
||||
// m: "l1LangCode and/or l2LangCode is null",
|
||||
// s: StackTrace.current,
|
||||
// data: {
|
||||
// "l1LangCode": choreographer.l1LangCode,
|
||||
// "l2LangCode": choreographer.l2LangCode,
|
||||
// },
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
if (choreographer.l1LangCode == null ||
|
||||
choreographer.l2LangCode == null) {
|
||||
debugger(when: kDebugMode);
|
||||
ErrorHandler.logError(
|
||||
m: "l1LangCode and/or l2LangCode is null",
|
||||
s: StackTrace.current,
|
||||
data: {
|
||||
"l1LangCode": choreographer.l1LangCode,
|
||||
"l2LangCode": choreographer.l2LangCode,
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// final TokensResponseModel res = await TokensRepo.tokenize(
|
||||
// await choreographer.pangeaController.userController.accessToken,
|
||||
// TokensRequestModel(
|
||||
// fullText: igcTextData!.originalInput,
|
||||
// userL1: choreographer.l1LangCode!,
|
||||
// userL2: choreographer.l2LangCode!,
|
||||
// ),
|
||||
// );
|
||||
// igcTextData?.tokens = res.tokens;
|
||||
// } catch (err, stack) {
|
||||
// debugger(when: kDebugMode);
|
||||
// choreographer.errorService.setError(
|
||||
// ChoreoError(type: ChoreoErrorType.unknown, raw: err),
|
||||
// );
|
||||
// Sentry.addBreadcrumb(
|
||||
// Breadcrumb.fromJson({"igctextDdata": igcTextData?.toJson()}),
|
||||
// );
|
||||
// ErrorHandler.logError(e: err, s: stack);
|
||||
// } finally {
|
||||
// igcTextData?.loading = false;
|
||||
// choreographer.stopLoading();
|
||||
// }
|
||||
// }
|
||||
final TokensResponseModel res = await TokensRepo.tokenize(
|
||||
await choreographer.pangeaController.userController.accessToken,
|
||||
TokensRequestModel(
|
||||
fullText: igcTextData!.originalInput,
|
||||
userL1: choreographer.l1LangCode!,
|
||||
userL2: choreographer.l2LangCode!,
|
||||
),
|
||||
);
|
||||
igcTextData?.tokens = res.tokens;
|
||||
} catch (err, stack) {
|
||||
debugger(when: kDebugMode);
|
||||
choreographer.errorService.setError(
|
||||
ChoreoError(type: ChoreoErrorType.unknown, raw: err),
|
||||
);
|
||||
Sentry.addBreadcrumb(
|
||||
Breadcrumb.fromJson({"igctextDdata": igcTextData?.toJson()}),
|
||||
);
|
||||
ErrorHandler.logError(e: err, s: stack);
|
||||
} finally {
|
||||
igcTextData?.loading = false;
|
||||
choreographer.stopLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void showFirstMatch(BuildContext context) {
|
||||
if (igcTextData == null || igcTextData!.matches.isEmpty) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class MyAnalyticsController {
|
|||
|
||||
/// the max number of messages that will be cached before
|
||||
/// an automatic update is triggered
|
||||
final int _maxMessagesCached = 1;
|
||||
final int _maxMessagesCached = 10;
|
||||
|
||||
/// the number of minutes before an automatic update is triggered
|
||||
final int _minutesBeforeUpdate = 5;
|
||||
|
|
@ -315,8 +315,10 @@ class MyAnalyticsController {
|
|||
// (allRecentMessages.isNotEmpty || recentActivityRecords.isNotEmpty),
|
||||
// );
|
||||
|
||||
await analyticsRoom.sendConstructsEvent(
|
||||
recentConstructUses,
|
||||
);
|
||||
if (recentConstructUses.isNotEmpty) {
|
||||
await analyticsRoom.sendConstructsEvent(
|
||||
recentConstructUses,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,8 +253,6 @@ extension AnalyticsRoomExtension on Room {
|
|||
Future<String?> sendSummaryAnalyticsEvent(
|
||||
List<RecentMessageRecord> records,
|
||||
) async {
|
||||
if (records.isEmpty) return null;
|
||||
|
||||
final SummaryAnalyticsModel analyticsModel = SummaryAnalyticsModel(
|
||||
messages: records,
|
||||
);
|
||||
|
|
@ -268,7 +266,6 @@ extension AnalyticsRoomExtension on Room {
|
|||
Future<String?> sendConstructsEvent(
|
||||
List<OneConstructUse> uses,
|
||||
) async {
|
||||
if (uses.isEmpty) return null;
|
||||
final ConstructAnalyticsModel constructsModel = ConstructAnalyticsModel(
|
||||
uses: uses,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import 'package:fluffychat/pangea/enum/activity_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/practice_activity_event.dart';
|
||||
import 'package:fluffychat/pangea/matrix_event_wrappers/practice_activity_record_event.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_record_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/practice_activity/multiple_choice_activity.dart';
|
||||
import 'package:fluffychat/pangea/widgets/practice_activity/practice_activity_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -18,70 +16,10 @@ class PracticeActivity extends StatefulWidget {
|
|||
});
|
||||
|
||||
@override
|
||||
MessagePracticeActivityContentState createState() =>
|
||||
MessagePracticeActivityContentState();
|
||||
PracticeActivityContentState createState() => PracticeActivityContentState();
|
||||
}
|
||||
|
||||
class MessagePracticeActivityContentState extends State<PracticeActivity> {
|
||||
int? selectedChoiceIndex;
|
||||
PracticeActivityRecordModel? recordModel;
|
||||
bool recordSubmittedThisSession = false;
|
||||
bool recordSubmittedPreviousSession = false;
|
||||
|
||||
PracticeActivityEvent get practiceEvent => widget.practiceEvent;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initalizeActivity();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant PracticeActivity oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.practiceEvent.event.eventId !=
|
||||
widget.practiceEvent.event.eventId) {
|
||||
initalizeActivity();
|
||||
}
|
||||
}
|
||||
|
||||
void initalizeActivity() {
|
||||
final PracticeActivityRecordEvent? recordEvent =
|
||||
widget.practiceEvent.userRecord;
|
||||
if (recordEvent?.record == null) {
|
||||
recordModel = PracticeActivityRecordModel(
|
||||
question:
|
||||
widget.practiceEvent.practiceActivity.multipleChoice!.question,
|
||||
);
|
||||
} else {
|
||||
recordModel = recordEvent!.record;
|
||||
|
||||
//Note that only MultipleChoice activities will have this so we probably should move this logic to the MultipleChoiceActivity widget
|
||||
selectedChoiceIndex = recordModel?.latestResponse?.text != null
|
||||
? widget.practiceEvent.practiceActivity.multipleChoice
|
||||
?.choiceIndex(recordModel!.latestResponse!.text!)
|
||||
: null;
|
||||
|
||||
recordSubmittedPreviousSession = true;
|
||||
recordSubmittedThisSession = true;
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void updateChoice(int index) {
|
||||
setState(() {
|
||||
selectedChoiceIndex = index;
|
||||
recordModel!.addResponse(
|
||||
score: widget.practiceEvent.practiceActivity.multipleChoice!
|
||||
.isCorrect(index)
|
||||
? 1
|
||||
: 0,
|
||||
text: widget
|
||||
.practiceEvent.practiceActivity.multipleChoice!.choices[index],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class PracticeActivityContentState extends State<PracticeActivity> {
|
||||
Widget get activityWidget {
|
||||
switch (widget.practiceEvent.practiceActivity.activityType) {
|
||||
case ActivityTypeEnum.multipleChoice:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue