Skip to content

Add a fixed course end date certificate variable - #51

Open
ottenhoff wants to merge 2 commits into
sakaicontrib:masterfrom
ottenhoff:feature/course-end-date-variable
Open

ottenhoff wants to merge 2 commits into
sakaicontrib:masterfrom
ottenhoff:feature/course-end-date-variable

Conversation

@ottenhoff

@ottenhoff ottenhoff commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Problem

The existing ${cert.date} value is recalculated from award criteria whenever a certificate is rendered. That means the printed date can move when a student earns or downloads the certificate after the course ends.

Solution

  • Add an optional, persisted date-only course end date to each certificate definition.
  • Expose the fixed value as ${cert.enddate} with locale-aware display formatting.
  • Keep ${cert.date} unchanged for backward compatibility.
  • Preserve the existing template-field select workflow; the new variable appears after an end date is configured.
  • Persist the value on both certificate creation and update.
  • Keep the database column nullable so existing certificate definitions continue to work.
  • Provide conversion/add-course-end-date.sql for installations with automatic database updates disabled.

Validation

  • Use a labeled native date input with associated help and error text.
  • Reject invalid dates during binding.
  • Allow an administrator to clear the date on step one and replace the existing mapping on step three in the same edit.
  • Validate the final date/mapping pair before the review screen.
  • Enforce the invariant again in service updates, field-mapping persistence, and activation so non-UI callers cannot store or activate ${cert.enddate} without a date.
  • Persist date and field mappings together during edits so the transition is atomic under the existing service transaction proxy.

Upgrade

For an existing database with automatic DDL disabled, apply:

ALTER TABLE certificate_definition ADD course_end_date DATE;

Tests

  • mvn clean package
  • 15 tests passed across the tool and implementation modules.
  • Hibernate/HSQL round-trip coverage verifies date and mapping persistence, valid remapping while clearing a date, invalid-update rollback, creation mapping validation, and defensive activation.
  • The conversion SQL was executed against an old-style HSQL table and verified to create a DATE column.

This is the typed, persistence-focused replacement for draft PR #50.

@ottenhoff

Copy link
Copy Markdown
Contributor Author

CI note: the workflow stopped during Maven project loading and never reached source compilation or tests because org.sakaiproject:master:pom:25-SNAPSHOT is unavailable from the configured Sonatype snapshots repository. With that parent already installed locally, mvn clean package succeeds and all 12 executed tests pass, including the 10 new regression tests in this PR.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant