|
@@ -259,18 +259,31 @@ export default {
|
|
let paperData = deepCopy(this.$refs.QuestionImportPaperEdit.getData());
|
|
let paperData = deepCopy(this.$refs.QuestionImportPaperEdit.getData());
|
|
const transformFieldMap = { body: "quesBody", options: "quesOptions" };
|
|
const transformFieldMap = { body: "quesBody", options: "quesOptions" };
|
|
const fields = Object.keys(transformFieldMap);
|
|
const fields = Object.keys(transformFieldMap);
|
|
|
|
+
|
|
|
|
+ const transformQuestion = (question) => {
|
|
|
|
+ question.id = null;
|
|
|
|
+ fields.forEach((field) => {
|
|
|
|
+ question[transformFieldMap[field]] = question[field];
|
|
|
|
+ delete question[field];
|
|
|
|
+ });
|
|
|
|
+ if (question.quesOptions && question.quesOptions.length) {
|
|
|
|
+ question.quesOptions = question.quesOptions.map((option) => {
|
|
|
|
+ option.optionBody = option.body;
|
|
|
|
+ delete option.body;
|
|
|
|
+ return option;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return question;
|
|
|
|
+ };
|
|
|
|
+
|
|
const detailInfo = paperData.map((detail) => {
|
|
const detailInfo = paperData.map((detail) => {
|
|
const questionInfo = detail.questions.map((question) => {
|
|
const questionInfo = detail.questions.map((question) => {
|
|
- question.id = null;
|
|
|
|
- fields.forEach((field) => {
|
|
|
|
- question[transformFieldMap[field]] = question[field];
|
|
|
|
- delete question[field];
|
|
|
|
- });
|
|
|
|
|
|
+ transformQuestion(question);
|
|
|
|
|
|
if (question.subQuestions && question.subQuestions.length) {
|
|
if (question.subQuestions && question.subQuestions.length) {
|
|
- question.subQuestions.forEach((subq) => {
|
|
|
|
- subq.id = null;
|
|
|
|
- });
|
|
|
|
|
|
+ question.subQuestions = question.subQuestions.map((subq) =>
|
|
|
|
+ transformQuestion(subq)
|
|
|
|
+ );
|
|
question.score = calcSum(
|
|
question.score = calcSum(
|
|
question.subQuestions.map((q) => q.score || 0)
|
|
question.subQuestions.map((q) => q.score || 0)
|
|
);
|
|
);
|