The outline tab's course end and certificate status alerts ignore the learner's time zone preference

Open
#2,253 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, react
Domain
frontend

Research direction

Start with useCourseEndAlert and useCertificateStatusAlert in the outline tab, then compare their time zone reads with CourseDates.jsx and check how CertificateStatusAlert.jsx passes formatting arguments to its FormattedDate elements. The issue also describes the outline test suite and the relevant test cases to add. Done means both alerts use the course metadata time zone when present and the browser time zone when it is absent; the issue does not name the test file.

Written by the indexing model from the issue text.

Description

The outline tab's course end alert and certificate status alert ignore the learner's time zone preference. Their dates are formatted in the browser's time zone; every other date on the tab uses the preference. The cause is the one in #2148, which #2149 fixed for the sequence due dates.

Both versions of Learning are affected: the frontend-build and frontend-platform version under src/, and the frontend-base version under frontend-base/ on the frontend-base branch, where #2252 (open) ports the two alerts with the same reads.

[!NOTE]
This issue was written by Claude (Claude Code) and reviewed before posting.

Claude Plan

Mechanism

Read from the code at the linked commits; not reproduced in a browser.

  • Both alerts' hooks read userTimezone as a top-level key of the outline data: useCourseEndAlert and useCertificateStatusAlert. The outline data has no such key (normalizeCourseHomeOutline): the outline response carries user_timezone only inside dates_widget (outline/serializers.py, outline/views.py). So each hook puts undefined in its alert's payload.

  • Each alert builds its format arguments as userTimezone ? { timeZone: userTimezone } : {} (CourseEndAlert.jsx, CertificateStatusAlert.jsx), so its dates are formatted in the browser's time zone.

  • The reads were right until #606 (70e2aa02, 2021), which moved the tab's time zone reads to the course metadata. In these two hooks it took userTimezone out of the datesWidget nesting and left the read on the outline data, as it did in the read #2148 describes:

       const {
         datesWidget: {
           courseDateBlocks,
    -      userTimezone,
         },
    +    userTimezone,
       } = useModel('outline', courseId);
    
  • The certificate status alert has a second fault. It spreads the format arguments onto its FormattedMessage, which has no timeZone prop, and the two FormattedDate elements inside the message get none (CertificateStatusAlert.jsx). With a time zone in its payload, the alert would still format both dates in the browser's time zone. The spread has been there since #477 added the alert, so its dates have never used the preference.

Timeline

When Change Course end alert Certificate status alert
2020-08-03 #146 (314b82d0) adds the course end alert; its hook reads datesWidget.userTimezone from the outline model working not there yet
2021-06-10 #477 (fab2da45) adds the certificate status alert; its hook reads datesWidget.userTimezone too, and the component spreads the time zone onto its FormattedMessage working hook right, dates never get the time zone
2021-09-03 #606 (70e2aa02) moves the tab's time zone reads to the course metadata; in these two hooks it takes userTimezone out of the datesWidget nesting and leaves the read on the outline model broken from here hook broken too
2026-09-22 #2093 (218c9dfb), part of the Redux to React Query migration, swaps useModel('outline', courseId) for useOutlineTabData(courseId, { enabled: false }).data broken, same read broken, same read

The outline model had no top-level userTimezone after #606: the store snapshot at that commit carries it only under courseHomeMeta, and #606 removed user_timezone from the outline test factory.

Where it shows

  • Course end alert, shown to an enrolled learner in the 14 days before the course ends (hooks.js). In the last day it reads "This course is ending {timeRemaining} at {courseEndTime}.", a date, a time and a time zone abbreviation. Before that it reads "This course is ending {timeRemaining} on {courseEndDate}.", a date only.
  • Certificate status alert, in the "earned but not available" status: "This course ends on {courseEndDateFormatted}. Final grades and any earned certificates are scheduled to be available after {certificateAvailableDate}.", both dates only.
  • A date with no time differs between the two time zones only when they put the instant on different days.

Elsewhere on the tab

The other dates on the tab read userTimezone from the course metadata, which carries it (course_metadata/views.py, api.ts): the dates widget (CourseDates.jsx), the sequence due dates since #2149 (SequenceDueDate.tsx), the course start alert (CourseStartAlert.jsx) and the access expiration alert (hooks.ts).

#2148 said, from the code and not observed, that the course end alert shows the preference's time zone. It does not.

Fix

  • useCourseEndAlert and useCertificateStatusAlert read userTimezone from useCourseHomeMeta(courseId, { enabled: false }).data, as CourseDates.jsx does.
  • CertificateStatusAlert.jsx spreads the format arguments onto its two FormattedDate elements in place of the FormattedMessage.
  • Tests: the outline suite gains a case for each alert under a course metadata response whose user_timezone puts the alert's date on a different day than the browser's time zone does, asserting the date in the preference's time zone, as #2149's case does for a sequence due date.

Acceptance

  • With user_timezone in the course metadata response, the course end alert's date and time are formatted in that time zone
  • With user_timezone in the course metadata response, the certificate status alert's two dates are formatted in that time zone
  • With no user_timezone, both alerts format their dates in the browser's time zone, as today
Dominant language
JavaScript
Stars
71
Forks
341
Avg merge
4d 18h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openedx/frontend-app-learning

All issues in openedx/frontend-app-learning

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.