Skip to content

Commit 9c5c9ad

Browse files
fix(Ideas Summary): Count only the latest annotations toward students with idea tally
1 parent 6afc3d7 commit 9c5c9ad

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/assets/wise5/directives/teacher-summary-display/ideas-summary/ideas-summary.component.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,14 @@ function ngInit_OR_FilterByPeriod() {
227227
const ideas = generateIdeas(1);
228228
spyOn(TestBed.inject(AnnotationService), 'getAnnotationsByNodeIdComponentId').and.returnValue(
229229
[
230-
new Annotation({ periodId: 1, data: { ideas: ideas } } as any),
231-
new Annotation({ periodId: 2, data: { ideas: ideas } } as any)
230+
new Annotation({ periodId: 1, data: { ideas: ideas }, toWorkgroupId: 1 } as any),
231+
new Annotation({ periodId: 1, data: { ideas: ideas }, toWorkgroupId: 1 } as any),
232+
new Annotation({ periodId: 2, data: { ideas: ideas }, toWorkgroupId: 2 } as any)
232233
]
233234
);
234235
});
235236

236-
it('includes all annotations when period is "All Periods" (-1)', () => {
237+
it('includes all latest annotations for workgroups when period is "All Periods" (-1)', () => {
237238
component.periodId = -1;
238239
spyOn<any>(component, 'groupIdeas');
239240
component.ngOnInit();

src/assets/wise5/directives/teacher-summary-display/ideas-summary/ideas-summary.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,16 @@ export class IdeasSummaryComponent extends TeacherSummaryDisplayComponent {
6262
} else if (this.componentType === 'OpenResponse') {
6363
const annotations = this.annotationService
6464
.getAnnotationsByNodeIdComponentId(this.nodeId, this.componentId)
65-
.filter((annotation) => this.periodId === -1 || annotation.periodId === this.periodId);
65+
.filter((annotation) => this.periodId === -1 || annotation.periodId === this.periodId)
66+
.reduceRight(
67+
(latestAnnotations, annotation) =>
68+
latestAnnotations.some(
69+
(latestAnnotation) => latestAnnotation.toWorkgroupId === annotation.toWorkgroupId
70+
)
71+
? latestAnnotations
72+
: latestAnnotations.concat(annotation),
73+
[]
74+
);
6675
this.groupIdeas(new OpenResponseSummaryData(annotations, this.rubric));
6776
}
6877
}

0 commit comments

Comments
 (0)