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 !

相关推荐
Flutter笔记2 小时前
独立开发了一个睡眠记录 App:SleepDiary / 睡眠声音日记
前端
YimWu2 小时前
面试官:能聊聊 oh-my-opencode 这个插件都有啥内容吗?
前端·agent·ai编程
洛阳泰山2 小时前
开源智能体搭建平台MaxKB4j 技术文档
java·开源·llm·springboot·agent·rag·langchain4j
爱吃的小肥羊2 小时前
等了整整一年,Midjourney V8今天终于开放测试了!
前端
玉米Yvmi2 小时前
给 JS穿上铠甲:TypeScript 基础核心概念详解(类型/接口/泛型)
前端·javascript·typescript
搞个锤子哟2 小时前
js并发请求,且限制并发请求数量实现方案
前端
米丘2 小时前
vue-router v5.x createRouter 是创建路由实例?
前端·vue.js
小小小小小鹿2 小时前
Claude Code Agent Skills 入门指南(下):理解Skill的工作机制
llm·ai编程·claude
2401_873204652 小时前
使用Scrapy框架构建分布式爬虫
jvm·数据库·python