@examind/block-sdk 0.1.27 → 0.1.28

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.
package/dist/index.js CHANGED
@@ -434,6 +434,11 @@ function isSerializedFillInTheBlankSpaceNode(node) {
434
434
  return node?.type === "space" && "id" in node && typeof node.id === "string" && "spaceName" in node && typeof node.spaceName === "string" && "matches" in node && typeof node.matches === "string" && "spaceType" in node;
435
435
  }
436
436
 
437
+ // src/exportToHtml/serializeErrorToleranceAttribute.ts
438
+ function serializeErrorToleranceAttribute(errorTolerance) {
439
+ return (errorTolerance ?? 0) / 100;
440
+ }
441
+
437
442
  // src/exportToHtml/FillInTheBlankSpaceNodeHandler.ts
438
443
  var FillInTheBlankSpaceNodeHandler = class extends NodeHandler {
439
444
  processNode(node) {
@@ -451,7 +456,7 @@ var FillInTheBlankSpaceNodeHandler = class extends NodeHandler {
451
456
  `data-x-case-sensitive="${!!node.caseSensitive}"`,
452
457
  `data-x-errors-allowed="${node.errorsAllowed ?? 0}"`,
453
458
  `data-x-min-decimals="${node.minDecimals ?? ""}"`,
454
- `data-x-error-tolerance="${(node.errorTolerance ?? 0) / 100}"`,
459
+ `data-x-error-tolerance="${serializeErrorToleranceAttribute(node.errorTolerance)}"`,
455
460
  // Divide by 100 to convert percentage to rate
456
461
  `data-x-distractors="${node.distractors ?? ""}"`
457
462
  ];
@@ -660,7 +665,7 @@ var JournalEntryQuestionNodeHandler = class extends NodeHandler {
660
665
  ];
661
666
  if (journalNode.errorTolerance !== void 0) {
662
667
  attributes.push(
663
- `data-x-error-tolerance="${journalNode.errorTolerance}"`
668
+ `data-x-error-tolerance="${serializeErrorToleranceAttribute(journalNode.errorTolerance)}"`
664
669
  );
665
670
  }
666
671
  attributes.push(
@@ -1525,6 +1530,15 @@ var FillInTheBlankQuestionNodeHandler2 = class extends NodeHandler2 {
1525
1530
  // src/importFromHtml/FillInTheBlankSpaceNodeHandler.ts
1526
1531
  var import_nanoid3 = require("nanoid");
1527
1532
  var import_node_html_parser5 = require("node-html-parser");
1533
+
1534
+ // src/importFromHtml/parseErrorToleranceAttribute.ts
1535
+ function parseErrorToleranceAttribute(attr) {
1536
+ const value = Number(attr);
1537
+ if (isNaN(value)) return 0;
1538
+ else return value * 100;
1539
+ }
1540
+
1541
+ // src/importFromHtml/FillInTheBlankSpaceNodeHandler.ts
1528
1542
  var FillInTheBlankSpaceNodeHandler2 = class extends NodeHandler2 {
1529
1543
  processNode(node) {
1530
1544
  if (!(node instanceof import_node_html_parser5.HTMLElement) || node.tagName !== "x-space".toUpperCase())
@@ -1558,16 +1572,11 @@ var FillInTheBlankSpaceNodeHandler2 = class extends NodeHandler2 {
1558
1572
  errorsAllowed: node.getAttribute("data-x-errors-allowed") ? Number(node.getAttribute("data-x-errors-allowed")) : void 0
1559
1573
  };
1560
1574
  }
1561
- parseErrorToleranceAttr(attr) {
1562
- const value = Number(attr);
1563
- if (isNaN(value)) return 0;
1564
- else return value * 100;
1565
- }
1566
1575
  processNumberSpace(node, baseNode) {
1567
1576
  return {
1568
1577
  ...baseNode,
1569
1578
  minDecimals: node.getAttribute("data-x-min-decimals") ? Number(node.getAttribute("data-x-min-decimals")) : void 0,
1570
- errorTolerance: this.parseErrorToleranceAttr(
1579
+ errorTolerance: parseErrorToleranceAttribute(
1571
1580
  node.getAttribute("data-x-error-tolerance")
1572
1581
  )
1573
1582
  };
@@ -1847,7 +1856,9 @@ var JournalEntryQuestionNodeHandler2 = class extends NodeHandler2 {
1847
1856
  id: node.getAttribute("id") ?? (0, import_nanoid6.nanoid)(),
1848
1857
  points: Number(node.getAttribute("data-x-points") ?? 1),
1849
1858
  noEntryRequired: node.getAttribute("data-x-no-entry-required-correct") === "true",
1850
- errorTolerance: node.getAttribute("data-x-error-tolerance") ? Number(node.getAttribute("data-x-error-tolerance")) : void 0,
1859
+ errorTolerance: parseErrorToleranceAttribute(
1860
+ node.getAttribute("data-x-error-tolerance")
1861
+ ),
1851
1862
  lineItems: [],
1852
1863
  type: "journal-entry-question",
1853
1864
  version: 1
package/dist/index.mjs CHANGED
@@ -405,6 +405,11 @@ function isSerializedFillInTheBlankSpaceNode(node) {
405
405
  return node?.type === "space" && "id" in node && typeof node.id === "string" && "spaceName" in node && typeof node.spaceName === "string" && "matches" in node && typeof node.matches === "string" && "spaceType" in node;
406
406
  }
407
407
 
408
+ // src/exportToHtml/serializeErrorToleranceAttribute.ts
409
+ function serializeErrorToleranceAttribute(errorTolerance) {
410
+ return (errorTolerance ?? 0) / 100;
411
+ }
412
+
408
413
  // src/exportToHtml/FillInTheBlankSpaceNodeHandler.ts
409
414
  var FillInTheBlankSpaceNodeHandler = class extends NodeHandler {
410
415
  processNode(node) {
@@ -422,7 +427,7 @@ var FillInTheBlankSpaceNodeHandler = class extends NodeHandler {
422
427
  `data-x-case-sensitive="${!!node.caseSensitive}"`,
423
428
  `data-x-errors-allowed="${node.errorsAllowed ?? 0}"`,
424
429
  `data-x-min-decimals="${node.minDecimals ?? ""}"`,
425
- `data-x-error-tolerance="${(node.errorTolerance ?? 0) / 100}"`,
430
+ `data-x-error-tolerance="${serializeErrorToleranceAttribute(node.errorTolerance)}"`,
426
431
  // Divide by 100 to convert percentage to rate
427
432
  `data-x-distractors="${node.distractors ?? ""}"`
428
433
  ];
@@ -631,7 +636,7 @@ var JournalEntryQuestionNodeHandler = class extends NodeHandler {
631
636
  ];
632
637
  if (journalNode.errorTolerance !== void 0) {
633
638
  attributes.push(
634
- `data-x-error-tolerance="${journalNode.errorTolerance}"`
639
+ `data-x-error-tolerance="${serializeErrorToleranceAttribute(journalNode.errorTolerance)}"`
635
640
  );
636
641
  }
637
642
  attributes.push(
@@ -1496,6 +1501,15 @@ var FillInTheBlankQuestionNodeHandler2 = class extends NodeHandler2 {
1496
1501
  // src/importFromHtml/FillInTheBlankSpaceNodeHandler.ts
1497
1502
  import { nanoid as nanoid3 } from "nanoid";
1498
1503
  import { HTMLElement as HTMLElement5 } from "node-html-parser";
1504
+
1505
+ // src/importFromHtml/parseErrorToleranceAttribute.ts
1506
+ function parseErrorToleranceAttribute(attr) {
1507
+ const value = Number(attr);
1508
+ if (isNaN(value)) return 0;
1509
+ else return value * 100;
1510
+ }
1511
+
1512
+ // src/importFromHtml/FillInTheBlankSpaceNodeHandler.ts
1499
1513
  var FillInTheBlankSpaceNodeHandler2 = class extends NodeHandler2 {
1500
1514
  processNode(node) {
1501
1515
  if (!(node instanceof HTMLElement5) || node.tagName !== "x-space".toUpperCase())
@@ -1529,16 +1543,11 @@ var FillInTheBlankSpaceNodeHandler2 = class extends NodeHandler2 {
1529
1543
  errorsAllowed: node.getAttribute("data-x-errors-allowed") ? Number(node.getAttribute("data-x-errors-allowed")) : void 0
1530
1544
  };
1531
1545
  }
1532
- parseErrorToleranceAttr(attr) {
1533
- const value = Number(attr);
1534
- if (isNaN(value)) return 0;
1535
- else return value * 100;
1536
- }
1537
1546
  processNumberSpace(node, baseNode) {
1538
1547
  return {
1539
1548
  ...baseNode,
1540
1549
  minDecimals: node.getAttribute("data-x-min-decimals") ? Number(node.getAttribute("data-x-min-decimals")) : void 0,
1541
- errorTolerance: this.parseErrorToleranceAttr(
1550
+ errorTolerance: parseErrorToleranceAttribute(
1542
1551
  node.getAttribute("data-x-error-tolerance")
1543
1552
  )
1544
1553
  };
@@ -1818,7 +1827,9 @@ var JournalEntryQuestionNodeHandler2 = class extends NodeHandler2 {
1818
1827
  id: node.getAttribute("id") ?? nanoid6(),
1819
1828
  points: Number(node.getAttribute("data-x-points") ?? 1),
1820
1829
  noEntryRequired: node.getAttribute("data-x-no-entry-required-correct") === "true",
1821
- errorTolerance: node.getAttribute("data-x-error-tolerance") ? Number(node.getAttribute("data-x-error-tolerance")) : void 0,
1830
+ errorTolerance: parseErrorToleranceAttribute(
1831
+ node.getAttribute("data-x-error-tolerance")
1832
+ ),
1822
1833
  lineItems: [],
1823
1834
  type: "journal-entry-question",
1824
1835
  version: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@examind/block-sdk",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "@comment version": [
5
5
  "Don't specify package version here. It will be injected by publish workflow."
6
6
  ],
@@ -21,7 +21,7 @@
21
21
  "peerDependencies": {
22
22
  "nanoid": ">=3.0.0",
23
23
  "node-html-parser": ">=6.0.0",
24
- "@examind/block-types": "^0.1.27"
24
+ "@examind/block-types": "^0.1.28"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@eslint/js": "^9.17.0",
@@ -36,7 +36,7 @@
36
36
  "tsup": "^8.3.5",
37
37
  "typescript": "^5.7.2",
38
38
  "typescript-eslint": "^8.18.2",
39
- "@examind/block-types": "0.1.27"
39
+ "@examind/block-types": "0.1.28"
40
40
  },
41
41
  "dependencies": {
42
42
  "lodash-es": "4.17.21"