Przeglądaj źródła

[修改]前后端对接bug

Johnson 7 lat temu
rodzic
commit
c52d05f009

+ 4 - 4
mock/modules/assignment/index.js

@@ -82,7 +82,7 @@ router.route("/teacher/code/:codeId/unsubmitted/groups").get((req, res) => {
 });
 
 //老师查看单个代码作业的成绩列表(所有组的)
-router.route("/teacher/code/:codeId/docResult").get((req, res) => {
+router.route("/teacher/code/:codeId/result").get((req, res) => {
   res.send({
     err: 0,
     data: [CodeResultSerializer, CodeResultSerializer]
@@ -90,7 +90,7 @@ router.route("/teacher/code/:codeId/docResult").get((req, res) => {
 });
 
 //学生查看单个代码作业的成绩
-router.route("/student/code/:codeId/docResult").get((req, res) => {
+router.route("/student/code/:codeId/result").get((req, res) => {
   res.send({
     err: 0,
     data: CodeResultSerializer
@@ -149,7 +149,7 @@ router.route("/student/document/:documentId").get((req, res) => {
 
 //老师查看文档作业的成绩列表(已提交小组)
 router
-  .route("/teacher/document/:documentId/submitted/docResult")
+  .route("/teacher/document/:documentId/submitted/result")
   .get((req, res) => {
     res.send({
       err: 0,
@@ -169,7 +169,7 @@ router
   });
 
 //学生查看文档作业的成绩
-router.route("/student/document/:documentId/docResult").get((req, res) => {
+router.route("/student/document/:documentId/result").get((req, res) => {
   res.send({
     err: 0,
     data: DocumentResultSerializer()

+ 1 - 1
mock/modules/review/index.js

@@ -128,7 +128,7 @@ router
   );
 
 // 学生选择查看某次互评作业中自己的文档
-router.route("/student/review/:reviewId/docResult").get((req, res) =>
+router.route("/student/review/:reviewId/result").get((req, res) =>
   res.send({
     data: reviewDocResultSerializer()
   })

+ 2 - 2
mock/serializers/assignment/DocumentResultSerializer.js

@@ -7,7 +7,7 @@ const groupSerializer = require("../course/GroupSerializer");
  * @property {number} document 所属文档作业Id
  * @property {GroupSerializerType} group 所属小组
  * @property {string} state 作业状态
- * @property {string} docResult 成绩等级
+ * @property {string} result 成绩等级
  */
 
 /**
@@ -21,7 +21,7 @@ module.exports = () => {
     document: makeId(),
     group: groupSerializer(),
     state: "互评中",
-    docResult: "B",
+    result: "A",
     url: "https://github.com",
     reviewGroup: [1, 2, 3]
   };

+ 1 - 1
mock/serializers/assignment/DocumentSerializer.js

@@ -25,7 +25,7 @@ module.exports = () => {
     id: makeId(),
     name: "需求规格说明文档",
     description: "请给该项目的需求规格说明文档",
-    status: "PREPARING",
+    status: "AVAILABLE",
     createAt: dayjs("2018-10-21").unix(),
     startAt: dayjs("2019-01-01").unix(),
     endAt: dayjs("2019-01-20").unix(),

+ 12 - 28
src/api/assignment.js

@@ -13,15 +13,10 @@ import { ASSIGNMENT_MODULE } from "./_prefix";
  * @param courseId
  * @returns {Promise<{data:CodeSerializerType}>}
  */
-export const postCodeAssignment = ({
-  type,
-  name,
-  description,
-  startAt,
-  endAt,
-  problem,
+export const postCodeAssignment = (
+  { type, name, description, startAt, endAt, problem },
   courseId
-}) => {
+) => {
   return request(`${ASSIGNMENT_MODULE}/course/${courseId}/code`, {
     method: "POST",
     body: {
@@ -43,13 +38,10 @@ export const postCodeAssignment = ({
  * @param codeId
  * @returns {Promise<{data:CodeSerializerType}>}
  */
-export const putCodeAssignment = ({
-  name,
-  description,
-  startAt,
-  endAt,
+export const putCodeAssignment = (
+  { name, description, startAt, endAt },
   codeId
-}) => {
+) => {
   return request(`${ASSIGNMENT_MODULE}/code/${codeId}`, {
     method: "PUT",
     body: {
@@ -158,15 +150,10 @@ export const getCodeResultListByCode = codeId => {
  * @param courseId
  * @returns {Promise<{data:DocumentSerializerType}>}
  */
-export const postDocAssignment = ({
-  type,
-  name,
-  description,
-  startAt,
-  endAt,
-  problem,
+export const postDocAssignment = (
+  { type, name, description, startAt, endAt, problem },
   courseId
-}) => {
+) => {
   return request(`${ASSIGNMENT_MODULE}/course/${courseId}/document`, {
     method: "POST",
     body: {
@@ -188,13 +175,10 @@ export const postDocAssignment = ({
  * @param documentId
  * @returns {Promise<{data:DocumentSerializerType}>}
  */
-export const putDocAssignment = ({
-  name,
-  description,
-  startAt,
-  endAt,
+export const putDocAssignment = (
+  { name, description, startAt, endAt },
   documentId
-}) => {
+) => {
   return request(`${ASSIGNMENT_MODULE}/document/${documentId}`, {
     method: "PUT",
     body: {

+ 2 - 0
src/data/documentState.js

@@ -17,5 +17,7 @@ export default function(state) {
       return { name: "正在进行", styledClass: "is-success" };
     case FINISHED:
       return { name: "已结束", styledClass: "is-danger" };
+    default:
+      return { name: "无状态", styledClass: "is-dark" };
   }
 }

+ 20 - 8
src/views/student/Document/detail.vue

@@ -12,10 +12,10 @@
       <template slot="content">
         {{ assignmentInfo.description }}
       </template>
-      <template slot="action">
-        <div @click="() => (this.showModal = true)" class="button is-primary">
-          成绩:{{ docResult.result }}
-        </div>
+      <template slot="action" v-if="resultDisplay">
+        <a class="button is-primary" v-if="resultDisplay"
+          >成绩:{{ docResult.result }}</a
+        >
       </template>
     </page-header>
     <page-body>
@@ -31,7 +31,7 @@
           <div class="column">
             <h5 class="title is-5">状态:</h5>
             <div class="subtitle is-6">
-              <document-state-tag :state="detail.status" />
+              <document-state-tag :state="detail.status"></document-state-tag>
             </div>
           </div>
         </div>
@@ -68,6 +68,7 @@
 </template>
 
 <script>
+import { mapState } from "vuex";
 import PageHeader from "../../../components/PageHeader";
 import PageBody from "../../../components/PageBody";
 import { getDocAssignmentDetailByDocuId } from "@/api/assignment";
@@ -92,19 +93,30 @@ export default {
   mixins: [timeMixins],
   mounted() {
     this.assignmentInfo = this.$route.query.assignmentInfo;
-    getDocAssignmentDetailByDocuId(123).then(res => {
+    getDocAssignmentDetailByDocuId(this.assignmentInfo.id).then(res => {
+      console.log(res.data);
       this.detail = res.data;
     });
-    getDocResultById(123).then(res => {
+    getDocResultById(this.assignmentInfo.id).then(res => {
       this.docResult = res.data;
+      console.log("doc.result" + this.docResult.result);
+      if (parseInt(this.docResult.result) !== -1) {
+        this.resultDisplay = true;
+      }
     });
   },
   data() {
     return {
       assignmentInfo,
       detail: {},
-      docResult: {}
+      docResult: {},
+      resultDisplay: false
     };
+  },
+  computed: {
+    ...mapState({
+      course: state => state.course.currentCourse
+    })
   }
 };
 </script>

+ 17 - 8
src/views/teacher/Code/index.vue

@@ -141,10 +141,12 @@
               :config="endAtConfig"
             ></flat-pickr>
           </b-field>
-
-          <a class="button is-link" @click="createDocAssignment()">{{
-            modal.submit
-          }}</a>
+          <!--传入codeId-->
+          <a
+            class="button is-link"
+            @click="createDocAssignment($v.params.id)"
+            >{{ modal.submit }}</a
+          >
         </div>
       </div>
     </b-modal>
@@ -162,6 +164,7 @@ import { delCodeAssignment } from "@/api/assignment";
 import timeMixins from "@/mixins/time";
 import { required } from "vuelidate/lib/validators";
 import pathMixins from "@/mixins/path";
+import { mapState } from "vuex";
 
 export default {
   components: {
@@ -170,7 +173,8 @@ export default {
   },
   mixins: [timeMixins, pathMixins],
   mounted() {
-    getCodeAssignmentListByTeacher(123).then(res => {
+    console.log(this.$v.params);
+    getCodeAssignmentListByTeacher(this.course.id).then(res => {
       this.codeData = res.data;
     });
   },
@@ -324,14 +328,14 @@ export default {
     /**
      * 确认新建或者修改
      */
-    createDocAssignment() {
+    createDocAssignment(codeId) {
       this.$v.$touch();
       if (!this.$v.$invalid) {
         this.isCardModalActive = false;
         if (this.flag === -1) {
           // 确认新建作业
           this.params["type"] = "DOCUMENT";
-          postCodeAssignment(this.params).then(res => {
+          postCodeAssignment(this.params, this.course.id).then(res => {
             console.log(res);
             if (res.err === 0) {
               //创建成功
@@ -353,7 +357,7 @@ export default {
           });
         } else {
           // 确认修改作业
-          putCodeAssignment(this.params).then(res => {
+          putCodeAssignment(this.params, codeId).then(res => {
             if (res.err === 0) {
               let id = res.data.id;
               for (let item of this.codeData) {
@@ -377,6 +381,11 @@ export default {
         }
       }
     }
+  },
+  computed: {
+    ...mapState({
+      course: state => state.course.currentCourse
+    })
   }
 };
 </script>

+ 10 - 3
src/views/teacher/Document/detail.vue

@@ -55,7 +55,7 @@
                 </b-table-column>
 
                 <b-table-column label="分数" centered>
-                  {{ props.row.docResult }}
+                  {{ props.row.result }}
                 </b-table-column>
                 <b-table-column field="difficulty" label="详情" centered
                   ><a :href="props.row.url" target="_blank">查看详情</a>
@@ -120,6 +120,7 @@ import PageHeader from "@/components/PageHeader";
 import PageBody from "@/components/PageBody/index";
 import { getSubmittedDocResultListByDocId } from "@/api/assignment";
 import { getUnsubmittedDocGroupsByDocId } from "@/api/assignment";
+import { mapState } from "vuex";
 
 const assignmentInfo = {
   id: 0,
@@ -128,6 +129,11 @@ const assignmentInfo = {
 };
 
 export default {
+  computed: {
+    ...mapState({
+      course: state => state.course.currentCourse
+    })
+  },
   components: {
     PageBody,
     PageHeader
@@ -135,12 +141,13 @@ export default {
   mounted() {
     this.assignmentInfo = this.$route.query.assignmentInfo;
     this.title = this.$route.query.title;
-    getSubmittedDocResultListByDocId(123).then(res => {
+    console.log(this.assignmentInfo);
+    getSubmittedDocResultListByDocId(this.assignmentInfo.id).then(res => {
       this.status = res.status;
       this.submittedData = res.data;
       this.submitInfo.yes = "已提交:" + this.submittedData.length;
     });
-    getUnsubmittedDocGroupsByDocId(123).then(res => {
+    getUnsubmittedDocGroupsByDocId(this.assignmentInfo.id).then(res => {
       this.unsubmitedGroups = res.data;
       this.submitInfo.no = "未提交:" + this.unsubmitedGroups.length;
     });

+ 9 - 2
src/views/teacher/Document/index.vue

@@ -160,15 +160,22 @@ import { delDocAssignment } from "@/api/assignment";
 import timeMixins from "@/mixins/time";
 import { required } from "vuelidate/lib/validators";
 import pathMixins from "@/mixins/path";
+import { mapState } from "vuex";
 
 export default {
+  computed: {
+    ...mapState({
+      course: state => state.course.currentCourse
+    })
+  },
   components: {
     PageBody,
     PageHeader
   },
   mixins: [timeMixins, pathMixins],
   mounted() {
-    getDocAssignmentListTeacherByCrs(123).then(res => {
+    console.log(this.course.id);
+    getDocAssignmentListTeacherByCrs(this.course.id).then(res => {
       this.docData = res.data;
     });
   },
@@ -338,7 +345,7 @@ export default {
         if (this.flag === -1) {
           // 确认新建作业
           this.params["type"] = "DOCUMENT";
-          postDocAssignment(this.params).then(res => {
+          postDocAssignment(this.params, this.course.id).then(res => {
             if (res.err === 0) {
               //创建成功
               this.docData.push(res.data);

+ 2 - 2
src/views/teacher/Result/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <page-header :routes="[{ name: '成绩管理', path: 'docResult/' }]">
+    <page-header :routes="[{ name: '成绩管理', path: 'result/' }]">
       <template slot="title">
         全部作业成绩
       </template>
@@ -265,7 +265,7 @@ export default {
       this.data = res.data;
     });
     //绘制图表
-    var resultChart = document.getElementById("docResult-chart");
+    var resultChart = document.getElementById("result-chart");
     var myChart2 = new Chart(resultChart, {
       type: "bar",
       data: {

+ 3 - 2
vue.config.js

@@ -2,8 +2,9 @@ module.exports = {
   devServer: {
     proxy: {
       "^/api": {
-        // target: "http://localhost:4000/",
-        target: "http://172.19.131.216:8080/",
+        target: "http://localhost:4000/",
+        // target: "http://172.19.131.216:8080/",
+        // target: "http://10.1.2.3:8080/",
         ws: true,
         changeOrigin: true
       }