Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/controller-utils/src/__tests__/persistence.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ describe('lockChoices', () => {
${false} | ${undefined} | ${undefined} | ${false}
${undefined} | ${session()} | ${env(false)} | ${false}
${undefined} | ${session()} | ${env(undefined)} | ${false}
${false} | ${session()} | ${env(false, 'instructor')} | ${true}
${false} | ${session([0, 1])} | ${env(false, 'instructor')} | ${true}
${false} | ${undefined} | ${env(false, 'instructor')} | ${true}
${false} | ${session()} | ${env(false, 'instructor')} | ${false}
${false} | ${session([0, 1])} | ${env(false, 'instructor')} | ${false}
${false} | ${undefined} | ${env(false, 'instructor')} | ${false}
`('1. model.lockChoiceOrder: $modelLock, $session, $env => $expected', ({ modelLock, session, env, expected }) => {
const model = { lockChoiceOrder: modelLock };
const result = lockChoices(model, session, env);
Expand All @@ -120,7 +120,7 @@ describe('lockChoices mod', () => {
${false} | ${session()} | ${env(false)} | ${false}
${undefined} | ${session()} | ${env(true)} | ${true}
${undefined} | ${session()} | ${env(undefined)} | ${false}
${undefined} | ${session()} | ${env(undefined, 'instructor')} | ${true}
${undefined} | ${session()} | ${env(undefined, 'instructor')} | ${false}
`('2. model.lockChoiceOrder: $modelLock, $session, $env => $expected', ({ modelLock, session, env, expected }) => {
const model = { lockChoiceOrder: modelLock };
const result = lockChoices(model, session, env);
Expand All @@ -142,7 +142,7 @@ describe('lockChoices', () => {
${false} | ${session()} | ${env(false)} | ${false}
${undefined} | ${session()} | ${env(true)} | ${true}
${undefined} | ${session()} | ${env(undefined)} | ${false}
${undefined} | ${session()} | ${env(undefined, 'instructor')} | ${true}
${undefined} | ${session()} | ${env(undefined, 'instructor')} | ${false}
`('3. model.lockChoiceOrder: $modelLock, $env => $expected', ({ modelLock, session, env, expected }) => {
const model = { lockChoiceOrder: modelLock };
const result = lockChoices(model, session, env);
Expand Down
19 changes: 4 additions & 15 deletions packages/controller-utils/src/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export const getShuffledChoices = (choices, session, updateSession, choiceKey) =
* - true - that means that the order of the choices will be ordinal (as is created in the configure item)
* - false - that means the getShuffledChoices above will be called and that in turn means that we either
* return the shuffled values on the session (if any exists) or we shuffle the choices
*
* Note: the role (student/instructor) is intentionally not considered here — instructor mode
* will respect the same `lockChoiceOrder` value as students, instead of forcing the order to be locked.
*
* @param model - model to check if we should lock order
* @param session - session to check if we should lock order
* @param env - env to check if we should lock order
Expand All @@ -85,20 +89,5 @@ export const lockChoices = (model, session, env) => {
return true;
}

const role = get(env, 'role', 'student');

if (role === 'instructor') {
// TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
/*const alreadyShuffled = hasShuffledValues(session);

if (alreadyShuffled) {
return false;
}

return true;*/
return true;
}

// here it's a student, so don't lock and it will shuffle if needs be
return false;
};
Loading