|
|
@@ -47,7 +47,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+import {ElMessage} from "element-plus";
|
|
|
import store from "@/store";
|
|
|
import timeUtil from "@/utils/time";
|
|
|
|
|
|
@@ -181,8 +181,9 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- // TODO 分情况处理跳转
|
|
|
async toTestInfo() {
|
|
|
+ const _this = this;
|
|
|
+ // 未登录
|
|
|
if (!this.isLogin) {
|
|
|
ElMessage({
|
|
|
showClose: true,
|
|
|
@@ -193,86 +194,70 @@ export default {
|
|
|
await this.$router.push({name: "Auth", params: {login_to: "/portal"}});
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ // 已登录
|
|
|
+ // 教师(拥有者)
|
|
|
if (this.isCreator) {
|
|
|
if (this.type === "eval") {
|
|
|
- this.$router.push(`/evalExam/${this.testVO.examId}/teacher/details`);
|
|
|
+ this.toEvalExamPage(this.testVO.examId);
|
|
|
} else {
|
|
|
- this.$router.push(`/exam/${this.testVO.id}`); //跳转到考试详情页
|
|
|
+ this.toCoderExamPage(this.testVO.coderId);
|
|
|
}
|
|
|
- } else if (this.isTeacher) {
|
|
|
+ }
|
|
|
+ // 其他教师
|
|
|
+ else if (this.isTeacher) {
|
|
|
this.$message.error("无权访问其他教师创建的课程");
|
|
|
- } else {
|
|
|
- let messageBoxContent = "";
|
|
|
- let messageBoxTitle = "";
|
|
|
- let confirmButtonText = "";
|
|
|
- let cancelButtonText = "让我想想";
|
|
|
- let nextURL = "";
|
|
|
- if (this.type === "eval") {
|
|
|
- messageBoxTitle = "Eval";
|
|
|
- if (this.testVO.isJoined) {
|
|
|
- nextURL = "https://eval.seec.seecoder.cn/exam/" + this.testVO.id + "/before-exam/?id_token=" + this.$store.state.user.token;
|
|
|
- window.open(nextURL);
|
|
|
- return;
|
|
|
- } else {
|
|
|
- const courseId = (await this.$apis.getCourseByEvalId(this.testVO.course.id)).data.data;
|
|
|
- if (courseId) {
|
|
|
- const isCourseSelected = (await this.$apis.checkCourseSelection(courseId, this.$store.state.user.id)).data.data;
|
|
|
- if (isCourseSelected) {
|
|
|
- messageBoxContent = "是否立即查看测试详情";
|
|
|
- confirmButtonText = "立即查看";
|
|
|
- nextURL = "https://eval.seec.seecoder.cn/student/home/?id_token=" + this.$store.state.user.token;
|
|
|
- } else {
|
|
|
- messageBoxContent = "尚未参加课程,是否立即参加?";
|
|
|
- confirmButtonText = "立即选课";
|
|
|
- nextURL = "/course/" + courseId;
|
|
|
- }
|
|
|
- } else {
|
|
|
- messageBoxContent = "是否立即查看测试详情";
|
|
|
- confirmButtonText = "立即查看";
|
|
|
- nextURL = "https://eval.seec.seecoder.cn/student/home/?id_token=" + this.$store.state.user.token;
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 学生
|
|
|
+ else {
|
|
|
+ if (this.testVO.isJoined || this.testVO.joined) {
|
|
|
+ switch (_this.type) {
|
|
|
+ case "coder":
|
|
|
+ _this.toCoderExamPage(_this.testVO.id);
|
|
|
+ break;
|
|
|
+ case "eval":
|
|
|
+ _this.toEvalExamPage(_this.testVO.examId, "student");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
} else {
|
|
|
- messageBoxTitle = "Coder";
|
|
|
- if (this.testVO.joined) {
|
|
|
- nextURL = "https://coder.seec.seecoder.cn/exam/" + this.testVO.id + "?id_token=" + this.$store.state.user.token;
|
|
|
- window.open(nextURL);
|
|
|
- return;
|
|
|
- } else {
|
|
|
- const courseId = (await this.$apis.getCourseByCoderId(this.testVO.courseId)).data.data;
|
|
|
- if (courseId) {
|
|
|
- const isCourseSelected = (await this.$apis.checkCourseSelection(courseId, this.$store.state.user.id)).data.data;
|
|
|
- if (isCourseSelected) {
|
|
|
- messageBoxContent = "是否立即查看测试详情";
|
|
|
- confirmButtonText = "立即查看";
|
|
|
- this.$router.push("/exam/" + this.testVO.id);
|
|
|
- // nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
|
|
|
- } else {
|
|
|
- messageBoxContent = "尚未选择课程,是否立即参加?";
|
|
|
- confirmButtonText = "立即选课";
|
|
|
- nextURL = "/course/" + courseId;
|
|
|
- }
|
|
|
- } else {
|
|
|
- messageBoxContent = "是否立即查看测试详情";
|
|
|
- confirmButtonText = "立即查看";
|
|
|
- nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
|
|
|
- }
|
|
|
+ let courseId;
|
|
|
+ switch (this.type) {
|
|
|
+ case "coder":
|
|
|
+ courseId = (await this.$apis.getCourseByCoderId(this.testVO.courseId)).data.data.id;
|
|
|
+ break;
|
|
|
+ case "eval":
|
|
|
+ courseId = (await this.$apis.getCourseByEvalId(this.testVO.course.id)).data.data.id;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
- }
|
|
|
- ElMessageBox.confirm(messageBoxContent, messageBoxTitle, {
|
|
|
- distinguishCancelAndClose: true,
|
|
|
- confirmButtonText,
|
|
|
- cancelButtonText,
|
|
|
- }).then(() => {
|
|
|
- if (nextURL.startsWith("http")) {
|
|
|
- window.open(nextURL);
|
|
|
+ const isSelected = (await this.$apis.checkCourseSelection(courseId, this.$store.state.user.id));
|
|
|
+ if (isSelected) {
|
|
|
+ switch (_this.type) {
|
|
|
+ case "coder":
|
|
|
+ _this.toCoderExamPage(_this.testVO.id);
|
|
|
+ break;
|
|
|
+ case "eval":
|
|
|
+ _this.toEvalExamPage(_this.testVO.examId, "student");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.$router.push(nextURL);
|
|
|
+ this.$router.push(`/course/${courseId}`);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ toEvalExamPage(examId, role="teacher") {
|
|
|
+ this.$router.push(`/evalExam/${examId}/${role}/details`);
|
|
|
+ },
|
|
|
+
|
|
|
+ toCoderExamPage(examId) {
|
|
|
+ this.$router.push(`/exam/${examId}`);
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|