AI Tutor v4:学习路径推荐(Learning Path)

目前系统已经有:

  • OCR识题
  • AI解析
  • RAG知识库
  • 错题本
  • 学习报告
  • 学习建议
  • 学生管理
  • 知识图谱

再添加一个功能 学习路径推荐(Learning Path)


功能效果

进入新标签:

复制代码
学习路径

系统会根据:

复制代码
知识图谱
↓
错误率
↓
知识点依赖关系
↓
生成学习路线

例如:

erlang 复制代码
一元一次方程   错误率 60%
↓
推荐练习
↓
一次函数
↓
二元一次方程

前端展示这样:

erlang 复制代码
学习路线

1️⃣ 一元一次方程(基础)
   错误率:60%
   推荐练习:10题

2️⃣ 一次函数
   错误率:35%
   推荐练习:5题

3️⃣ 二元一次方程
   错误率:20%
   推荐复习

后端实现

新增文件:

bash 复制代码
backend/app/learning_path_service.py

代码:

python 复制代码
from sqlalchemy.orm import Session
from app.models import StudentKnowledgeStat

def generate_learning_path(db: Session, student_id: int):

    rows = (
        db.query(StudentKnowledgeStat)
        .filter(StudentKnowledgeStat.student_id == student_id)
        .all()
    )

    items = []

    for row in rows:

        if row.total_count == 0:
            continue

        wrong_rate = row.wrong_count / row.total_count

        items.append({
            "knowledge_name": row.knowledge_name,
            "total": row.total_count,
            "wrong": row.wrong_count,
            "wrong_rate": round(wrong_rate * 100, 2)
        })

    # 按错误率排序
    items.sort(key=lambda x: x["wrong_rate"], reverse=True)

    path = []

    for item in items:

        if item["wrong_rate"] > 50:
            suggestion = "重点训练(推荐10题)"

        elif item["wrong_rate"] > 20:
            suggestion = "强化练习(推荐5题)"

        else:
            suggestion = "保持复习"

        path.append({
            "knowledge_name": item["knowledge_name"],
            "wrong_rate": item["wrong_rate"],
            "suggestion": suggestion
        })

    return path

修改 main.py

添加 import:

javascript 复制代码
from app.learning_path_service import generate_learning_path

新增接口:

python 复制代码
@app.get("/api/learning-path")
def get_learning_path(
    student_id: int = Query(1),
    db: Session = Depends(get_db),
):

    try:

        path = generate_learning_path(db, student_id)

        return {
            "student_id": student_id,
            "path": path
        }

    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))

前端 API

修改:

bash 复制代码
frontend/src/api/math.ts

新增:

typescript 复制代码
export interface LearningPathItem {
  knowledge_name: string
  wrong_rate: number
  suggestion: string
}

export function getLearningPath(student_id: number) {
  return request.get('/api/learning-path', {
    params: { student_id },
  })
}

Tab新增

修改:

bash 复制代码
src/components/TabNav.vue

新增:

css 复制代码
{ label: '学习路径', value: 'path' },

类型修改

arduino 复制代码
activeTab: 'solve' | 'history' | 'wrong' | 'report' | 'suggestion' | 'graph' | 'path'

App.vue

新增状态:

csharp 复制代码
const learningPath = ref<any[]>([])
const pathLoading = ref(false)

新增方法:

typescript 复制代码
const loadLearningPath = async () => {

  pathLoading.value = true

  try {

    const { data } = await getLearningPath(currentStudentId.value)

    learningPath.value = data.path

  } catch (error:any) {

    console.error(error)

  } finally {

    pathLoading.value = false
  }
}

修改:

复制代码
handleTabChange

新增:

csharp 复制代码
else if (tab === 'path') {
  await loadLearningPath()
}

UI展示

App.vue template 新增:

ini 复制代码
<template v-else-if="activeTab === 'path'">

  <div v-if="pathLoading" class="empty">
    学习路径生成中...
  </div>

  <div v-else class="report-panel">

    <div class="result-card">

      <h2>AI学习路径</h2>

      <div
        v-for="(item,index) in learningPath"
        :key="index"
        class="path-item"
      >

        <div class="path-header">

          <strong>{{ index+1 }}. {{ item.knowledge_name }}</strong>

          <span class="weak-rate">
            错误率 {{ item.wrong_rate }}%
          </span>

        </div>

        <div class="path-suggestion">
          {{ item.suggestion }}
        </div>

      </div>

    </div>

  </div>

</template>

样式

App.vue 添加:

css 复制代码
.path-item{
padding:16px 0;
border-bottom:1px solid #eee;
}

.path-header{
display:flex;
justify-content:space-between;
margin-bottom:8px;
}

.path-suggestion{
color:#666;
font-size:14px;
}

此处尝试了三个是否能构成三角形的问题

其中一个加入了错题

此处建议和其他 是不一样的 nice !

相关推荐
元Y亨H6 小时前
如何管理大模型的上下文窗口
llm
聪明的一休丶9 小时前
VLLM v0.24.0 版本深度解析:新引擎、新架构与大规模服务全家桶升级
python·架构·vllm
梦帮科技10 小时前
GRAVIS v4.0:基于Web的极速套利架构设计与实时数据流实现
前端·人工智能·rust·自动化·区块链·智能合约·数字货币
爱勇宝10 小时前
办公资料反复修改、补传、交接混乱,我做了个桌面工具来解决这件事
前端·后端·程序员
万亿少女的梦16810 小时前
基于Python的高考志愿填报辅助系统设计与实现
java·spring boot·python·mysql·vue
微信开发api-视频号协议11 小时前
企业微信外部群开发自动化实践过程
java·前端·微信·自动化·企业微信·ipad
甲维斯11 小时前
Fable5:20美金的顶级设计师!
前端·人工智能
kyriewen11 小时前
我同时用了 Claude Code、Cursor 和 Codex,说说三个工具的真实差距——2026 年选错工具比不用 AI 更浪费时间
前端·ai编程·claude
Jackson__12 小时前
为了拯救我的腰椎和颈椎,我做了款浏览器插件!
前端·javascript·开源
闲猫12 小时前
Python FastAPI + SQLAlchemy 入门教程:从零搭建你的第一个 Web 应用
前端·python·fastapi