Procházet zdrojové kódy

增加对于机器学习作业的CRUD处理

Prevalence před 7 roky
rodič
revize
4b1f4b4654

+ 60 - 0
src/api/dlwork.js

@@ -28,3 +28,63 @@ export const getDLProjectDetail = dlworkId => {
   console.log(dlworkId);
   return request(`${DL_WORK_MODULE}/${dlworkId}`);
 };
+/**
+ * 老师新建机器学习作业
+ * @param type
+ * @param name
+ * @param description
+ * @param startAt
+ * @param endAt
+ * @param problem
+ * @param courseId
+ * @returns {Promise<*>}
+ */
+export const postDLAssignment = (
+  { type, name, description, startAt, endAt, problem },
+  courseId
+) => {
+  return request(`${DL_WORK_MODULE}/course/${courseId}/dlwork`, {
+    method: "POST",
+    body: {
+      type: type || null,
+      name: name || null,
+      description: description || null,
+      startAt: startAt || null,
+      endAt: endAt || null,
+      problem: problem || null
+    }
+  });
+};
+
+/**
+ * 老师删除机器学习作业
+ * @param dlworkId
+ * @returns {Promise<{}>}
+ */
+export const delDLAssignment = dlworkId => {
+  return request(`${DL_WORK_MODULE}/dlwork/${dlworkId}`, { method: "DELETE" });
+};
+
+/**
+ * 老师更新机器学习作业信息
+ * @param name
+ * @param description
+ * @param startAt
+ * @param endAt
+ * @param dlworkId
+ * @returns {Promise<{data:CodeSerializerType}>}
+ */
+export const putDLAssignment = (
+  { name, description, startAt, endAt },
+  dlworkId
+) => {
+  return request(`${DL_WORK_MODULE}/dlwork/${dlworkId}`, {
+    method: "PUT",
+    body: {
+      name: name || null,
+      description: description || null,
+      startAt: startAt || null,
+      endAt: endAt || null
+    }
+  });
+};

+ 9 - 2
src/components/AssignmentCRUD/CreateAssignment/index.vue

@@ -174,6 +174,7 @@ import { getTeacherKeywordQuestionsByCode } from "@/api/question";
 import { getTeacherKeywordQuestionsByDoc } from "@/api/question";
 import { postDocAssignment } from "@/api/assignment";
 import { postCodeAssignment } from "@/api/assignment";
+import { postDLAssignment } from "@/api/dlwork";
 import timeMixins from "@/mixins/time";
 import { required } from "vuelidate/lib/validators";
 import pathMixins from "@/mixins/path";
@@ -192,9 +193,12 @@ export default {
     if (this.assignType === 1) {
       this.createTitle = "文档";
       this.postParam = "DOCUMENT";
-    } else {
+    } else if (this.assignType === 0) {
       this.createTitle = "代码";
       this.postParam = "CODE";
+    } else {
+      this.createTitle = "机器学习";
+      this.postParam = "ML";
     }
   },
   data() {
@@ -313,9 +317,12 @@ export default {
         if (this.assignType === 1) {
           // 文档作业
           this.myPromise = postDocAssignment(param, this.courseId);
-        } else {
+        } else if (this.assignType === 0) {
           // 代码作业
           this.myPromise = postCodeAssignment(param, this.courseId);
+        } else {
+          // 机器学习作业
+          this.myPromise = postDLAssignment(param, this.courseId);
         }
         this.myPromise
           .then(res => {

+ 4 - 1
src/components/AssignmentCRUD/DeleteAssignment/index.vue

@@ -5,6 +5,7 @@
 <script>
 import { delDocAssignment } from "@/api/assignment";
 import { delCodeAssignment } from "@/api/assignment";
+import { delDLAssignment } from "@/api/dlwork";
 
 export default {
   props: {
@@ -32,8 +33,10 @@ export default {
         onConfirm: () => {
           if (this.assignType === 1) {
             this.myPromise = delDocAssignment(this.delId);
-          } else {
+          } else if (this.assignType === 0) {
             this.myPromise = delCodeAssignment(this.delId);
+          } else {
+            this.myPromise = delDLAssignment(this.delId);
           }
           this.myPromise.then(res => {
             if (res.code === 0) {

+ 7 - 2
src/components/AssignmentCRUD/UpdateAssignment/index.vue

@@ -62,6 +62,7 @@
 import timeMixins from "@/mixins/time";
 import { putDocAssignment } from "@/api/assignment";
 import { putCodeAssignment } from "@/api/assignment";
+import { putDLAssignment } from "@/api/dlwork";
 import { required } from "vuelidate/lib/validators";
 import BInput from "buefy/src/components/input/Input";
 export default {
@@ -78,8 +79,10 @@ export default {
   mounted() {
     if (this.assignType === 1) {
       this.updateTitle = "文档";
-    } else {
+    } else if (this.assignType === 0) {
       this.updateTitle = "代码";
+    } else {
+      this.updateTitle = "机器学习";
     }
   },
   data() {
@@ -136,8 +139,10 @@ export default {
         };
         if (this.assignType === 1) {
           this.myPromise = putDocAssignment(param, this.updateItem.id);
-        } else {
+        } else if (this.assignType === 0) {
           this.myPromise = putCodeAssignment(param, this.updateItem.id);
+        } else {
+          this.myPromise = putDLAssignment(param, this.updateItem.id);
         }
         this.myPromise.then(res => {
           if (res.code === 0) {

+ 1 - 1
src/views/teacher/DlWork/index.vue

@@ -121,7 +121,7 @@ export default {
   data() {
     return {
       dlworkData: [],
-      assignType: 0,
+      assignType: 2,
       loadingDlWorkList: false
     };
   },