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

Aperta
#2,253 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, react
Ambito
frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
JavaScript
Stelle
71
Fork
341
Merge medio
4g 11h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openedx/frontend-app-learning

Tutte le issue di openedx/frontend-app-learning

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.