@tinyweb_dev/oe-exam-sdk 1.0.9 → 1.0.11

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.
Files changed (124) hide show
  1. package/dist/components/exams/take/ExamTakingPageContainer.js +6 -0
  2. package/dist/components/exams/take/components/QuestionRenderer.js +7 -7
  3. package/dist/components/exams/take/components/question-renderers/MoversCrossOutWordGroupRenderer.js +24 -10
  4. package/dist/components/exams/take/components/question-renderers/MoversCrosswordPuzzleRenderer.js +1 -1
  5. package/dist/components/exams/take/components/question-renderers/MoversFillInBlankGroupRenderer.js +2 -1
  6. package/dist/components/exams/take/components/question-renderers/MoversMatchWordToPictureGroupRenderer.d.ts +14 -0
  7. package/dist/components/exams/take/components/question-renderers/MoversMatchWordToPictureGroupRenderer.js +36 -0
  8. package/dist/components/exams/take/components/question-renderers/MoversMatchingWithLinesGroupRenderer.js +4 -0
  9. package/dist/components/exams/take/components/question-renderers/index.d.ts +1 -0
  10. package/dist/components/exams/take/components/question-renderers/index.js +1 -0
  11. package/dist/components/exams/take/components/speaking/renderers/SpeakingSpontaneousQaGroupRenderer.js +12 -2
  12. package/dist/components/exams/take/hooks/useSpontaneousQaGroupRendererSetup.js +2 -1
  13. package/dist/components/exams/take/utils/answer-transformers.js +17 -1
  14. package/dist/components/exams/take/utils/cross-out-word-group.transformer.js +4 -6
  15. package/dist/components/exams/take/utils/question-transformers.d.ts +32 -3
  16. package/dist/components/exams/take/utils/question-transformers.js +51 -2
  17. package/dist/components/questions/_shared/components/compact/KidChoiceRow.d.ts +12 -0
  18. package/dist/components/questions/_shared/components/compact/KidChoiceRow.js +33 -0
  19. package/dist/components/questions/_shared/components/compact/KidInstruction.d.ts +5 -0
  20. package/dist/components/questions/_shared/components/compact/KidInstruction.js +9 -0
  21. package/dist/components/questions/_shared/components/compact/KidPrompt.d.ts +5 -0
  22. package/dist/components/questions/_shared/components/compact/KidPrompt.js +9 -0
  23. package/dist/components/questions/_shared/components/compact/KidQuestionCard.d.ts +12 -0
  24. package/dist/components/questions/_shared/components/compact/KidQuestionCard.js +7 -0
  25. package/dist/components/questions/_shared/components/compact/index.d.ts +4 -0
  26. package/dist/components/questions/_shared/components/compact/index.js +4 -0
  27. package/dist/components/questions/_shared/types/crossword-puzzle.type.d.ts +5 -1
  28. package/dist/components/questions/_shared/types/match-word-to-picture-group.type.d.ts +1 -0
  29. package/dist/components/questions/_shared/types/match-word-to-picture-group.type.js +14 -0
  30. package/dist/components/questions/_shared/types/matching-with-lines-group.type.d.ts +2 -2
  31. package/dist/components/questions/_shared/types/spontaneous-qa-group.type.d.ts +17 -0
  32. package/dist/components/questions/components/QuestionSearchDropdown.js +1 -0
  33. package/dist/components/questions/types/answer-the-question/AnswerTheQuestionClient.js +18 -19
  34. package/dist/components/questions/types/answer-the-question-group/AnswerTheQuestionGroupClient.js +8 -7
  35. package/dist/components/questions/types/answer-the-question-group/AnswerTheQuestionGroupCreator.js +5 -4
  36. package/dist/components/questions/types/arrange-letters-into-words/ArrangeLettersIntoWordsClient.js +17 -11
  37. package/dist/components/questions/types/choose-correct-adjective/ChooseCorrectAdjectiveClient.js +15 -42
  38. package/dist/components/questions/types/choose-the-correct-answer/ChooseTheCorrectAnswerClient.js +15 -36
  39. package/dist/components/questions/types/choose-the-correct-answer-group/ChooseTheCorrectAnswerGroupClient.js +9 -30
  40. package/dist/components/questions/types/choose-then-answer-group/ChooseThenAnswerGroupClient.js +8 -7
  41. package/dist/components/questions/types/cross-out-word-group/CrossOutWordGroupClient.js +50 -32
  42. package/dist/components/questions/types/cross-out-word-group/CrossOutWordGroupCreator.js +24 -44
  43. package/dist/components/questions/types/cross-out-word-group/index.d.ts +1 -0
  44. package/dist/components/questions/types/cross-out-word-group/index.js +1 -0
  45. package/dist/components/questions/types/cross-out-word-group/map-cross-out-word-group-data.js +9 -9
  46. package/dist/components/questions/types/cross-out-word-group/tokenize.d.ts +2 -0
  47. package/dist/components/questions/types/cross-out-word-group/tokenize.js +11 -0
  48. package/dist/components/questions/types/cross-out-word-group/transform.js +2 -4
  49. package/dist/components/questions/types/crossword-puzzle/CrosswordPuzzleClient.d.ts +2 -1
  50. package/dist/components/questions/types/crossword-puzzle/CrosswordPuzzleClient.js +8 -6
  51. package/dist/components/questions/types/crossword-puzzle/CrosswordPuzzleCreator.js +68 -11
  52. package/dist/components/questions/types/crossword-puzzle/transform.js +59 -30
  53. package/dist/components/questions/types/fill-in-blank/FillInBlankClient.js +26 -31
  54. package/dist/components/questions/types/fill-in-blank-group/FillInBlankAnswerKey.d.ts +6 -0
  55. package/dist/components/questions/types/fill-in-blank-group/FillInBlankAnswerKey.js +17 -0
  56. package/dist/components/questions/types/fill-in-blank-group/FillInBlankGroupClient.js +32 -28
  57. package/dist/components/questions/types/fill-in-blank-group/FillInBlankGroupCreator.js +109 -26
  58. package/dist/components/questions/types/fill-in-blank-group/FillInBlankGroupMediaField.js +21 -11
  59. package/dist/components/questions/types/fill-in-blank-group/blank-utils.d.ts +1 -0
  60. package/dist/components/questions/types/fill-in-blank-group/blank-utils.js +4 -1
  61. package/dist/components/questions/types/fill-missing-words-in-grid/FillMissingWordsInGridClient.js +32 -31
  62. package/dist/components/questions/types/find-words-in-matrix/FindWordsInMatrixClient.js +71 -28
  63. package/dist/components/questions/types/find-words-in-matrix/FindWordsInMatrixCreator.js +6 -2
  64. package/dist/components/questions/types/find-words-in-matrix/transform.js +5 -0
  65. package/dist/components/questions/types/label-the-picture/LabelThePictureClient.js +4 -3
  66. package/dist/components/questions/types/listen-and-choose-from-answer-group/ListenAndChooseFromAnswerGroupClient.js +11 -30
  67. package/dist/components/questions/types/listen-and-speak-answer/ListenAndSpeakAnswerClient.js +7 -6
  68. package/dist/components/questions/types/listen-and-speak-compare-images/ListenAndSpeakCompareImagesClient.js +2 -1
  69. package/dist/components/questions/types/listen-and-speak-image-group/ListenAndSpeakImageGroupClient.js +14 -13
  70. package/dist/components/questions/types/listen-and-speak-info-exchange/ListenAndSpeakInfoExchangeClient.js +4 -3
  71. package/dist/components/questions/types/listen-and-speak-odd-one-out/ListenAndSpeakOddOneOutClient.js +4 -3
  72. package/dist/components/questions/types/listen-and-speak-question-list/ListenAndSpeakQuestionListClient.js +11 -10
  73. package/dist/components/questions/types/listen-and-speak-with-story-images/ListenAndSpeakWithStoryImagesClient.js +4 -3
  74. package/dist/components/questions/types/match-by-writing-answer/MatchByWritingAnswerClient.js +13 -11
  75. package/dist/components/questions/types/match-columns-to-make-sentences/MatchColumnsToMakeSentencesClient.js +17 -14
  76. package/dist/components/questions/types/match-word-to-picture/MatchWordToPictureClient.js +16 -12
  77. package/dist/components/questions/types/match-word-to-picture/MatchWordToPictureGroupClient.js +14 -14
  78. package/dist/components/questions/types/match-word-to-picture-group/MatchWordToPictureGroupClient.js +24 -35
  79. package/dist/components/questions/types/match-word-to-picture-group/MatchWordToPictureGroupCreator.js +16 -3
  80. package/dist/components/questions/types/match-word-to-picture-group/MatchWordToPictureGroupImageField.d.ts +2 -1
  81. package/dist/components/questions/types/match-word-to-picture-group/MatchWordToPictureGroupImageField.js +25 -6
  82. package/dist/components/questions/types/matching-with-lines-group/MatchingWithLinesBoard.js +1 -1
  83. package/dist/components/questions/types/matching-with-lines-group/MatchingWithLinesGroupClient.js +22 -10
  84. package/dist/components/questions/types/matching-with-lines-group/MatchingWithLinesGroupCreator.js +60 -18
  85. package/dist/components/questions/types/matching-with-lines-group/MatchingWithLinesImageField.d.ts +2 -1
  86. package/dist/components/questions/types/matching-with-lines-group/MatchingWithLinesImageField.js +24 -5
  87. package/dist/components/questions/types/matching-with-lines-group/map-matching-with-lines-group-data.js +8 -4
  88. package/dist/components/questions/types/matching-with-lines-group/transform.js +5 -4
  89. package/dist/components/questions/types/read-passage-and-answer-questions/ReadPassageAndAnswerQuestionsClient.js +8 -26
  90. package/dist/components/questions/types/sort-words-into-categories/SortWordsIntoCategoriesClient.js +2 -1
  91. package/dist/components/questions/types/speaking-conversation/SpeakingConversationPreviewClient.js +6 -5
  92. package/dist/components/questions/types/speaking-cue-card/SpeakingCueCardClient.js +2 -1
  93. package/dist/components/questions/types/speaking-describe-image/SpeakingDescribeImageClient.js +5 -4
  94. package/dist/components/questions/types/spontaneous-qa-group/SpontaneousQaGroupClient.d.ts +1 -1
  95. package/dist/components/questions/types/spontaneous-qa-group/SpontaneousQaGroupClient.js +54 -11
  96. package/dist/components/questions/types/spontaneous-qa-group/SpontaneousQaGroupCreator.js +11 -7
  97. package/dist/components/questions/types/spontaneous-qa-group/creator-helpers.js +8 -2
  98. package/dist/components/questions/types/spontaneous-qa-group/flatten.d.ts +1 -0
  99. package/dist/components/questions/types/spontaneous-qa-group/flatten.js +4 -2
  100. package/dist/components/questions/types/spontaneous-qa-group/map-spontaneous-qa-group-data.js +5 -3
  101. package/dist/components/questions/types/spontaneous-qa-group/register.js +5 -2
  102. package/dist/components/questions/types/spontaneous-qa-group/transform.js +6 -2
  103. package/dist/components/questions/types/true-false/TrueFalseClient.js +5 -54
  104. package/dist/components/questions/types/true-false-correct-group/TrueFalseCorrectGroupClient.js +21 -23
  105. package/dist/components/questions/types/true-false-group/TrueFalseGroupClient.js +8 -17
  106. package/dist/components/questions/types/word-fill-paragraph/WordFillParagraphClient.js +76 -81
  107. package/dist/components/questions/types/word-fill-structured-form/WordFillStructuredFormClient.js +17 -16
  108. package/dist/components/questions/types/word-order-and-match-group/WordOrderAndMatchGroupClient.js +31 -36
  109. package/dist/components/questions/types/word-ordering/WordOrderingClient.js +15 -14
  110. package/dist/components/questions/types/word-ordering-group/WordOrderingGroupClient.js +9 -8
  111. package/dist/components/questions/types/write-correct-verb-form/WriteCorrectVerbFormClient.js +16 -13
  112. package/dist/components/questions/viewer/CrossOutWordGroupViewer.js +1 -4
  113. package/dist/components/questions/viewer/FillInBlankGroupViewer.d.ts +6 -2
  114. package/dist/components/questions/viewer/FillInBlankGroupViewer.js +13 -7
  115. package/dist/components/questions/viewer/QuestionViewer.js +2 -2
  116. package/dist/components/questions/viewer/SpontaneousQaGroupViewer.d.ts +7 -1
  117. package/dist/components/questions/viewer/SpontaneousQaGroupViewer.js +14 -2
  118. package/dist/components/results/renderers/review-question-body-movers.js +7 -3
  119. package/dist/components/results/review-data.js +20 -1
  120. package/dist/shared/lib/utils/question-reverse-transform.js +48 -7
  121. package/dist/shared/types/questions/crossword-puzzle.d.ts +1 -0
  122. package/dist/shared/types/questions/find-words-in-matrix.d.ts +1 -0
  123. package/dist/shared/types/questions/matching-with-lines-group.d.ts +2 -2
  124. package/package.json +1 -1
@@ -511,14 +511,29 @@ const reverseMatchingWithLinesGroup = (apiQuestion) => {
511
511
  questionNumber: asNumber(item.questionNumber, index + 1),
512
512
  };
513
513
  });
514
+ const readMatchingMedia = (value) => {
515
+ if (Array.isArray(value)) {
516
+ const cleaned = value
517
+ .filter((item) => typeof item === 'string')
518
+ .map((item) => item.trim())
519
+ .filter((item) => item !== '');
520
+ if (cleaned.length === 0)
521
+ return undefined;
522
+ return cleaned.length === 1 ? cleaned[0] : cleaned;
523
+ }
524
+ const single = asString(value).trim();
525
+ return single || undefined;
526
+ };
527
+ const audioUrl = readMatchingMedia(meta.audioUrl);
528
+ const imageUrl = readMatchingMedia(meta.imageUrl);
514
529
  return {
515
530
  content: '',
516
531
  answer: {
517
532
  title: asString(meta.title),
518
533
  instruction: asString(meta.instruction, 'Look and match.'),
519
534
  ...(asString(meta.passage).trim() ? { passage: asString(meta.passage).trim() } : {}),
520
- ...(asString(meta.audioUrl).trim() ? { audioUrl: asString(meta.audioUrl).trim() } : {}),
521
- ...(asString(meta.imageUrl).trim() ? { imageUrl: asString(meta.imageUrl).trim() } : {}),
535
+ ...(audioUrl !== undefined ? { audioUrl } : {}),
536
+ ...(imageUrl !== undefined ? { imageUrl } : {}),
522
537
  rightItems,
523
538
  items,
524
539
  explanation: asString(apiQuestion.explanation),
@@ -537,18 +552,27 @@ const reverseCrossOutWordGroup = (apiQuestion) => {
537
552
  const fallback = asRecord(fallbackAnswers[index]);
538
553
  const answerRaw = Object.keys(itemAnswer).length > 0 ? itemAnswer : fallback;
539
554
  const isExample = item.isExample === true;
540
- const type = itemContent.type === 'CROSS_OUT_AND_REPLACE' ||
541
- answerRaw.type === 'CROSS_OUT_AND_REPLACE'
555
+ const type = itemContent.type === 'CROSS_OUT_AND_REPLACE'
542
556
  ? 'CROSS_OUT_AND_REPLACE'
543
- : 'CROSS_OUT';
557
+ : itemContent.type === 'CROSS_OUT'
558
+ ? 'CROSS_OUT'
559
+ : answerRaw.type === 'CROSS_OUT_AND_REPLACE'
560
+ ? 'CROSS_OUT_AND_REPLACE'
561
+ : 'CROSS_OUT';
562
+ const rawIndex = answerRaw.wordIndex;
563
+ const wordIndex = typeof rawIndex === 'number' && Number.isInteger(rawIndex) && rawIndex >= 0
564
+ ? rawIndex
565
+ : null;
544
566
  const correctAnswer = type === 'CROSS_OUT_AND_REPLACE'
545
567
  ? {
546
568
  type: 'CROSS_OUT_AND_REPLACE',
569
+ wordIndex,
547
570
  crossOut: asString(answerRaw.crossOut),
548
571
  replaceWith: asString(answerRaw.replaceWith),
549
572
  }
550
573
  : {
551
574
  type: 'CROSS_OUT',
575
+ wordIndex,
552
576
  crossOut: asString(answerRaw.crossOut),
553
577
  };
554
578
  return {
@@ -638,12 +662,14 @@ const reverseSpontaneousQaGroup = (apiQuestion) => {
638
662
  const fallback = asRecord(flattenedAnswers[questionIndex]);
639
663
  const expected = asArray(childAnswer.expectedAnswers ?? fallback.expectedAnswers)
640
664
  .filter((value) => typeof value === 'string');
665
+ const isExample = child.isExample === true;
641
666
  return {
642
667
  questionText: asString(childContent.questionText),
643
668
  inputType: asString(childContent.inputType, 'TEXT') === 'AUDIO' ? 'AUDIO' : 'TEXT',
644
669
  audioUrl: asString(childContent.audioUrl),
645
670
  expectedAnswers: expected.length > 0 ? expected : [''],
646
- points: asNumber(child.points, 1),
671
+ isExample,
672
+ points: isExample ? 0 : asNumber(child.points, 1),
647
673
  questionNumber: asNumber(child.questionNumber, questionIndex + 1),
648
674
  };
649
675
  }),
@@ -890,6 +916,9 @@ function reverseCrosswordPuzzle(apiQuestion) {
890
916
  const rows = apiContent.gridSize?.rows || apiContent.rows || 12;
891
917
  const cols = apiContent.gridSize?.cols || apiContent.cols || 12;
892
918
  const title = apiContent.title || '';
919
+ const type = apiContent.type === 'HIDDEN_WORD' ? 'HIDDEN_WORD' : 'STANDARD';
920
+ const instruction = asString(apiQuestion.instruction, asString(apiContent.instruction));
921
+ const markedColumn = typeof apiContent.markedColumn === 'number' ? apiContent.markedColumn : undefined;
893
922
  const across = Array.isArray(apiContent.clues?.across) ? apiContent.clues.across : [];
894
923
  const down = Array.isArray(apiContent.clues?.down) ? apiContent.clues.down : [];
895
924
  const answers = apiAnswer.answers || {};
@@ -904,6 +933,7 @@ function reverseCrosswordPuzzle(apiQuestion) {
904
933
  length: a.length || 1,
905
934
  direction: 'across',
906
935
  answer: answers[`across-${a.number}`] || '',
936
+ ...(a.isExample === true ? { isExample: true } : {}),
907
937
  });
908
938
  }
909
939
  for (const d of down) {
@@ -916,24 +946,32 @@ function reverseCrosswordPuzzle(apiQuestion) {
916
946
  length: d.length || 1,
917
947
  direction: 'down',
918
948
  answer: answers[`down-${d.number}`] || '',
949
+ ...(d.isExample === true ? { isExample: true } : {}),
919
950
  });
920
951
  }
921
952
  return {
922
953
  content: {
954
+ type,
923
955
  title,
956
+ instruction,
924
957
  rows,
925
958
  cols,
926
959
  gridSize: { rows, cols },
960
+ ...(type === 'HIDDEN_WORD' && markedColumn ? { markedColumn } : {}),
927
961
  clues: { across, down },
928
962
  },
929
963
  answer: {
964
+ type,
930
965
  title,
966
+ instruction,
931
967
  rows,
932
968
  cols,
969
+ ...(type === 'HIDDEN_WORD' && markedColumn ? { markedColumn } : {}),
970
+ hiddenWord: answers['hidden-word'] || '',
933
971
  clues,
934
972
  answers,
935
973
  caseSensitive: apiAnswer.caseSensitive || false,
936
- explanation: apiQuestion.explanation || '',
974
+ explanation: asString(apiQuestion.explanation),
937
975
  },
938
976
  };
939
977
  }
@@ -944,6 +982,7 @@ function reverseFindWordsInMatrix(apiQuestion) {
944
982
  const rows = apiContent.gridSize?.rows || (Array.isArray(apiContent.grid) ? apiContent.grid.length : 14);
945
983
  const cols = apiContent.gridSize?.cols || (Array.isArray(apiContent.grid?.[0]) ? apiContent.grid[0].length : 14);
946
984
  const title = apiContent.title || '';
985
+ const instruction = typeof apiContent.instruction === 'string' ? apiContent.instruction : '';
947
986
  const grid = Array.isArray(apiContent.grid) ? apiContent.grid : [];
948
987
  const categories = Array.isArray(apiContent.categories) ? apiContent.categories : [];
949
988
  const wordBank = Array.isArray(apiContent.wordBank) ? apiContent.wordBank : [];
@@ -977,6 +1016,7 @@ function reverseFindWordsInMatrix(apiQuestion) {
977
1016
  content: {
978
1017
  type,
979
1018
  title,
1019
+ instruction,
980
1020
  rows,
981
1021
  cols,
982
1022
  gridSize: { rows, cols },
@@ -989,6 +1029,7 @@ function reverseFindWordsInMatrix(apiQuestion) {
989
1029
  answer: {
990
1030
  type,
991
1031
  title,
1032
+ instruction,
992
1033
  rows,
993
1034
  cols,
994
1035
  grid,
@@ -20,6 +20,7 @@ export type CrosswordSubtype = 'STANDARD' | 'HIDDEN_WORD';
20
20
  export interface CrosswordPuzzleContent {
21
21
  type?: CrosswordSubtype;
22
22
  title?: string;
23
+ instruction?: string;
23
24
  gridSize: {
24
25
  rows: number;
25
26
  cols: number;
@@ -30,6 +30,7 @@ export interface ExampleSelection {
30
30
  export interface FindWordsInMatrixContent {
31
31
  type?: FindWordsInMatrixType;
32
32
  title?: string;
33
+ instruction?: string;
33
34
  gridSize: {
34
35
  rows: number;
35
36
  cols: number;
@@ -20,9 +20,9 @@ export interface MatchingWithLinesGroupContent {
20
20
  meta?: {
21
21
  instruction?: string;
22
22
  title?: string;
23
- audioUrl?: string;
23
+ audioUrl?: string | string[];
24
24
  passage?: string;
25
- imageUrl?: string;
25
+ imageUrl?: string | string[];
26
26
  };
27
27
  rightItems: MatchingWithLinesRightItem[];
28
28
  items: MatchingWithLinesGroupItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinyweb_dev/oe-exam-sdk",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Reusable OceanEdu question components.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",