Skip to content

feat(TeacherPresentation): Add event logging - #2361

Merged
breity merged 6 commits into
developfrom
feat/teacher-presentation-events
Oct 26, 2026
Merged

breity merged 6 commits into
developfrom
feat/teacher-presentation-events

Conversation

@hirokiterashima

Copy link
Copy Markdown
Member

Description

This PR adds event logging for teacher interactions with the newly introduced Teacher Presentation and Ideas Summary displays in the Classroom Monitor. These logs enable researchers to study how teachers navigate, curate, and orchestrate whole-class discussions and review student ideas.

In addition, this PR fixes an issue where periodId and componentType were not being populated on teacher event rows in the database.


Key Changes

  1. Teacher Data Service (TeacherDataService)

    • Included periodId: this.getCurrentPeriodId() and componentType in saveEvent() payload so that events are attributed with the active class period and target component type.
    • Added safe optional chaining in getCurrentPeriodId() (this.currentPeriod?.periodId).
  2. Component Summary Expansion (ComponentSummaryComponent)

    • Logs LargeSummaryViewOpened when the maximize button is clicked on summary cards.
    • Logs LargeSummaryViewClosed with durationMs when the expanded dialog is closed.
  3. Teacher Presentation View (TeacherPresentationButtonComponent)

    • Injected TeacherDataService to track presentation launches.
    • Added getSelectionCounts() to calculate selection counts appropriately based on presentation type:
      • Ideas: counts totalIdeasSelected and totalResponsesSelected.
      • Discussion: counts totalResponsesSelected (selected posts/comments).
    • Logs TeacherPresentationOpened with the active periodId and selection counts.
    • Logs TeacherPresentationClosed with periodId and durationMs upon dialog closure.
  4. Ideas Summary Interactions (IdeasSummaryComponent)

    • Row Toggling: Logs IdeasSummaryRowToggled when an idea category row is expanded or collapsed, including ideaId, expanded, studentCount, and isUnique.
    • Sorting: Logs IdeasSummarySortChanged with column and direction (asc / desc) when sorting by idea text or student count.
    • Search Filtering: Logs IdeasSummaryFilterChanged with query and resultCount using a 2-second debounce to prevent network request spamming during typing.
    • Implemented OnDestroy to clean up RxJS subscriptions.

Events Summary

All events are recorded via TeacherDataService.saveEvent(context, nodeId, componentId, componentType, category, eventName, data):

Event Name Category Context / Trigger Sample data Payload
TeacherPresentationOpened 'TeacherPresentation' Presentation button clicked { periodId: 1, totalIdeasSelected: 2, totalResponsesSelected: 5 } (Ideas)
{ periodId: 1, totalResponsesSelected: 3 } (Discussion)
TeacherPresentationClosed 'TeacherPresentation' Presentation dialog closed { periodId: 1, durationMs: 142000 }
LargeSummaryViewOpened 'TeacherSummary' Maximize summary button clicked { type: 'ideas' }
LargeSummaryViewClosed 'TeacherSummary' Large summary dialog closed { type: 'ideas', durationMs: 45000 }
IdeasSummaryRowToggled 'TeacherSummary' Idea row expanded or collapsed { ideaId: 'idea_1', expanded: true, studentCount: 6, isUnique: false }
IdeasSummarySortChanged 'TeacherSummary' Column header clicked for sorting { column: 'count', direction: 'desc' }
IdeasSummaryFilterChanged 'TeacherSummary' Search filter input applied { query: 'energy', resultCount: 3 }

Manual Tests

  • Verify the above events are saved in the database

Automated Testing

  • Updated and added unit test suites covering the new event emissions:
    • component-summary.component.spec.ts: Verifies LargeSummaryViewOpened and LargeSummaryViewClosed with durationMs.
    • teacher-presentation-button.component.spec.ts: Verifies TeacherPresentationOpened (for both Ideas and Discussion selection counts) and TeacherPresentationClosed.
    • ideas-summary.component.spec.ts: Verifies IdeasSummaryRowToggled, IdeasSummarySortChanged, and debounced IdeasSummaryFilterChanged.

@qltysh

qltysh Bot commented Oct 22, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

Unable to calculate total coverage change because base branch coverage was not found.

Modified Files with Diff Coverage (3)

RatingFile% DiffUncovered Line #s
New file Coverage rating: A
...acher-summary-display/ideas-summary/ideas-summary.component.ts87.0%154-157
New file Coverage rating: A
...r-presentation-button/teacher-presentation-button.component.ts88.9%90
New file Coverage rating: D
...torComponents/component-summary/component-summary.component.ts50.0%213-214
Total83.3%
🤖 Increase coverage with AI coding...
In the `feat/teacher-presentation-events` branch, add test coverage for this new code:

- `src/assets/wise5/classroomMonitor/classroomMonitorComponents/component-summary/component-summary.component.ts` -- Line 213-214
- `src/assets/wise5/directives/teacher-summary-display/ideas-summary/ideas-summary.component.ts` -- Line 154-157
- `src/assets/wise5/teacher-presentation/teacher-presentation-button/teacher-presentation-button.component.ts` -- Line 90

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@hirokiterashima hirokiterashima added the enhancement New feature of any size or improvement (UI, performance, security) label Oct 22, 2026

@breity breity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍

@breity
breity merged commit a04bc64 into develop Oct 26, 2026
4 checks passed
@breity
breity deleted the feat/teacher-presentation-events branch October 26, 2026 20:53
@hirokiterashima

Copy link
Copy Markdown
Member Author

🎉 This PR is included in version 5.249.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature of any size or improvement (UI, performance, security) released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants