1485-too-many-points-for-lemma-meaning-activity (#1490)

* fix(activity scoring): only give points for lemma in meaning activity

* fix: dart formatting

---------

Co-authored-by: ggurdin <ggurdin@gmail.com>
Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
pull/1593/head
wcjord 10 months ago committed by GitHub
parent 5c04b37484
commit d8210a39fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -212,11 +212,8 @@ class PracticeActivityRequest {
}
class PracticeActivityModel {
// deprecated in favor of targetTokens
final List<ConstructIdentifier> tgtConstructs;
// being added after creation from request info
// TODO - replace tgtConstructs with targetTokens in server return
List<PangeaToken>? targetTokens;
final String langCode;

@ -171,45 +171,27 @@ class ActivityRecordResponse {
PracticeActivityModel practiceActivity,
ConstructUseMetaData metadata,
) {
if (practiceActivity.targetTokens == null ||
practiceActivity.targetTokens!.isEmpty) {
if (practiceActivity.tgtConstructs.isEmpty ||
practiceActivity.targetTokens == null) {
debugger();
return [];
}
if (practiceActivity.activityType == ActivityTypeEnum.emoji) {
final token = practiceActivity.targetTokens!.first;
// if the emoji is already set, don't give points
if (token.getEmoji() != null) return [];
return [
OneConstructUse(
lemma: token.lemma.text,
form: token.text.content,
constructType: ConstructTypeEnum.vocab,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: token.pos,
),
];
}
if (practiceActivity.activityType == ActivityTypeEnum.morphId) {
return practiceActivity.tgtConstructs
.map(
(token) => OneConstructUse(
lemma: token.lemma,
form: practiceActivity.targetTokens!.first.text.content,
constructType: ConstructTypeEnum.morph,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: token.category,
),
)
.toList();
// if the emoji is already set, don't give points
// IMPORTANT: This assumes that scoring is happening before saving of the user's emoji choice.
if (practiceActivity.activityType == ActivityTypeEnum.emoji &&
practiceActivity.targetTokens?.first.getEmoji() != null) {
return [];
}
final uses = practiceActivity.targetTokens!
.map(
(token) => OneConstructUse(
switch (practiceActivity.activityType) {
case ActivityTypeEnum.emoji:
case ActivityTypeEnum.wordMeaning:
case ActivityTypeEnum.wordFocusListening:
case ActivityTypeEnum.lemmaId:
final token = practiceActivity.targetTokens!.first;
return [
OneConstructUse(
lemma: token.lemma.text,
form: token.text.content,
constructType: ConstructTypeEnum.vocab,
@ -217,38 +199,34 @@ class ActivityRecordResponse {
metadata: metadata,
category: token.pos,
),
)
.toList();
uses.addAll(
practiceActivity.targetTokens!.map((token) {
return OneConstructUse(
lemma: token.pos,
form: token.text.content,
constructType: ConstructTypeEnum.morph,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: "POS",
);
}),
);
for (final token in practiceActivity.targetTokens!) {
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(
useType: useType(practiceActivity.activityType),
lemma: entry.value,
form: token.text.content,
category: entry.key,
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
);
}
];
case ActivityTypeEnum.hiddenWordListening:
return practiceActivity.targetTokens!
.map(
(token) => OneConstructUse(
lemma: token.lemma.text,
form: practiceActivity.targetTokens!.first.text.content,
constructType: ConstructTypeEnum.vocab,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: token.pos,
),
)
.toList();
case ActivityTypeEnum.morphId:
return practiceActivity.tgtConstructs
.map(
(c) => OneConstructUse(
lemma: c.lemma,
form: practiceActivity.targetTokens!.first.text.content,
constructType: c.type,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: c.category,
),
)
.toList();
}
return uses;
}
factory ActivityRecordResponse.fromJson(Map<String, dynamic> json) {

Loading…
Cancel
Save