diff --git a/apps/src/templates/teacherDashboard/teacherSectionsRedux.js b/apps/src/templates/teacherDashboard/teacherSectionsRedux.js index 891e496136026..ab97f2ddb9ede 100644 --- a/apps/src/templates/teacherDashboard/teacherSectionsRedux.js +++ b/apps/src/templates/teacherDashboard/teacherSectionsRedux.js @@ -414,6 +414,7 @@ function newSectionData(id, courseId, scriptId, loginType) { } const defaultVersionYear = '2017'; +const defaultStageExtras = false; // Fields to copy from the assignmentInfo when creating an assignmentFamily. export const assignmentFamilyFields = [ @@ -653,8 +654,6 @@ export default function teacherSections(state = initialState, action) { } if (action.type === EDIT_SECTION_PROPERTIES) { - const stageExtraSettings = {}; - if (!state.sectionBeingEdited) { throw new Error( 'Cannot edit section properties; no section is' + @@ -668,13 +667,14 @@ export default function teacherSections(state = initialState, action) { } } - // Selecting Course 1-4 or A-F should auto-enable Stage Extras. + const stageExtraSettings = {}; if (action.props.scriptId) { const script = state.validAssignments[assignmentId(null, action.props.scriptId)]; - stageExtraSettings.stageExtras = !!( - script && /course[1-4a-f]/.test(script.script_name) - ); + if (script) { + stageExtraSettings.stageExtras = + script.stage_extras_available || defaultStageExtras; + } } return { diff --git a/apps/test/unit/templates/teacherDashboard/teacherSectionsReduxTest.js b/apps/test/unit/templates/teacherDashboard/teacherSectionsReduxTest.js index 1aed39f8ca112..146b8484fe536 100644 --- a/apps/test/unit/templates/teacherDashboard/teacherSectionsReduxTest.js +++ b/apps/test/unit/templates/teacherDashboard/teacherSectionsReduxTest.js @@ -170,7 +170,8 @@ const validScripts = [ script_name: 'course3', category: 'other', position: null, - category_priority: 3 + category_priority: 3, + stage_extras_available: true }, { id: 112, @@ -210,6 +211,15 @@ const validScripts = [ assignment_family_name: 'coursea', version_year: '2017', is_stable: true + }, + { + id: 37, + name: 'Express Course', + script_name: 'express-2018', + category: 'other', + position: null, + category_priority: 3, + stage_extras_available: true } ]; @@ -627,7 +637,7 @@ describe('teacherSectionsRedux', () => { ).to.throw(); }); - it('switching to non-CSF course assignment turns off stage extras', () => { + it('switching script assignment updates stage extras value from script', () => { let state = reducer( editingNewSectionState, setValidAssignments(validCourses, validScripts) @@ -637,6 +647,9 @@ describe('teacherSectionsRedux', () => { state = reducer(state, editSectionProperties({scriptId: 36})); expect(state.sectionBeingEdited.stageExtras).to.equal(true); + + state = reducer(state, editSectionProperties({scriptId: 37})); + expect(state.sectionBeingEdited.stageExtras).to.equal(true); }); }); diff --git a/dashboard/app/models/script.rb b/dashboard/app/models/script.rb index 0f08901cc98be..6b08379ee3a77 100644 --- a/dashboard/app/models/script.rb +++ b/dashboard/app/models/script.rb @@ -1442,6 +1442,7 @@ def assignable_info info[:category] = I18n.t("data.script.category.#{info[:category]}_category_name", default: info[:category]) info[:supported_locales] = supported_locale_names + info[:stage_extras_available] = stage_extras_available info end diff --git a/dashboard/test/models/script_test.rb b/dashboard/test/models/script_test.rb index 47fe89cf88fa2..98f640d5b0197 100644 --- a/dashboard/test/models/script_test.rb +++ b/dashboard/test/models/script_test.rb @@ -1360,12 +1360,13 @@ def populate_cache_and_disconnect_db end test "assignable_info: returns assignable info for a script" do - script = create(:script, name: 'fake-script', hidden: true) + script = create(:script, name: 'fake-script', hidden: true, stage_extras_available: true) assignable_info = script.assignable_info assert_equal("fake-script *", assignable_info[:name]) assert_equal("fake-script", assignable_info[:script_name]) assert_equal("other", assignable_info[:category]) + assert(assignable_info[:stage_extras_available]) end test "assignable_info: correctly translates script info" do