From a8726c81865e15dbe4ddc4193c09004fbc4bbbc9 Mon Sep 17 00:00:00 2001 From: Elim Pizza Date: Fri, 7 Aug 2026 16:20:11 -0300 Subject: [PATCH 1/2] Fix Hide & Reveal settings dropped on non-deep-linked assignments --- .../components/FilePickerApp.tsx | 11 ++++--- .../components/FilePickerFormFields.tsx | 14 +++++++++ .../test/FilePickerFormFields-test.js | 31 +++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx b/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx index 6785f5f9b3..b5b49abbf5 100644 --- a/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx +++ b/lms/static/scripts/frontend_apps/components/FilePickerApp.tsx @@ -306,6 +306,8 @@ export default function FilePickerApp({ onSubmit }: FilePickerAppProps) { // instructor picked that type in the workflow. This drives the // `checkpoint_enabled` field the backend persists. const checkpointEnabled = assignmentType === 'hide_and_reveal'; + // UTC ISO string for the backend. Both submit paths send this same value. + const dueDateISO = dueDate ? new Date(dueDate).toISOString() : null; // Current sub-step of the assignment-type workflow. When the workflow isn't // enabled we start as `done` so it is skipped entirely. const [workflowStep, setWorkflowStep] = useState( @@ -454,10 +456,7 @@ export default function FilePickerApp({ onSubmit }: FilePickerAppProps) { ...deepLinkingAPI.data, auto_grading_config: autoGradingConfigToSave, checkpoint_enabled: checkpointEnabled, - // Optional due date for "Hide & Reveal" assignments. The picker holds - // a local `datetime-local` value; convert it to a UTC ISO string for - // the backend. `null` when left blank or not a checkpoint assignment. - due_date: dueDate ? new Date(dueDate).toISOString() : null, + due_date: dueDateISO, content, group_set: groupConfig.useGroupSet ? groupConfig.groupSet : null, title, @@ -486,7 +485,7 @@ export default function FilePickerApp({ onSubmit }: FilePickerAppProps) { [ authToken, checkpointEnabled, - dueDate, + dueDateISO, deepLinkingFields, deepLinkingAPI, groupConfig.groupSet, @@ -824,6 +823,8 @@ export default function FilePickerApp({ onSubmit }: FilePickerAppProps) { formFields={formFields} groupSet={groupConfig.useGroupSet ? groupConfig.groupSet : null} autoGradingConfig={autoGradingConfigToSave} + checkpointEnabled={checkpointEnabled} + dueDate={dueDateISO} /> ) } diff --git a/lms/static/scripts/frontend_apps/components/FilePickerFormFields.tsx b/lms/static/scripts/frontend_apps/components/FilePickerFormFields.tsx index ca47765d7d..e89b7e5e3f 100644 --- a/lms/static/scripts/frontend_apps/components/FilePickerFormFields.tsx +++ b/lms/static/scripts/frontend_apps/components/FilePickerFormFields.tsx @@ -24,6 +24,12 @@ export type FilePickerFormFieldsProps = { /** Auto-grading configuration for assignments where it is enabled */ autoGradingConfig: AutoGradingConfig | null; + + /** Whether this is a "Hide & Reveal" assignment. */ + checkpointEnabled: boolean; + + /** Due date as a UTC ISO string, or `null` when not set. */ + dueDate: string | null; }; /** @@ -38,6 +44,8 @@ export default function FilePickerFormFields({ formFields, groupSet, autoGradingConfig, + checkpointEnabled, + dueDate, }: FilePickerFormFieldsProps) { return ( <> @@ -58,6 +66,12 @@ export default function FilePickerFormFields({ value={JSON.stringify(autoGradingConfig)} /> )} + {checkpointEnabled && ( + <> + + {dueDate && } + + )} ); } diff --git a/lms/static/scripts/frontend_apps/components/test/FilePickerFormFields-test.js b/lms/static/scripts/frontend_apps/components/test/FilePickerFormFields-test.js index 282376b36b..f5063fb026 100644 --- a/lms/static/scripts/frontend_apps/components/test/FilePickerFormFields-test.js +++ b/lms/static/scripts/frontend_apps/components/test/FilePickerFormFields-test.js @@ -16,6 +16,8 @@ describe('FilePickerFormFields', () => { formFields={staticFormFields} groupSet={null} title={null} + checkpointEnabled={false} + dueDate={null} {...props} />, ); @@ -91,4 +93,33 @@ describe('FilePickerFormFields', () => { assert.isTrue(configField.exists()); assert.equal(configField.prop('value'), JSON.stringify(autoGradingConfig)); }); + + it('omits checkpoint fields when `checkpointEnabled` is false', () => { + const formFields = createComponent({ dueDate: '2026-09-01T12:00:00.000Z' }); + + assert.isFalse( + formFields.find('input[name="checkpoint_enabled"]').exists(), + ); + assert.isFalse(formFields.find('input[name="due_date"]').exists()); + }); + + it('renders `checkpoint_enabled` when `checkpointEnabled` is set', () => { + const formFields = createComponent({ checkpointEnabled: true }); + + const field = formFields.find('input[name="checkpoint_enabled"]'); + assert.isTrue(field.exists()); + assert.equal(field.prop('value'), 'true'); + assert.isFalse(formFields.find('input[name="due_date"]').exists()); + }); + + it('renders `due_date` when a due date is set', () => { + const formFields = createComponent({ + checkpointEnabled: true, + dueDate: '2026-09-01T12:00:00.000Z', + }); + + const field = formFields.find('input[name="due_date"]'); + assert.isTrue(field.exists()); + assert.equal(field.prop('value'), '2026-09-01T12:00:00.000Z'); + }); }); From a552d6273a5a17ba34fe976f815b8f20bd8dcd7a Mon Sep 17 00:00:00 2001 From: Elim Pizza Date: Fri, 7 Aug 2026 16:31:02 -0300 Subject: [PATCH 2/2] tests fixed --- .../frontend_apps/components/test/FilePickerApp-test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lms/static/scripts/frontend_apps/components/test/FilePickerApp-test.js b/lms/static/scripts/frontend_apps/components/test/FilePickerApp-test.js index 0bbebaa528..a63187c551 100644 --- a/lms/static/scripts/frontend_apps/components/test/FilePickerApp-test.js +++ b/lms/static/scripts/frontend_apps/components/test/FilePickerApp-test.js @@ -75,6 +75,8 @@ describe('FilePickerApp', () => { formFields = {}, title = null, autoGradingConfig = null, + checkpointEnabled = false, + dueDate = null, }, ) { const fieldsComponent = wrapper.find('FilePickerFormFields'); @@ -85,6 +87,8 @@ describe('FilePickerApp', () => { groupSet, title, autoGradingConfig, + checkpointEnabled, + dueDate, }); }