Browse Source

添加coder考试 停止运行的功能

mjh 3 years ago
parent
commit
b6ce5ff356
2 changed files with 38 additions and 6 deletions
  1. 15 6
      src/api/coder.js
  2. 23 0
      src/views/CoderPage/ExamDetail.vue

+ 15 - 6
src/api/coder.js

@@ -9,7 +9,7 @@ function getStudentCoderExams({page, limit}) {
   });
 }
 
-function getStudentCoderExamsGroupByCourse(){
+function getStudentCoderExamsGroupByCourse() {
   return axios.get(`${prefix}/exam/student/groupByCourse`);
 }
 
@@ -24,7 +24,7 @@ function getRecommendCoderExams() {
   return axios.get(`${prefix}/exam/recommend`);
 }
 
-function getRecommendCoderExamsGroupByCourse(){
+function getRecommendCoderExamsGroupByCourse() {
   return axios.get(`${prefix}/exam/recommend/groupByCourse`);
 }
 
@@ -36,11 +36,11 @@ function getStudentCoderExamsByCourseId(courseId) {
   return axios.get(`${prefix}/exam/student/course`, {params: {courseId,}});
 }
 
-function getTeacherCoderExamsGroupByCourse(){
+function getTeacherCoderExamsGroupByCourse() {
   return axios.get(`${prefix}/exam/teacher/groupByCourse`);
 }
 
-function retrievePageProblem(page, limit, typeStr, name){
+function retrievePageProblem(page, limit, typeStr, name) {
   return axios.get(`${prefix}/problem`, {
     params: {
       page,
@@ -51,7 +51,7 @@ function retrievePageProblem(page, limit, typeStr, name){
   });
 }
 
-function createCoderExam(data){
+function createCoderExam(data) {
   return axios.post(`${prefix}/exam/create`, data);
 }
 
@@ -119,6 +119,14 @@ function changeExamIsShownForStu(examId, status) {
   return axios.post(`${prefix}/exam/${examId}/console?showConsole=${status}`);
 }
 
+function stopRecord(recordId) {
+  return axios.put(`${prefix}/record/stop`, null, {
+    params: {
+      recordId,
+    }
+  });
+}
+
 const coderAPIs = {
   getStudentCoderExams,
   getStudentCoderExamsGroupByCourse,
@@ -147,7 +155,8 @@ const coderAPIs = {
   getCommitByCommitId,
   getRecordByRecordId,
   getExamIsShownForStu,
-  changeExamIsShownForStu
+  changeExamIsShownForStu,
+  stopRecord,
 };
 
 export default coderAPIs;

+ 23 - 0
src/views/CoderPage/ExamDetail.vue

@@ -226,6 +226,12 @@
               >
                 详情
               </el-button>
+              <el-divider direction="vertical"/>
+              <el-button type="text"
+                         @click="stopRecord(scope.row.id)"
+                         class="commit-stop-button">
+                停止
+              </el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -417,6 +423,7 @@ import PageHeader from "../../components/PageHeader.vue";
 import Echarts from "@/views/CoderPage/ResultPage/Echarts.vue";
 import {ElMessage} from "element-plus";
 import Clipboard from "clipboard";
+import colorUtil from "@/utils/color";
 
 export default {
   name: "ExamDetail",
@@ -490,6 +497,9 @@ export default {
     };
   },
   computed: {
+    colorUtil() {
+      return colorUtil;
+    },
     ...mapGetters([
       "isStudentGroup",
       "isTeacherGroup",
@@ -761,6 +771,11 @@ export default {
     //跳转到具体结果信息页
     jumpToResultDetail(resultId) {
       this.$router.push(`${this.$route.path}/result/${resultId}`);
+    },
+    // stop coder record
+    async stopRecord(recordId){
+       const res = (await this.$apis.stopRecord(recordId)).data;
+       console.log(res);
     }
   }
 };
@@ -817,4 +832,12 @@ export default {
 //  color: black;
 //  border-bottom: 1px solid #afaaaa;
 //}
+
+.commit-stop-button{
+  color: var(--el-color-danger)
+}
+
+.commit-stop-button:hover{
+  opacity: 75%;
+}
 </style>