考试相关

This commit is contained in:
wuchunlei
2024-08-26 13:52:55 +08:00
parent ee81ac7dfb
commit bfca58dcbe
15 changed files with 235 additions and 155 deletions

View File

@@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -155,6 +154,20 @@ public class ClassController {
return R.ok(); return R.ok();
} }
//删除任务
@RequestMapping("/delClassTask")
public R delClassTask(@RequestBody Map<String,Object> params){
classEntityService.delClassTask(params);
return R.ok();
}
//生成班级任务
@RequestMapping("/generateClassTask")
public R generateClassTask(@RequestBody Map<String,Object> params){
classEntityService.generateClassTask(params);
return R.ok();
}
//获取班级任务列表 //获取班级任务列表
@RequestMapping("/getClassTaskList") @RequestMapping("/getClassTaskList")
public R getClassTaskList(@RequestBody Map<String,Object> params){ public R getClassTaskList(@RequestBody Map<String,Object> params){
@@ -224,13 +237,6 @@ public class ClassController {
return R.ok(); return R.ok();
} }
//生成成绩
@RequestMapping("/generateScore")
public R generateScore(@RequestBody Map<String,Object> params){
classEntityService.generateScore(params);
return R.ok();
}
//编辑作业 //编辑作业
@RequestMapping("/editClassTaskAndQuesReply") @RequestMapping("/editClassTaskAndQuesReply")
public R editClassTaskAndQuesReply(@RequestBody ClassTaskAndQuesReply classTaskAndQuesReply){ public R editClassTaskAndQuesReply(@RequestBody ClassTaskAndQuesReply classTaskAndQuesReply){

View File

@@ -24,7 +24,7 @@ public class ClassExamController {
//导入考试题 //导入考试题
@RequestMapping("/importSubject") @RequestMapping("/importSubject")
public R importSubject(@RequestParam("file") MultipartFile file, @RequestParam("courseId") String courseId) { public R importSubject(@RequestParam("file") MultipartFile file, @RequestParam("courseId") int courseId) {
String res = classExamService.importSubject(file,courseId); String res = classExamService.importSubject(file,courseId);
if (res==null){ if (res==null){
return R.ok(); return R.ok();
@@ -62,61 +62,49 @@ public class ClassExamController {
//添加题目 //添加题目
@RequestMapping("/addClassExamSubject") @RequestMapping("/addClassExamSubject")
public R addClassExamSubject(@RequestBody ClassExamSubject classExamSubject){ public R addClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
if (classExamService.addClassExamSubject(classExamSubject)>0){ classExamService.addClassExamSubject(classExamSubject);
return R.ok(); return R.ok();
}else {
return R.error();
}
} }
//添加选项 //添加选项
@RequestMapping("/addClassExamOption") @RequestMapping("/addClassExamOption")
public R addClassExamOption(@RequestBody ClassExamOption classExamOption){ public R addClassExamOption(@RequestBody ClassExamOption classExamOption){
if (classExamService.addClassExamOption(classExamOption)>0){ classExamService.addClassExamOption(classExamOption);
return R.ok(); return R.ok();
}else { }
return R.error();
} //题目详情
@RequestMapping("/classExamSubjectInfo")
public R classExamSubjectInfo(@RequestBody Map<String,Object> params){
return R.ok().put("classExamSubjectInfo",classExamService.classExamSubjectInfo(params));
} }
//修改题目 //修改题目
@RequestMapping("/updateClassExamSubject") @RequestMapping("/updateClassExamSubject")
public R updateClassExamSubject(@RequestBody ClassExamSubject classExamSubject){ public R updateClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
if (classExamService.updateClassExamSubject(classExamSubject)>0){ classExamService.updateClassExamSubject(classExamSubject);
return R.ok(); return R.ok();
}else {
return R.error();
}
} }
//修改选项 //修改选项
@RequestMapping("/updateClassExamOption") @RequestMapping("/updateClassExamOption")
public R updateClassExamOption(@RequestBody ClassExamOption classExamOption){ public R updateClassExamOption(@RequestBody ClassExamOption classExamOption){
if (classExamService.updateClassExamOption(classExamOption)>0){ classExamService.updateClassExamOption(classExamOption);
return R.ok(); return R.ok();
}else {
return R.error();
}
} }
//删除题目 //删除题目
@RequestMapping("/delClassExamSubject") @RequestMapping("/delClassExamSubject")
public R delClassExamSubject(@RequestBody Map<String,Object> params){ public R delClassExamSubject(@RequestBody Map<String,Object> params){
if (classExamService.delClassExamSubject(params)>0){ classExamService.delClassExamSubject(params);
return R.ok(); return R.ok();
}else {
return R.error();
}
} }
//删除选项 //删除选项
@RequestMapping("/delClassExamOption") @RequestMapping("/delClassExamOption")
public R delClassExamOption(@RequestBody Map<String,Object> params){ public R delClassExamOption(@RequestBody Map<String,Object> params){
if (classExamService.delClassExamOption(params)>0){ classExamService.delClassExamOption(params);
return R.ok(); return R.ok();
}else {
return R.error();
}
} }
} }

View File

@@ -0,0 +1,10 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ClassExam;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClassExamDao extends MPJBaseMapper<ClassExam> {
}

View File

@@ -0,0 +1,10 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ClassExamOption;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClassExamOptionDao extends MPJBaseMapper<ClassExamOption> {
}

View File

@@ -0,0 +1,10 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ClassExamSubject;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClassExamSubjectDao extends MPJBaseMapper<ClassExamSubject> {
}

View File

@@ -0,0 +1,10 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ClassExamUser;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClassExamUserDao extends MPJBaseMapper<ClassExamUser> {
}

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ClassTaskAndQuesReply;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClassTaskAndQuesReplyDao extends MPJBaseMapper<ClassTaskAndQuesReply> {
}

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ClassTask;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClassTaskDao extends MPJBaseMapper<ClassTask> {
}

View File

@@ -18,7 +18,7 @@ public class ClassExamUser {
private Integer score;//分数 private Integer score;//分数
private String scoreSuccess;//是否完成 private Integer scoreSuccess;//考试完成0否1
private String subject; private String subject;

View File

@@ -25,13 +25,15 @@ public class ClassTask {
private String display;//是否展示 0否1是 private String display;//是否展示 0否1是
private String sort;//排序
private String title; private String title;
private String content; private String content;
private String img; private String img;
private String scoreSuccess;//是否已评分 0否1是 private int scoreSuccess;//已评分人数
private double score;//分数 private double score;//分数

View File

@@ -29,7 +29,7 @@ public class ClassTaskAndQuesReply {
private String scoreInfo;//打分情况 private String scoreInfo;//打分情况
private String scoreSuccess;//是否已评分 0否1是 private int scoreSuccess;//已评分人数
private double score;//分数 private double score;//分数

View File

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.*; import com.peanut.modules.common.entity.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -48,6 +47,10 @@ public interface ClassEntityService extends IService<ClassEntity> {
void addClassTask(ClassTask classTask); void addClassTask(ClassTask classTask);
void delClassTask(Map<String,Object> params);
void generateClassTask(Map<String,Object> params);
Page getClassTaskList(Map<String ,Object> params); Page getClassTaskList(Map<String ,Object> params);
Page getClassTaskListStudent(Map<String ,Object> params); Page getClassTaskListStudent(Map<String ,Object> params);
@@ -68,15 +71,13 @@ public interface ClassEntityService extends IService<ClassEntity> {
void editScore(Map<String,Object> params); void editScore(Map<String,Object> params);
void generateScore(Map<String,Object> params);
void editClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply); void editClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply);
ClassTaskAndQuesReply getClassTaskAndQuesReplyInfo(Map<String ,Object> params); ClassTaskAndQuesReply getClassTaskAndQuesReplyInfo(Map<String ,Object> params);
ClassTaskAndQuesReply getQuesReplyInfo(Map<String ,Object> params); ClassTaskAndQuesReply getQuesReplyInfo(Map<String ,Object> params);
List getThinkQuestionList(Map<String,Object> params); Page getThinkQuestionList(Map<String,Object> params);
Map<String,Object> getUserScore(Map<String,Object> params); Map<String,Object> getUserScore(Map<String,Object> params);

View File

@@ -6,24 +6,25 @@ import com.peanut.modules.common.entity.ClassExam;
import com.peanut.modules.common.entity.ClassExamOption; import com.peanut.modules.common.entity.ClassExamOption;
import com.peanut.modules.common.entity.ClassExamSubject; import com.peanut.modules.common.entity.ClassExamSubject;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.Map; import java.util.Map;
public interface ClassExamService extends IService<ClassExam> { public interface ClassExamService extends IService<ClassExam> {
String importSubject(MultipartFile file, String courseId); String importSubject(MultipartFile file, int courseId);
int addClassExamSubject(ClassExamSubject classExamSubject); void addClassExamSubject(ClassExamSubject classExamSubject);
int addClassExamOption(ClassExamOption classExamOption); void addClassExamOption(ClassExamOption classExamOption);
int updateClassExamSubject(ClassExamSubject classExamSubject); ClassExamSubject classExamSubjectInfo(Map<String,Object> params);
int updateClassExamOption(ClassExamOption classExamOption); void updateClassExamSubject(ClassExamSubject classExamSubject);
int delClassExamSubject(Map<String,Object> params); void updateClassExamOption(ClassExamOption classExamOption);
int delClassExamOption(Map<String,Object> params); void delClassExamSubject(Map<String,Object> params);
void delClassExamOption(Map<String,Object> params);
Page getClassExamSubjectList(Map<String,Object> params); Page getClassExamSubjectList(Map<String,Object> params);

View File

@@ -1,12 +1,11 @@
package com.peanut.modules.common.service.impl; package com.peanut.modules.common.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.DateUtils;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.common.utils.ShiroUtils; import com.peanut.common.utils.ShiroUtils;
import com.peanut.modules.common.dao.*; import com.peanut.modules.common.dao.*;
@@ -18,7 +17,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
@@ -183,7 +181,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
userWrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,ClassUser::getUserId); userWrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,ClassUser::getUserId);
userWrapper.select("t.role,t.user_id as userId,t1.tel,t1.name,t1.nickname"); userWrapper.select("t.role,t.user_id as userId,t1.tel,t1.name,t1.nickname");
userWrapper.eq(ClassUser::getClassId,classEntity.getId()); userWrapper.eq(ClassUser::getClassId,classEntity.getId());
userWrapper.in(ClassUser::getRole,"1","2","3","4","5"); userWrapper.in(ClassUser::getRole,"1","2","3","4");
classEntity.setClassUsers(classUserDao.selectMaps(userWrapper)); classEntity.setClassUsers(classUserDao.selectMaps(userWrapper));
} }
return classEntityPage; return classEntityPage;
@@ -237,8 +235,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>() int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>()
.eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0")); .eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0"));
ClassModel classModel = classModelDao.selectById(classEntity.getModelId()); ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
if (taskCount<(classModel.getDays()/7)){ if (taskCount<(classModel.getDays()/7.0)){
return R.error("请至少发布"+Math.ceil(classModel.getDays()/7)+"个任务。"); return R.error("请至少发布"+Math.ceil(classModel.getDays()/7.0)+"个任务。");
} }
int studentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>() int studentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0")); .eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0"));
@@ -246,8 +244,12 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
return R.error("学生人数未满"); return R.error("学生人数未满");
} }
classEntity.setState("1"); classEntity.setState("1");
Date startTime = new Date();
classEntity.setStartTime(startTime);
classEntity.setEndTime(DateUtils.addDateDays(startTime,classModelDao.selectById(classEntity.getModelId()).getDays()));
}else { }else {
classEntity.setState("2"); classEntity.setState("2");
classEntity.setEndTime(new Date());
} }
this.getBaseMapper().updateById(classEntity); this.getBaseMapper().updateById(classEntity);
return R.ok(); return R.ok();
@@ -273,7 +275,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
String dmonitor = params.get("dmonitor").toString(); String dmonitor = params.get("dmonitor").toString();
String learner = params.get("learner").toString(); String learner = params.get("learner").toString();
String scorer = params.get("scorer").toString(); String scorer = params.get("scorer").toString();
String counter = params.get("counter").toString(); //判断是否有重复
Set<String> list = new HashSet<>(); Set<String> list = new HashSet<>();
boolean flag = false; boolean flag = false;
list.add(monitor); list.add(monitor);
@@ -292,16 +294,11 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
flag = true; flag = true;
} }
} }
if (StringUtils.isNotEmpty(counter)){
if (!list.addAll(Arrays.asList(counter.split(",")))){
flag = true;
}
}
if (flag){ if (flag){
return R.error("同一人不能拥有多职务"); return R.error("同一人不能拥有多职务");
} }
classUserDao.delete(new LambdaQueryWrapper<ClassUser>() classUserDao.delete(new LambdaQueryWrapper<ClassUser>()
.eq(ClassUser::getClassId,classId).in(ClassUser::getRole,"1","2","3","4","5")); .eq(ClassUser::getClassId,classId).in(ClassUser::getRole,"1","2","3","4"));
if (StringUtils.isNotEmpty(monitor)){ if (StringUtils.isNotEmpty(monitor)){
addClassUser(classId,Integer.parseInt(monitor),"1"); addClassUser(classId,Integer.parseInt(monitor),"1");
} }
@@ -317,12 +314,6 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
addClassUser(classId,Integer.parseInt(s),"4"); addClassUser(classId,Integer.parseInt(s),"4");
} }
} }
if (StringUtils.isNotEmpty(counter)){
String[] scorers = counter.split(",");
for (String s : scorers) {
addClassUser(classId,Integer.parseInt(s),"5");
}
}
return R.ok(); return R.ok();
} }
@@ -369,7 +360,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
//是否班委 //是否班委
LambdaQueryWrapper<ClassUser> committeeWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ClassUser> committeeWrapper = new LambdaQueryWrapper<>();
committeeWrapper.eq(ClassUser::getUserId,userEntity.getId()); committeeWrapper.eq(ClassUser::getUserId,userEntity.getId());
committeeWrapper.in(ClassUser::getRole,"1","2","3","4","5"); committeeWrapper.in(ClassUser::getRole,"1","2","3","4");
result.put("isCommittee",classUserDao.selectCount(committeeWrapper)>0); result.put("isCommittee",classUserDao.selectCount(committeeWrapper)>0);
//是否班长 //是否班长
LambdaQueryWrapper<ClassUser> monitorWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ClassUser> monitorWrapper = new LambdaQueryWrapper<>();
@@ -395,7 +386,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
commentWrapper.eq(ClassUser::getUserId,userEntity.getId()); commentWrapper.eq(ClassUser::getUserId,userEntity.getId());
commentWrapper.in(ClassUser::getRole,"5"); commentWrapper.in(ClassUser::getRole,"5");
result.put("isComment",classUserDao.selectCount(commentWrapper)>0); result.put("isComment",classUserDao.selectCount(commentWrapper)>0);
//是学员 //是学员
LambdaQueryWrapper<ClassUser> studentWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ClassUser> studentWrapper = new LambdaQueryWrapper<>();
studentWrapper.eq(ClassUser::getUserId,userEntity.getId()); studentWrapper.eq(ClassUser::getUserId,userEntity.getId());
studentWrapper.in(ClassUser::getRole,"0"); studentWrapper.in(ClassUser::getRole,"0");
@@ -436,7 +427,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
//管理人员 //管理人员
List<ClassUser> admins = classUserDao.selectList(new LambdaQueryWrapper<ClassUser>() List<ClassUser> admins = classUserDao.selectList(new LambdaQueryWrapper<ClassUser>()
.eq(ClassUser::getClassId,classEntity.getId()) .eq(ClassUser::getClassId,classEntity.getId())
.ne(ClassUser::getRole,"0")); .in(ClassUser::getRole,"1","2","3","4"));
if (admins.size() > 0){ if (admins.size() > 0){
for (ClassUser classUser:admins){ for (ClassUser classUser:admins){
classUser.setUser(myUserDao.selectById(classUser.getUserId())); classUser.setUser(myUserDao.selectById(classUser.getUserId()));
@@ -513,6 +504,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
wrapper.leftJoin(ClassUser.class,ClassUser::getClassId,ClassEntity::getId); wrapper.leftJoin(ClassUser.class,ClassUser::getClassId,ClassEntity::getId);
wrapper.eq(ClassCourse::getCourseId,params.get("courseId")); wrapper.eq(ClassCourse::getCourseId,params.get("courseId"));
wrapper.eq(ClassUser::getUserId,ShiroUtils.getUId()); wrapper.eq(ClassUser::getUserId,ShiroUtils.getUId());
wrapper.eq(ClassEntity::getState,"2");
List<ClassEntity> classesUser = this.baseMapper.selectList(wrapper); List<ClassEntity> classesUser = this.baseMapper.selectList(wrapper);
if (classesUser.size() > 0){ if (classesUser.size() > 0){
return new ArrayList<>(); return new ArrayList<>();
@@ -614,7 +606,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
wrapper.distinct(); wrapper.distinct();
wrapper.eq(ClassEntity::getState,params.get("state")); wrapper.eq(ClassEntity::getState,params.get("state"));
if("1".equals(params.get("isCommittee").toString())){ if("1".equals(params.get("isCommittee").toString())){
wrapper.in(ClassUser::getRole,"1","2","3","4","5"); wrapper.in(ClassUser::getRole,"1","2","3","4");
}else { }else {
wrapper.eq(ClassUser::getRole,"0"); wrapper.eq(ClassUser::getRole,"0");
} }
@@ -638,6 +630,36 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
public void addClassTask(ClassTask classTask) { public void addClassTask(ClassTask classTask) {
classTask.setUserId(ShiroUtils.getUId()); classTask.setUserId(ShiroUtils.getUId());
classTaskDao.insert(classTask); classTaskDao.insert(classTask);
}
@Override
public void delClassTask(Map<String, Object> params) {
classTaskDao.deleteById(params.get("taskId").toString());
classTaskAndQuesReplyDao.delete(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
.eq(ClassTaskAndQuesReply::getRelationId,params.get("taskId")));
}
@Override
public void generateClassTask(Map<String, Object> params) {
ClassEntity classEntity = this.getById(params.get("classId").toString());
List<ClassTask> tasks = classTaskDao.selectList(new LambdaQueryWrapper<ClassTask>()
.eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0"));
if (tasks.size() > 0) {
for (ClassTask classTask : tasks) {
classTaskDao.deleteById(classTask.getId());
}
}
ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
for (int i = 1; i <= Math.ceil((classModel.getDays()/7.0));i++){
ClassTask classTask = new ClassTask();
classTask.setClassId(classEntity.getId());
classTask.setUserId(ShiroUtils.getUId());
classTask.setSort(i*10+"");
classTask.setTitle(""+i+"周的笔记");
classTask.setContent("请提交第"+i+"周的笔记");
classTaskDao.insert(classTask);
}
} }
@Override @Override
@@ -653,24 +675,16 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
wrapper.like(ClassTask::getTitle,params.get("title")); wrapper.like(ClassTask::getTitle,params.get("title"));
} }
wrapper.orderByAsc(ClassTask::getScoreSuccess); wrapper.orderByAsc(ClassTask::getScoreSuccess);
wrapper.orderByDesc(ClassTask::getCreateTime); wrapper.orderByAsc(ClassTask::getSort);
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper); Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
for (ClassTask classTask:classTaskPage.getRecords()){ for (ClassTask classTask:classTaskPage.getRecords()){
classTask.setCreateUser(myUserDao.selectById(classTask.getUserId()));
ClassEntity classEntity = this.baseMapper.selectById(classTask.getClassId());
int alreadyReply = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>() int alreadyReply = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())); .eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()));
int noReply = classEntity.getNumber() - alreadyReply;
int alreadyScore = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
.eq(ClassTaskAndQuesReply::getScoreSuccess,"1"));
int noScore = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>() int noScore = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()) .eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
.eq(ClassTaskAndQuesReply::getScoreSuccess,"0")); .eq(ClassTaskAndQuesReply::getScoreSuccess,0));
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
result.put("setGiveHomeWorkNumber",alreadyReply); result.put("setGiveHomeWorkNumber",alreadyReply);
result.put("setNoGiveHomeWorkNumber",noReply);
result.put("setGiveScoreNumber",alreadyScore);
result.put("setNoGiveScoreNumber",noScore); result.put("setNoGiveScoreNumber",noScore);
classTask.setOtherInfo(result); classTask.setOtherInfo(result);
} }
@@ -694,6 +708,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
}else { }else {
wrapper.eq(ClassTask::getDisplay,"1"); wrapper.eq(ClassTask::getDisplay,"1");
} }
wrapper.orderByAsc(ClassTask::getSort);
wrapper.orderByDesc(ClassTask::getCreateTime); wrapper.orderByDesc(ClassTask::getCreateTime);
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper); Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
for (ClassTask classTask:classTaskPage.getRecords()){ for (ClassTask classTask:classTaskPage.getRecords()){
@@ -728,7 +743,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()) .eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
.eq(ClassTaskAndQuesReply::getUserId,classUser.getUserId())); .eq(ClassTaskAndQuesReply::getUserId,classUser.getUserId()));
classUser.setReply(reply==null?false:true); classUser.setReply(reply==null?false:true);
classUser.setReplySuccess(reply==null?false:("0".equals(reply.getScoreSuccess())?false:true)); classUser.setReplySuccess(reply==null?false:(reply.getScoreSuccess()==0?false:true));
classUser.setScore(reply==null?0:reply.getScore()); classUser.setScore(reply==null?0:reply.getScore());
} }
} }
@@ -796,7 +811,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
@Override @Override
public void editTaskScore(Map<String, Object> params) { public void editTaskScore(Map<String, Object> params) {
ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString()); ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString());
classTask.setScoreSuccess("1"); classTask.setScoreSuccess(classTask.getScoreSuccess()+1);
classTask.setScore(Double.parseDouble(params.get("score").toString())); classTask.setScore(Double.parseDouble(params.get("score").toString()));
classTaskDao.updateById(classTask); classTaskDao.updateById(classTask);
} }
@@ -825,24 +840,18 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
scoreInfo = JSON.toJSONString(userIdAndScore); scoreInfo = JSON.toJSONString(userIdAndScore);
classTaskAndQuesReply.setScoreInfo(scoreInfo); classTaskAndQuesReply.setScoreInfo(scoreInfo);
classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply); classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply);
} //生成成绩
Map<String,Object> userIdScore = JSON.parseObject(classTaskAndQuesReply.getScoreInfo());
@Override double socre = 0;
public void generateScore(Map<String, Object> params) { for (Map.Entry<String,Object> key : userIdScore.entrySet()) {
ClassTaskAndQuesReply classTaskAndQuesReply = classTaskAndQuesReplyDao.selectById(params.get("replyId").toString()); socre = socre + Double.valueOf(key.getValue().toString());
if (StringUtils.isNotEmpty(classTaskAndQuesReply.getScoreInfo())) {
Map<String,Object> userIdAndScore = JSON.parseObject(classTaskAndQuesReply.getScoreInfo());
double socre = 0;
for (Map.Entry<String,Object> key : userIdAndScore.entrySet()) {
socre = socre + Double.valueOf(key.getValue().toString());
}
socre = socre/userIdAndScore.size();
BigDecimal socre2 = new BigDecimal(socre);
socre2 = socre2.setScale(2,RoundingMode.HALF_UP);
classTaskAndQuesReply.setScoreSuccess("1");
classTaskAndQuesReply.setScore(socre2.doubleValue());
classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply);
} }
socre = socre/userIdScore.size();
BigDecimal socre2 = new BigDecimal(socre);
socre2 = socre2.setScale(2,RoundingMode.HALF_UP);
classTaskAndQuesReply.setScoreSuccess(classTaskAndQuesReply.getScoreSuccess()+1);
classTaskAndQuesReply.setScore(socre2.doubleValue());
classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply);
} }
@Override @Override
@@ -867,34 +876,26 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
} }
@Override @Override
public List getThinkQuestionList(Map<String, Object> params) { public Page getThinkQuestionList(Map<String, Object> params) {
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>(); Integer limit = Integer.valueOf(params.get("limit").toString());
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId); Integer page = Integer.valueOf(params.get("page").toString());
wrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseEntity::getId); MPJLambdaWrapper<ClassTaskAndQuesReply> replyWrap = new MPJLambdaWrapper<>();
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId); replyWrap.leftJoin(CourseCatalogueChapterEntity.class,CourseCatalogueChapterEntity::getId,ClassTaskAndQuesReply::getRelationId);
wrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId); replyWrap.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueChapterEntity::getCourseId);
wrapper.eq(ClassEntity::getId,params.get("classId")); replyWrap.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassCourse::getModelId);
wrapper.select(CourseEntity::getId,CourseEntity::getTitle,CourseEntity replyWrap.eq(ClassEntity::getId,params.get("classId"));
::getSort); replyWrap.eq(ClassTaskAndQuesReply::getType,"1");
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId"); replyWrap.selectAs(ClassTaskAndQuesReply::getId,"replyId");
wrapper.selectAs(CourseCatalogueEntity::getTitle,"catalogueTitle"); replyWrap.selectAs(ClassTaskAndQuesReply::getContent,"content");
wrapper.selectAs(CourseCatalogueEntity::getSort,"catalogueSort"); replyWrap.selectAs(ClassTaskAndQuesReply::getImg,"img");
wrapper.orderByAsc("sort","catalogueSort"); replyWrap.selectAs(ClassTaskAndQuesReply::getScoreInfo,"scoreInfo");
List<Map<String,Object>> list = courseDao.selectMaps(wrapper); replyWrap.selectAs(ClassTaskAndQuesReply::getScoreSuccess,"scoreSuccess");
if (list.size() > 0){ replyWrap.selectAs(ClassTaskAndQuesReply::getScore,"score");
for (Map<String,Object> map : list){ replyWrap.selectAs(CourseCatalogueChapterEntity::getId,"chapterId");
List<Map<String,Object>> chapters = courseCatalogueChapterDao.selectMaps( replyWrap.selectAs(CourseCatalogueChapterEntity::getQuestions,"questions");
new LambdaQueryWrapper<CourseCatalogueChapterEntity>() replyWrap.orderByAsc(ClassTaskAndQuesReply::getScoreSuccess);
.eq(CourseCatalogueChapterEntity::getCatalogueId,map.get("catalogueId")) Page<Map<String,Object>> replyPage = classTaskAndQuesReplyDao.selectMapsPage(new Page<>(page, limit), replyWrap);
.ne(CourseCatalogueChapterEntity::getQuestions,"") return replyPage;
.orderByAsc(CourseCatalogueChapterEntity::getSort)
.select(CourseCatalogueChapterEntity::getId
,CourseCatalogueChapterEntity::getTitle
,CourseCatalogueChapterEntity::getQuestions));
map.put("chapters",chapters);
}
}
return list;
} }
@Override @Override
@@ -910,7 +911,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
List<ClassTaskAndQuesReply> task0Replys = classTaskAndQuesReplyDao.selectList(task0wrapper); List<ClassTaskAndQuesReply> task0Replys = classTaskAndQuesReplyDao.selectList(task0wrapper);
if (task0Replys.size() > 0) { if (task0Replys.size() > 0) {
for (ClassTaskAndQuesReply reply : task0Replys) { for (ClassTaskAndQuesReply reply : task0Replys) {
if ("1".equals(reply.getScoreSuccess())){ if (reply.getScoreSuccess()>=1){
task0Score += reply.getScore(); task0Score += reply.getScore();
} }
} }
@@ -925,7 +926,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
List<ClassTaskAndQuesReply> task1Replys = classTaskAndQuesReplyDao.selectList(task1wrapper); List<ClassTaskAndQuesReply> task1Replys = classTaskAndQuesReplyDao.selectList(task1wrapper);
if (task1Replys.size() > 0) { if (task1Replys.size() > 0) {
for (ClassTaskAndQuesReply reply : task1Replys) { for (ClassTaskAndQuesReply reply : task1Replys) {
if ("1".equals(reply.getScoreSuccess())){ if (reply.getScoreSuccess()>=1){
task1Score += reply.getScore(); task1Score += reply.getScore();
} }
} }
@@ -938,15 +939,15 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
List<ClassTask> experiences = classTaskDao.selectList(experiencewrapper); List<ClassTask> experiences = classTaskDao.selectList(experiencewrapper);
if (experiences.size() > 0) { if (experiences.size() > 0) {
for (ClassTask task : experiences) { for (ClassTask task : experiences) {
if ("1".equals(task.getScoreSuccess())){ if (task.getScoreSuccess()>=1){
experienceScore += task.getScore(); experienceScore += task.getScore();
} }
} }
} }
double questionScore = 0; double questionScore = 0;
MPJLambdaWrapper<ClassTaskAndQuesReply> questionWrapper = new MPJLambdaWrapper<>(); MPJLambdaWrapper<ClassTaskAndQuesReply> questionWrapper = new MPJLambdaWrapper<>();
questionWrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getId,ClassTaskAndQuesReply::getRelationId); questionWrapper.leftJoin(CourseCatalogueChapterEntity.class,CourseCatalogueChapterEntity::getId,ClassTaskAndQuesReply::getRelationId);
questionWrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueEntity::getCourseId); questionWrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueChapterEntity::getCourseId);
questionWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId); questionWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
questionWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId); questionWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
questionWrapper.selectAll(ClassTaskAndQuesReply.class); questionWrapper.selectAll(ClassTaskAndQuesReply.class);
@@ -955,7 +956,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
List<ClassTaskAndQuesReply> questionReplys = classTaskAndQuesReplyDao.selectList(questionWrapper); List<ClassTaskAndQuesReply> questionReplys = classTaskAndQuesReplyDao.selectList(questionWrapper);
if (questionReplys.size() > 0) { if (questionReplys.size() > 0) {
for (ClassTaskAndQuesReply reply : questionReplys) { for (ClassTaskAndQuesReply reply : questionReplys) {
if ("1".equals(reply.getScoreSuccess())){ if (reply.getScoreSuccess()>=1){
questionScore += reply.getScore(); questionScore += reply.getScore();
} }
} }

View File

@@ -36,7 +36,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
@Override @Override
@Transactional @Transactional
public String importSubject(MultipartFile file, String courseId) { public String importSubject(MultipartFile file, int courseId) {
try (InputStream fis = file.getInputStream()) { try (InputStream fis = file.getInputStream()) {
Workbook workbook = WorkbookFactory.create(fis); Workbook workbook = WorkbookFactory.create(fis);
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
@@ -47,7 +47,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
continue; continue;
} }
ClassExamSubject subject = new ClassExamSubject(); ClassExamSubject subject = new ClassExamSubject();
subject.setCourseId(1); subject.setCourseId(courseId);
//类型 //类型
String type = row.getCell(0)==null?"":row.getCell(0).toString(); String type = row.getCell(0)==null?"":row.getCell(0).toString();
if (type.contains("单选")){ if (type.contains("单选")){
@@ -113,34 +113,57 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
} }
@Override @Override
public int addClassExamSubject(ClassExamSubject classExamSubject) { public void addClassExamSubject(ClassExamSubject classExamSubject) {
return classExamSubjectDao.insert(classExamSubject); classExamSubjectDao.insert(classExamSubject);
if (classExamSubject.getOptions()!=null&&classExamSubject.getOptions().size() > 0){
for (ClassExamOption option:classExamSubject.getOptions()){
option.setSubjectId(classExamSubject.getId());
classExamOptionDao.insert(option);
}
}
} }
@Override @Override
public int addClassExamOption(ClassExamOption classExamOption) { public void addClassExamOption(ClassExamOption classExamOption) {
return classExamOptionDao.insert(classExamOption); classExamOptionDao.insert(classExamOption);
} }
@Override @Override
public int updateClassExamSubject(ClassExamSubject classExamSubject) { public ClassExamSubject classExamSubjectInfo(Map<String, Object> params) {
return classExamSubjectDao.updateById(classExamSubject); ClassExamSubject subject = classExamSubjectDao.selectById(params.get("subjectId").toString());
if (subject != null) {
subject.setOptions(classExamOptionDao.selectList(new LambdaQueryWrapper<ClassExamOption>()
.eq(ClassExamOption::getSubjectId,subject.getId())));
}
return subject;
}
@Override
public void updateClassExamSubject(ClassExamSubject classExamSubject) {
classExamSubjectDao.updateById(classExamSubject);
if (classExamSubject.getOptions()!=null&&classExamSubject.getOptions().size() > 0){
classExamOptionDao.delete(new LambdaQueryWrapper<ClassExamOption>().eq(ClassExamOption::getSubjectId,classExamSubject.getId()));
for (ClassExamOption option:classExamSubject.getOptions()){
option.setSubjectId(classExamSubject.getId());
classExamOptionDao.insert(option);
}
}
} }
@Override @Override
public int updateClassExamOption(ClassExamOption classExamOption) { public void updateClassExamOption(ClassExamOption classExamOption) {
return classExamOptionDao.updateById(classExamOption); classExamOptionDao.updateById(classExamOption);
} }
@Override @Override
public int delClassExamSubject(Map<String, Object> params) { public void delClassExamSubject(Map<String, Object> params) {
return classExamSubjectDao.deleteById(params.get("subjectId").toString()); classExamSubjectDao.deleteById(params.get("subjectId").toString());
} }
@Override @Override
public int delClassExamOption(Map<String, Object> params) { public void delClassExamOption(Map<String, Object> params) {
return classExamOptionDao.deleteById(params.get("optionId").toString()); classExamOptionDao.deleteById(params.get("optionId").toString());
} }
@Override @Override
@@ -260,7 +283,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
} }
classExamUser.setAnswer(JSONUtil.toJsonStr(resAnswerList)); classExamUser.setAnswer(JSONUtil.toJsonStr(resAnswerList));
classExamUser.setScore(score); classExamUser.setScore(score);
classExamUser.setScoreSuccess("1"); classExamUser.setScoreSuccess(1);
classExamUserDao.updateById(classExamUser); classExamUserDao.updateById(classExamUser);
return classExamUser; return classExamUser;
} }