use filtered construct list and number of lemmas in learning analytics view
This commit is contained in:
parent
db6b7fa7a8
commit
662098ee4c
3 changed files with 17 additions and 13 deletions
|
|
@ -26,6 +26,10 @@ class ConstructListModel {
|
|||
/// All unique lemmas used in the construct events
|
||||
List<String> get lemmas => constructList.map((e) => e.lemma).toSet().toList();
|
||||
|
||||
/// All unique lemmas used in the construct events with non-zero points
|
||||
List<String> get lemmasWithPoints =>
|
||||
constructListWithPoints.map((e) => e.lemma).toSet().toList();
|
||||
|
||||
/// A map of lemmas to ConstructUses, each of which contains a lemma
|
||||
/// key = lemmma + constructType.string, value = ConstructUses
|
||||
void _buildConstructMap() {
|
||||
|
|
@ -72,6 +76,9 @@ class ConstructListModel {
|
|||
return _constructList!;
|
||||
}
|
||||
|
||||
List<ConstructUses> get constructListWithPoints =>
|
||||
constructList.where((constructUse) => constructUse.points > 0).toList();
|
||||
|
||||
get maxXPPerLemma {
|
||||
return type != null
|
||||
? type!.maxXPPerLemma
|
||||
|
|
|
|||
|
|
@ -16,11 +16,6 @@ class AnalyticsPopup extends StatelessWidget {
|
|||
super.key,
|
||||
});
|
||||
|
||||
// we just want to show the constructs that have points
|
||||
List<ConstructUses> get constructs => constructsModel.constructList
|
||||
.where((constructUse) => constructUse.points > 0)
|
||||
.toList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
|
|
@ -41,29 +36,31 @@ class AnalyticsPopup extends StatelessWidget {
|
|||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: constructs.isEmpty
|
||||
child: constructsModel.constructListWithPoints.isEmpty
|
||||
? Center(
|
||||
child: Text(L10n.of(context)!.noDataFound),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: constructs.length,
|
||||
itemCount: constructsModel.constructListWithPoints.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Tooltip(
|
||||
message:
|
||||
"${constructs[index].points} / ${constructsModel.maxXPPerLemma}",
|
||||
"${constructsModel.constructListWithPoints[index].points} / ${constructsModel.maxXPPerLemma}",
|
||||
child: ListTile(
|
||||
onTap: () {},
|
||||
title: Text(
|
||||
constructsModel.type == ConstructTypeEnum.morph
|
||||
? getGrammarCopy(
|
||||
constructsModel
|
||||
.constructList[index].lemma,
|
||||
.constructListWithPoints[index].lemma,
|
||||
context,
|
||||
)
|
||||
: constructs[index].lemma,
|
||||
: constructsModel
|
||||
.constructListWithPoints[index].lemma,
|
||||
),
|
||||
subtitle: LinearProgressIndicator(
|
||||
value: constructs[index].points /
|
||||
value: constructsModel
|
||||
.constructListWithPoints[index].points /
|
||||
constructsModel.maxXPPerLemma,
|
||||
minHeight: 20,
|
||||
borderRadius: const BorderRadius.all(
|
||||
|
|
|
|||
|
|
@ -111,9 +111,9 @@ class LearningProgressIndicatorsState
|
|||
int? getProgressPoints(ProgressIndicatorEnum indicator) {
|
||||
switch (indicator) {
|
||||
case ProgressIndicatorEnum.wordsUsed:
|
||||
return words?.lemmas.length;
|
||||
return words?.lemmasWithPoints.length;
|
||||
case ProgressIndicatorEnum.morphsUsed:
|
||||
return morphs?.lemmas.length;
|
||||
return morphs?.lemmasWithPoints.length;
|
||||
case ProgressIndicatorEnum.level:
|
||||
return level;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue