Browse Source

feat(course&student): add PPT operation record related functions

1. add selectPPTOp and addPPTOp API methods in course service
2. add opRes state to store operation record data
3. fetch operation record when getting course detail
4. add logic to add operation record when class starts for creator
lsc 4 days ago
parent
commit
3ecbbacf86
2 changed files with 61 additions and 2 deletions
  1. 23 0
      src/services/course.ts
  2. 38 2
      src/views/Student/index.vue

+ 23 - 0
src/services/course.ts

@@ -221,6 +221,27 @@ export const getClassById = (params: any): Promise<any> => {
   return axios.get(`${API_URL}getClassById`, { params: params })
   return axios.get(`${API_URL}getClassById`, { params: params })
 }
 }
 
 
+/**
+ * 
+ * 查询操作记录
+ * @param any id VARCHAR(3000), type VARCHAR(36), `index` int
+ * @returns Promise<any>
+ */
+
+export const selectPPTOp = (params: any): Promise<any> => {
+  return axios.post(`${API_URL}selectPPTOp`, [params])
+}
+
+/**
+ * 
+ * 新增操作记录
+ * @param any id VARCHAR(3000), type VARCHAR(36), `index` INT, `json` LONGTEXT
+ * @returns Promise<any>
+ */
+
+export const addPPTOp = (params: any): Promise<any> => {
+  return axios.post(`${API_URL}addPPTOp`, [params])
+}
 
 
 
 
 export default {
 export default {
@@ -243,5 +264,7 @@ export default {
   getWorkPageId,
   getWorkPageId,
   likeWork,
   likeWork,
   getClassById,
   getClassById,
+  selectPPTOp,
+  addPPTOp,
 }
 }
 
 

+ 38 - 2
src/views/Student/index.vue

@@ -642,6 +642,8 @@ const courseDetail = ref<any>({})
 const aiAssistant = ref<boolean>(false)
 const aiAssistant = ref<boolean>(false)
 const studentArray = ref<any>([])
 const studentArray = ref<any>([])
 const isResultArray = ref<any>([])
 const isResultArray = ref<any>([])
+const opRes = ref<any>([])
+
 
 
 // 跟随模式相关状态
 // 跟随模式相关状态
 const isCreator = ref(false) // 是否为创建人
 const isCreator = ref(false) // 是否为创建人
@@ -2761,12 +2763,19 @@ const checkPPTFile = async (jsonObj: any) => {
     uploadFile2(pptJsonFile, props.courseid as string)
     uploadFile2(pptJsonFile, props.courseid as string)
   }
   }
 }
 }
-
 const getCourseDetail = async () => {
 const getCourseDetail = async () => {
   isLoading.value = true
   isLoading.value = true
   try {
   try {
     const res = await api.getCourseDetail(props.courseid as string)
     const res = await api.getCourseDetail(props.courseid as string)
-    console.log(res)
+    const opRes1 = await api.selectPPTOp({
+      id: props.courseid + '-' + props.cid,
+      type: '1',
+      index: 0
+    })
+    opRes.value = opRes1[0]
+    console.log('操作记录:', opRes1[0])
+    console.log('操作记录:', opRes.value)
+    console.log(res, opRes.value)
     const courseData = res[0][0]
     const courseData = res[0][0]
     courseDetail.value = courseData
     courseDetail.value = courseData
     selectWorksStudent()
     selectWorksStudent()
@@ -2839,8 +2848,10 @@ const getCourseDetail = async () => {
               isResultArray: JSON.stringify(isResultArray.value),
               isResultArray: JSON.stringify(isResultArray.value),
               courseid: props.courseid 
               courseid: props.courseid 
             })
             })
+
             console.log(isResultArray.value)
             console.log(isResultArray.value)
           }
           }
+
         }
         }
         catch (e) {
         catch (e) {
           console.error('解析pptdata.data失败:', e)
           console.error('解析pptdata.data失败:', e)
@@ -3414,6 +3425,10 @@ const messageInit = () => {
       }
       }
     })
     })
   }
   }
+
+  if (props.type === '2') {
+    sendMessage({ type: 'class_begin', courseid: props.courseid })
+  }
 }
 }
 
 
 /**
 /**
@@ -3740,6 +3755,26 @@ const getMessages = (msgObj: any) => {
       choiceQuestionDetailDialogRef.value?.exitCastScreen?.()
       choiceQuestionDetailDialogRef.value?.exitCastScreen?.()
     }, 500)
     }, 500)
   }
   }
+
+  if (opRes.value && opRes.value.length === 0 && msgObj.type === 'class_begin' && isCreator.value && props.cid) {
+    console.log('操作记录:', opRes.value)
+    api.addPPTOp({
+      id: props.courseid + '-' + props.cid,
+      type: '1',
+      index: 0,
+      data: new Date().toISOString()
+    }).then(() => {
+      const opRes1 = api.selectPPTOp({
+        id: props.courseid + '-' + props.cid,
+        type: '1',
+        index: 0
+      }).then(res => {
+        console.log('操作记录:', res)
+        opRes.value = res[0]
+        console.log('操作记录:', opRes.value)
+      })
+    })
+  }
 }
 }
 
 
 
 
@@ -3902,6 +3937,7 @@ onMounted(() => {
       // TODO: 根据type设置特定的显示模式或功能
       // TODO: 根据type设置特定的显示模式或功能
     }
     }
   }
   }
+  
   getCourseDetail()
   getCourseDetail()