@qti-editor/interaction-select-point 1.1.1 → 1.2.1

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-select-point-interaction.compose.d.ts","sourceRoot":"","sources":["../../../src/components/qti-select-point-interaction/qti-select-point-interaction.compose.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,wBAAwB,EAAmD,MAAM,kDAAkD,CAAC;AA8FnK,wBAAgB,oCAAoC,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,wBAAwB,CAkFvH"}
1
+ {"version":3,"file":"qti-select-point-interaction.compose.d.ts","sourceRoot":"","sources":["../../../src/components/qti-select-point-interaction/qti-select-point-interaction.compose.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,wBAAwB,EAAmD,MAAM,kDAAkD,CAAC;AA8FnK,wBAAgB,oCAAoC,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,wBAAwB,CAmFvH"}
@@ -1,3 +1,4 @@
1
+ import { parseCorrectResponseAttribute } from '@qti-editor/interaction-shared';
1
2
  import { selectPointInteractionComposerMetadata, SELECT_POINT_INTERACTION_TAG } from '../../composer/metadata.js';
2
3
  function toFiniteNumber(value, fallback) {
3
4
  if (value == null || value.trim().length === 0)
@@ -84,6 +85,7 @@ export function composeSelectPointInteractionElement(sourceElement, xmlDoc) {
84
85
  const responseIdentifier = toNonEmptyString(sourceElement.getAttribute('response-identifier'));
85
86
  const maxChoices = toFiniteNumber(sourceElement.getAttribute('max-choices'), 1);
86
87
  const minChoices = toFiniteNumber(sourceElement.getAttribute('min-choices'), 0);
88
+ const score = toFiniteNumber(sourceElement.getAttribute('score'), 1);
87
89
  const promptFromChild = sourceElement.querySelector('qti-prompt')?.textContent;
88
90
  const prompt = toNonEmptyString(promptFromChild ?? null);
89
91
  const imageElement = sourceElement.querySelector('img');
@@ -133,7 +135,7 @@ export function composeSelectPointInteractionElement(sourceElement, xmlDoc) {
133
135
  });
134
136
  }
135
137
  else {
136
- const correctResponse = toNonEmptyString(sourceElement.getAttribute('correct-response'));
138
+ const correctResponse = parseCorrectResponseAttribute(sourceElement.getAttribute('correct-response'));
137
139
  responseDeclaration = {
138
140
  identifier: responseIdentifier,
139
141
  cardinality: maxChoices > 1 ? 'multiple' : 'single',
@@ -141,6 +143,7 @@ export function composeSelectPointInteractionElement(sourceElement, xmlDoc) {
141
143
  correctResponse: correctResponse ?? undefined,
142
144
  areaMapping: areaMappingResult.areaMapping,
143
145
  sourceTag: metadata.tagName,
146
+ score,
144
147
  };
145
148
  }
146
149
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"qti-select-point-interaction.schema.d.ts","sourceRoot":"","sources":["../../../src/components/qti-select-point-interaction/qti-select-point-interaction.schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA0C,QAAQ,EAAU,MAAM,mBAAmB,CAAC;AAqElG,eAAO,MAAM,iCAAiC,EAAE,QA2C/C,CAAC"}
1
+ {"version":3,"file":"qti-select-point-interaction.schema.d.ts","sourceRoot":"","sources":["../../../src/components/qti-select-point-interaction/qti-select-point-interaction.schema.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAA0C,QAAQ,EAAU,MAAM,mBAAmB,CAAC;AAwElG,eAAO,MAAM,iCAAiC,EAAE,QA8C/C,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { parseCorrectResponseAttribute, serializeCorrectResponseAttribute, } from '@qti-editor/interaction-shared';
1
2
  import { Fragment } from 'prosemirror-model';
2
3
  function parseNumberAttribute(value) {
3
4
  if (value == null || value === '')
@@ -14,13 +15,15 @@ function isElementLike(node) {
14
15
  typeof node.querySelector === 'function');
15
16
  }
16
17
  function parseWrapperAttrs(node) {
18
+ const scoreAttr = node.getAttribute('score');
17
19
  return {
18
20
  responseIdentifier: node.getAttribute('response-identifier'),
19
21
  maxChoices: parseNumberAttribute(node.getAttribute('max-choices')) ?? 0,
20
22
  minChoices: parseNumberAttribute(node.getAttribute('min-choices')) ?? 0,
21
23
  class: node.getAttribute('class') || null,
22
24
  areaMappings: node.getAttribute('area-mappings') || '[]',
23
- correctResponse: node.getAttribute('correct-response') || null,
25
+ correctResponse: parseCorrectResponseAttribute(node.getAttribute('correct-response')),
26
+ score: scoreAttr && Number.isFinite(Number(scoreAttr)) ? Number(scoreAttr) : 1,
24
27
  };
25
28
  }
26
29
  function buildPromptNode(schema, node) {
@@ -61,6 +64,7 @@ export const qtiSelectPointInteractionNodeSpec = {
61
64
  class: { default: null },
62
65
  areaMappings: { default: '[]' },
63
66
  correctResponse: { default: null },
67
+ score: { default: 1 },
64
68
  },
65
69
  parseDOM: [
66
70
  {
@@ -91,8 +95,10 @@ export const qtiSelectPointInteractionNodeSpec = {
91
95
  attrs.class = String(node.attrs.class);
92
96
  if (node.attrs.areaMappings)
93
97
  attrs['area-mappings'] = String(node.attrs.areaMappings);
94
- if (node.attrs.correctResponse)
95
- attrs['correct-response'] = String(node.attrs.correctResponse);
98
+ const cr = serializeCorrectResponseAttribute(node.attrs.correctResponse);
99
+ if (cr)
100
+ attrs['correct-response'] = cr;
101
+ attrs.score = String(node.attrs.score ?? 1);
96
102
  return ['qti-select-point-interaction', attrs, 0];
97
103
  },
98
104
  };
@@ -17,6 +17,12 @@ export declare const selectPointNodeAttributePanelMetadataByNodeTypeName: {
17
17
  [x: string]: {
18
18
  nodeTypeName: "qtiSelectPointInteraction";
19
19
  editableAttributes: string[];
20
+ fields: {
21
+ score: {
22
+ label: string;
23
+ input: "number";
24
+ };
25
+ };
20
26
  };
21
27
  };
22
28
  //# sourceMappingURL=metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/composer/metadata.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,gFACuC,CAAC;AAWhF,eAAO,MAAM,4BAA4B,EAAG,8BAAuC,CAAC;AACpF,eAAO,MAAM,kCAAkC,EAAG,2BAAoC,CAAC;AAEvF,eAAO,MAAM,sCAAsC;;;;;;;;;;;CAWZ,CAAC;AAExC,eAAO,MAAM,mDAAmD;;;;;CAKV,CAAC"}
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/composer/metadata.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,gFACuC,CAAC;AAWhF,eAAO,MAAM,4BAA4B,EAAG,8BAAuC,CAAC;AACpF,eAAO,MAAM,kCAAkC,EAAG,2BAAoC,CAAC;AAEvF,eAAO,MAAM,sCAAsC;;;;;;;;;;;CAWZ,CAAC;AAExC,eAAO,MAAM,mDAAmD;;;;;;;;;;;CAMV,CAAC"}
@@ -18,12 +18,13 @@ export const selectPointInteractionComposerMetadata = {
18
18
  internalKind: 'map_response_point',
19
19
  internalSourceXml: MAP_RESPONSE_POINT_INTERNAL_TEMPLATE,
20
20
  },
21
- editorOnlyAttributes: ['class', 'area-mappings', 'correct-response'],
22
- userEditableAttributes: ['maxChoices', 'minChoices'],
21
+ editorOnlyAttributes: ['area-mappings', 'correct-response', 'score'],
22
+ userEditableAttributes: ['maxChoices', 'minChoices', 'score'],
23
23
  };
24
24
  export const selectPointNodeAttributePanelMetadataByNodeTypeName = {
25
25
  [SELECT_POINT_INTERACTION_NODE_TYPE.toLowerCase()]: {
26
26
  nodeTypeName: SELECT_POINT_INTERACTION_NODE_TYPE,
27
27
  editableAttributes: selectPointInteractionComposerMetadata.userEditableAttributes,
28
+ fields: { score: { label: 'Score', input: 'number' } },
28
29
  },
29
30
  };
@@ -24,6 +24,12 @@ export declare const selectPointInteractionDescriptor: {
24
24
  [x: string]: {
25
25
  nodeTypeName: "qtiSelectPointInteraction";
26
26
  editableAttributes: string[];
27
+ fields: {
28
+ score: {
29
+ label: string;
30
+ input: "number";
31
+ };
32
+ };
27
33
  };
28
34
  };
29
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../src/descriptor.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYZ,CAAC"}
1
+ {"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../src/descriptor.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYZ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qti-editor/interaction-select-point",
3
3
  "description": "QTI select-point interaction schemas, components, commands, and composer",
4
- "version": "1.1.1",
4
+ "version": "1.2.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/Citolab/qti-editor",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@qti-components/select-point-interaction": "^1.0.1",
25
- "@qti-editor/interaction-shared": "1.2.0",
26
- "@qti-editor/interfaces": "1.1.0",
25
+ "@qti-editor/interaction-shared": "1.3.1",
26
+ "@qti-editor/interfaces": "1.2.1",
27
27
  "prosemirror-model": "^1.25.4",
28
28
  "prosemirror-state": "^1.4.4",
29
29
  "prosemirror-view": "^1.31.0"