Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default stage extras to 'yes' for express courses #27888

Merged
merged 5 commits into from Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/src/templates/teacherDashboard/teacherSectionsRedux.js
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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' +
Expand All @@ -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 {
Expand Down
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
];

Expand Down Expand Up @@ -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)
Expand All @@ -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);
});
});

Expand Down
1 change: 1 addition & 0 deletions dashboard/app/models/script.rb
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion dashboard/test/models/script_test.rb
Expand Up @@ -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
Expand Down