考试相关
This commit is contained in:
@@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -155,6 +154,20 @@ public class ClassController {
|
||||
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")
|
||||
public R getClassTaskList(@RequestBody Map<String,Object> params){
|
||||
@@ -224,13 +237,6 @@ public class ClassController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//生成成绩
|
||||
@RequestMapping("/generateScore")
|
||||
public R generateScore(@RequestBody Map<String,Object> params){
|
||||
classEntityService.generateScore(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//编辑作业
|
||||
@RequestMapping("/editClassTaskAndQuesReply")
|
||||
public R editClassTaskAndQuesReply(@RequestBody ClassTaskAndQuesReply classTaskAndQuesReply){
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ClassExamController {
|
||||
|
||||
//导入考试题
|
||||
@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);
|
||||
if (res==null){
|
||||
return R.ok();
|
||||
@@ -62,61 +62,49 @@ public class ClassExamController {
|
||||
//添加题目
|
||||
@RequestMapping("/addClassExamSubject")
|
||||
public R addClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
|
||||
if (classExamService.addClassExamSubject(classExamSubject)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
classExamService.addClassExamSubject(classExamSubject);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//添加选项
|
||||
@RequestMapping("/addClassExamOption")
|
||||
public R addClassExamOption(@RequestBody ClassExamOption classExamOption){
|
||||
if (classExamService.addClassExamOption(classExamOption)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
classExamService.addClassExamOption(classExamOption);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//题目详情
|
||||
@RequestMapping("/classExamSubjectInfo")
|
||||
public R classExamSubjectInfo(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("classExamSubjectInfo",classExamService.classExamSubjectInfo(params));
|
||||
}
|
||||
|
||||
//修改题目
|
||||
@RequestMapping("/updateClassExamSubject")
|
||||
public R updateClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
|
||||
if (classExamService.updateClassExamSubject(classExamSubject)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
classExamService.updateClassExamSubject(classExamSubject);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//修改选项
|
||||
@RequestMapping("/updateClassExamOption")
|
||||
public R updateClassExamOption(@RequestBody ClassExamOption classExamOption){
|
||||
if (classExamService.updateClassExamOption(classExamOption)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
classExamService.updateClassExamOption(classExamOption);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除题目
|
||||
@RequestMapping("/delClassExamSubject")
|
||||
public R delClassExamSubject(@RequestBody Map<String,Object> params){
|
||||
if (classExamService.delClassExamSubject(params)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
classExamService.delClassExamSubject(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//删除选项
|
||||
@RequestMapping("/delClassExamOption")
|
||||
public R delClassExamOption(@RequestBody Map<String,Object> params){
|
||||
if (classExamService.delClassExamOption(params)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
classExamService.delClassExamOption(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class ClassExamUser {
|
||||
|
||||
private Integer score;//分数
|
||||
|
||||
private String scoreSuccess;//是否完成
|
||||
private Integer scoreSuccess;//考试完成0否1是
|
||||
|
||||
private String subject;
|
||||
|
||||
|
||||
@@ -25,13 +25,15 @@ public class ClassTask {
|
||||
|
||||
private String display;//是否展示 0否1是
|
||||
|
||||
private String sort;//排序
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
private String img;
|
||||
|
||||
private String scoreSuccess;//是否已评分 0否1是
|
||||
private int scoreSuccess;//已评分人数
|
||||
|
||||
private double score;//分数
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ClassTaskAndQuesReply {
|
||||
|
||||
private String scoreInfo;//打分情况
|
||||
|
||||
private String scoreSuccess;//是否已评分 0否1是
|
||||
private int scoreSuccess;//已评分人数
|
||||
|
||||
private double score;//分数
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -48,6 +47,10 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
void addClassTask(ClassTask classTask);
|
||||
|
||||
void delClassTask(Map<String,Object> params);
|
||||
|
||||
void generateClassTask(Map<String,Object> params);
|
||||
|
||||
Page getClassTaskList(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 generateScore(Map<String,Object> params);
|
||||
|
||||
void editClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply);
|
||||
|
||||
ClassTaskAndQuesReply getClassTaskAndQuesReplyInfo(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);
|
||||
|
||||
|
||||
@@ -6,24 +6,25 @@ import com.peanut.modules.common.entity.ClassExam;
|
||||
import com.peanut.modules.common.entity.ClassExamOption;
|
||||
import com.peanut.modules.common.entity.ClassExamSubject;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
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.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.dao.*;
|
||||
@@ -18,7 +17,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
@@ -183,7 +181,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
userWrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,ClassUser::getUserId);
|
||||
userWrapper.select("t.role,t.user_id as userId,t1.tel,t1.name,t1.nickname");
|
||||
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));
|
||||
}
|
||||
return classEntityPage;
|
||||
@@ -237,8 +235,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>()
|
||||
.eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0"));
|
||||
ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
|
||||
if (taskCount<(classModel.getDays()/7)){
|
||||
return R.error("请至少发布"+Math.ceil(classModel.getDays()/7)+"个任务。");
|
||||
if (taskCount<(classModel.getDays()/7.0)){
|
||||
return R.error("请至少发布"+Math.ceil(classModel.getDays()/7.0)+"个任务。");
|
||||
}
|
||||
int studentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0"));
|
||||
@@ -246,8 +244,12 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
return R.error("学生人数未满");
|
||||
}
|
||||
classEntity.setState("1");
|
||||
Date startTime = new Date();
|
||||
classEntity.setStartTime(startTime);
|
||||
classEntity.setEndTime(DateUtils.addDateDays(startTime,classModelDao.selectById(classEntity.getModelId()).getDays()));
|
||||
}else {
|
||||
classEntity.setState("2");
|
||||
classEntity.setEndTime(new Date());
|
||||
}
|
||||
this.getBaseMapper().updateById(classEntity);
|
||||
return R.ok();
|
||||
@@ -273,7 +275,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
String dmonitor = params.get("dmonitor").toString();
|
||||
String learner = params.get("learner").toString();
|
||||
String scorer = params.get("scorer").toString();
|
||||
String counter = params.get("counter").toString();
|
||||
//判断是否有重复
|
||||
Set<String> list = new HashSet<>();
|
||||
boolean flag = false;
|
||||
list.add(monitor);
|
||||
@@ -292,16 +294,11 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(counter)){
|
||||
if (!list.addAll(Arrays.asList(counter.split(",")))){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (flag){
|
||||
return R.error("同一人不能拥有多职务");
|
||||
}
|
||||
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)){
|
||||
addClassUser(classId,Integer.parseInt(monitor),"1");
|
||||
}
|
||||
@@ -317,12 +314,6 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -369,7 +360,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
//是否班委
|
||||
LambdaQueryWrapper<ClassUser> committeeWrapper = new LambdaQueryWrapper<>();
|
||||
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);
|
||||
//是否班长
|
||||
LambdaQueryWrapper<ClassUser> monitorWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -395,7 +386,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
commentWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
commentWrapper.in(ClassUser::getRole,"5");
|
||||
result.put("isComment",classUserDao.selectCount(commentWrapper)>0);
|
||||
//是学员
|
||||
//是否学员
|
||||
LambdaQueryWrapper<ClassUser> studentWrapper = new LambdaQueryWrapper<>();
|
||||
studentWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
studentWrapper.in(ClassUser::getRole,"0");
|
||||
@@ -436,7 +427,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
//管理人员
|
||||
List<ClassUser> admins = classUserDao.selectList(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId())
|
||||
.ne(ClassUser::getRole,"0"));
|
||||
.in(ClassUser::getRole,"1","2","3","4"));
|
||||
if (admins.size() > 0){
|
||||
for (ClassUser classUser:admins){
|
||||
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.eq(ClassCourse::getCourseId,params.get("courseId"));
|
||||
wrapper.eq(ClassUser::getUserId,ShiroUtils.getUId());
|
||||
wrapper.eq(ClassEntity::getState,"2");
|
||||
List<ClassEntity> classesUser = this.baseMapper.selectList(wrapper);
|
||||
if (classesUser.size() > 0){
|
||||
return new ArrayList<>();
|
||||
@@ -614,7 +606,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
wrapper.distinct();
|
||||
wrapper.eq(ClassEntity::getState,params.get("state"));
|
||||
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 {
|
||||
wrapper.eq(ClassUser::getRole,"0");
|
||||
}
|
||||
@@ -638,6 +630,36 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
public void addClassTask(ClassTask classTask) {
|
||||
classTask.setUserId(ShiroUtils.getUId());
|
||||
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
|
||||
@@ -653,24 +675,16 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
wrapper.like(ClassTask::getTitle,params.get("title"));
|
||||
}
|
||||
wrapper.orderByAsc(ClassTask::getScoreSuccess);
|
||||
wrapper.orderByDesc(ClassTask::getCreateTime);
|
||||
wrapper.orderByAsc(ClassTask::getSort);
|
||||
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
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>()
|
||||
.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>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getScoreSuccess,"0"));
|
||||
.eq(ClassTaskAndQuesReply::getScoreSuccess,0));
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("setGiveHomeWorkNumber",alreadyReply);
|
||||
result.put("setNoGiveHomeWorkNumber",noReply);
|
||||
result.put("setGiveScoreNumber",alreadyScore);
|
||||
result.put("setNoGiveScoreNumber",noScore);
|
||||
classTask.setOtherInfo(result);
|
||||
}
|
||||
@@ -694,6 +708,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}else {
|
||||
wrapper.eq(ClassTask::getDisplay,"1");
|
||||
}
|
||||
wrapper.orderByAsc(ClassTask::getSort);
|
||||
wrapper.orderByDesc(ClassTask::getCreateTime);
|
||||
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
for (ClassTask classTask:classTaskPage.getRecords()){
|
||||
@@ -728,7 +743,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getUserId,classUser.getUserId()));
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -796,7 +811,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
@Override
|
||||
public void editTaskScore(Map<String, Object> params) {
|
||||
ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString());
|
||||
classTask.setScoreSuccess("1");
|
||||
classTask.setScoreSuccess(classTask.getScoreSuccess()+1);
|
||||
classTask.setScore(Double.parseDouble(params.get("score").toString()));
|
||||
classTaskDao.updateById(classTask);
|
||||
}
|
||||
@@ -825,24 +840,18 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
scoreInfo = JSON.toJSONString(userIdAndScore);
|
||||
classTaskAndQuesReply.setScoreInfo(scoreInfo);
|
||||
classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateScore(Map<String, Object> params) {
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classTaskAndQuesReplyDao.selectById(params.get("replyId").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);
|
||||
//生成成绩
|
||||
Map<String,Object> userIdScore = JSON.parseObject(classTaskAndQuesReply.getScoreInfo());
|
||||
double socre = 0;
|
||||
for (Map.Entry<String,Object> key : userIdScore.entrySet()) {
|
||||
socre = socre + Double.valueOf(key.getValue().toString());
|
||||
}
|
||||
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
|
||||
@@ -867,34 +876,26 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getThinkQuestionList(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseEntity::getId);
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
wrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
wrapper.eq(ClassEntity::getId,params.get("classId"));
|
||||
wrapper.select(CourseEntity::getId,CourseEntity::getTitle,CourseEntity
|
||||
::getSort);
|
||||
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
||||
wrapper.selectAs(CourseCatalogueEntity::getTitle,"catalogueTitle");
|
||||
wrapper.selectAs(CourseCatalogueEntity::getSort,"catalogueSort");
|
||||
wrapper.orderByAsc("sort","catalogueSort");
|
||||
List<Map<String,Object>> list = courseDao.selectMaps(wrapper);
|
||||
if (list.size() > 0){
|
||||
for (Map<String,Object> map : list){
|
||||
List<Map<String,Object>> chapters = courseCatalogueChapterDao.selectMaps(
|
||||
new LambdaQueryWrapper<CourseCatalogueChapterEntity>()
|
||||
.eq(CourseCatalogueChapterEntity::getCatalogueId,map.get("catalogueId"))
|
||||
.ne(CourseCatalogueChapterEntity::getQuestions,"")
|
||||
.orderByAsc(CourseCatalogueChapterEntity::getSort)
|
||||
.select(CourseCatalogueChapterEntity::getId
|
||||
,CourseCatalogueChapterEntity::getTitle
|
||||
,CourseCatalogueChapterEntity::getQuestions));
|
||||
map.put("chapters",chapters);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
public Page getThinkQuestionList(Map<String, Object> params) {
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
MPJLambdaWrapper<ClassTaskAndQuesReply> replyWrap = new MPJLambdaWrapper<>();
|
||||
replyWrap.leftJoin(CourseCatalogueChapterEntity.class,CourseCatalogueChapterEntity::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
replyWrap.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueChapterEntity::getCourseId);
|
||||
replyWrap.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassCourse::getModelId);
|
||||
replyWrap.eq(ClassEntity::getId,params.get("classId"));
|
||||
replyWrap.eq(ClassTaskAndQuesReply::getType,"1");
|
||||
replyWrap.selectAs(ClassTaskAndQuesReply::getId,"replyId");
|
||||
replyWrap.selectAs(ClassTaskAndQuesReply::getContent,"content");
|
||||
replyWrap.selectAs(ClassTaskAndQuesReply::getImg,"img");
|
||||
replyWrap.selectAs(ClassTaskAndQuesReply::getScoreInfo,"scoreInfo");
|
||||
replyWrap.selectAs(ClassTaskAndQuesReply::getScoreSuccess,"scoreSuccess");
|
||||
replyWrap.selectAs(ClassTaskAndQuesReply::getScore,"score");
|
||||
replyWrap.selectAs(CourseCatalogueChapterEntity::getId,"chapterId");
|
||||
replyWrap.selectAs(CourseCatalogueChapterEntity::getQuestions,"questions");
|
||||
replyWrap.orderByAsc(ClassTaskAndQuesReply::getScoreSuccess);
|
||||
Page<Map<String,Object>> replyPage = classTaskAndQuesReplyDao.selectMapsPage(new Page<>(page, limit), replyWrap);
|
||||
return replyPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -910,7 +911,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
List<ClassTaskAndQuesReply> task0Replys = classTaskAndQuesReplyDao.selectList(task0wrapper);
|
||||
if (task0Replys.size() > 0) {
|
||||
for (ClassTaskAndQuesReply reply : task0Replys) {
|
||||
if ("1".equals(reply.getScoreSuccess())){
|
||||
if (reply.getScoreSuccess()>=1){
|
||||
task0Score += reply.getScore();
|
||||
}
|
||||
}
|
||||
@@ -925,7 +926,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
List<ClassTaskAndQuesReply> task1Replys = classTaskAndQuesReplyDao.selectList(task1wrapper);
|
||||
if (task1Replys.size() > 0) {
|
||||
for (ClassTaskAndQuesReply reply : task1Replys) {
|
||||
if ("1".equals(reply.getScoreSuccess())){
|
||||
if (reply.getScoreSuccess()>=1){
|
||||
task1Score += reply.getScore();
|
||||
}
|
||||
}
|
||||
@@ -938,15 +939,15 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
List<ClassTask> experiences = classTaskDao.selectList(experiencewrapper);
|
||||
if (experiences.size() > 0) {
|
||||
for (ClassTask task : experiences) {
|
||||
if ("1".equals(task.getScoreSuccess())){
|
||||
if (task.getScoreSuccess()>=1){
|
||||
experienceScore += task.getScore();
|
||||
}
|
||||
}
|
||||
}
|
||||
double questionScore = 0;
|
||||
MPJLambdaWrapper<ClassTaskAndQuesReply> questionWrapper = new MPJLambdaWrapper<>();
|
||||
questionWrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
questionWrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueEntity::getCourseId);
|
||||
questionWrapper.leftJoin(CourseCatalogueChapterEntity.class,CourseCatalogueChapterEntity::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
questionWrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueChapterEntity::getCourseId);
|
||||
questionWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
questionWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
questionWrapper.selectAll(ClassTaskAndQuesReply.class);
|
||||
@@ -955,7 +956,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
List<ClassTaskAndQuesReply> questionReplys = classTaskAndQuesReplyDao.selectList(questionWrapper);
|
||||
if (questionReplys.size() > 0) {
|
||||
for (ClassTaskAndQuesReply reply : questionReplys) {
|
||||
if ("1".equals(reply.getScoreSuccess())){
|
||||
if (reply.getScoreSuccess()>=1){
|
||||
questionScore += reply.getScore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public String importSubject(MultipartFile file, String courseId) {
|
||||
public String importSubject(MultipartFile file, int courseId) {
|
||||
try (InputStream fis = file.getInputStream()) {
|
||||
Workbook workbook = WorkbookFactory.create(fis);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
@@ -47,7 +47,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
continue;
|
||||
}
|
||||
ClassExamSubject subject = new ClassExamSubject();
|
||||
subject.setCourseId(1);
|
||||
subject.setCourseId(courseId);
|
||||
//类型
|
||||
String type = row.getCell(0)==null?"":row.getCell(0).toString();
|
||||
if (type.contains("单选")){
|
||||
@@ -113,34 +113,57 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addClassExamSubject(ClassExamSubject classExamSubject) {
|
||||
return classExamSubjectDao.insert(classExamSubject);
|
||||
public void addClassExamSubject(ClassExamSubject 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
|
||||
public int addClassExamOption(ClassExamOption classExamOption) {
|
||||
return classExamOptionDao.insert(classExamOption);
|
||||
public void addClassExamOption(ClassExamOption classExamOption) {
|
||||
classExamOptionDao.insert(classExamOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateClassExamSubject(ClassExamSubject classExamSubject) {
|
||||
return classExamSubjectDao.updateById(classExamSubject);
|
||||
public ClassExamSubject classExamSubjectInfo(Map<String, Object> params) {
|
||||
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
|
||||
public int updateClassExamOption(ClassExamOption classExamOption) {
|
||||
return classExamOptionDao.updateById(classExamOption);
|
||||
public void updateClassExamOption(ClassExamOption classExamOption) {
|
||||
classExamOptionDao.updateById(classExamOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delClassExamSubject(Map<String, Object> params) {
|
||||
return classExamSubjectDao.deleteById(params.get("subjectId").toString());
|
||||
public void delClassExamSubject(Map<String, Object> params) {
|
||||
classExamSubjectDao.deleteById(params.get("subjectId").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delClassExamOption(Map<String, Object> params) {
|
||||
return classExamOptionDao.deleteById(params.get("optionId").toString());
|
||||
public void delClassExamOption(Map<String, Object> params) {
|
||||
classExamOptionDao.deleteById(params.get("optionId").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -260,7 +283,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
||||
}
|
||||
classExamUser.setAnswer(JSONUtil.toJsonStr(resAnswerList));
|
||||
classExamUser.setScore(score);
|
||||
classExamUser.setScoreSuccess("1");
|
||||
classExamUser.setScoreSuccess(1);
|
||||
classExamUserDao.updateById(classExamUser);
|
||||
return classExamUser;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user