Skip to content

Commit 8f37441

Browse files
authored
Merge pull request #2640 from pie-framework/fix/PD-5025
fix(image-cloze-association): get rid of correctResponse from model i…
2 parents 1c7d8ad + 1817673 commit 8f37441

4 files changed

Lines changed: 26 additions & 26 deletions

File tree

packages/drag-in-the-blank/controller/src/__tests__/index.test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,36 @@ describe('controller', () => {
5252
describe('correctResponse behavior across modes', () => {
5353
it('does not include correctResponse in gather mode', async () => {
5454
const result = await model(question, {}, { mode: 'gather' });
55-
55+
5656
expect(result.correctResponse).toBeUndefined();
5757
});
58-
58+
5959
it('includes correctResponse in view mode for instructor', async () => {
6060
const result = await model(question, {}, { mode: 'view', role: 'instructor' });
61-
62-
expect(result.correctResponse).toBeDefined();
61+
62+
expect(result.correctResponse).toBeUndefined();
6363
});
64-
64+
6565
it('does not include correctResponse in view mode for student', async () => {
6666
const result = await model(question, {}, { mode: 'view', role: 'student' });
67-
67+
6868
expect(result.correctResponse).toBeUndefined();
6969
});
70-
70+
7171
it('includes correctResponse in evaluate mode', async () => {
7272
const result = await model(question, {}, { mode: 'evaluate' });
73-
73+
7474
expect(result.correctResponse).toBeDefined();
7575
});
76-
76+
7777
it('ensures correctResponse is explicitly undefined when not in evaluate mode or instructor view', async () => {
7878
const gatherResult = await model(question, {}, { mode: 'gather' });
7979
const viewStudentResult = await model(question, {}, { mode: 'view', role: 'student' });
80-
80+
8181
expect(gatherResult.correctResponse).toBeUndefined();
8282
expect(viewStudentResult.correctResponse).toBeUndefined();
8383
});
84-
});
84+
});
8585

8686
const assertGather = (label, extra, session, expected) => {
8787
it(`'mode: gather, ${label}'`, async () => {
@@ -164,7 +164,7 @@ describe('controller', () => {
164164
disabled: true,
165165
feedback: {},
166166
responseCorrect: undefined,
167-
correctResponse: q.correctResponse,
167+
correctResponse: undefined,
168168
...expected,
169169
});
170170
});

packages/drag-in-the-blank/controller/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function model(question, session, env, updateSession) {
5959
choices = await getShuffledChoices(choices, session, updateSession, 'id');
6060
}
6161

62-
const shouldIncludeCorrectResponse = env.mode === 'evaluate' || (env.role === 'instructor' && env.mode === 'view');
62+
const shouldIncludeCorrectResponse = env.mode === 'evaluate';
6363

6464
const out = {
6565
...normalizedQuestion,
@@ -68,7 +68,7 @@ export function model(question, session, env, updateSession) {
6868
feedback,
6969
mode: env.mode,
7070
disabled: env.mode !== 'gather',
71-
responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined,
71+
responseCorrect: shouldIncludeCorrectResponse ? getScore(normalizedQuestion, session) === 1 : undefined,
7272
correctResponse: shouldIncludeCorrectResponse ? normalizedQuestion.correctResponse : undefined,
7373
};
7474

packages/image-cloze-association/controller/src/__tests__/index.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -546,32 +546,32 @@ describe('controller', () => {
546546
describe('validation property behavior across modes', () => {
547547
it('does not include validation in gather mode', async () => {
548548
const result = await model(question, {}, { mode: 'gather' });
549-
549+
550550
expect(result.validation).toBeUndefined();
551551
});
552-
552+
553553
it('does not include validation in view mode', async () => {
554554
const result = await model(question, {}, { mode: 'view' });
555-
555+
556556
expect(result.validation).toBeUndefined();
557557
});
558-
558+
559559
it('includes validation in evaluate mode and when instructor is in view mode', async () => {
560560
const evalResult = await model(question, {}, { mode: 'evaluate' });
561561
const viewResult = await model(question, {}, { mode: 'view', role: 'instructor' });
562-
562+
563563
expect(evalResult.validation).toBeDefined();
564-
expect(viewResult.validation).toBeDefined();
565-
});
566-
564+
expect(viewResult.validation).toBeUndefined();
565+
});
566+
567567
it('ensures validation is explicitly undefined when not in evaluate or instructor view mode', async () => {
568568
const gatherResult = await model(question, {}, { mode: 'gather' });
569569
const studentViewResult = await model(question, {}, { mode: 'view', role: 'student' });
570-
570+
571571
expect(gatherResult.validation).toBeUndefined();
572572
expect(studentViewResult.validation).toBeUndefined();
573-
});
574-
});
573+
});
574+
});
575575

576576
describe('getPartialScore', () => {
577577
const returnPartialScore = (sess) => {

packages/image-cloze-association/controller/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const model = (question, session, env) => {
1515
const questionCamelized = camelizeKeys(questionNormalized);
1616

1717
return new Promise((resolve) => {
18-
const shouldIncludeCorrectResponse = env.mode === 'evaluate' || (env.role === 'instructor' && env.mode === 'view');
18+
const shouldIncludeCorrectResponse = env.mode === 'evaluate';
1919

2020
const out = {
2121
disabled: env.mode !== 'gather',

0 commit comments

Comments
 (0)