@qti-editor/interaction-associate 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"qti-associate-interaction.compose.d.ts","sourceRoot":"","sources":["../../../src/components/qti-associate-interaction/qti-associate-interaction.compose.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,wBAAwB,EAAkC,MAAM,kDAAkD,CAAC;AAclJ,wBAAgB,kCAAkC,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,wBAAwB,CA+CrH"}
1
+ {"version":3,"file":"qti-associate-interaction.compose.d.ts","sourceRoot":"","sources":["../../../src/components/qti-associate-interaction/qti-associate-interaction.compose.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,wBAAwB,EAAkC,MAAM,kDAAkD,CAAC;AAclJ,wBAAgB,kCAAkC,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,wBAAwB,CA+CrH"}
@@ -1,3 +1,4 @@
1
+ import { parseCorrectResponseAttribute } from '@qti-editor/interaction-shared';
1
2
  import { associateInteractionComposerMetadata } from '../../composer/metadata.js';
2
3
  function toFiniteNumber(value, fallback) {
3
4
  if (value == null || value.trim().length === 0)
@@ -16,7 +17,7 @@ export function composeAssociateInteractionElement(sourceElement, xmlDoc) {
16
17
  const warnings = [];
17
18
  const normalizedElement = xmlDoc.importNode(sourceElement, true);
18
19
  const responseIdentifier = toNonEmptyString(sourceElement.getAttribute('response-identifier'));
19
- const correctResponse = toNonEmptyString(sourceElement.getAttribute('correct-response'));
20
+ const correctResponse = parseCorrectResponseAttribute(sourceElement.getAttribute('correct-response'));
20
21
  const maxAssociations = toFiniteNumber(sourceElement.getAttribute('max-associations'), 1);
21
22
  const minAssociations = toFiniteNumber(sourceElement.getAttribute('min-associations'), 0);
22
23
  const score = toFiniteNumber(sourceElement.getAttribute('score'), 1);
@@ -1 +1 @@
1
- {"version":3,"file":"qti-associate-interaction.schema.d.ts","sourceRoot":"","sources":["../../../src/components/qti-associate-interaction/qti-associate-interaction.schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEjE,eAAO,MAAM,+BAA+B,EAAE,QAmD7C,CAAC"}
1
+ {"version":3,"file":"qti-associate-interaction.schema.d.ts","sourceRoot":"","sources":["../../../src/components/qti-associate-interaction/qti-associate-interaction.schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEjE,eAAO,MAAM,+BAA+B,EAAE,QAoD7C,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { parseCorrectResponseAttribute, serializeCorrectResponseAttribute } from '@qti-editor/interaction-shared';
1
2
  export const qtiAssociateInteractionNodeSpec = {
2
3
  group: 'block',
3
4
  content: 'qtiPrompt? qtiSimpleAssociableChoice+',
@@ -25,7 +26,7 @@ export const qtiAssociateInteractionNodeSpec = {
25
26
  minAssociations: minAssociations ? parseInt(minAssociations, 10) : 0,
26
27
  shuffle: node.getAttribute('shuffle') === 'true',
27
28
  class: className || null,
28
- correctResponse: node.getAttribute('correct-response'),
29
+ correctResponse: parseCorrectResponseAttribute(node.getAttribute('correct-response')),
29
30
  responseIdentifier: node.getAttribute('response-identifier'),
30
31
  score: scoreAttr && Number.isFinite(Number(scoreAttr)) ? Number(scoreAttr) : 1,
31
32
  };
@@ -44,8 +45,9 @@ export const qtiAssociateInteractionNodeSpec = {
44
45
  }
45
46
  if (node.attrs.class)
46
47
  attrs.class = node.attrs.class;
47
- if (node.attrs.correctResponse)
48
- attrs['correct-response'] = node.attrs.correctResponse;
48
+ const cr = serializeCorrectResponseAttribute(node.attrs.correctResponse);
49
+ if (cr)
50
+ attrs['correct-response'] = cr;
49
51
  if (node.attrs.responseIdentifier)
50
52
  attrs['response-identifier'] = node.attrs.responseIdentifier;
51
53
  attrs.score = String(node.attrs.score ?? 1);
@@ -27,7 +27,7 @@ export const associateInteractionComposerMetadata = {
27
27
  internalKind: 'map_response',
28
28
  internalSourceXml: MAP_RESPONSE_INTERNAL_TEMPLATE,
29
29
  },
30
- editorOnlyAttributes: ['class', 'score'],
30
+ editorOnlyAttributes: ['score'],
31
31
  userEditableAttributes: ['maxAssociations', 'minAssociations', 'shuffle', 'correctResponse', 'score'],
32
32
  };
33
33
  export const associateNodeAttributePanelMetadataByNodeTypeName = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qti-editor/interaction-associate",
3
3
  "description": "QTI associate interaction schemas, components, commands, and composer",
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/Citolab/qti-editor",
@@ -24,8 +24,8 @@
24
24
  "@qti-components/associate-interaction": "^1.1.3",
25
25
  "@qti-components/interactions": "1.10.2",
26
26
  "@qti-components/utilities": "1.3.2",
27
- "@qti-editor/interaction-shared": "1.3.0",
28
- "@qti-editor/interfaces": "1.2.0"
27
+ "@qti-editor/interaction-shared": "1.3.1",
28
+ "@qti-editor/interfaces": "1.2.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "lit": "^3.3.2",