|
|
@@ -1,8 +1,14 @@
|
|
|
<template>
|
|
|
<div class="task-tab">
|
|
|
<div v-if="isCreator">
|
|
|
- <el-button v-if="coderId" icon="el-icon-circle-plus-outline" style="color: #8dc9e2">Coder测试</el-button>
|
|
|
- <el-button v-if="evalId" icon="el-icon-circle-plus-outline" style="color: #f5b86e;">Eval测试</el-button>
|
|
|
+ <el-button v-if="coderId"
|
|
|
+ @click="handleAddCoderClick"
|
|
|
+ icon="el-icon-circle-plus-outline"
|
|
|
+ style="color: #8dc9e2">Coder测试</el-button>
|
|
|
+ <el-button v-if="evalId"
|
|
|
+ @click="handleAddEvalClick"
|
|
|
+ icon="el-icon-circle-plus-outline"
|
|
|
+ style="color: #f5b86e;">Eval测试</el-button>
|
|
|
</div>
|
|
|
<el-timeline>
|
|
|
<el-timeline-item
|
|
|
@@ -44,11 +50,132 @@
|
|
|
</el-timeline-item>
|
|
|
</el-timeline>
|
|
|
</div>
|
|
|
+ <!-- 创建Coder考试-->
|
|
|
+ <el-dialog v-model="coderExamDialog" :before-close="handleExamFormCancel" :width="1200"
|
|
|
+ :title="coderExamForm.dialogTitle">
|
|
|
+ <el-form ref="coderExamFormRef" :model="coderExamForm" :rules="coderExamFormRules" label-width="150px">
|
|
|
+ <el-form-item label="所属课程" prop="course">
|
|
|
+ <el-input disabled :placeholder="courseName"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="测试名称" prop="name">
|
|
|
+ <el-input class="course-form-item" v-model="coderExamForm.name" placeholder="请输入课程名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="测试时间" prop="range">
|
|
|
+ <el-date-picker v-model="coderExamForm.range" range-separator="至"
|
|
|
+ start-placeholder="开始时间" end-placeholder="结束时间" type="datetimerange">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="允许学生查看控制台">
|
|
|
+ <el-switch v-model="coderExamForm.isConsoleOutputShownForStu" :disabled="switchExamDisabled" active-text="开启"
|
|
|
+ inactive-text="不开启"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="启用代码分析">
|
|
|
+ <el-switch v-model="coderExamForm.isCodeAnalysisNeeded" :disabled="switchExamDisabled" active-text="开启"
|
|
|
+ inactive-text="不开启"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="题目列表">
|
|
|
+ <el-button type="text" @click="showProblemDialog">选择题目</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="$store.state.problem.cart.length">
|
|
|
+ <el-collapse accordion>
|
|
|
+ <el-collapse-item
|
|
|
+ v-for="problem in $store.state.problem.cart"
|
|
|
+ :key="problem.id"
|
|
|
+ :name="problem.id"
|
|
|
+ >
|
|
|
+ <template #title>
|
|
|
+ <span>{{ problem.name }}</span>
|
|
|
+ <el-tag class="problem-type">{{ problem.type }}</el-tag>
|
|
|
+ </template>
|
|
|
+ <b>题目描述:</b>
|
|
|
+ <span class="problem-description">{{ problem.description }}</span>
|
|
|
+ <div class="remove-button">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ size="mini"
|
|
|
+ @click="$store.commit('removeProblem', problem)"
|
|
|
+ >移除该题
|
|
|
+ </el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </el-collapse-item>
|
|
|
+ </el-collapse>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div style="margin: auto;width: fit-content">
|
|
|
+ <el-button type="primary" @click="handleExamCreate">确定</el-button>
|
|
|
+ <el-button @click="handleExamFormCancel">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <!-- 展示Coder所有题目-->
|
|
|
+ <el-dialog v-model="coderProblemDialog" :width="1200">
|
|
|
+ <el-input v-model="dialogProblemName"
|
|
|
+ style="width:200px;"
|
|
|
+ placeholder="搜索"
|
|
|
+ />
|
|
|
+ <el-select v-model="dialogProblemTypeStr" style="width: 300px" @change="fetchProblemData(1)">
|
|
|
+ <el-option v-for="item in problemTypeOptions" :key="item.value" :value="item.value">
|
|
|
+ {{ item.label }}
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-table :data="problemList">
|
|
|
+ <el-table-column type="expand">
|
|
|
+ <template #default="props">
|
|
|
+ <div>{{ props.row.description }}</div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="name" label="名称"></el-table-column>
|
|
|
+ <el-table-column label="类型">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ problemTypeToTagContent(scope.row.type) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="上传时间">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ formatTimestamp(scope.row.createdAt) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ @click="checkDetails"
|
|
|
+ >详情
|
|
|
+ </el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="removeEnable(scope.row)"
|
|
|
+ type="danger"
|
|
|
+ size="mini"
|
|
|
+ @click="$store.commit('removeProblem', scope.row)"
|
|
|
+ >移出试题清单
|
|
|
+ </el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-else-if="addEnable(scope.row)"
|
|
|
+ type="success"
|
|
|
+ size="mini"
|
|
|
+ @click="$store.commit('addProblem', scope.row)"
|
|
|
+ >加入试题清单
|
|
|
+ </el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ layout="prev, pager, next"
|
|
|
+ :total="problemPageInfo.total"
|
|
|
+ @current-change="changePage"
|
|
|
+ />
|
|
|
+ </el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import portal from "@/utils/portal";
|
|
|
-import {ElMessage} from "element-plus";
|
|
|
+import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+import {formatTimestamp, problemTypeOptions, problemTypeToTagContent} from "@/utils/coder-utils";
|
|
|
|
|
|
export default {
|
|
|
name: "TaskTab",
|
|
|
@@ -77,6 +204,42 @@ export default {
|
|
|
themeColor,
|
|
|
evalExamList: [],
|
|
|
coderExamList: [],
|
|
|
+
|
|
|
+ //create Coder exam
|
|
|
+ coderExamDialog: false,
|
|
|
+ coderExamDialogTitle: "新建Coder考试",
|
|
|
+ coderExamForm: {
|
|
|
+ examType: "coder",
|
|
|
+ course: "",
|
|
|
+ name: "",
|
|
|
+ range: [],
|
|
|
+ isCodeAnalysisNeeded: false,
|
|
|
+ isConsoleOutputShownForStu: false
|
|
|
+ },
|
|
|
+ coderExamFormRules: {
|
|
|
+ // type: {
|
|
|
+ // required: true, message: "请选择测试种类",
|
|
|
+ // },
|
|
|
+ name: {
|
|
|
+ required: true, message: "请输入测试名称", trigger: "blur",
|
|
|
+ },
|
|
|
+ course: {
|
|
|
+ required: true, message: "请选择测试名称",
|
|
|
+ },
|
|
|
+ range: {
|
|
|
+ required: true, message: "请选择测试时间段", trigger: "blur",
|
|
|
+ }
|
|
|
+ },
|
|
|
+ switchExamDisabled: false,
|
|
|
+
|
|
|
+ //Coder problems
|
|
|
+ coderProblemDialog: false,
|
|
|
+ dialogProblemPage: 1,
|
|
|
+ dialogProblemLimit: 10,
|
|
|
+ dialogProblemTypeStr: "",
|
|
|
+ dialogProblemName: "",
|
|
|
+ problemList: [],
|
|
|
+ problemPageInfo: {}
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -99,12 +262,19 @@ export default {
|
|
|
isStudent() {
|
|
|
return this.$store.getters.isStudent;
|
|
|
},
|
|
|
+ courseName() {
|
|
|
+ const res = this.$apis.getCourseById(this.courseId);
|
|
|
+ return res.data.data.name;
|
|
|
+ },
|
|
|
+ problemTypeOptions() {
|
|
|
+ return problemTypeOptions(true);
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.init();
|
|
|
},
|
|
|
methods: {
|
|
|
- async init(){
|
|
|
+ async init() {
|
|
|
const _this = this;
|
|
|
if (_this.isTeacher) {
|
|
|
if (_this.evalId !== null) {
|
|
|
@@ -135,6 +305,7 @@ export default {
|
|
|
return _this.themeColor.blue;
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
state(VO) {
|
|
|
if (VO["examId"]) {
|
|
|
if (new Date(VO.endTime) < new Date()) {
|
|
|
@@ -156,6 +327,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
toTask(task) {
|
|
|
const _this = this;
|
|
|
const type = task["examId"] ? "eval" : "coder";
|
|
|
@@ -195,13 +367,122 @@ export default {
|
|
|
}
|
|
|
window.open(url + "?id_token=" + this.$store.state.user.token);
|
|
|
},
|
|
|
+ // 创建Coder考试的Dialog
|
|
|
+ handleExamFormCancel(done) {
|
|
|
+ //关闭dialog的提示
|
|
|
+ ElMessageBox.confirm("是否确认退出?退出后将不保存表格信息。", "提示", {
|
|
|
+ confirmButtonText: "确认退出",
|
|
|
+ cancelButtonText: "我再想想",
|
|
|
+ type: "warning",
|
|
|
+ center: true,
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.coderExamDialog = false;
|
|
|
+ // this.clearForm();
|
|
|
+ //TODO 清除表格信息
|
|
|
+ done();
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 展示Coder所有的problem题目(代码题)
|
|
|
+ showProblemDialog() { //打开弹框,获取初始数据
|
|
|
+ this.fetchProblemData();
|
|
|
+ this.coderProblemDialog = true;
|
|
|
+ },
|
|
|
+ fetchProblemData(page = 1) { // 按需获得Coder题目
|
|
|
+ this.$apis.retrievePageProblem(page, this.dialogProblemLimit, this.dialogProblemTypeStr, this.dialogProblemName)
|
|
|
+ .then(_res => {
|
|
|
+ this.problemPageInfo = _res.data.page;
|
|
|
+ this.problemList = _res.data.res;
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //验证表单数据,创建考试
|
|
|
+ handleExamCreate() {
|
|
|
+ const form = this.$refs.coderExamFormRef;
|
|
|
+ form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ console.log("validate 成功");
|
|
|
+ this.createCoderExam();
|
|
|
+ } else {
|
|
|
+ console.log("validate 失败了");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ createCoderExam() {
|
|
|
+ //创建Coder考试
|
|
|
+ this.$apis.createCoderExam({
|
|
|
+ course: this.coderExamForm.course,
|
|
|
+ name: this.coderExamForm.name,
|
|
|
+ startAt: this.coderExamForm.range[0].getTime() / 1000,
|
|
|
+ endAt: this.coderExamForm.range[1].getTime() / 1000,
|
|
|
+ problems: this.$store.state.problem.cart.map((item) => item.id),
|
|
|
+ isConsoleOutputShownForStu: this.coderExamForm.isConsoleOutputShownForStu
|
|
|
+ }).then(_res => {
|
|
|
+ this.$store.commit("clearProblem");
|
|
|
+ ElMessage.success("创建测试成功!");
|
|
|
+ this.clearCoderExamForm(); //清空Coder考试表单内容
|
|
|
+ this.fetchData(); //重新获取数据,实时刷新页面
|
|
|
+ this.coderExamDialog = false;
|
|
|
+ }).catch(_err => {
|
|
|
+ console.log(_err);
|
|
|
+ ElMessage.warning("创建测试失败!");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //查看题目详情(暂不支持)
|
|
|
+ checkDetails() {
|
|
|
+ ElMessage.warning("暂不支持查看详情!");
|
|
|
+ },
|
|
|
+ //题目购物车cart
|
|
|
+ removeEnable(problem) { //是否可以移除题目
|
|
|
+ return this.$store.state.problem.cart.length && this.$store.state.problem.cart
|
|
|
+ .map((item) => item.id)
|
|
|
+ .includes(problem.id);
|
|
|
+ },
|
|
|
+
|
|
|
+ addEnable(problem) { //是否可以添加题目
|
|
|
+ return this.$store.getters.isTeacher && problem.modifiedAt;
|
|
|
+ },
|
|
|
+
|
|
|
+ changePage(val) {
|
|
|
+ this.fetchProblemData(val);
|
|
|
+ },
|
|
|
+
|
|
|
+ clearCoderExamForm() {
|
|
|
+ this.coderExamForm = {
|
|
|
+ examType: "coder",
|
|
|
+ course: this.courseInfo.coderId,
|
|
|
+ name: "",
|
|
|
+ range: [],
|
|
|
+ isCodeAnalysisNeeded: false,
|
|
|
+ isConsoleOutputShownForStu: false
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ formatTimestamp,
|
|
|
+
|
|
|
+ problemTypeToTagContent,
|
|
|
+
|
|
|
+ handleAddEvalClick() {
|
|
|
+ window.open();
|
|
|
+ },
|
|
|
+
|
|
|
+ handleAddCoderClick() {
|
|
|
+ this.coderExamDialog = true;
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
@import "tabs.css";
|
|
|
-.el-timeline{
|
|
|
+
|
|
|
+.el-timeline {
|
|
|
margin-top: 10px;
|
|
|
padding-left: 10px;
|
|
|
}
|