|
@@ -1,4 +1,4 @@
|
|
|
-import { numberToChinese } from "@/plugins/utils";
|
|
|
+import { numberToChinese, maxNum } from "@/plugins/utils";
|
|
|
import {
|
|
|
getModel as createFillQuestion,
|
|
|
getFullModel as getFillQuesitonElements,
|
|
@@ -177,6 +177,47 @@ export function getFillBackClozeCount(questionBodyContent) {
|
|
|
return num;
|
|
|
}
|
|
|
|
|
|
+function parseCommonQuestionPresetData(struct) {
|
|
|
+ const choiceQs = [
|
|
|
+ "SINGLE_ANSWER_QUESTION",
|
|
|
+ "MULTIPLE_ANSWER_QUESTION",
|
|
|
+ "BOOL_ANSWER_QUESTION",
|
|
|
+ ];
|
|
|
+ const { questions, structType } = struct;
|
|
|
+ let info = {};
|
|
|
+ if (choiceQs.includes(structType)) {
|
|
|
+ const optionCount = maxNum(questions.map((q) => q.optionCount));
|
|
|
+ const maxQuestionNo = maxNum(questions.map((q) => q.questionNo));
|
|
|
+ info = {
|
|
|
+ questionsCount: questions.length,
|
|
|
+ optionCount,
|
|
|
+ startNumber: maxQuestionNo - questions.length + 1,
|
|
|
+ };
|
|
|
+ } else if (structType === "FILL_BLANK_QUESTION") {
|
|
|
+ const optionCount = maxNum(questions.map((q) => q.fillCount));
|
|
|
+ const maxQuestionNo = maxNum(questions.map((q) => q.questionNo));
|
|
|
+ info = {
|
|
|
+ questionLineNums: questions.map((item) => {
|
|
|
+ return {
|
|
|
+ no: item.questionNo,
|
|
|
+ count: item.fillCount,
|
|
|
+ };
|
|
|
+ }),
|
|
|
+ questionLineType: "custom",
|
|
|
+ questionsCount: questions.length,
|
|
|
+ optionCount,
|
|
|
+ startNumber: maxQuestionNo - questions.length + 1,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ const maxQuestionNo = maxNum(questions);
|
|
|
+ info = {
|
|
|
+ questionsCount: questions.length,
|
|
|
+ startNumber: maxQuestionNo - questions.length + 1,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return info;
|
|
|
+}
|
|
|
+
|
|
|
export function buildCardElements(structList, elementTypePreSetInfo = {}) {
|
|
|
let cardElements = [];
|
|
|
structList.forEach((struct) => {
|
|
@@ -193,7 +234,8 @@ export function buildCardElements(structList, elementTypePreSetInfo = {}) {
|
|
|
const presetData = {
|
|
|
...elementTypePreSet,
|
|
|
topicName: `${topicName}、${qno}`,
|
|
|
- paperStruct: { ...struct, questions: [qno] },
|
|
|
+ questionsCount: 1,
|
|
|
+ startNumber: qno,
|
|
|
};
|
|
|
|
|
|
const elements = elementModel[modelType](presetData);
|
|
@@ -202,10 +244,10 @@ export function buildCardElements(structList, elementTypePreSetInfo = {}) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- let presetData = {
|
|
|
- ...elementTypePreSet,
|
|
|
+ const presetData = {
|
|
|
topicName,
|
|
|
- paperStruct: struct,
|
|
|
+ ...elementTypePreSet,
|
|
|
+ ...parseCommonQuestionPresetData(struct),
|
|
|
};
|
|
|
if (struct.structType === "MULTIPLE_ANSWER_QUESTION")
|
|
|
presetData.isMultiply = true;
|