|
@@ -1,7 +1,7 @@
|
|
<template>
|
|
<template>
|
|
<div class="answer">
|
|
<div class="answer">
|
|
<header class="header">
|
|
<header class="header">
|
|
- <div class="back round" @click="$router.push('/personal_question')">
|
|
|
|
|
|
+ <div class="back round" @click="goBack">
|
|
<i class="el-icon-arrow-left"></i>
|
|
<i class="el-icon-arrow-left"></i>
|
|
<span>返回</span>
|
|
<span>返回</span>
|
|
</div>
|
|
</div>
|
|
@@ -16,7 +16,9 @@
|
|
|
|
|
|
<main class="main">
|
|
<main class="main">
|
|
<StartQuestion
|
|
<StartQuestion
|
|
- v-if="curQuestionIndex === -1"
|
|
|
|
|
|
+ v-if="
|
|
|
|
+ curQuestionIndex === -1 && !(user_answer_record_info.is_exist_answer_record === 'true' && answer_mode === 2)
|
|
|
|
+ "
|
|
:question-length="questionList.length"
|
|
:question-length="questionList.length"
|
|
:answer-time-limit-minute="answer_time_limit_minute"
|
|
:answer-time-limit-minute="answer_time_limit_minute"
|
|
@startAnswer="startAnswer"
|
|
@startAnswer="startAnswer"
|
|
@@ -39,7 +41,11 @@
|
|
<div v-show="isAnnotations" class="annotations"><i class="el-icon-plus"></i>批注</div>
|
|
<div v-show="isAnnotations" class="annotations"><i class="el-icon-plus"></i>批注</div>
|
|
|
|
|
|
<div>
|
|
<div>
|
|
- <template v-if="curQuestionIndex === -1">
|
|
|
|
|
|
+ <template
|
|
|
|
+ v-if="
|
|
|
|
+ curQuestionIndex === -1 && !(user_answer_record_info.is_exist_answer_record === 'true' && answer_mode === 2)
|
|
|
|
+ "
|
|
|
|
+ >
|
|
<el-button type="primary" round @click="startAnswer">开始答题</el-button>
|
|
<el-button type="primary" round @click="startAnswer">开始答题</el-button>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -70,6 +76,7 @@ import {
|
|
SubmitAnswer,
|
|
SubmitAnswer,
|
|
GetQuestionInfo_AnswerRecord,
|
|
GetQuestionInfo_AnswerRecord,
|
|
} from '@/api/exercise';
|
|
} from '@/api/exercise';
|
|
|
|
+import { subjectiveQuestionList } from './answer';
|
|
|
|
|
|
import StartQuestion from './components/StartQuestion.vue';
|
|
import StartQuestion from './components/StartQuestion.vue';
|
|
import AnswerReport from './components/AnswerReport.vue';
|
|
import AnswerReport from './components/AnswerReport.vue';
|
|
@@ -105,6 +112,7 @@ export default {
|
|
answer_time_limit_minute: 30, // 答题时间限制
|
|
answer_time_limit_minute: 30, // 答题时间限制
|
|
time: 1800,
|
|
time: 1800,
|
|
isSubmit: false,
|
|
isSubmit: false,
|
|
|
|
+ isView: false, // 练习模式下是否查看
|
|
curQuestionPage: '', // 当前问题页面
|
|
curQuestionPage: '', // 当前问题页面
|
|
isAnnotations: false, // 是否显示批注
|
|
isAnnotations: false, // 是否显示批注
|
|
};
|
|
};
|
|
@@ -130,10 +138,18 @@ export default {
|
|
|
|
|
|
if (this.share_record_id) {
|
|
if (this.share_record_id) {
|
|
GetShareRecordInfo({ share_record_id: this.share_record_id }).then(
|
|
GetShareRecordInfo({ share_record_id: this.share_record_id }).then(
|
|
- ({ user_answer_record_info, share_record: { exercise_id } }) => {
|
|
|
|
|
|
+ ({ user_answer_record_info, share_record: { exercise_id, answer_mode, answer_time_limit_minute } }) => {
|
|
this.user_answer_record_info = user_answer_record_info;
|
|
this.user_answer_record_info = user_answer_record_info;
|
|
this.exercise_id = exercise_id;
|
|
this.exercise_id = exercise_id;
|
|
this.getExerciseQuestionIndexList();
|
|
this.getExerciseQuestionIndexList();
|
|
|
|
+ this.answer_time_limit_minute = answer_time_limit_minute;
|
|
|
|
+ this.time = answer_time_limit_minute * 60;
|
|
|
|
+ // 如果是考试模式,且已经存在答题记录,则直接显示答题报告
|
|
|
|
+ if (this.user_answer_record_info.is_exist_answer_record === 'true' && answer_mode === 2) {
|
|
|
|
+ this.answer_record_id = this.user_answer_record_info.answer_record_id;
|
|
|
|
+ this.answer_mode = answer_mode;
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -146,6 +162,14 @@ export default {
|
|
}));
|
|
}));
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ goBack() {
|
|
|
|
+ if (this.isView) {
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+ this.isView = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.$router.push('/personal_question');
|
|
|
|
+ },
|
|
// 倒计时
|
|
// 倒计时
|
|
countDown() {
|
|
countDown() {
|
|
this.countDownTimer = setInterval(() => {
|
|
this.countDownTimer = setInterval(() => {
|
|
@@ -161,10 +185,8 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
StartAnswer({ exercise_id: this.exercise_id, share_record_id: this.share_record_id }).then(
|
|
StartAnswer({ exercise_id: this.exercise_id, share_record_id: this.share_record_id }).then(
|
|
- ({ answer_time_limit_minute, answer_mode, answer_record_id }) => {
|
|
|
|
|
|
+ ({ answer_mode, answer_record_id }) => {
|
|
this.answer_record_id = answer_record_id;
|
|
this.answer_record_id = answer_record_id;
|
|
- this.answer_time_limit_minute = answer_time_limit_minute;
|
|
|
|
- this.time = answer_time_limit_minute * 60;
|
|
|
|
this.countDown();
|
|
this.countDown();
|
|
this.answer_mode = answer_mode;
|
|
this.answer_mode = answer_mode;
|
|
this.curQuestionIndex = 0;
|
|
this.curQuestionIndex = 0;
|
|
@@ -172,14 +194,6 @@ export default {
|
|
},
|
|
},
|
|
);
|
|
);
|
|
},
|
|
},
|
|
- preQuestion() {
|
|
|
|
- if (this.curQuestionIndex === 0) return;
|
|
|
|
- this.curQuestionIndex -= 1;
|
|
|
|
- },
|
|
|
|
- nextQuestion() {
|
|
|
|
- if (this.curQuestionIndex === this.questionList.length - 1) return;
|
|
|
|
- this.curQuestionIndex += 1;
|
|
|
|
- },
|
|
|
|
// 获取题目信息
|
|
// 获取题目信息
|
|
getQuestionInfo() {
|
|
getQuestionInfo() {
|
|
GetQuestionInfo({ question_id: this.questionList[this.curQuestionIndex].id })
|
|
GetQuestionInfo({ question_id: this.questionList[this.curQuestionIndex].id })
|
|
@@ -194,6 +208,14 @@ export default {
|
|
})
|
|
})
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
},
|
|
},
|
|
|
|
+ preQuestion() {
|
|
|
|
+ if (this.curQuestionIndex === 0) return;
|
|
|
|
+ this.curQuestionIndex -= 1;
|
|
|
|
+ },
|
|
|
|
+ nextQuestion() {
|
|
|
|
+ if (this.curQuestionIndex === this.questionList.length - 1) return;
|
|
|
|
+ this.curQuestionIndex += 1;
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 填写答案
|
|
* 填写答案
|
|
* @param {'pre' | 'next'} type 上一题/下一题
|
|
* @param {'pre' | 'next'} type 上一题/下一题
|
|
@@ -205,7 +227,11 @@ export default {
|
|
this.curQuestionIndex = type === 'pre' ? this.curQuestionIndex - 1 : this.curQuestionIndex + 1;
|
|
this.curQuestionIndex = type === 'pre' ? this.curQuestionIndex - 1 : this.curQuestionIndex + 1;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (this.questionList[this.curQuestionIndex].isFill) {
|
|
|
|
|
|
+ // 如果是主观题或已填写,直接跳转
|
|
|
|
+ if (
|
|
|
|
+ this.questionList[this.curQuestionIndex].isFill ||
|
|
|
|
+ subjectiveQuestionList.includes(this.currentQuestion.type)
|
|
|
|
+ ) {
|
|
if (type === 'pre') return this.preQuestion();
|
|
if (type === 'pre') return this.preQuestion();
|
|
if (type === 'next') return this.nextQuestion();
|
|
if (type === 'next') return this.nextQuestion();
|
|
}
|
|
}
|
|
@@ -219,6 +245,7 @@ export default {
|
|
this.questionList[this.curQuestionIndex].isFill = true;
|
|
this.questionList[this.curQuestionIndex].isFill = true;
|
|
// if (type === 'pre') return this.preQuestion();
|
|
// if (type === 'pre') return this.preQuestion();
|
|
// if (type === 'next') return this.nextQuestion();
|
|
// if (type === 'next') return this.nextQuestion();
|
|
|
|
+ // 显示答案
|
|
this.$refs.exercise[0].showAnswer(
|
|
this.$refs.exercise[0].showAnswer(
|
|
this.answer_mode === 1,
|
|
this.answer_mode === 1,
|
|
this.user_answer_record_info.correct_answer_show_mode === 1,
|
|
this.user_answer_record_info.correct_answer_show_mode === 1,
|
|
@@ -236,7 +263,7 @@ export default {
|
|
this.$refs.exercise[0].showAnswer(
|
|
this.$refs.exercise[0].showAnswer(
|
|
this.answer_mode === 1,
|
|
this.answer_mode === 1,
|
|
this.user_answer_record_info.correct_answer_show_mode === 1,
|
|
this.user_answer_record_info.correct_answer_show_mode === 1,
|
|
- JSON.parse(content),
|
|
|
|
|
|
+ JSON.parse(content || '{}'),
|
|
);
|
|
);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -246,21 +273,25 @@ export default {
|
|
|
|
|
|
// 如果已经填写过答案,直接提交
|
|
// 如果已经填写过答案,直接提交
|
|
if (this.questionList[this.curQuestionIndex].isFill) {
|
|
if (this.questionList[this.curQuestionIndex].isFill) {
|
|
- SubmitAnswer({ answer_record_id: this.answer_record_id }).then(() => {
|
|
|
|
- this.isSubmit = true;
|
|
|
|
- });
|
|
|
|
|
|
+ SubmitAnswer({ answer_record_id: this.answer_record_id })
|
|
|
|
+ .then(() => {
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
this.fillQuestionAnswer('next').then(() => {
|
|
this.fillQuestionAnswer('next').then(() => {
|
|
- SubmitAnswer({ answer_record_id: this.answer_record_id }).then(() => {
|
|
|
|
- this.isSubmit = true;
|
|
|
|
- });
|
|
|
|
|
|
+ SubmitAnswer({ answer_record_id: this.answer_record_id })
|
|
|
|
+ .then(() => {
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
});
|
|
});
|
|
},
|
|
},
|
|
selectQuestion(i) {
|
|
selectQuestion(i) {
|
|
- console.log(i);
|
|
|
|
this.isSubmit = false;
|
|
this.isSubmit = false;
|
|
|
|
+ this.isView = true;
|
|
this.curQuestionIndex = i;
|
|
this.curQuestionIndex = i;
|
|
},
|
|
},
|
|
},
|
|
},
|