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 { class PracticeActivityModel {
// deprecated in favor of targetTokens
final List<ConstructIdentifier> tgtConstructs; final List<ConstructIdentifier> tgtConstructs;
// being added after creation from request info
// TODO - replace tgtConstructs with targetTokens in server return
List<PangeaToken>? targetTokens; List<PangeaToken>? targetTokens;
final String langCode; final String langCode;

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

Loading…
Cancel
Save