Browse Source

feat:eai通过portal进行登录

lalala 1 year ago
parent
commit
7115a39bed

File diff suppressed because it is too large
+ 552 - 158
package-lock.json


+ 25 - 0
src/api/eai.js

@@ -0,0 +1,25 @@
+const prefix = "/eai";
+
+import {axios} from "@/requests/axios.config";
+
+
+
+function getTeacherEaiExamsByCourseId(courseId) {
+    return axios.get(`${prefix}/exam/teacher/course`, {
+      params: {
+        courseId,
+      }
+    });
+  }
+
+  function getStudentEvalExams() {
+    return axios.get(`${prefix}/exam/student`);
+  }
+
+
+  const eaiAPIs = {
+    getTeacherEaiExamsByCourseId,
+    getStudentEvalExams
+  };
+  
+  export default eaiAPIs;

+ 2 - 0
src/api/index.js

@@ -1,6 +1,7 @@
 import userAPIs from "@/api/user";
 import courseAPIs from "@/api/course/course";
 import evalAPIs from "@/api/eval";
+import eaiAPIs from "@/api/eai";
 import coderAPIs from "@/api/coder";
 import superAPIs from "@/api/super";
 import announcementAPIs from "@/api/announcement";
@@ -14,6 +15,7 @@ const api = {
   ...userAPIs,
   ...courseAPIs,
   ...evalAPIs,
+  ...eaiAPIs,
   ...coderAPIs,
   ...superAPIs,
   ...announcementAPIs,

+ 14 - 0
src/views/AuthPage/components/AuthCard.vue

@@ -327,6 +327,13 @@ export default {
         thatForm.validateField("password", v2 => {
           if (!v1 && !v2) {
             if (this.cardVerified) {
+               // 1. Parse URL for 'from' parameter
+              const urlParams = new URLSearchParams(window.location.search);
+              const from = urlParams.get("from");
+              // 2. Set redirect_uri cookie if 'from' exists
+              if (from) {
+                document.cookie = `redirect_uri=${encodeURIComponent(from)}; path=/; max-age=300`;
+              }
               const params = {
                 phone: this.cardForm.phone,
                 password: this.cardForm.password
@@ -334,6 +341,12 @@ export default {
               this.$apis.loginAPI(params)
                 .then((res) => {
                   if (res.data.code === 0) {
+                    if(res.data.data.redirectUri !== null){
+                      // 跳转到外部系统的home页面,并携带token
+                      console.log(res.data.data);
+                      window.location.href = `${res.data.data.redirectUri}/home?token=${res.data.data.token}`;
+                      return;
+                    }
                     if (this.rememberMe) {
                       localStorage.phone = this.cardForm.phone;
                       localStorage.password = this.cardForm.password;
@@ -355,6 +368,7 @@ export default {
                       type: "success",
                       duration: 1000,
                     });
+                    
                     setTimeout(() => {
                       if (!res.data.data.redirectUri) {
                         if (this.$route.params.login_to) {

+ 2 - 1
src/views/CourseDetailPage/CourseDetailPage.vue

@@ -61,6 +61,7 @@
                       v-if="taskTabVisible"
                       :coder-id="courseInfo.coderId"
                       :eval-id="courseInfo.evalId"
+                      :eai-id="courseInfo.eaiId"
                       :teacher-id="courseInfo.teacher.id"
                       :course-id="courseInfo.id"/>
           </el-tab-pane>
@@ -84,7 +85,7 @@
           </el-tab-pane>
           <el-tab-pane label="项目" name="project">
             <project-tab ref="projectTab"
-                         v-if="projectTabVisible"
+                         v-if="projectTabVisible && courseInfo.eaiId == null"
                          :course-id="courseInfo.id"
                          :teacher-id="courseInfo.teacher.id"/>
           </el-tab-pane>

+ 70 - 0
src/views/CourseDetailPage/tabs/TaskTab.vue

@@ -11,6 +11,11 @@
                  icon="el-icon-circle-plus-outline"
                  style="color: #f5b86e;">Eval测试
       </el-button>
+      <el-button v-if="eaiId"
+                 @click="handleAddEaiClick"
+                 icon="el-icon-circle-plus-outline"
+                 style="color: #50A879;">Eai任务
+      </el-button>
       <el-timeline>
         <el-timeline-item
             v-for="task in courseTaskList"
@@ -279,6 +284,9 @@ export default {
     evalId: {
       required: true,
     },
+    eaiId: {
+      require:true,
+    },
     courseId: {
       required: true,
     },
@@ -297,6 +305,7 @@ export default {
       themeColor,
       evalExamList: [],
       coderExamList: [],
+      eaiExamList: [],
       courseName: "",
 
       //create Coder exam
@@ -427,6 +436,7 @@ export default {
       return []
           .concat(this.evalExamList)
           .concat(this.coderExamList)
+          .concat(this.eaiExamList)
           .sort((a, b) => {
             let a_time = a["startAt"] * 1000 || new Date(a.startTime).getTime();
             let b_time = b["startAt"] * 1000 || new Date(b.startTime).getTime();
@@ -458,6 +468,9 @@ export default {
         if (_this.coderId !== null) {
           _this.coderExamList = (await _this.$apis.getTeacherCoderExamsByCourseId(_this.coderId)).data.data || [];
         }
+        if(this.eaiId !== null) {
+          _this.eaiExamList = (await _this.$apis.getTeacherEaiExamsByCourseId(_this.eaiId)).data.data || [];
+        }
       } else if (this.isStudent) {
         if (_this.evalId !== null) {
           _this.evalExamList = (await _this.$apis.getStudentEvalExamsByCourseId(_this.evalId)).data.data || [];
@@ -465,6 +478,9 @@ export default {
         if (_this.coderId !== null) {
           _this.coderExamList = (await _this.$apis.getStudentCoderExamsByCourseId(_this.coderId)).data.data || [];
         }
+        if (_this.eaiId !== null) {
+          _this.eaiExamList = (await _this.$apis.getStudentEaiExamsByCourseId(_this.eaiId)).data.data || [];
+        }
       }
     },
 
@@ -654,6 +670,12 @@ export default {
       this.evalExamDialog = true;
     },
 
+    handleAddEaiClick() {
+      this.eaiExamDialog = true;
+    },
+
+    
+
     handleAddCoderClick() {
       this.coderExamDialog = true;
     },
@@ -664,6 +686,13 @@ export default {
       this.$refs.evalExamFormRef.resetFields();
     },
 
+    handleEaiExamFormCancel() {
+      this.eaiExamDialog = false;
+      this.$refs.eaiExamFormRef.resetFields();
+    },
+
+
+
     //格式化日期函数
     formatDate(date, fmt) {
       if (typeof date == "string") {
@@ -727,8 +756,49 @@ export default {
       ).catch(_err => {
         ElMessage.error("创建Eval评测失败");
       });
+    },
+
+    // 创建Eval评测
+  createEaiExam() {
+      const obj = {
+        creatorId: this.$store.state.user.id,
+        examName: this.evalExamForm.examName,
+        position: this.evalExamForm.position,
+        skills: Object.values(this.evalExamForm.skills),
+        difficulty: this.evalExamForm.difficulty,
+        startTime: this.formatDate(this.evalExamForm.range[0], "yyyy-MM-dd hh:mm:ss"),
+        endTime: this.formatDate(this.evalExamForm.range[1], "yyyy-MM-dd hh:mm:ss"),
+        comment: this.evalExamForm.comment,
+        antiCheating: this.evalExamForm.antiCheating,
+        isPublic: !this.evalExamForm.isPrivate,
+        isHidden: false,
+        courseId: this.evalId,
+        courseName: this.courseName
+      };
+      console.log("创建eval测试", obj);
+      this.$apis.createEvalExam(obj).then(
+          _res => {
+            ElMessage.success("创建Eval评测成功");
+            this.init();
+            console.log(_res);
+            this.evalExamDialog = false;
+            this.isEvalExamCreated = !!_res.data;
+            console.log(this.isEvalExamCreated);
+            const examId = _res.data.data.result.examId;
+            this.$router.push({
+              name: "edit-exams",
+              params: {
+                examId: examId
+              }
+            });
+          }
+      ).catch(_err => {
+        ElMessage.error("创建Eval评测失败");
+      });
     }
   },
+  
+  
 };
 </script>
 

+ 10 - 3
src/views/ManagePage/ManagePage.vue

@@ -168,9 +168,9 @@
         <el-pagination
             background
             layout="prev, pager, next"
-            :current-page="problemPageInfo.page"
-            :page-size="problemPageInfo.limit"
-            :total="problemPageInfo.total"
+            :current-page="0"
+            :page-size="0"
+            :total="0"
             @current-change="changePage"
         />
       </el-card>
@@ -246,6 +246,9 @@
         <el-form-item label="Eval课程">
           <el-switch v-model="form.evalLink" :disabled="switchDisabled" active-text="创建" inactive-text="不创建"/>
         </el-form-item>
+        <el-form-item label="Eai课程">
+          <el-switch v-model="form.eaiLink" :disabled="switchDisabled" active-text="创建" inactive-text="不创建"/>
+        </el-form-item>
       </el-form>
       <div style="margin: auto;width: fit-content">
         <el-button type="primary" @click="handleFormConfirm">确定</el-button>
@@ -533,6 +536,7 @@ export default {
         imageUrl: null,
         coderLink: false,
         evalLink: false,
+        eaiLink:false
       },
       examForm: {
         examType: "coder",
@@ -716,6 +720,7 @@ export default {
               price: Number(_this.form.price),
               coderId: _this.form.coderLink ? -1 : null,
               evalId: _this.form.evalLink ? -1 : null,
+              eaiId:_this.form.eaiLink ? -1 : null
             }).then(async (res) => {
               const createdCourse = res.data.data;
               if (createdCourse) {
@@ -881,6 +886,7 @@ export default {
         imageUrl: null,
         coderLink: false,
         evalLink: false,
+        eaiLink: false
       };
     },
     // el-upload相关的方法
@@ -923,6 +929,7 @@ export default {
       this.form.imageUrl = item.imageUrl;
       this.form.coderLink = item.coderId !== null;
       this.form.evalLink = item.evalId !== null;
+      this.form.eaiLink = item.eaiId !== null;
       this.dialogTitle = "修改课程";
       this.switchDisabled = true;
       this.dialogVisible = true;

File diff suppressed because it is too large
+ 301 - 301
yarn.lock


Some files were not shown because too many files changed in this diff