一、个人简介
💖💖作者:计算机编程果茶熊 💙💙个人简介:曾长期从事计算机专业培训教学,担任过编程老师,同时本人也热爱上课教学,擅长Java、微信小程序、Python、Golang、安卓Android等多个IT方向。会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 计算机毕业设计选题 💕💕文末获取源码联系计算机编程果茶熊
二、系统介绍
开发语言:Java+Python 数据库:MySQL 系统架构:B/S 后端框架:SpringBoot(Spring+SpringMVC+Mybatis)+Django 前端:Vue+HTML+CSS+JavaScript+jQuery
本在线网络学习平台是一个基于Spring Boot和Vue技术栈开发的教育管理系统,采用前后端分离的B/S架构模式。平台整合了学生管理、教师管理、课程视频管理等多个核心模块,支持课程类型分类、课程资料上传下载、付费与免费课程的灵活配置。系统提供了完整的课程报名流程,学员可以根据需求选择付费或免费课程进行学习。平台内置课程公告发布、作业布置与批改、论坛讨论等互动功能,通过排行榜机制激励学习积极性,并设计了积分兑换礼品的奖励体系。教师端可以管理课程内容、发布作业、批改学生提交的作业,学生端则可以观看课程视频、下载学习资料、参与论坛讨论、完成课程作业。系统还具备举报记录管理功能,维护平台的良好学习氛围。整体功能设计围绕教学活动的全流程展开,为线上教育提供了一套实用的管理解决方案。
三、视频解说
四、部分功能展示
五、部分代码展示
// ========== 核心功能一: 课程报名与支付处理 ==========
@Service
public class CourseEnrollmentService {
@Autowired
private CourseMapper courseMapper;
@Autowired
private EnrollmentMapper enrollmentMapper;
@Autowired
private StudentMapper studentMapper;
@Autowired
private OrderMapper orderMapper;
@Transactional(rollbackFor = Exception.class)
public EnrollmentResult enrollCourse(Long studentId, Long courseId, Integer enrollType) {
// 查询课程信息验证课程是否存在
Course course = courseMapper.selectById(courseId);
if (course == null || course.getStatus() != 1) {
return EnrollmentResult.fail("课程不存在或已下架");
}
// 检查学生是否已经报名该课程
QueryWrapper<Enrollment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("student_id", studentId)
.eq("course_id", courseId)
.in("status", Arrays.asList(0, 1)); // 0待支付 1已报名
Enrollment existEnrollment = enrollmentMapper.selectOne(queryWrapper);
if (existEnrollment != null) {
return EnrollmentResult.fail("您已报名该课程,请勿重复报名");
}
// 检查课程容量限制
if (course.getMaxStudents() != null && course.getMaxStudents() > 0) {
Integer currentCount = enrollmentMapper.countByCourseId(courseId);
if (currentCount >= course.getMaxStudents()) {
return EnrollmentResult.fail("课程人数已满,报名失败");
}
}
// 创建报名记录
Enrollment enrollment = new Enrollment();
enrollment.setStudentId(studentId);
enrollment.setCourseId(courseId);
enrollment.setEnrollTime(new Date());
enrollment.setEnrollType(enrollType); // 0免费 1付费
// 免费课程直接报名成功
if (enrollType == 0 || course.getPrice() == null || course.getPrice().compareTo(BigDecimal.ZERO) == 0) {
enrollment.setStatus(1); // 已报名
enrollment.setPayStatus(2); // 无需支付
enrollmentMapper.insert(enrollment);
// 更新学生已报课程数
studentMapper.incrementEnrollCount(studentId);
// 初始化学习进度记录
initStudyProgress(studentId, courseId);
return EnrollmentResult.success("报名成功", enrollment);
}
// 付费课程需要创建订单
enrollment.setStatus(0); // 待支付
enrollment.setPayStatus(0); // 未支付
enrollmentMapper.insert(enrollment);
// 生成支付订单
Order order = new Order();
order.setOrderNo(generateOrderNo());
order.setStudentId(studentId);
order.setCourseId(courseId);
order.setEnrollmentId(enrollment.getId());
order.setOrderAmount(course.getPrice());
order.setPayAmount(course.getPrice());
order.setOrderStatus(0); // 待支付
order.setCreateTime(new Date());
order.setExpireTime(new Date(System.currentTimeMillis() + 30 * 60 * 1000)); // 30分钟过期
orderMapper.insert(order);
return EnrollmentResult.success("订单创建成功,请完成支付", enrollment, order);
}
private String generateOrderNo() {
return "ORD" + System.currentTimeMillis() + (int)(Math.random() * 10000);
}
private void initStudyProgress(Long studentId, Long courseId) {
// 初始化该课程下所有视频的学习进度为0
List<CourseVideo> videos = courseMapper.selectVideosByCourseId(courseId);
for (CourseVideo video : videos) {
StudyProgress progress = new StudyProgress();
progress.setStudentId(studentId);
progress.setCourseId(courseId);
progress.setVideoId(video.getId());
progress.setWatchProgress(0);
progress.setIsComplete(0);
progressMapper.insert(progress);
}
}
}
// ========== 核心功能二: 作业批改与成绩计算 ==========
@Service
public class HomeworkGradingService {
@Autowired
private HomeworkSubmitMapper submitMapper;
@Autowired
private HomeworkMapper homeworkMapper;
@Autowired
private StudentMapper studentMapper;
@Autowired
private GradeMapper gradeMapper;
@Transactional(rollbackFor = Exception.class)
public GradingResult gradeHomework(Long submitId, Long teacherId, Integer score, String comment) {
// 查询提交记录
HomeworkSubmit submit = submitMapper.selectById(submitId);
if (submit == null) {
return GradingResult.fail("作业提交记录不存在");
}
if (submit.getGradeStatus() == 1) {
return GradingResult.fail("该作业已批改,请勿重复批改");
}
// 获取作业信息验证分数范围
Homework homework = homeworkMapper.selectById(submit.getHomeworkId());
if (homework == null) {
return GradingResult.fail("作业不存在");
}
if (score < 0 || score > homework.getTotalScore()) {
return GradingResult.fail("分数超出范围,满分为" + homework.getTotalScore());
}
// 更新提交记录的批改信息
submit.setScore(score);
submit.setTeacherComment(comment);
submit.setGradeStatus(1); // 已批改
submit.setGradeTime(new Date());
submit.setTeacherId(teacherId);
submitMapper.updateById(submit);
// 计算该学生在本课程中的作业平均分
QueryWrapper<HomeworkSubmit> wrapper = new QueryWrapper<>();
wrapper.eq("student_id", submit.getStudentId())
.eq("course_id", submit.getCourseId())
.eq("grade_status", 1);
List<HomeworkSubmit> graded = submitMapper.selectList(wrapper);
if (graded != null && !graded.isEmpty()) {
int totalScore = 0;
int totalWeight = 0;
for (HomeworkSubmit sub : graded) {
Homework hw = homeworkMapper.selectById(sub.getHomeworkId());
int weight = hw.getWeight() != null ? hw.getWeight() : 1;
totalScore += sub.getScore() * weight;
totalWeight += hw.getTotalScore() * weight;
}
double avgScore = totalWeight > 0 ? (double) totalScore / totalWeight * 100 : 0;
// 更新或插入成绩记录
Grade grade = gradeMapper.selectByStudentAndCourse(submit.getStudentId(), submit.getCourseId());
if (grade == null) {
grade = new Grade();
grade.setStudentId(submit.getStudentId());
grade.setCourseId(submit.getCourseId());
grade.setHomeworkScore(BigDecimal.valueOf(avgScore));
grade.setUpdateTime(new Date());
gradeMapper.insert(grade);
} else {
grade.setHomeworkScore(BigDecimal.valueOf(avgScore));
grade.setUpdateTime(new Date());
gradeMapper.updateById(grade);
}
// 计算综合成绩(作业40% + 考试60%)
if (grade.getExamScore() != null) {
double finalScore = avgScore * 0.4 + grade.getExamScore().doubleValue() * 0.6;
grade.setFinalScore(BigDecimal.valueOf(finalScore));
gradeMapper.updateById(grade);
}
}
// 判断是否获得积分奖励(90分以上奖励积分)
if (score >= homework.getTotalScore() * 0.9) {
int points = 10;
studentMapper.incrementPoints(submit.getStudentId(), points);
// 记录积分获取日志
PointsLog log = new PointsLog();
log.setStudentId(submit.getStudentId());
log.setPoints(points);
log.setType(1); // 作业获得
log.setRemark("作业《" + homework.getTitle() + "》获得" + score + "分");
log.setCreateTime(new Date());
pointsLogMapper.insert(log);
}
return GradingResult.success("批改成功", submit);
}
}
六、部分文档展示
七、END
💕💕文末获取源码联系计算机编程果茶熊