@tinyweb_dev/oe-exam-sdk 0.1.29 → 0.1.31

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 (56) hide show
  1. package/dist/components/exams/ExamPreviewDialog.d.ts +9 -3
  2. package/dist/components/exams/ExamPreviewDialog.js +23 -5
  3. package/dist/components/exams/ExamPreviewPartContent.d.ts +2 -1
  4. package/dist/components/exams/ExamPreviewPartContent.js +3 -2
  5. package/dist/components/exams/ExamPreviewSidebar.d.ts +3 -1
  6. package/dist/components/exams/ExamPreviewSidebar.js +7 -2
  7. package/dist/components/exams/exam-preview.mode.d.ts +4 -0
  8. package/dist/components/exams/exam-preview.mode.js +5 -0
  9. package/dist/components/exams/index.d.ts +1 -0
  10. package/dist/components/exams/index.js +1 -0
  11. package/dist/components/exams/take/components/QuestionRenderer.js +5 -1
  12. package/dist/components/exams/take/utils/answer-transformers.js +2 -1
  13. package/dist/components/exams/take/utils/question-transformers.d.ts +6 -1
  14. package/dist/components/exams/take/utils/question-transformers.js +33 -0
  15. package/dist/components/questions/_shared/config/question-types.config.js +6 -0
  16. package/dist/components/questions/_shared/types/answer-the-question-group.type.d.ts +32 -0
  17. package/dist/components/questions/_shared/types/answer-the-question-group.type.js +1 -0
  18. package/dist/components/questions/creator/question-type-registry.js +2 -0
  19. package/dist/components/questions/types/answer-the-question-group/AnswerTheQuestionGroupClient.d.ts +2 -0
  20. package/dist/components/questions/types/answer-the-question-group/AnswerTheQuestionGroupClient.js +13 -0
  21. package/dist/components/questions/types/answer-the-question-group/AnswerTheQuestionGroupCreator.d.ts +2 -0
  22. package/dist/components/questions/types/answer-the-question-group/AnswerTheQuestionGroupCreator.js +183 -0
  23. package/dist/components/questions/types/answer-the-question-group/index.d.ts +5 -0
  24. package/dist/components/questions/types/answer-the-question-group/index.js +5 -0
  25. package/dist/components/questions/types/answer-the-question-group/map-answer-the-question-group-data.d.ts +4 -0
  26. package/dist/components/questions/types/answer-the-question-group/map-answer-the-question-group-data.js +83 -0
  27. package/dist/components/questions/types/answer-the-question-group/register.d.ts +2 -0
  28. package/dist/components/questions/types/answer-the-question-group/register.js +36 -0
  29. package/dist/components/questions/types/answer-the-question-group/transform.d.ts +2 -0
  30. package/dist/components/questions/types/answer-the-question-group/transform.js +72 -0
  31. package/dist/components/questions/types/speaking-conversation/SpeakingConversationPreviewClient.js +1 -1
  32. package/dist/components/questions/viewer/QuestionViewer.js +2 -2
  33. package/dist/components/questions/viewer/SpontaneousQaGroupViewer.js +4 -4
  34. package/dist/components/results/ReviewQuestionRenderer.js +1 -0
  35. package/dist/components/results/renderers/ReviewAnswerTheQuestionGroupRenderer.d.ts +19 -0
  36. package/dist/components/results/renderers/ReviewAnswerTheQuestionGroupRenderer.js +27 -0
  37. package/dist/components/results/renderers/review-question-body-dedicated.d.ts +1 -0
  38. package/dist/components/results/renderers/review-question-body-dedicated.js +47 -2
  39. package/dist/components/results/review-data.js +12 -0
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +1 -1
  42. package/dist/shared/constants/question-skills.js +2 -0
  43. package/dist/shared/lib/i18n/messages/en/admin.d.ts +5 -0
  44. package/dist/shared/lib/i18n/messages/en/admin.js +5 -0
  45. package/dist/shared/lib/i18n/messages/en.d.ts +5 -0
  46. package/dist/shared/lib/i18n/messages/vi/admin.d.ts +5 -0
  47. package/dist/shared/lib/i18n/messages/vi/admin.js +5 -0
  48. package/dist/shared/lib/i18n/messages/vi.d.ts +5 -0
  49. package/dist/shared/lib/utils/question-reverse-transform.js +39 -0
  50. package/dist/shared/lib/utils/question-transform.js +2 -0
  51. package/dist/shared/types/common.types.d.ts +1 -1
  52. package/dist/shared/types/questions/answer-the-question-group.d.ts +39 -0
  53. package/dist/shared/types/questions/answer-the-question-group.js +1 -0
  54. package/dist/shared/types/questions/index.d.ts +1 -0
  55. package/dist/shared/types/questions/index.js +2 -0
  56. package/package.json +1 -1
@@ -186,6 +186,44 @@ const reverseChooseTheCorrectAnswerGroup = (apiQuestion) => {
186
186
  },
187
187
  };
188
188
  };
189
+ const reverseAnswerTheQuestionGroup = (apiQuestion) => {
190
+ const content = asRecord(apiQuestion.content);
191
+ const answer = readAnswer(apiQuestion);
192
+ const fallbackAnswers = asArray(answer.answer);
193
+ const items = asArray(content.items).map((rawItem, index) => {
194
+ const item = asRecord(rawItem);
195
+ const itemContent = asRecord(item.content);
196
+ const itemAnswer = asRecord(item.correctAnswer);
197
+ const nested = asArray(itemAnswer.expectedAnswers)
198
+ .filter((value) => typeof value === 'string')
199
+ .map((value) => value.trim())
200
+ .filter((value) => value !== '');
201
+ const fallback = asRecord(fallbackAnswers[index]);
202
+ const fallbackExpected = asArray(fallback.expectedAnswers)
203
+ .filter((value) => typeof value === 'string')
204
+ .map((value) => value.trim())
205
+ .filter((value) => value !== '');
206
+ const expectedAnswers = nested.length > 0 ? nested : (fallbackExpected.length > 0 ? fallbackExpected : ['']);
207
+ const isExample = item.isExample === true;
208
+ return {
209
+ question: asString(itemContent.question),
210
+ expectedAnswers,
211
+ isExample,
212
+ points: isExample ? 0 : asNumber(item.points, 1),
213
+ questionNumber: asNumber(item.questionNumber, index + 1),
214
+ };
215
+ });
216
+ return {
217
+ content: '',
218
+ answer: {
219
+ instruction: asString(asRecord(content.meta).instruction, 'Read the text again and answer the questions.'),
220
+ passage: asString(asRecord(content.meta).passage),
221
+ items,
222
+ explanation: asString(apiQuestion.explanation),
223
+ points: items.reduce((total, item) => (item.isExample ? total : total + item.points), 0),
224
+ },
225
+ };
226
+ };
189
227
  const reverseTrueFalseGroup = (apiQuestion) => {
190
228
  const content = asRecord(apiQuestion.content);
191
229
  const answer = readAnswer(apiQuestion);
@@ -367,6 +405,7 @@ const reverseSimpleAnswer = (apiQuestion) => {
367
405
  const handlers = {
368
406
  CHOOSE_THE_CORRECT_ANSWER: reverseChooseTheCorrectAnswer,
369
407
  CHOOSE_THE_CORRECT_ANSWER_GROUP: reverseChooseTheCorrectAnswerGroup,
408
+ ANSWER_THE_QUESTION_GROUP: reverseAnswerTheQuestionGroup,
370
409
  TRUE_FALSE_GROUP: reverseTrueFalseGroup,
371
410
  CROSS_OUT_WORD_GROUP: reverseCrossOutWordGroup,
372
411
  WORD_ORDER_AND_MATCH_GROUP: reverseWordOrderAndMatchGroup,
@@ -17,6 +17,7 @@ import { transformFillInBlank } from '../../../components/questions/types/fill-i
17
17
  import { transformWriteCorrectVerbForm } from '../../../components/questions/types/write-correct-verb-form/transform';
18
18
  import { transformChooseCorrectAdjective } from '../../../components/questions/types/choose-correct-adjective/transform';
19
19
  import { transformAnswerTheQuestion } from '../../../components/questions/types/answer-the-question/transform';
20
+ import { transformAnswerTheQuestionGroup } from '../../../components/questions/types/answer-the-question-group/transform';
20
21
  import { transformTrueFalse } from '../../../components/questions/types/true-false/transform';
21
22
  import { transformWordOrdering } from '../../../components/questions/types/word-ordering/transform';
22
23
  import { transformWordFillParagraph } from '../../../components/questions/types/word-fill-paragraph/transform';
@@ -63,6 +64,7 @@ const questionTransformHandlers = {
63
64
  WRITE_CORRECT_VERB_FORM: transformWriteCorrectVerbForm,
64
65
  CHOOSE_CORRECT_ADJECTIVE: transformChooseCorrectAdjective,
65
66
  ANSWER_THE_QUESTION: transformAnswerTheQuestion,
67
+ ANSWER_THE_QUESTION_GROUP: transformAnswerTheQuestionGroup,
66
68
  TRUE_FALSE: transformTrueFalse,
67
69
  WORD_ORDERING: transformWordOrdering,
68
70
  WORD_FILL_PARAGRAPH: transformWordFillParagraph,
@@ -29,7 +29,7 @@ export declare enum StudentSelectionType {
29
29
  }
30
30
  export type ResultStatus = 'PENDING' | 'PARTIAL_GRADED' | 'GRADED';
31
31
  export type StudentStatus = 'NOT_STARTED' | 'IN_PROGRESS' | 'SUBMITTED';
32
- export type QuestionType = 'FILL_IN_BLANK' | 'TRUE_FALSE' | 'MATCHING' | 'ORDERING' | 'LISTENING' | 'COLORING' | 'ESSAY' | 'LISTEN_AND_FILL_IN_THE_BLANK_WITH_IMAGE' | 'LISTEN_AND_TICK_ANSWER' | 'LISTEN_AND_FILL_NAME_NUMBER' | 'LISTENING_FILL_BLANK' | 'LISTENING_COLOR' | 'TICK_TRUE_OR_FALSE' | 'TICK_YES_OR_NO' | 'READING_TICK_CROSS' | 'ARRANGE_LETTERS_INTO_WORDS' | 'READ_PASSAGE_AND_COMPLETE_STORY' | 'CLOZE_TEST_WITH_TICK_BOX' | 'READ_AND_CHOOSE_APPROPRIATE_WORD' | 'WRITE_SHORT_PARAGRAPH' | 'LABEL_THE_PICTURE' | 'READING_LETTER_ARRANGE' | 'READING_PASSAGE_FILL' | 'FILL_BLANK' | 'FILL_MISSING_WORDS_IN_GRID' | 'LOOK_PICTURE_CHOOSE_CORRECT_ANSWER' | 'LOOK_PICTURE_FILL_BLANK_CHOOSE_ANSWER' | 'LOOK_PICTURE_FILL_WORD_HINT' | 'LABEL_THE_PICTURE' | 'READ_AND_COLOR_OBJECTS' | 'IMAGE_OBJECT_MATCHING' | 'READ_PASSAGE_AND_ANSWER_QUESTIONS' | 'CHOOSE_THE_CORRECT_ANSWER' | 'CHOOSE_THE_CORRECT_ANSWER_GROUP' | 'TRUE_FALSE_GROUP' | 'CROSS_OUT_WORD_GROUP' | 'SPONTANEOUS_QA_GROUP' | 'WORD_ORDER_AND_MATCH_GROUP' | 'WRITE_A_SHORT_LETTER' | 'WRITE_CORRECT_VERB_FORM' | 'CHOOSE_CORRECT_ADJECTIVE' | 'ANSWER_THE_QUESTION' | 'WORD_ORDERING' | 'WORD_FILL_PARAGRAPH' | 'MATCH_BY_WRITING_ANSWER' | 'WRITE_SENTENCES' | 'LISTEN_AND_CHOOSE_FROM_ANSWER_GROUP' | 'LISTEN_AND_CHOOSE_OBJECTS_IN_SCENE' | 'LISTEN_AND_DRAG_OBJECTS_INTO_SCENE' | 'LISTEN_AND_SPEAK_ANSWER' | 'LISTEN_AND_SPEAK_IMAGE_GROUP' | 'LISTEN_AND_SPEAK_QUESTION_LIST' | 'LISTEN_AND_SPEAK_COMPARE_IMAGES' | 'LISTEN_AND_SPEAK_WITH_STORY_IMAGES' | 'LISTEN_AND_SPEAK_ODD_ONE_OUT' | 'LISTEN_AND_SPEAK_INFO_EXCHANGE' | 'READ_DISPLAYED_CONTENT' | 'SPEAKING_DESCRIBE_IMAGE' | 'SPONTANEOUS_QA' | 'SPEAKING_CONVERSATION' | 'GN_SPEAKING_INTERVIEW' | 'SPEAKING_CUE_CARD' | 'WORD_FILL_STRUCTURED_FORM';
32
+ export type QuestionType = 'FILL_IN_BLANK' | 'TRUE_FALSE' | 'MATCHING' | 'ORDERING' | 'LISTENING' | 'COLORING' | 'ESSAY' | 'LISTEN_AND_FILL_IN_THE_BLANK_WITH_IMAGE' | 'LISTEN_AND_TICK_ANSWER' | 'LISTEN_AND_FILL_NAME_NUMBER' | 'LISTENING_FILL_BLANK' | 'LISTENING_COLOR' | 'TICK_TRUE_OR_FALSE' | 'TICK_YES_OR_NO' | 'READING_TICK_CROSS' | 'ARRANGE_LETTERS_INTO_WORDS' | 'READ_PASSAGE_AND_COMPLETE_STORY' | 'CLOZE_TEST_WITH_TICK_BOX' | 'READ_AND_CHOOSE_APPROPRIATE_WORD' | 'WRITE_SHORT_PARAGRAPH' | 'LABEL_THE_PICTURE' | 'READING_LETTER_ARRANGE' | 'READING_PASSAGE_FILL' | 'FILL_BLANK' | 'FILL_MISSING_WORDS_IN_GRID' | 'LOOK_PICTURE_CHOOSE_CORRECT_ANSWER' | 'LOOK_PICTURE_FILL_BLANK_CHOOSE_ANSWER' | 'LOOK_PICTURE_FILL_WORD_HINT' | 'LABEL_THE_PICTURE' | 'READ_AND_COLOR_OBJECTS' | 'IMAGE_OBJECT_MATCHING' | 'READ_PASSAGE_AND_ANSWER_QUESTIONS' | 'CHOOSE_THE_CORRECT_ANSWER' | 'CHOOSE_THE_CORRECT_ANSWER_GROUP' | 'TRUE_FALSE_GROUP' | 'CROSS_OUT_WORD_GROUP' | 'SPONTANEOUS_QA_GROUP' | 'WORD_ORDER_AND_MATCH_GROUP' | 'WRITE_A_SHORT_LETTER' | 'WRITE_CORRECT_VERB_FORM' | 'CHOOSE_CORRECT_ADJECTIVE' | 'ANSWER_THE_QUESTION' | 'ANSWER_THE_QUESTION_GROUP' | 'WORD_ORDERING' | 'WORD_FILL_PARAGRAPH' | 'MATCH_BY_WRITING_ANSWER' | 'WRITE_SENTENCES' | 'LISTEN_AND_CHOOSE_FROM_ANSWER_GROUP' | 'LISTEN_AND_CHOOSE_OBJECTS_IN_SCENE' | 'LISTEN_AND_DRAG_OBJECTS_INTO_SCENE' | 'LISTEN_AND_SPEAK_ANSWER' | 'LISTEN_AND_SPEAK_IMAGE_GROUP' | 'LISTEN_AND_SPEAK_QUESTION_LIST' | 'LISTEN_AND_SPEAK_COMPARE_IMAGES' | 'LISTEN_AND_SPEAK_WITH_STORY_IMAGES' | 'LISTEN_AND_SPEAK_ODD_ONE_OUT' | 'LISTEN_AND_SPEAK_INFO_EXCHANGE' | 'READ_DISPLAYED_CONTENT' | 'SPEAKING_DESCRIBE_IMAGE' | 'SPONTANEOUS_QA' | 'SPEAKING_CONVERSATION' | 'GN_SPEAKING_INTERVIEW' | 'SPEAKING_CUE_CARD' | 'WORD_FILL_STRUCTURED_FORM';
33
33
  export type Level = 'Pre-A1' | 'A1' | 'A2' | 'B1' | 'B2' | 'C1' | 'C2';
34
34
  export type Difficulty = 'EASY' | 'MEDIUM' | 'HARD';
35
35
  export type Skill = 'LISTENING' | 'READING' | 'WRITING' | 'SPEAKING';
@@ -0,0 +1,39 @@
1
+ export declare const ANSWER_THE_QUESTION_GROUP_GRADING_TYPE: "AI";
2
+ export interface AnswerTheQuestionGroupItemContent {
3
+ question: string;
4
+ }
5
+ export interface AnswerTheQuestionGroupItemExpectedAnswer {
6
+ expectedAnswers: string[];
7
+ }
8
+ export interface AnswerTheQuestionGroupItem {
9
+ questionType?: 'ANSWER_THE_QUESTION';
10
+ isExample?: boolean;
11
+ content: AnswerTheQuestionGroupItemContent;
12
+ correctAnswer?: AnswerTheQuestionGroupItemExpectedAnswer;
13
+ points?: number;
14
+ questionNumber?: number;
15
+ }
16
+ export interface AnswerTheQuestionGroupContent {
17
+ meta?: {
18
+ instruction?: string;
19
+ passage?: string;
20
+ gradingType: typeof ANSWER_THE_QUESTION_GROUP_GRADING_TYPE;
21
+ isAiGraded: true;
22
+ };
23
+ items: AnswerTheQuestionGroupItem[];
24
+ }
25
+ export interface AnswerTheQuestionGroupCorrectAnswer {
26
+ answer: AnswerTheQuestionGroupItemExpectedAnswer[];
27
+ }
28
+ export interface AnswerTheQuestionGroupAPIPayload {
29
+ id?: string;
30
+ questionType: 'ANSWER_THE_QUESTION_GROUP';
31
+ content: AnswerTheQuestionGroupContent;
32
+ correctAnswer: AnswerTheQuestionGroupCorrectAnswer;
33
+ points: number;
34
+ explanation?: string;
35
+ questionNumber: number;
36
+ partId?: string;
37
+ partNo?: number;
38
+ }
39
+ export type AnswerTheQuestionGroupLocalStorage = AnswerTheQuestionGroupAPIPayload;
@@ -0,0 +1 @@
1
+ export const ANSWER_THE_QUESTION_GROUP_GRADING_TYPE = 'AI';
@@ -16,6 +16,7 @@
16
16
  * - LocalStorage: Same format but WITHOUT addToQuestionBank and questionBank
17
17
  */
18
18
  export * from './choose-the-correct-answer';
19
+ export * from './answer-the-question-group';
19
20
  export * from './choose-the-correct-answer-group';
20
21
  export * from './cross-out-word-group';
21
22
  export * from './write-correct-verb-form';
@@ -17,6 +17,8 @@
17
17
  */
18
18
  // CHOOSE_THE_CORRECT_ANSWER
19
19
  export * from './choose-the-correct-answer';
20
+ // ANSWER_THE_QUESTION_GROUP
21
+ export * from './answer-the-question-group';
20
22
  // CHOOSE_THE_CORRECT_ANSWER_GROUP
21
23
  export * from './choose-the-correct-answer-group';
22
24
  // CROSS_OUT_WORD_GROUP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinyweb_dev/oe-exam-sdk",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "Reusable OceanEdu question components.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",