questionModel.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import { deepCopy } from "@/plugins/utils";
  2. export const selectQuestion = {
  3. questionType: "SINGLE_ANSWER_QUESTION", // 2多选
  4. quesBody: null,
  5. quesOptions: [
  6. {
  7. number: 1,
  8. optionBody: null,
  9. },
  10. {
  11. number: 2,
  12. optionBody: null,
  13. },
  14. {
  15. number: 3,
  16. optionBody: null,
  17. },
  18. {
  19. number: 4,
  20. optionBody: null,
  21. },
  22. ],
  23. quesAnswer: null,
  24. answerAnalysis: null,
  25. };
  26. export const booleanQuestion = {
  27. questionType: "BOOL_ANSWER_QUESTION",
  28. quesBody: null,
  29. quesAnswer: null,
  30. answerAnalysis: null,
  31. };
  32. export const fillBlankQuestion = {
  33. questionType: "FILL_BLANK_QUESTION",
  34. quesBody: null,
  35. quesAnswer: [
  36. // {
  37. // index: 1,
  38. // sections: [{ blocks: [{ type: "text", value: "" }] }],
  39. // },
  40. ],
  41. answerAnalysis: null,
  42. };
  43. export const textAnswerQuestion = {
  44. questionType: "TEXT_ANSWER_QUESTION",
  45. quesBody: null,
  46. // only one
  47. quesAnswer: [
  48. // {
  49. // index: 1,
  50. // sections: [{ blocks: [{ type: "text", value: "" }] }],
  51. // },
  52. ],
  53. answerAnalysis: null,
  54. };
  55. // 完形填空/听力/阅读理解
  56. export const readingComprehensionQuestion = {
  57. questionType: "READING_COMPREHENSION",
  58. quesBody: null,
  59. answerAnalysis: null,
  60. subQuestions: [],
  61. };
  62. // 段落匹配/选词填空
  63. export const bankedClozeQuestion = {
  64. questionType: "BANKED_CLOZE",
  65. quesBody: null,
  66. answerAnalysis: null,
  67. subQuestions: [
  68. // {
  69. // number: 1,
  70. // quesAnswer: null,
  71. // difficulty: "易",
  72. // quesProperties: [],
  73. // },
  74. ],
  75. quesOptions: [
  76. {
  77. number: 1,
  78. optionBody: null,
  79. },
  80. {
  81. number: 2,
  82. optionBody: null,
  83. },
  84. ],
  85. quesParam: { matchingMode: 1, matchingType: 1 },
  86. // 段落匹配: "param": { "matchingMode": 2, "matchingType": 2 },
  87. // matchingType是配对题的属性,目前系统应该是用不到了
  88. // quesAnswer: [{ number: 1, answer: [8] }],
  89. };
  90. const models = {
  91. SINGLE_ANSWER_QUESTION: selectQuestion,
  92. MULTIPLE_ANSWER_QUESTION: Object.assign({}, selectQuestion, {
  93. questionType: "MULTIPLE_ANSWER_QUESTION",
  94. }),
  95. BOOL_ANSWER_QUESTION: booleanQuestion,
  96. FILL_BLANK_QUESTION: fillBlankQuestion,
  97. TEXT_ANSWER_QUESTION: textAnswerQuestion,
  98. READING_COMPREHENSION: readingComprehensionQuestion,
  99. LISTENING_QUESTION: Object.assign({}, readingComprehensionQuestion, {
  100. questionType: "LISTENING_QUESTION",
  101. }),
  102. CLOZE: Object.assign({}, readingComprehensionQuestion, {
  103. questionType: "CLOZE",
  104. }),
  105. PARAGRAPH_MATCHING: Object.assign({}, bankedClozeQuestion, {
  106. questionType: "PARAGRAPH_MATCHING",
  107. param: { matchingMode: 2, matchingType: 2 },
  108. }),
  109. BANKED_CLOZE: bankedClozeQuestion,
  110. };
  111. export const getInitQuestionModel = (qtype) => {
  112. return {
  113. id: null,
  114. editMode: "question",
  115. sourceDetailId: "",
  116. courseId: "",
  117. difficulty: "易",
  118. quesProperties: [],
  119. score: 0,
  120. publicity: true,
  121. control: { maxAnswerTime: 0 },
  122. ...deepCopy(models[qtype]),
  123. };
  124. };
  125. export const getMatchQuestionModel = () => {
  126. let matchQuestionModel = getInitQuestionModel("SINGLE_ANSWER_QUESTION");
  127. matchQuestionModel.quesOptions = null;
  128. return matchQuestionModel;
  129. };
  130. export const STRUCT_TYPE_COMP_DICT = {
  131. SINGLE_ANSWER_QUESTION: "select-question",
  132. MULTIPLE_ANSWER_QUESTION: "select-question",
  133. BOOL_ANSWER_QUESTION: "boolean-question",
  134. FILL_BLANK_QUESTION: "fill-blank-question",
  135. TEXT_ANSWER_QUESTION: "text-answer-question",
  136. READING_COMPREHENSION: "nested-question",
  137. LISTENING_QUESTION: "nested-question",
  138. CLOZE: "nested-question",
  139. PARAGRAPH_MATCHING: "banked-cloze-question",
  140. BANKED_CLOZE: "banked-cloze-question",
  141. };