Skip to content

feat(TeacherPresentation): Add API endpoints for config - #362

Open
hirokiterashima wants to merge 5 commits into
developfrom
feat/teacher-presentation
Open

hirokiterashima wants to merge 5 commits into
developfrom
feat/teacher-presentation

Conversation

@hirokiterashima

@hirokiterashima hirokiterashima commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Notes

If WISE-API doesn't start up for you, it might be a flyway database issue. (you might already have a V2 from reviewing email_verification, which has not been merged yet). Try removing the row from the flyway_schema_history table (delete from flyway_schema_history where version = 2;) and restart WISE-API.

Summary

Adds backend persistence and REST APIs for the TeacherPresentation feature. This allows teachers to configure and save which student work items (e.g. discussion posts and comments) should be presented to the classroom, configure student name display settings (show, hide, anonymize), and specify an optional customized presentation prompt for each run, period, and component.

(Note: Teacher reflection questions have been decoupled from this feature and will be implemented in a dedicated standalone feature branch).

Changes

1. Database Migration

  • V2__create_teacher_presentation_tables.sql:
    • Creates the teacher_presentation_config table:
      • Primary key: id (bigint auto-increment).
      • Foreign keys: runId references runs(id), periodId references `groups`(id), updatedByWorkgroupId references workgroups(id).
      • Unique key: (runId, periodId, nodeId, componentId).
      • Attributes: componentType (varchar), items (text storing JSON array of studentWorkIds), studentNamesDisplay (varchar, default 'hide'), prompt (text), createdAt and updatedAt.

2. Domain Model & Entities

  • Added org.wise.vle.domain.teacherpresentation.TeacherPresentationConfig:
    • JPA entity mapped to teacher_presentation_config.
    • Constants for NAMES_SHOW, NAMES_HIDE, and NAMES_ANONYMIZE.

3. DAO Layer

  • Added TeacherPresentationConfigDao and HibernateTeacherPresentationConfigDao:
    • getConfig(run, period, nodeId, componentId): Retrieves the saved presentation config for a given component and period.
    • Extends AbstractHibernateDao<TeacherPresentationConfig> for standard CRUD operations.

4. Service Layer

  • Added TeacherPresentationConfigService and TeacherPresentationConfigServiceImpl:
    • getConfig(...): Fetches presentation configuration.
    • getStudentWorkIds(config): Deserializes the JSON items array into student work IDs.
    • saveConfig(...): Validates input parameters (validates studentNamesDisplay, prompt length <= 1000, max 500 items, and verifies all studentWorkIds belong to the target run and period), deduplicates IDs, and persists configuration with the teacher's workgroup and timestamp.

5. Controller & REST Endpoints

  • Added TeacherPresentationConfigAPIController (/api/teacher/presentation-config):
    • Requires ROLE_TEACHER and verifies teacher permissions against the run.
    • GET /api/teacher/presentation-config: Fetches presentation config for runId, periodId, nodeId, and componentId. Returns default values (studentNamesDisplay: 'hide', empty items) if none has been saved yet.
    • PUT /api/teacher/presentation-config: Saves or updates presentation config.

Testing & Verification

  • Unit & integration tests added with 100% passing coverage:
    • HibernateTeacherPresentationConfigDaoTest: Verifies persistence, unique key constraints, retrieval, and deletion.
    • TeacherPresentationConfigServiceImplTest: Verifies validation (max items, prompt length, invalid student names display, cross-period/cross-run student work validation, item deduplication, and defaults).
    • TeacherPresentationConfigAPIControllerTest: Verifies authorization, permission checks, bad request handling, and response serialization.
  • Maven test run: ./mvnw test -Dtest="TeacherPresentation*Test" -> 17 tests run, 0 failures, 0 errors.

How to Test

Test with WISE-Community/WISE-Client#2351. See testing instructions there.

Database migration should occur automatically (via Flyway) when you restart WISE-API.

@hirokiterashima hirokiterashima changed the title feat(TeacherPresentation): Add API endpoints for config and reflections feat(TeacherPresentation): Add API endpoints for config Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant