考试相关
This commit is contained in:
@@ -5,6 +5,7 @@ import com.peanut.common.excel.ExcelUtil;
|
|||||||
import com.peanut.common.utils.R;
|
import com.peanut.common.utils.R;
|
||||||
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 com.peanut.modules.common.entity.ClassExamUser;
|
||||||
import com.peanut.modules.common.service.ClassExamOptionService;
|
import com.peanut.modules.common.service.ClassExamOptionService;
|
||||||
import com.peanut.modules.common.service.ClassExamService;
|
import com.peanut.modules.common.service.ClassExamService;
|
||||||
import com.peanut.modules.common.service.ClassExamSubjectService;
|
import com.peanut.modules.common.service.ClassExamSubjectService;
|
||||||
@@ -172,6 +173,13 @@ public class ClassExamController {
|
|||||||
return classExamService.generateExamPaper(params);
|
return classExamService.generateExamPaper(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//考试中的试卷
|
||||||
|
@RequestMapping("/examingPaper")
|
||||||
|
public R examingPaper(){
|
||||||
|
ClassExamUser classExamUser = classExamService.examingPaper();
|
||||||
|
return R.ok().put("classExamUser",classExamUser);
|
||||||
|
}
|
||||||
|
|
||||||
//提交选项
|
//提交选项
|
||||||
@RequestMapping("/submitOption")
|
@RequestMapping("/submitOption")
|
||||||
public R submitOption(@RequestBody Map<String,Object> params){
|
public R submitOption(@RequestBody Map<String,Object> params){
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.peanut.common.utils.R;
|
|||||||
import com.peanut.modules.common.entity.ClassExam;
|
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 com.peanut.modules.common.entity.ClassExamUser;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface ClassExamService extends IService<ClassExam> {
|
public interface ClassExamService extends IService<ClassExam> {
|
||||||
@@ -30,6 +32,8 @@ public interface ClassExamService extends IService<ClassExam> {
|
|||||||
|
|
||||||
R generateExamPaper(Map<String,Object> params);
|
R generateExamPaper(Map<String,Object> params);
|
||||||
|
|
||||||
|
ClassExamUser examingPaper();
|
||||||
|
|
||||||
void submitOption(Map<String,Object> params);
|
void submitOption(Map<String,Object> params);
|
||||||
|
|
||||||
Object submitExamPaper(Map<String,Object> params);
|
Object submitExamPaper(Map<String,Object> params);
|
||||||
|
|||||||
@@ -1093,27 +1093,31 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
|||||||
Map<String,Object> map = getUserScore(params);
|
Map<String,Object> map = getUserScore(params);
|
||||||
map.put("user",myUserDao.selectById(classUser.getUserId()));
|
map.put("user",myUserDao.selectById(classUser.getUserId()));
|
||||||
if (classModel.getIsExam()==1){
|
if (classModel.getIsExam()==1){
|
||||||
List<ClassExamUser> classExamUsers = classExamUserDao.selectList(new LambdaQueryWrapper<ClassExamUser>()
|
List<Map<String,Object>> classExamUsers = classExamUserDao.selectMaps(new MPJLambdaWrapper<ClassExamUser>()
|
||||||
.eq(ClassExamUser::getUserId,classUser.getUserId())
|
.eq(ClassExamUser::getUserId,classUser.getUserId())
|
||||||
.eq(ClassExamUser::getClassId,classEntity.getId()));
|
.eq(ClassExamUser::getClassId,classEntity.getId())
|
||||||
|
.eq(ClassExamUser::getScoreSuccess,1)
|
||||||
|
.selectAs(ClassExamUser::getId,"id")
|
||||||
|
.selectAs(ClassExamUser::getScore,"score")
|
||||||
|
.orderByAsc(ClassExamUser::getStartTime));
|
||||||
int examScore = 0;
|
int examScore = 0;
|
||||||
for (ClassExamUser classExamUser:classExamUsers){
|
if (classExamUsers.size() > 0){
|
||||||
if (classExamUser.getScore()>examScore){
|
for (Map<String,Object> classExamUser:classExamUsers){
|
||||||
examScore = classExamUser.getScore();
|
if ((int)classExamUser.get("score")>examScore){
|
||||||
|
examScore = (int)classExamUser.get("score");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.put("examScore",examScore);
|
map.put("examScore",examScore);
|
||||||
|
map.put("classExamUsers",classExamUsers);
|
||||||
}
|
}
|
||||||
//处理分数占比
|
//处理分数占比
|
||||||
BigDecimal userScore = new BigDecimal(0);;
|
BigDecimal userScore = new BigDecimal(0);;
|
||||||
double staticScore = 2.5;
|
double staticScore = 2.5;
|
||||||
if(classModel.getIsExam()==1){
|
if(classModel.getIsExam()==1){
|
||||||
BigDecimal examScore = new BigDecimal(map.get("examScore").toString());
|
BigDecimal examScore = new BigDecimal(map.get("examScore").toString());
|
||||||
examScore.divide(new BigDecimal(100));
|
|
||||||
examScore.multiply(new BigDecimal(classModel.getQuestionScore()));
|
|
||||||
examScore = examScore.setScale(2,RoundingMode.HALF_UP);
|
|
||||||
map.put("examScore",examScore);
|
map.put("examScore",examScore);
|
||||||
userScore.add(examScore);
|
userScore = userScore.add(examScore);
|
||||||
}
|
}
|
||||||
if(classModel.getIsQuestion()==1){
|
if(classModel.getIsQuestion()==1){
|
||||||
BigDecimal questionScore = new BigDecimal(map.get("questionScore").toString());
|
BigDecimal questionScore = new BigDecimal(map.get("questionScore").toString());
|
||||||
@@ -1124,11 +1128,11 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
|||||||
wrapper.ne(CourseCatalogueChapterEntity::getQuestions,"");
|
wrapper.ne(CourseCatalogueChapterEntity::getQuestions,"");
|
||||||
int count = courseCatalogueChapterDao.selectCount(wrapper);
|
int count = courseCatalogueChapterDao.selectCount(wrapper);
|
||||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||||
questionScore.divide(totalScore);
|
questionScore = questionScore.divide(totalScore);
|
||||||
questionScore.multiply(new BigDecimal(classModel.getQuestionScore()));
|
questionScore = questionScore.multiply(new BigDecimal(classModel.getQuestionScore()));
|
||||||
questionScore = questionScore.setScale(2,RoundingMode.HALF_UP);
|
questionScore = questionScore.setScale(2,RoundingMode.HALF_UP);
|
||||||
map.put("questionScore",questionScore);
|
map.put("questionScore",questionScore);
|
||||||
userScore.add(questionScore);
|
userScore = userScore.add(questionScore);
|
||||||
}
|
}
|
||||||
if(classModel.getIsTask()==1){
|
if(classModel.getIsTask()==1){
|
||||||
BigDecimal task0Score = new BigDecimal(map.get("task0Score").toString());
|
BigDecimal task0Score = new BigDecimal(map.get("task0Score").toString());
|
||||||
@@ -1137,11 +1141,11 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
|||||||
wrapper.eq(ClassTask::getType,"0");
|
wrapper.eq(ClassTask::getType,"0");
|
||||||
int count = classTaskDao.selectCount(wrapper);
|
int count = classTaskDao.selectCount(wrapper);
|
||||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||||
task0Score.divide(totalScore);
|
task0Score = task0Score.divide(totalScore);
|
||||||
task0Score.multiply(new BigDecimal(classModel.getTaskScore()));
|
task0Score = task0Score.multiply(new BigDecimal(classModel.getTaskScore()));
|
||||||
task0Score = task0Score.setScale(2,RoundingMode.HALF_UP);
|
task0Score = task0Score.setScale(2,RoundingMode.HALF_UP);
|
||||||
map.put("task0Score",task0Score);
|
map.put("task0Score",task0Score);
|
||||||
userScore.add(task0Score);
|
userScore = userScore.add(task0Score);
|
||||||
}
|
}
|
||||||
if(classModel.getIsMedicalcase()==1){
|
if(classModel.getIsMedicalcase()==1){
|
||||||
BigDecimal task1Score = new BigDecimal(map.get("task1Score").toString());
|
BigDecimal task1Score = new BigDecimal(map.get("task1Score").toString());
|
||||||
@@ -1150,11 +1154,11 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
|||||||
wrapper.eq(ClassTask::getType,"1");
|
wrapper.eq(ClassTask::getType,"1");
|
||||||
int count = classTaskDao.selectCount(wrapper);
|
int count = classTaskDao.selectCount(wrapper);
|
||||||
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
BigDecimal totalScore = new BigDecimal(staticScore*count);
|
||||||
task1Score.divide(totalScore);
|
task1Score = task1Score.divide(totalScore);
|
||||||
task1Score.multiply(new BigDecimal(classModel.getMedicalcaseScore()));
|
task1Score = task1Score.multiply(new BigDecimal(classModel.getMedicalcaseScore()));
|
||||||
task1Score = task1Score.setScale(2,RoundingMode.HALF_UP);
|
task1Score = task1Score.setScale(2,RoundingMode.HALF_UP);
|
||||||
map.put("task1Score",task1Score);
|
map.put("task1Score",task1Score);
|
||||||
userScore.add(task1Score);
|
userScore = userScore.add(task1Score);
|
||||||
}
|
}
|
||||||
if(classModel.getIsExperience()==1){
|
if(classModel.getIsExperience()==1){
|
||||||
BigDecimal experienceScore = new BigDecimal(map.get("experienceScore").toString());
|
BigDecimal experienceScore = new BigDecimal(map.get("experienceScore").toString());
|
||||||
@@ -1162,7 +1166,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
|||||||
experienceScore = new BigDecimal(classModel.getExperienceScore());
|
experienceScore = new BigDecimal(classModel.getExperienceScore());
|
||||||
}
|
}
|
||||||
map.put("experienceScore",experienceScore);
|
map.put("experienceScore",experienceScore);
|
||||||
userScore.add(experienceScore);
|
userScore = userScore.add(experienceScore);
|
||||||
}
|
}
|
||||||
map.put("userScore",userScore);
|
map.put("userScore",userScore);
|
||||||
resultList.add(map);
|
resultList.add(map);
|
||||||
|
|||||||
@@ -140,6 +140,11 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R generateExamPaper(Map<String, Object> params) {
|
public R generateExamPaper(Map<String, Object> params) {
|
||||||
|
List list = classExamUserDao.selectList(new LambdaQueryWrapper<ClassExamUser>()
|
||||||
|
.eq(ClassExamUser::getUserId,ShiroUtils.getUId()).eq(ClassExamUser::getScoreSuccess,0));
|
||||||
|
if (list.size() > 0){
|
||||||
|
return R.error("存在正在考试,请结束再试");
|
||||||
|
}
|
||||||
ClassEntity classEntity = classEntityDao.selectById(params.get("classId").toString());
|
ClassEntity classEntity = classEntityDao.selectById(params.get("classId").toString());
|
||||||
MPJLambdaWrapper<ClassCourse> courseWrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<ClassCourse> courseWrapper = new MPJLambdaWrapper<>();
|
||||||
courseWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
courseWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||||
@@ -224,12 +229,19 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
|
|||||||
DelayQueueConfig.COMMON_EXCHANGE,
|
DelayQueueConfig.COMMON_EXCHANGE,
|
||||||
DelayQueueConfig.COMMON_ROUTING_KEY,
|
DelayQueueConfig.COMMON_ROUTING_KEY,
|
||||||
"examSubmit"+","+classExamUser.getId(),
|
"examSubmit"+","+classExamUser.getId(),
|
||||||
messagePostProcessor(60*60*1000)
|
messagePostProcessor(60*60*1000+10000)//10秒延迟
|
||||||
);
|
);
|
||||||
return R.ok().put("examPaper",resultList).put("id",classExamUser.getId()).put("startTime",classExamUser.getStartTime());
|
return R.ok().put("examPaper",resultList).put("id",classExamUser.getId()).put("startTime",classExamUser.getStartTime());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassExamUser examingPaper() {
|
||||||
|
ClassExamUser classExamUser = classExamUserDao.selectOne(new LambdaQueryWrapper<ClassExamUser>()
|
||||||
|
.eq(ClassExamUser::getUserId,ShiroUtils.getUId()).eq(ClassExamUser::getScoreSuccess,0));
|
||||||
|
return classExamUser;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitOption(Map<String, Object> params) {
|
public void submitOption(Map<String, Object> params) {
|
||||||
ClassExamUser classExamUser = classExamUserDao.selectById(params.get("id").toString());
|
ClassExamUser classExamUser = classExamUserDao.selectById(params.get("id").toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user