Some checks failed
continuous-integration/drone/push Build is failing
1. 课程学习进度追踪
- 新增 UserCourseProgress 和 UserMaterialProgress 模型
- 新增 /api/v1/progress/* 进度追踪 API
- 更新 admin.py 使用真实课程完成率数据
2. 路由权限检查完善
- 新增前端 permissionChecker.ts 权限检查工具
- 更新 router/guard.ts 实现团队和课程权限验证
- 新增后端 permission_service.py
3. AI 陪练音频转文本
- 新增 speech_recognition.py 语音识别服务
- 新增 /api/v1/speech/* API
- 更新 ai-practice-coze.vue 支持语音输入
4. 双人对练报告生成
- 更新 practice_room_service.py 添加报告生成功能
- 新增 /rooms/{room_code}/report API
- 更新 duo-practice-report.vue 调用真实 API
5. 学习提醒推送
- 新增 notification_service.py 通知服务
- 新增 scheduler_service.py 定时任务服务
- 支持钉钉、企微、站内消息推送
6. 智能学习推荐
- 新增 recommendation_service.py 推荐服务
- 新增 /api/v1/recommendations/* API
- 支持错题、能力、进度、热门多维度推荐
7. 安全问题修复
- DEBUG 默认值改为 False
- 添加 SECRET_KEY 安全警告
- 新增 check_security_settings() 检查函数
8. 证书 PDF 生成
- 更新 certificate_service.py 添加 PDF 生成
- 添加 weasyprint、Pillow、qrcode 依赖
- 更新下载 API 支持 PDF 和 PNG 格式
159 lines
3.5 KiB
TypeScript
159 lines
3.5 KiB
TypeScript
/**
|
|
* 用户学习进度 API
|
|
*/
|
|
import { request } from '@/utils/request'
|
|
|
|
// ============ 类型定义 ============
|
|
|
|
export interface MaterialProgress {
|
|
material_id: number
|
|
material_name: string
|
|
is_completed: boolean
|
|
progress_percent: number
|
|
last_position: number
|
|
study_time: number
|
|
first_accessed_at: string | null
|
|
last_accessed_at: string | null
|
|
completed_at: string | null
|
|
}
|
|
|
|
export interface CourseProgress {
|
|
course_id: number
|
|
course_name: string
|
|
status: 'not_started' | 'in_progress' | 'completed'
|
|
progress_percent: number
|
|
completed_materials: number
|
|
total_materials: number
|
|
total_study_time: number
|
|
first_accessed_at: string | null
|
|
last_accessed_at: string | null
|
|
completed_at: string | null
|
|
materials?: MaterialProgress[]
|
|
}
|
|
|
|
export interface ProgressSummary {
|
|
total_courses: number
|
|
completed_courses: number
|
|
in_progress_courses: number
|
|
not_started_courses: number
|
|
total_study_time: number
|
|
average_progress: number
|
|
}
|
|
|
|
export interface MaterialProgressUpdate {
|
|
progress_percent: number
|
|
last_position?: number
|
|
study_time_delta?: number
|
|
is_completed?: boolean
|
|
}
|
|
|
|
// ============ API 方法 ============
|
|
|
|
/**
|
|
* 获取学习进度摘要
|
|
*/
|
|
export const getProgressSummary = () => {
|
|
return request.get<ProgressSummary>('/api/v1/progress/summary')
|
|
}
|
|
|
|
/**
|
|
* 获取所有课程学习进度
|
|
*/
|
|
export const getAllCourseProgress = (status?: string) => {
|
|
return request.get<CourseProgress[]>('/api/v1/progress/courses', {
|
|
params: status ? { status } : undefined,
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取指定课程的详细学习进度
|
|
*/
|
|
export const getCourseProgress = (courseId: number) => {
|
|
return request.get<CourseProgress>(`/api/v1/progress/courses/${courseId}`)
|
|
}
|
|
|
|
/**
|
|
* 更新资料学习进度
|
|
*/
|
|
export const updateMaterialProgress = (
|
|
materialId: number,
|
|
data: MaterialProgressUpdate
|
|
) => {
|
|
return request.post<MaterialProgress>(
|
|
`/api/v1/progress/materials/${materialId}`,
|
|
data
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 标记资料为已完成
|
|
*/
|
|
export const markMaterialComplete = (materialId: number) => {
|
|
return request.post<MaterialProgress>(
|
|
`/api/v1/progress/materials/${materialId}/complete`
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 开始学习课程
|
|
*/
|
|
export const startCourse = (courseId: number) => {
|
|
return request.post(`/api/v1/progress/courses/${courseId}/start`)
|
|
}
|
|
|
|
/**
|
|
* 格式化学习时长
|
|
*/
|
|
export const formatStudyTime = (seconds: number): string => {
|
|
if (seconds < 60) {
|
|
return `${seconds}秒`
|
|
}
|
|
if (seconds < 3600) {
|
|
const minutes = Math.floor(seconds / 60)
|
|
return `${minutes}分钟`
|
|
}
|
|
const hours = Math.floor(seconds / 3600)
|
|
const minutes = Math.floor((seconds % 3600) / 60)
|
|
return minutes > 0 ? `${hours}小时${minutes}分钟` : `${hours}小时`
|
|
}
|
|
|
|
/**
|
|
* 获取进度状态文本
|
|
*/
|
|
export const getProgressStatusText = (
|
|
status: 'not_started' | 'in_progress' | 'completed'
|
|
): string => {
|
|
const statusMap = {
|
|
not_started: '未开始',
|
|
in_progress: '学习中',
|
|
completed: '已完成',
|
|
}
|
|
return statusMap[status] || status
|
|
}
|
|
|
|
/**
|
|
* 获取进度状态颜色
|
|
*/
|
|
export const getProgressStatusType = (
|
|
status: 'not_started' | 'in_progress' | 'completed'
|
|
): 'info' | 'warning' | 'success' => {
|
|
const typeMap: Record<string, 'info' | 'warning' | 'success'> = {
|
|
not_started: 'info',
|
|
in_progress: 'warning',
|
|
completed: 'success',
|
|
}
|
|
return typeMap[status] || 'info'
|
|
}
|
|
|
|
export default {
|
|
getProgressSummary,
|
|
getAllCourseProgress,
|
|
getCourseProgress,
|
|
updateMaterialProgress,
|
|
markMaterialComplete,
|
|
startCourse,
|
|
formatStudyTime,
|
|
getProgressStatusText,
|
|
getProgressStatusType,
|
|
}
|