feat:学习进度对接和逻辑计算
This commit is contained in:
parent
f0320a021d
commit
adeaf086c4
@ -781,6 +781,21 @@ export class CourseApi {
|
|||||||
return ApiRequest.get(`/courses/${courseId}/progress`)
|
return ApiRequest.get(`/courses/${courseId}/progress`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取课程学习进度 - 新接口
|
||||||
|
static async getCourseProgress(courseId: string): Promise<ApiResponse<any>> {
|
||||||
|
try {
|
||||||
|
console.log('🚀 调用课程学习进度API,课程ID:', courseId)
|
||||||
|
|
||||||
|
const response = await ApiRequest.get<any>(`/aiol/aiolCourse/${courseId}/progress`)
|
||||||
|
console.log('🔍 课程学习进度API响应:', response)
|
||||||
|
|
||||||
|
return response
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ 获取课程学习进度失败:', error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 更新学习进度
|
// 更新学习进度
|
||||||
static updateLearningProgress(data: {
|
static updateLearningProgress(data: {
|
||||||
courseId: number
|
courseId: number
|
||||||
|
@ -1072,6 +1072,9 @@ const videoProgress = ref(0)
|
|||||||
const exerciseProgress = ref(0)
|
const exerciseProgress = ref(0)
|
||||||
const examProgress = ref(0)
|
const examProgress = ref(0)
|
||||||
|
|
||||||
|
// 进度数据
|
||||||
|
const progressData = ref<any>(null)
|
||||||
|
|
||||||
// 处理记笔记点击事件
|
// 处理记笔记点击事件
|
||||||
// const handleNotesClick = () => {
|
// const handleNotesClick = () => {
|
||||||
// if (isUserEnrolled.value) {
|
// if (isUserEnrolled.value) {
|
||||||
@ -1591,6 +1594,9 @@ const loadCourseDetail = async () => {
|
|||||||
console.log('课程数据设置成功:', course.value)
|
console.log('课程数据设置成功:', course.value)
|
||||||
console.log('课程AI模式:', (course.value as any)?.izAi)
|
console.log('课程AI模式:', (course.value as any)?.izAi)
|
||||||
|
|
||||||
|
// 加载课程学习进度
|
||||||
|
await loadCourseProgress()
|
||||||
|
|
||||||
// 确保讲师和时长信息正确显示
|
// 确保讲师和时长信息正确显示
|
||||||
if (course.value) {
|
if (course.value) {
|
||||||
if (!course.value.instructor?.name) {
|
if (!course.value.instructor?.name) {
|
||||||
@ -2047,6 +2053,70 @@ const handleUpload = ({ file, onFinish }: any) => {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载课程学习进度
|
||||||
|
const loadCourseProgress = async () => {
|
||||||
|
try {
|
||||||
|
console.log('🚀 开始加载课程学习进度,课程ID:', courseId.value)
|
||||||
|
const response = await CourseApi.getCourseProgress(courseId.value)
|
||||||
|
console.log('📊 课程学习进度响应:', response)
|
||||||
|
|
||||||
|
// 检查响应数据结构
|
||||||
|
if (response.data && response.data.code === 200 && response.data.result) {
|
||||||
|
console.log('✅ 课程学习进度加载成功:', response.data.result)
|
||||||
|
progressData.value = response.data.result
|
||||||
|
|
||||||
|
// 计算各项进度百分比
|
||||||
|
calculateProgress()
|
||||||
|
} else {
|
||||||
|
console.warn('⚠️ 课程学习进度API返回异常:', response)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ 加载课程学习进度失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算进度百分比
|
||||||
|
const calculateProgress = () => {
|
||||||
|
if (!progressData.value) {
|
||||||
|
console.log('⚠️ 进度数据为空,无法计算')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = progressData.value
|
||||||
|
console.log('🔍 原始进度数据:', data)
|
||||||
|
|
||||||
|
// 计算视频进度百分比
|
||||||
|
videoProgress.value = data.video?.total > 0 ?
|
||||||
|
(data.video.completed / data.video.total) * 100 : 0
|
||||||
|
|
||||||
|
// 计算作业进度百分比
|
||||||
|
exerciseProgress.value = data.homework?.total > 0 ?
|
||||||
|
(data.homework.completed / data.homework.total) * 100 : 0
|
||||||
|
|
||||||
|
// 计算考试进度百分比
|
||||||
|
examProgress.value = data.exam?.total > 0 ?
|
||||||
|
(data.exam.completed / data.exam.total) * 100 : 0
|
||||||
|
|
||||||
|
// 更新完成的课程数
|
||||||
|
completedLessons.value = data.total?.completed || 0
|
||||||
|
|
||||||
|
console.log('📊 进度计算结果:', {
|
||||||
|
原始数据: data,
|
||||||
|
视频进度: `${data.video?.completed}/${data.video?.total} = ${videoProgress.value.toFixed(1)}%`,
|
||||||
|
作业进度: `${data.homework?.completed}/${data.homework?.total} = ${exerciseProgress.value.toFixed(1)}%`,
|
||||||
|
考试进度: `${data.exam?.completed}/${data.exam?.total} = ${examProgress.value.toFixed(1)}%`,
|
||||||
|
总体进度: `${completedLessons.value}/${totalSections.value} = ${overallProgress.value.toFixed(1)}%`,
|
||||||
|
计算后的值: {
|
||||||
|
video: videoProgress.value,
|
||||||
|
exercise: exerciseProgress.value,
|
||||||
|
exam: examProgress.value,
|
||||||
|
overall: overallProgress.value,
|
||||||
|
completed: completedLessons.value,
|
||||||
|
total: totalSections.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 发送聊天消息
|
// 发送聊天消息
|
||||||
const sendMessage = () => {
|
const sendMessage = () => {
|
||||||
if (chatMessage.value.trim()) {
|
if (chatMessage.value.trim()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user