Explorar o código

[修改]获取题目分类、获取题目列表、获取文档作列表业接口

soleil %!s(int64=7) %!d(string=hai) anos
pai
achega
45326095da

+ 1 - 1
src/api/assignment.js

@@ -193,7 +193,7 @@ export const delDocAssignment = () => {
  * 老师查看文档作业列表
  * @returns {Promise<{data:DocumentSerializerType[]}>}
  */
-export const getDocAssignmentListTeacherByCrs = (courseId = 123) => {
+export const getDocAssignmentListTeacherByCrs = courseId => {
   return request(`${ASSIGNMENT_MODULE}/teacher/course/${courseId}/document`);
 };
 

+ 16 - 4
src/api/question.js

@@ -13,10 +13,22 @@ export const getTeacherQuestionType = () => {
  * 按题目分类 || 作业分类获得题目
  * @returns {Promise<{data:QuestionSerializer[]}>}
  */
-export const getTeacherQuestions = () => {
-  return request(`${QUESTION_MODULE}/teacher/questions`);
+export const getQuestionsByAssignType = ({ type, page, limit }) => {
+  return request(
+    `${QUESTION_MODULE}/teacher/questions/assignmentType?type=${type ||
+      ""}&page=${page || 0}&limit=${limit || 20}`
+  );
+};
+/**
+ * 按题目分类 || 题目分类获得题目
+ * @returns {Promise<{data:QuestionSerializer[]}>}
+ */
+export const getQuestionByQuesType = ({ type, page, limit }) => {
+  return request(
+    `${QUESTION_MODULE}/teacher/questions/type?type=${type || ""}&page=${page ||
+      1}&limit=${limit || 10}`
+  );
 };
-
 /**
  * 根据关键字进行查找
  * @param {string} keyword
@@ -31,6 +43,6 @@ export const getTeacherKeywordQuestions = (keyword = "123") => {
  * @param {number | string} questionId
  * @returns {Promise<{data:QuestionSerializer}>}
  */
-export const getQuestionDetail = (questionId = 123) => {
+export const getQuestionDetail = questionId => {
   return request(`${QUESTION_MODULE}/question/${questionId}`);
 };

+ 9 - 0
src/views/student/Document/index.vue

@@ -71,12 +71,21 @@
 import PageHeader from "@/components/PageHeader";
 import PageBody from "@/components/PageBody/index";
 import { getDocAssignmentListByCrs } from "@/api/assignment";
+import { mapState } from "vuex";
+
 export default {
   components: {
     PageBody,
     PageHeader
   },
+  computed: {
+    ...mapState({
+      course: state => state.course.currentCourse
+    })
+  },
   mounted() {
+    const { courseId } = this.$route.params;
+    console.log(courseId);
     getDocAssignmentListByCrs(123).then(res => {
       console.log(typeof res.data);
       this.docList = res.data;

+ 10 - 1
src/views/teacher/Document/index.vue

@@ -123,16 +123,25 @@ import PageHeader from "@/components/PageHeader";
 import PageBody from "@/components/PageBody/index";
 import { required } from "vuelidate/lib/validators";
 import { getDocAssignmentListTeacherByCrs } from "@/api/assignment";
+import { mapState } from "vuex";
+
 export default {
   components: {
     PageBody,
     PageHeader
   },
   mounted() {
-    getDocAssignmentListTeacherByCrs(123).then(res => {
+    // const { courseId } = this.$route.params;
+    getDocAssignmentListTeacherByCrs(1).then(res => {
+      console.log(res);
       this.docData = res.data;
     });
   },
+  computed: {
+    ...mapState({
+      course: state => state.course.currentCourse
+    })
+  },
   data() {
     return {
       docData: [],

+ 57 - 31
src/views/teacher/Question/index.vue

@@ -14,11 +14,11 @@
           <b-field>
             <b-select placeholder="选择题目类型">
               <option
-                v-for="option in questionType"
-                :value="option.title"
-                :key="option.id"
+                v-for="(option, index) in questionType"
+                :value="option"
+                :key="index"
               >
-                {{ option.title }}
+                {{ option }}
               </option>
             </b-select>
           </b-field>
@@ -53,7 +53,10 @@
                 <router-link
                   :to="{
                     path: `${props.row.id}`,
-                    query: { questionName: props.row.name }
+                    query: {
+                      questionName: props.row.name,
+                      questionId: props.row.id
+                    }
                   }"
                   >{{ props.row.name }}</router-link
                 >
@@ -78,11 +81,11 @@
 
               <b-table-column
                 label="平均时长"
-                field="expectTime"
+                field="expect_time"
                 sortable
                 centered
               >
-                {{ props.row.expectTime }}分钟
+                {{ props.row.expect_time }}分钟
               </b-table-column>
             </template>
 
@@ -92,22 +95,27 @@
                   <div class="content">
                     <p class="detail-content">
                       <strong>{{ props.row.name }}</strong>
-                      <small
-                        ><b-tag type="is-info"
-                          >{{ props.row.expectTime }}分钟</b-tag
-                        ></small
-                      >
-                      <small
-                        ><b-tag
+                      <small v-show="props.row.expect_time">
+                        <b-tag type="is-info"
+                          >{{ props.row.expect_time }}分钟</b-tag
+                        >
+                      </small>
+                      <small v-show="props.row.difficulty">
+                        <b-tag
                           :type="`${difficultyClass(props.row.difficulty)}`"
                           >{{ difficultyType(props.row.difficulty) }}</b-tag
-                        ></small
-                      >
-                      <small
-                        ><b-tag type="is-link">{{
-                          props.row.assignmentType.value
-                        }}</b-tag></small
-                      >
+                        >
+                      </small>
+                      <small v-show="props.row.assignmentType">
+                        <b-tag type="is-link">{{
+                          props.row.assignmentType
+                        }}</b-tag>
+                      </small>
+                      <small v-show="props.row.questionType">
+                        <b-tag type="is-primary">{{
+                          props.row.questionType
+                        }}</b-tag>
+                      </small>
                       <br /><br />
                       {{ props.row.description }}
                     </p>
@@ -123,8 +131,10 @@
 </template>
 <script>
 import { mapState } from "vuex";
-import { getStudentCourseReviewList } from "@/api/review";
-import { getTeacherQuestions } from "@/api/question";
+import {
+  getQuestionsByAssignType,
+  getTeacherQuestionType
+} from "@/api/question";
 import PageHeader from "@/components/PageHeader";
 import PageBody from "@/components/PageBody/index";
 
@@ -142,18 +152,34 @@ export default {
     return {
       courses: [],
       review: [],
-      questionType: [
-        { id: 1, title: "文档作业题目" },
-        { id: 2, title: "代码作业题目" }
-      ],
+      questionType: [],
       data: []
     };
   },
   mounted() {
-    getStudentCourseReviewList(this.courses.id).then(
-      value => (this.review = value.data)
-    );
-    getTeacherQuestions().then(value => (this.data = value.data));
+    //获取全部题目分类
+    getTeacherQuestionType()
+      .then(value => {
+        this.questionType = value.res;
+      })
+      .catch(e => {
+        this.$toast.open({
+          message: e.message,
+          type: "is-link"
+        });
+      });
+    //获取全部题目
+    getQuestionsByAssignType({ type: "DOCUMENT", page: 0, limit: 10 })
+      .then(value => {
+        console.log(value);
+        this.data = value.res.content;
+      })
+      .catch(e => {
+        this.$toast.open({
+          message: e.message,
+          type: "is-danger"
+        });
+      });
   },
   methods: {
     difficultyType: level => {

+ 4 - 2
src/views/teacher/Question/questionDetail.vue

@@ -62,7 +62,8 @@ export default {
   },
   mounted() {
     this.questionName = this.$route.query.questionName;
-    getQuestionDetail(234).then(res => {
+    this.questionId = this.$route.query.questionId;
+    getQuestionDetail(this.questionId).then(res => {
       console.log(res.data);
       this.questionInfo = res.data;
     });
@@ -70,7 +71,8 @@ export default {
   data() {
     return {
       questionName: "",
-      questionInfo: {}
+      questionInfo: {},
+      questionId: ""
     };
   },
   methods: {

+ 2 - 1
vue.config.js

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