diff --git a/package-lock.json b/package-lock.json index f1c0ee8..df5f8b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "siteforge", - "version": "2.11.1", + "version": "2.11.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "siteforge", - "version": "2.11.1", + "version": "2.11.2", "dependencies": { "@aws-sdk/client-s3": "^3.1135.0", "@dnd-kit/core": "^6.3.1", diff --git a/package.json b/package.json index c39a0b0..1b407fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "siteforge", "private": true, - "version": "2.11.1", + "version": "2.11.2", "type": "module", "scripts": { "dev": "vite", diff --git a/server/study-helpers.js b/server/study-helpers.js index e685148..d94c57b 100644 --- a/server/study-helpers.js +++ b/server/study-helpers.js @@ -225,17 +225,18 @@ export async function backfillCompletedStudies() { return updated } -// Discussion (community posts, replies, likes and lesson comments) is only open while a -// study is active. Finished and planned studies are closed. +// Discussion (community posts, replies, likes and lesson comments) is open for any study that +// has started: the current study and finished ones, so students who take a study later can +// still talk with each other. Only planned studies (not started yet) are closed. export function isStudyDiscussionOpen(studySlug) { const normalized = normalizeStudySlug(studySlug) const studies = state.cachedSiteContent?.studies if (!normalized || !Array.isArray(studies)) return false const study = studies.find(item => normalizeStudySlug(item?.slug) === normalized) - return Boolean(study) && getEffectiveStudyStatus(study) === 'active' + return Boolean(study) && getEffectiveStudyStatus(study) !== 'planned' } -export const DISCUSSION_CLOSED_MESSAGE = 'Discussion is only open while a study is active.' +export const DISCUSSION_CLOSED_MESSAGE = 'Discussion opens once this study has started.' export function findStudyUserById(userId) { if (typeof userId !== 'string' || !userId.trim()) return undefined diff --git a/src/studyPages.tsx b/src/studyPages.tsx index ad04070..c71daa1 100644 --- a/src/studyPages.tsx +++ b/src/studyPages.tsx @@ -212,9 +212,11 @@ function getEffectiveStudyStatus(study: StudyProgram): 'active' | 'planned' | 'c return 'active' } -// Discussion (community board and lesson comments) is only open while a study is active. +// Discussion (community board and lesson comments) is open for every study that has started, +// including finished ones, so students who take a study later can still join in. Planned +// studies are closed until they begin. function isDiscussionOpen(study: StudyProgram | undefined): boolean { - return Boolean(study) && getEffectiveStudyStatus(study as StudyProgram) === 'active' + return Boolean(study) && getEffectiveStudyStatus(study as StudyProgram) !== 'planned' } function getNextReleaseLabel(study: StudyProgram): string { @@ -1698,7 +1700,7 @@ export function ColossiansStudyIndexPage({ content }: Props) { )} {allLessonsDone && 🏅 My Certificate} {enrolled && My Notes} - {enrolled && studyStatus === 'active' && Community} + {enrolled && studyStatus !== 'planned' && Community} {auth.authenticated && My Account} {enrollMessage &&

{enrollMessage}

} @@ -4204,12 +4206,12 @@ export function StudyDiscussionHubPage({ content }: Props) {

Student Community

Study Discussion

-

Pick an active study to see what other students are saying, ask questions, and share what God is teaching you. Discussion is open while a study is active.

+

Pick a study track to see what other students are saying, ask questions, and share what God is teaching you.

{openDiscussionStudies.length === 0 ? ( -

Discussion opens while a study is active. There are no active studies right now — check back when the next one starts.

+

There are no studies open for discussion yet. Check back when the next one starts.

) : (
{openDiscussionStudies.map(study => { @@ -4294,8 +4296,8 @@ export function StudyCommunityPage({ content }: Props) {

{study.title}

-

Discussion Is Closed

-

Discussion is only open while a study is active, and this study isn't active right now.

+

Discussion Isn't Open Yet

+

Discussion opens once this study has started. Check back when it begins.

Back to Study
diff --git a/test/study-completion.test.js b/test/study-completion.test.js index c0c90ac..6c78579 100644 --- a/test/study-completion.test.js +++ b/test/study-completion.test.js @@ -60,7 +60,7 @@ test('re-engagement emails skip students whose only study is finished', async () assert.deepEqual(sent, ['c@d.co']) }) -test('discussion is open only for active studies', async () => { +test('discussion is open for active and finished studies, closed only for planned ones', async () => { const { isStudyDiscussionOpen } = await import('../server/study-helpers.js') const past = '2020-01-01T00:00:00Z' const future = '2099-01-01T00:00:00Z' @@ -73,8 +73,8 @@ test('discussion is open only for active studies', async () => { ], } assert.equal(isStudyDiscussionOpen('live'), true) - assert.equal(isStudyDiscussionOpen('done'), false) - assert.equal(isStudyDiscussionOpen('auto-done'), false) + assert.equal(isStudyDiscussionOpen('done'), true) + assert.equal(isStudyDiscussionOpen('auto-done'), true) assert.equal(isStudyDiscussionOpen('soon'), false) assert.equal(isStudyDiscussionOpen('missing'), false) })