Damon 4 anni fa
parent
commit
a8a804e25a

+ 0 - 205
src/components/CoderCard.vue

@@ -1,205 +0,0 @@
-<template>
-  <el-card class="coder" shadow="hover" @click="toTestInfo">
-
-    <div
-      style="border-bottom: 30px solid #8dc9e2; float: right; width: 0; height: 0; position: absolute;right: 0;bottom: 0;border-left: 30px solid transparent;">
-      <div style="padding: 0 3px 0 3px; position: absolute; right: 0; bottom: -30px; color: white">
-        C
-      </div>
-    </div>
-
-    <el-row>
-      <el-col :span="16" class="name">
-        {{ coderVO.name !== undefined ? coderVO.name : "待添加" }}
-      </el-col>
-      <el-col :span="8" class="status">
-        <el-tag v-if="state==='NOT_STARTED'" size="small" type="info">未开始</el-tag>
-        <el-tag v-else-if="state==='RUNNING'" size="small">进行中</el-tag>
-        <el-tag v-else-if="state==='CLOSED'" size="small" type="info">已关闭</el-tag>
-        <el-tag v-else-if="state==='FINISHED'" size="small" type="danger">已结束</el-tag>
-      </el-col>
-    </el-row>
-    <el-row class="teacher">
-      教师: {{ teacher.name }}
-    </el-row>
-    <el-row class="course">
-      所属课程: {{ coderVO.course }}
-    </el-row>
-    <el-row class="time">
-      时间: {{ timestampToTime(coderVO.startAt) }} 至 {{ timestampToTime(coderVO.endAt) }}
-    </el-row>
-    <!--    <el-row class="button">-->
-    <!--      <el-col :span="24">-->
-    <!--        <el-button v-if="state==='FINISHED'" size="small" type="success" plain>结果报告</el-button>-->
-    <!--        <el-button v-else size="small" type="primary" plain>查看详情</el-button>-->
-    <!--      </el-col>-->
-    <!--    </el-row>-->
-  </el-card>
-</template>
-
-<script>
-import {ElMessageBox, ElMessage} from "element-plus";
-
-export default {
-  name: "CoderCard",
-  props: {
-    coderVO: {
-      type: Object,
-    }
-  },
-  data() {
-    return {
-      teacher: {
-        type: Object,
-        default: {
-          name: "暂无信息",
-        },
-      },
-    };
-  },
-  computed: {
-    state: function () {
-      if (this.coderVO.status === "CLOSED") {
-        return "CLOSED";
-      } else if (this.coderVO.startAt * 1000 > new Date()) {
-        return "NOT_STARTED";
-      } else if (this.coderVO.endAt * 1000 < new Date()) {
-        return "FINISHED";
-      } else {
-        return "RUNNING";
-      }
-    },
-    isTeacher() {
-      return this.$store.state.user.role === "TEACHER";
-    }
-  },
-  async mounted() {
-    if (this.coderVO.creator) {
-      const res = await this.$apis.getUserAPI(this.coderVO.creator.id);
-      if (res.data.code === 0) {
-        this.teacher = res.data.data;
-      } else {
-        this.teacher = {name: this.coderVO.creator.username};
-      }
-    }
-  },
-  methods: {
-    timestampToTime(timestamp) {
-      const date = new Date(timestamp * 1000);
-      const Y = date.getFullYear() + "-";
-      const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
-      const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
-      return Y + M + D;
-    },
-    async toTestInfo() {
-      if (!this.$store.state.user.token) {
-        await this.$router.push("/auth");
-        return;
-      }
-      let messageBoxContent = "";
-      let messageBoxTitle = "Coder";
-      let confirmButtonText = "";
-      let cancelButtonText = "让我想想";
-      let nextURL = "";
-      if (this.isTeacher) {
-        if (this.$store.state.user.id === this.coderVO.id) {
-          nextURL = "https://coder.seec.seecoder.cn/exam/" + this.coderVO.id + "?id_token=" + this.$store.state.user.token;
-          window.open(nextURL);
-        } else {
-          ElMessage.error("无权访问其他教师创建的测试");
-        }
-      } else {
-        // todo: 跳转流程中还需要考虑CoderExam的状态
-        const res = await this.$apis.getStudentCoderExams({});
-        const userCoderExams = res.data.data.res;
-        for (let userCoderExam of userCoderExams) {
-          if (this.coderVO.id === userCoderExam.id) {
-            if (userCoderExam.joined) {
-              nextURL = "https://coder.seec.seecoder.cn/exam/" + this.coderVO.id + "?id_token=" + this.$store.state.user.token;
-              window.open(nextURL);
-              return;
-            } else {
-              messageBoxContent = "尚未参加该测试,是否立即参加?";
-              confirmButtonText = "立即参加";
-              nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
-            }
-          }
-        }
-        if (messageBoxContent === "") {
-          const res = await this.$apis.getCourseByCoderId(this.coderVO.courseId);
-          if (res.data.data === null) {
-            nextURL = "https://coder.seec.seecoder.cn/course/select?id_token=" + this.$store.state.user.token;
-            messageBoxContent = "尚未选择该Coder课程,是否前往Coder系统?";
-            confirmButtonText = "前往选课";
-          } else {
-            nextURL = "/course/" + res.data.data.id;
-            messageBoxContent = "尚未选择该课程,是否前往选课?";
-            confirmButtonText = "前往选课";
-          }
-        }
-        ElMessageBox.confirm(messageBoxContent, messageBoxTitle, {
-          distinguishCancelAndClose: true,
-          confirmButtonText,
-          cancelButtonText,
-        })
-          .then(() => {
-            if (nextURL.startsWith("http")) {
-              window.open(nextURL);
-            } else {
-              this.$router.push(nextURL);
-            }
-          })
-          .catch(action => {
-          });
-      }
-    },
-  },
-};
-</script>
-
-<style scoped>
-.coder {
-  border-radius: 8px;
-  height: calc(100% - 14px);
-  position: relative;
-  border: 1px solid #cccccc;
-}
-
-.coder:hover {
-  cursor: pointer;
-  border: 1px solid #aaaaaa;
-}
-
-.name {
-  font-weight: bold;
-  font-size: medium;
-}
-
-.status {
-  text-align: right;
-}
-
-.teacher {
-  font-size: 10px;
-  margin-top: 10px;
-  color: #999999;
-}
-
-.course {
-  font-size: 10px;
-  margin-top: 4px;
-  color: #999999;
-}
-
-.time {
-  margin-top: 4px;
-  font-size: 10px;
-  margin-bottom: 16px;
-  color: #999999;
-}
-
-/*.button {*/
-/*  margin-top: 12px;*/
-/*  text-align: center;*/
-/*}*/
-</style>

+ 0 - 193
src/components/EvalCard.vue

@@ -1,193 +0,0 @@
-<template>
-  <el-card class="eval" shadow="hover" @click="toTestInfo">
-
-    <div
-      style="border-bottom: 30px solid #f5b86e; float: right; width: 0; height: 0; position: absolute;right: 0;bottom: 0;border-left: 30px solid transparent;">
-      <div style="padding: 0 4px 0 4px; position: absolute; right: 0; bottom: -30px; color: white">
-        E
-      </div>
-    </div>
-
-    <el-row>
-      <el-col :span="16" class="name">
-        {{ examVO.examName !== undefined ? examVO.examName : "待添加" }}
-      </el-col>
-      <el-col :span="8" class="status">
-        <el-tag v-if="state==='NOT_STARTED'" size="small" type="info">未开始</el-tag>
-        <el-tag v-else-if="state==='RUNNING'" size="small">进行中</el-tag>
-        <el-tag v-else-if="state==='FINISHED'" size="small" type="danger">已结束</el-tag>
-      </el-col>
-    </el-row>
-    <el-row class="teacher">
-      教师: {{ teacher.name }}
-    </el-row>
-    <el-row class="time">
-      时间: {{ timestampToTime(examVO.startTime) }} 至 {{ timestampToTime(examVO.endTime) }}
-    </el-row>
-    <el-row class="comment">
-      {{ examVO.comment }}
-    </el-row>
-    <!--    <el-row class="button">-->
-    <!--      <el-col :span="24">-->
-    <!--        <el-button v-if="state==='FINISHED'" plain size="small" type="success">结果报告</el-button>-->
-    <!--        <el-button v-else plain size="small" type="primary">查看详情</el-button>-->
-    <!--      </el-col>-->
-    <!--    </el-row>-->
-  </el-card>
-</template>
-
-<script>
-import {ElMessage, ElMessageBox} from "element-plus";
-
-export default {
-  name: "EvalCard",
-  props: {
-    examVO: {
-      type: Object,
-      default: () => {
-      }
-    }
-  },
-  data() {
-    return {
-      teacher: {
-        type: Object,
-        default: null,
-      }
-    };
-  },
-  computed: {
-    state: function () {
-      if (new Date(this.examVO.endTime) < new Date()) {
-        return "FINISHED";
-      } else if (new Date(this.examVO.startTime) > new Date()) {
-        return "NOT_STARTED";
-      } else {
-        return "RUNNING";
-      }
-    },
-    isTeacher() {
-      return this.$store.state.user.role === "TEACHER";
-    }
-  },
-  async mounted() {
-    if (this.examVO.creatorId) {
-      const res = await this.$apis.getUserAPI(this.examVO.creatorId);
-      this.teacher = res.data.data;
-    }
-  },
-  methods: {
-    timestampToTime(timestamp) {
-      const date = new Date(timestamp);
-      const Y = date.getFullYear() + "-";
-      const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
-      const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
-      return Y + M + D;
-    },
-    async toTestInfo() {
-      if (!this.$store.state.user.token) {
-        await this.$router.push("/auth");
-        return;
-      }
-      let messageBoxContent = "";
-      let messageBoxTitle = "Eval";
-      let confirmButtonText = "";
-      let cancelButtonText = "让我想想";
-      let nextURL = "";
-      if (this.isTeacher) {
-        if(this.$store.state.user.id === this.examVO.creatorId){
-          nextURL = "https://eval.seec.seecoder.cn?id_token=" + this.$store.state.user.token;
-          window.open(nextURL);
-        }else {
-          ElMessage.error("无权访问其他教师创建的测试");
-        }
-      } else {
-        // todo: 跳转流程还需要考虑EvalExam的状态
-        const res = await this.$apis.getStudentEvalExams({state: 0});
-        const userEvalExams = res.data.data.examVOList;
-        for (let userEvalExam of userEvalExams) {
-          if (userEvalExam.examId === this.examVO.examId) {
-            if (this.examVO.isJoined) {
-              nextURL = "https://eval.seec.seecoder.cn/student/home?id_token=" + this.$store.state.user.token;
-              window.open(nextURL);
-              return;
-            } else {
-              // todo: eval系统暂时应该不存在参加了评测但是isJoined字段为false的情况。
-            }
-          }
-        }
-        if (messageBoxContent === "") {
-          messageBoxContent = "尚未参加该测试,是否立即参加?";
-          confirmButtonText = "立即参加";
-          nextURL = "https://eval.seec.seecoder.cn/student/home?id_token=" + this.$store.state.user.token;
-        }
-        ElMessageBox.confirm(messageBoxContent, messageBoxTitle, {
-          distinguishCancelAndClose: true,
-          confirmButtonText,
-          cancelButtonText,
-        }).then(() => {
-          if (nextURL.startsWith("http")) {
-            window.open(nextURL);
-          } else {
-            this.$router.push(nextURL);
-          }
-        });
-      }
-    },
-  }
-};
-</script>
-
-<style lang="scss" scoped>
-.eval {
-  min-height: 180px;
-  border-radius: 8px;
-  height: calc(100% - 14px);
-  position: relative;
-  border: 1px solid #cccccc;
-}
-
-.eval:hover {
-  cursor: pointer;
-  border: 1px solid #aaaaaa;
-}
-
-.name {
-  font-weight: bold;
-  font-size: medium;
-}
-
-.status {
-  text-align: right;
-}
-
-.teacher {
-  font-size: 10px;
-  margin-top: 10px;
-  color: #999999;
-}
-
-.time {
-  margin-top: 4px;
-  font-size: 10px;
-  color: #999999;
-}
-
-.comment {
-  background-color: #f6f6f6;
-  color: #777777;
-  margin-top: 10px;
-  border-radius: 8px;
-  padding: 10px;
-  font-size: 10px;
-  margin-bottom: 16px;
-}
-
-//.button {
-//  margin-top: 12px;
-//  text-align: center;
-//  position: absolute;
-//  bottom: 8px;
-//  left: calc(50% - 40px);
-//}
-</style>

+ 16 - 29
src/components/GlobalHeader.vue

@@ -9,24 +9,19 @@
       <el-menu-item v-if="isStudent" index="2">
         任务
       </el-menu-item>
-      <el-submenu index="3">
-        <template #title>
-          {{ quickAccessTitle }}
-        </template>
-        <el-menu-item index="3-1">
-          全部课程
-        </el-menu-item>
-        <el-menu-item index="3-2">
-          全部测试
-        </el-menu-item>
-      </el-submenu>
-      <el-menu-item index="4">
+      <el-menu-item v-if="isStudent" index="3">
+        课程广场
+      </el-menu-item>
+      <el-menu-item v-if="isStudent" index="4">
+        测试广场
+      </el-menu-item>
+      <el-menu-item index="5">
         个人中心
       </el-menu-item>
-      <el-menu-item v-if="isTeacher" index="5">
-        教师管理
+      <el-menu-item v-if="isTeacher" index="6">
+        教师[临]
       </el-menu-item>
-      <el-menu-item index="6">
+      <el-menu-item index="7">
         问题[临]
       </el-menu-item>
     </el-menu>
@@ -76,18 +71,17 @@ export default {
   components: { InfoCard },
   data() {
     return {
-      quickAccessTitle: "快速访问",
       myUnReadAnnouncements: [],
       myUnReadMessages: [],
       menuIndex: [
         ["1", "Portal"],
         ["2", "Task"],
-        ["3-1", "Course"],
-        ["3-2", "Test"],
-        ["4", "Home"],
-        ["5", "Manage"],
-        ["6", "Problem"],
-        ["7", "CourseDetail"],
+        ["3", "Course"],
+        ["4", "Test"],
+        ["5", "Home"],
+        ["6", "Manage"],
+        ["7", "Problem"],
+        ["8", "CourseDetail"],
       ]
     };
   },
@@ -162,13 +156,6 @@ export default {
         }
       });
       this.$router.push({ name: target });
-      if (key === "3-1") {
-        this.quickAccessTitle = "全部课程";
-      } else if (key === "3-2") {
-        this.quickAccessTitle = "全部测试";
-      } else {
-        this.quickAccessTitle = "快速访问";
-      }
     },
   },
 };

+ 20 - 2
src/views/ManagePage/ManagePage.vue

@@ -48,7 +48,7 @@
           </div>
         </template>
         <div class="course-card-list-container">
-          <CourseCard v-for="(item,index) in myCourseList" :key="index" :ref="'courseCard'+item.id" :courseVO="item" @delete="deleteCourse(item)" @update="beforeUpdateCourse(item)"/>
+          <CourseCard v-for="(item,index) in filterCourses" :key="index" :ref="'courseCard'+item.id" :courseVO="item" @delete="deleteCourse(item)" @update="beforeUpdateCourse(item)"/>
         </div>
       </el-card>
 
@@ -294,7 +294,15 @@ export default {
       ],
     };
   },
-  computed: {},
+  computed: {
+    filterCourses: function () {
+      if (this.courseType === "all") return this.myCourseList;
+      if (this.courseType === "pending") return this.myCourseList.filter(i => this.state(i) === "NOT_STARTED");
+      if (this.courseType === "start") return this.myCourseList.filter(i => this.state(i) === "RUNNING");
+      if (this.courseType === "end") return this.myCourseList.filter(i => this.state(i) === "FINISHED");
+      else return this.myCourseList;
+    },
+  },
   mounted() {
     this.$apis.getTeacherCourses().then(res => {
       this.myCourseList = res.data.data;
@@ -307,6 +315,16 @@ export default {
     });
   },
   methods: {
+    state(courseVO) {
+      const now = new Date();
+      if (new Date(courseVO.endTime) < now) {
+        return "FINISHED";
+      } else if (new Date(courseVO.startTime) > now) {
+        return "NOT_STARTED";
+      } else {
+        return "RUNNING";
+      }
+    },
     handleSelect(index) {
       if (index === "0") {
         this.$router.push("portal");

+ 2 - 2
src/views/PortalPage/PortalPage.vue

@@ -62,7 +62,7 @@
                          @current-change="handleCourseCurrentChange"
                          layout="prev, pager, next"
                          style="width: 200px; margin: 0 auto 0 auto"/>
-          <ElButton plain round type="primary" @click="toCourse">查看全部课程</ElButton>
+          <ElButton plain round type="primary" @click="toCourse">前往课程广场</ElButton>
         </div>
         <el-divider class="portal-card-divider"/>
         <div class="portal-card-content" v-if="showExampleCourseList.length !== 0">
@@ -130,7 +130,7 @@
       <el-card id="portal-test-card-main" ref="portalTestCardBodyMain">
         <div class="portal-card-title">
           <div class="portal-card-title-main">智能测试</div>
-          <ElButton plain round type="primary" @click="toTest">查看全部测试</ElButton>
+          <ElButton plain round type="primary" @click="toTest">前往测试广场</ElButton>
         </div>
         <el-divider class="portal-card-divider"/>
         <el-tabs v-model="activeTestPaneName" @tab-click="changeTestPane" style="min-height: 400px;">

+ 1 - 1
src/views/TestPage/TestPage.vue

@@ -39,7 +39,7 @@
                   <el-divider style="margin: 10px 0 20px 0" content-position="left">{{key}}</el-divider>
                 </div>
                 <div class="test-page-main">
-                  <TestCard v-for="exam in item" :key="exam.id" :testVO="exam"/>
+                  <TestCard v-for="exam in item" :key="exam.id" :testVO="exam" :isPublicTest="true"/>
                 </div>
               </div>
             </el-tab-pane>