fix: capture practice choice option content
This commit is contained in:
@@ -16,6 +16,43 @@ test('extracts confirmed choices atomically and ignores student selection', () =
|
||||
assert.deepEqual(q.answerTexts, ['提高温度']);
|
||||
});
|
||||
|
||||
test('practice single-choice itemContent preserves standard answers by option id', () => {
|
||||
const raw = {
|
||||
id: 'practice-single', quesType: 0, content: '<p>升温时应选择?</p>',
|
||||
choiceItems: [
|
||||
{ id: 'a2', itemContent: '<p>提高温度</p>', content: '旧选项正文', selected: 0 },
|
||||
{ id: 'a1', itemContent: '<p>降低温度</p>', selected: 1 }
|
||||
],
|
||||
correctAnswers: ['a2']
|
||||
};
|
||||
const [q] = extractQuestions({ data: { praId: 'p1', listQues: [raw] } });
|
||||
assert.ok(q);
|
||||
assert.equal(q.answerStatus, 'confirmed');
|
||||
assert.deepEqual(q.options.map(option => option.text), ['提高温度', '降低温度']);
|
||||
assert.deepEqual(q.correctOptionIds, ['a2']);
|
||||
assert.deepEqual(q.answerTexts, ['提高温度']);
|
||||
assert.equal(q.options[0].label, 'A');
|
||||
});
|
||||
|
||||
test('practice multiple-choice itemContent keeps shuffled answers and content fallback', () => {
|
||||
const raw = {
|
||||
id: 'practice-multiple', quesType: 1, content: '<p>可采用哪些措施?</p>',
|
||||
choiceItems: [
|
||||
{ id: 'a3', itemContent: '<p>保持压力</p>' },
|
||||
{ id: 'a1', itemContent: '<p>降低温度</p>', selected: 1 },
|
||||
{ id: 'a2', itemContent: ' ', content: '<p>提高温度</p>' }
|
||||
],
|
||||
correctAnswers: ['a2', 'a3']
|
||||
};
|
||||
const [q] = extractQuestions({ data: { praId: 'p2', listQues: [raw] } });
|
||||
assert.ok(q);
|
||||
assert.equal(q.answerStatus, 'confirmed');
|
||||
assert.deepEqual(q.options.map(option => option.text), ['保持压力', '降低温度', '提高温度']);
|
||||
assert.deepEqual(q.correctOptionIds, ['a2', 'a3']);
|
||||
assert.deepEqual(q.answerTexts, ['提高温度', '保持压力']);
|
||||
assert.equal(q.options.find(option => option.id === 'a2').label, 'C');
|
||||
});
|
||||
|
||||
test('selected, submitContent, userAnswer and top-level answer/answers are not standard answers', () => {
|
||||
const raw = single();
|
||||
raw.choiceItems.forEach(o => delete o.answer);
|
||||
|
||||
Reference in New Issue
Block a user