diff --git a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java index 8b3621c..42bfc5d 100644 --- a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java +++ b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java @@ -33,7 +33,7 @@ public class CmsEssayController { * @return */ @PostMapping("/add") - public BaseResponse addEssay(CmsEssay cmsEssay){ + public BaseResponse addEssay(@RequestBody CmsEssay cmsEssay){ return cmsEssayService.addEssay(cmsEssay); } diff --git a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java index 8c132cb..1faff85 100644 --- a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java @@ -96,4 +96,16 @@ public class KnowledgeLearningRecordController { return CommonResult.success(coursesVOList); } + /** + * 学生知识点的完成度 + * @param userId + * @param courseId + * @return + */ + @ApiOperation("学生知识点的完成度") + @PostMapping("/studentfinish") + public BaseResponse studentFinish(@RequestParam String userId, @RequestParam String courseId) { + return knowledgeLearningRecordService.studentFinish(userId,courseId); + } + } diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java index b120f8a..6d389a1 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.ResultUtils; +import com.teaching.backend.mapper.Knowtemp.KnowtmpMapper; import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; @@ -54,6 +55,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { //知识点id @@ -213,4 +215,18 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl studentFinish(String userId, String courseId) { + //获取学生该课程已完成的知识点数量 + Long count = recordKnowledgeFinishService.query() + .eq("user_id", userId) + .eq("course_id", courseId) + .count(); + //获取这门课程的总知识点数 + BaseResponse allKnows = knowtmpService.getAllKnows(courseId); + double finish = (double) count /allKnows.getData() * 100; + System.out.println(finish); + return ResultUtils.success(String.valueOf(finish)); + } + } diff --git a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java index a90f9c4..b2858af 100644 --- a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java +++ b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java @@ -31,5 +31,7 @@ public interface IKnowledgeLearningRecordService extends IService queryMaxKnowledge(String userId); List queryRecommendKnowledge(String userId); + + BaseResponse studentFinish(String userId, String courseId); }