评分修改
This commit is contained in:
@@ -333,15 +333,13 @@ public class ClassController {
|
||||
//心得评分
|
||||
@RequestMapping("/editTaskScore")
|
||||
public R editTaskScore(@RequestBody Map<String,Object> params){
|
||||
classEntityService.editTaskScore(params);
|
||||
return R.ok();
|
||||
return classEntityService.editTaskScore(params);
|
||||
}
|
||||
|
||||
//打分
|
||||
@RequestMapping("/editScore")
|
||||
public R editScore(@RequestBody Map<String,Object> params){
|
||||
classEntityService.editScore(params);
|
||||
return R.ok();
|
||||
return classEntityService.editScore(params);
|
||||
}
|
||||
|
||||
//编辑作业
|
||||
|
||||
@@ -77,9 +77,9 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
Page getReplyListByTaskIdStudent(Map<String ,Object> params);
|
||||
|
||||
void editTaskScore(Map<String,Object> params);
|
||||
R editTaskScore(Map<String,Object> params);
|
||||
|
||||
void editScore(Map<String,Object> params);
|
||||
R editScore(Map<String,Object> params);
|
||||
|
||||
void editClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply);
|
||||
|
||||
|
||||
@@ -962,49 +962,62 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editTaskScore(Map<String, Object> params) {
|
||||
public R editTaskScore(Map<String, Object> params) {
|
||||
ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString());
|
||||
classTask.setScoreSuccess(classTask.getScoreSuccess()+1);
|
||||
classTask.setScore(Double.parseDouble(params.get("score").toString()));
|
||||
classTaskDao.updateById(classTask);
|
||||
ClassEntity classEntity = this.baseMapper.selectById(classTask.getClassId());
|
||||
if ("1".equals(classEntity.getState())||"3".equals(classEntity.getState())){
|
||||
classTask.setScoreSuccess(classTask.getScoreSuccess()+1);
|
||||
classTask.setScore(Double.parseDouble(params.get("score").toString()));
|
||||
classTaskDao.updateById(classTask);
|
||||
}else {
|
||||
return R.error("此班级状态不能评分");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editScore(Map<String, Object> params) {
|
||||
@Transactional
|
||||
public R editScore(Map<String, Object> params) {
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classTaskAndQuesReplyDao.selectById(params.get("replyId").toString());
|
||||
String score = params.get("score").toString();
|
||||
String scoreInfo = "";
|
||||
Map<String,Object> userIdAndScore = new HashMap<>();
|
||||
if (StringUtils.isNotEmpty(classTaskAndQuesReply.getScoreInfo())){
|
||||
boolean flag = true;
|
||||
userIdAndScore = JSON.parseObject(classTaskAndQuesReply.getScoreInfo());
|
||||
for (Map.Entry<String,Object> key : userIdAndScore.entrySet()) {
|
||||
if (key.equals(ShiroUtils.getUId().toString())){
|
||||
flag = false;
|
||||
key.setValue(score);
|
||||
ClassEntity classEntity = this.baseMapper.selectById(classTaskAndQuesReply.getClassId());
|
||||
if ("1".equals(classEntity.getState())||"3".equals(classEntity.getState())){
|
||||
String score = params.get("score").toString();
|
||||
String scoreInfo = "";
|
||||
Map<String,Object> userIdAndScore = new HashMap<>();
|
||||
if (StringUtils.isNotEmpty(classTaskAndQuesReply.getScoreInfo())){
|
||||
boolean flag = true;
|
||||
userIdAndScore = JSON.parseObject(classTaskAndQuesReply.getScoreInfo());
|
||||
for (Map.Entry<String,Object> key : userIdAndScore.entrySet()) {
|
||||
if (key.equals(ShiroUtils.getUId().toString())){
|
||||
flag = false;
|
||||
key.setValue(score);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
if (flag) {
|
||||
userIdAndScore.put(""+ShiroUtils.getUId(),score);
|
||||
}
|
||||
}else {
|
||||
userIdAndScore.put(""+ShiroUtils.getUId(),score);
|
||||
}
|
||||
scoreInfo = JSON.toJSONString(userIdAndScore);
|
||||
classTaskAndQuesReply.setScoreInfo(scoreInfo);
|
||||
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);
|
||||
}else {
|
||||
userIdAndScore.put(""+ShiroUtils.getUId(),score);
|
||||
return R.error("此班级状态不能评分");
|
||||
}
|
||||
scoreInfo = JSON.toJSONString(userIdAndScore);
|
||||
classTaskAndQuesReply.setScoreInfo(scoreInfo);
|
||||
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);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user