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 !

相关推荐
程序猿DD6 小时前
OctaFuse Gateway 2.6.0:完善 Vertex AI 鉴权、图片计费与日常调试
llm·agent
名明鸣冥6 小时前
k8s-agent架构思考(一)
python
szp20056 小时前
为了在浏览器里跑多线程 ONNX 推理,我把自己的支付浮层弄挂了
前端·webassembly
kisshyshy7 小时前
从 useRef 到 Web Worker:理解 React 可变对象与浏览器多线程
前端·javascript·react.js
fatcoder7 小时前
玩转Nginx 04 — 反向代理:给 nginx 接上后端
前端·后端·nginx
DoLovya7 小时前
从零实现 ESP8266 + MQTT 智能门禁:公网一键开门、舵机控制、在线监控完整方案
python·物联网·mqtt·嵌入式·esp8266·门禁系统
AI情绪识别开源7 小时前
检信ALLEMOTION VibrationAI 2.4.0 12维度情绪识别开源源代码
开发语言·python
极创信息7 小时前
国产化信创适配认证高频术语:信创适配、软件自主可控、国产化率、代码溯源率、代码自主率、代码开源率是什么?
java·python·struts·eclipse·开源·php·hibernate
Data_Journal7 小时前
什么是 CAPTCHA,它是如何工作的?
java·大数据·服务器·前端·数据库
计算机魔术师8 小时前
我看了这个更新,把原来的检索方案推翻了
前端