Skip to content

Commit f4dbd0e

Browse files
committed
Condense Correct Response declaration and use expectedLength on Editor
1 parent fdeef39 commit f4dbd0e

2 files changed

Lines changed: 4 additions & 22 deletions

File tree

contentcuration/contentcuration/frontend/shared/views/QTIEditor/interactions/textEntry/TextEntryEditor.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
:placeholder="isNumeric ? answerValuePlaceholder$() : answerTextPlaceholder$()"
8585
class="answer-native-input"
8686
dir="auto"
87-
:maxlength="DEFAULT_EXPECTED_LENGTH"
87+
:maxlength="state.expectedLength"
8888
:disabled="mode !== 'edit'"
8989
:style="{
9090
color: $themeTokens.text,
@@ -102,7 +102,7 @@
102102
:style="{ color: $themePalette.grey.v_700 }"
103103
aria-hidden="true"
104104
>
105-
{{ answer.value.length }}/{{ DEFAULT_EXPECTED_LENGTH }}
105+
{{ answer.value.length }}/{{ state.expectedLength }}
106106
</span>
107107
</div>
108108

@@ -182,7 +182,6 @@
182182
import { qtiEditorStrings } from '../../qtiEditorStrings';
183183
import { QuestionType, ValidationError } from '../../constants';
184184
import { useTextEntryInteraction } from '../../composables/useTextEntryInteraction';
185-
import { DEFAULT_EXPECTED_LENGTH } from './parse';
186185
import ValidationMessage from 'shared/views/QTIEditor/components/ValidationMessage';
187186
import AddListItemButton from 'shared/views/QTIEditor/components/AddListItemButton';
188187
import EditorImageProcessor from 'shared/views/TipTapEditor/TipTapEditor/services/imageService';
@@ -348,7 +347,6 @@
348347
);
349348
350349
return {
351-
DEFAULT_EXPECTED_LENGTH,
352350
state,
353351
windowIsSmall,
354352
isNumeric,

contentcuration/contentcuration/frontend/shared/views/QTIEditor/interactions/textEntry/parse.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { buildXmlNode } from '../../serialization/assembleItem';
44
import CorrectResponse from '../../serialization/qti/declarations/correctResponse';
55
import { generateRandomSlug } from '../../utils/generateRandomSlug';
66
import { BaseType, QuestionType, RESPONSE_IDENTIFIER } from '../../constants';
7-
import { CAPABILITY } from '../../serialization/qti/declarations/capabilities';
87

98
const serializer = new XMLSerializer();
109

@@ -210,23 +209,8 @@ export function buildTextEntryInteractionXML(state, questionType, declarationSch
210209
tag: 'qti-response-declaration',
211210
});
212211

213-
if (questionType === QuestionType.FREE_RESPONSE) {
214-
// No correct answer
215-
} else if (baseType === BaseType.STRING) {
216-
if (answers.length > 0) {
217-
const textAnswers = answers.slice();
218-
declaration.registerCapability(CAPABILITY.CORRECT_RESPONSE, {
219-
get: () => textAnswers.map(a => a.value),
220-
getXML: () => {
221-
const valueEls = textAnswers.map(a =>
222-
buildXmlNode({ tag: 'qti-value', children: [a.value] }),
223-
);
224-
return buildXmlNode({ tag: 'qti-correct-response', children: valueEls });
225-
},
226-
});
227-
}
228-
} else {
229-
if (answers.length > 0) {
212+
if (questionType !== QuestionType.FREE_RESPONSE) {
213+
if (answers.length !== 0) {
230214
new CorrectResponse(
231215
answers.map(a => a.value),
232216
declaration,

0 commit comments

Comments
 (0)