|
|
|
@ -58,20 +58,14 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
String singleIds = stuTheoryExam.getSingleIds();
|
|
|
|
|
String multipleIds = stuTheoryExam.getMultipleIds();
|
|
|
|
|
String judgeIds = stuTheoryExam.getJudgeIds();
|
|
|
|
|
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(","));
|
|
|
|
|
List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(","));
|
|
|
|
|
List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(","));
|
|
|
|
|
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", "));
|
|
|
|
|
List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", "));
|
|
|
|
|
List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", "));
|
|
|
|
|
List<String> idlist=new ArrayList<>();
|
|
|
|
|
idlist.addAll(singleIdList);
|
|
|
|
|
idlist.addAll(multipleIdList);
|
|
|
|
|
idlist.addAll(judgeIdList);
|
|
|
|
|
List<SysObjectiveQuestion> returnQuestionList = new ArrayList();
|
|
|
|
|
for (int i = 0; i < idlist.size(); i++) {
|
|
|
|
|
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(idlist.get(i));
|
|
|
|
|
returnQuestionList.add(objectiveQuestion);
|
|
|
|
|
}
|
|
|
|
|
// List<SysObjectiveQuestion> returnQuestionList = objectiveQuestionMapper.selectBatchByIdList(idlist);
|
|
|
|
|
|
|
|
|
|
List<SysObjectiveQuestion> returnQuestionList = objectiveQuestionMapper.selectBatchByIdList(idlist);
|
|
|
|
|
return returnQuestionList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -122,9 +116,11 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
Integer examCount = record.getExamCount();
|
|
|
|
|
BigDecimal averageScore = record.getAverageScore();
|
|
|
|
|
BigDecimal multiply = averageScore.multiply(BigDecimal.valueOf(examCount));
|
|
|
|
|
multiply.add(score).divide(BigDecimal.valueOf(examCount).add(BigDecimal.valueOf(1))).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
BigDecimal newAvg = multiply.add(score).divide(BigDecimal.valueOf(examCount).add(BigDecimal.valueOf(1)), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
record.setAverageScore(newAvg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
theoryRecordMapper.updateByPrimaryKey(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -202,7 +198,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
} else {
|
|
|
|
|
StuErrorWithBLOBs stuError = stuErrors.get(0);
|
|
|
|
|
if (stuError.getSingleIds()!=null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(","));
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getSingleIds().substring(1, stuError.getSingleIds().length() - 1).split(", "));
|
|
|
|
|
List<String> singleErrorIds = theoryTestDto.getSingleErrorIds();
|
|
|
|
|
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
@ -214,7 +210,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
stuError.setSingleIds(String.valueOf(theoryTestDto.getSingleErrorIds()));
|
|
|
|
|
}
|
|
|
|
|
if (stuError.getMultipleIds()!=null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(","));
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getMultipleIds().substring(1, stuError.getMultipleIds().length() - 1).split(", "));
|
|
|
|
|
List<String> multipleErrorIds = theoryTestDto.getMultipleErrorIds();
|
|
|
|
|
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
@ -226,7 +222,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
stuError.setMultipleIds(String.valueOf(theoryTestDto.getMultipleErrorIds()));
|
|
|
|
|
}
|
|
|
|
|
if (stuError.getJudgeIds()!=null) {
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getJudgeIds().substring(1, stuError.getJudgeIds().length() - 1).split(","));
|
|
|
|
|
List<String> stringList = Arrays.asList(stuError.getJudgeIds().substring(1, stuError.getJudgeIds().length() - 1).split(", "));
|
|
|
|
|
List<String> judgeErrorIds = theoryTestDto.getJudgeErrorIds();
|
|
|
|
|
List<String> combinedList = new ArrayList<>(stringList);
|
|
|
|
|
combinedList.addAll(judgeErrorIds);
|
|
|
|
@ -254,7 +250,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
StuErrorWithBLOBs stuError = stuErrors.get(0);
|
|
|
|
|
String singleIds = stuError.getSingleIds();
|
|
|
|
|
if (!singleIds.isEmpty()) {
|
|
|
|
|
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(","));
|
|
|
|
|
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", "));
|
|
|
|
|
for (int i = 0; i < singleIdList.size(); i++) {
|
|
|
|
|
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(singleIdList.get(i));
|
|
|
|
|
objectiveQuestionList.add(objectiveQuestion);
|
|
|
|
@ -262,7 +258,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
String multipleIds = stuError.getMultipleIds();
|
|
|
|
|
if (!multipleIds.isEmpty()) {
|
|
|
|
|
List<String> stringList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(","));
|
|
|
|
|
List<String> stringList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", "));
|
|
|
|
|
for (int i = 0; i < stringList.size(); i++) {
|
|
|
|
|
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(stringList.get(i));
|
|
|
|
|
objectiveQuestionList.add(objectiveQuestion);
|
|
|
|
@ -270,7 +266,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
String judgeIds = stuError.getJudgeIds();
|
|
|
|
|
if (!judgeIds.isEmpty()) {
|
|
|
|
|
List<String> stringList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(","));
|
|
|
|
|
List<String> stringList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", "));
|
|
|
|
|
for (int i = 0; i < stringList.size(); i++) {
|
|
|
|
|
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(stringList.get(i));
|
|
|
|
|
objectiveQuestionList.add(objectiveQuestion);
|
|
|
|
@ -290,7 +286,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
StuErrorWithBLOBs error = stuErrors.get(0);
|
|
|
|
|
if (Constant.OBJECTIVE_TYPE_SINGLE.equals(type)) {
|
|
|
|
|
List<String> stringList = Arrays.asList(error.getSingleIds().substring(1, stuErrors.get(0).getSingleIds().length() - 1).split(","));
|
|
|
|
|
List<String> stringList = Arrays.asList(error.getSingleIds().substring(1, stuErrors.get(0).getSingleIds().length() - 1).split(", "));
|
|
|
|
|
Set<String> set = new LinkedHashSet<>(stringList);
|
|
|
|
|
set.remove(objectiveQuestionId);
|
|
|
|
|
if(set.isEmpty()){
|
|
|
|
@ -301,7 +297,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Constant.OBJECTIVE_TYPE_Many.equals(type)) {
|
|
|
|
|
Set<String> set = new LinkedHashSet<>(Arrays.asList(error.getMultipleIds().substring(1, error.getMultipleIds().length() - 1).split(",")));
|
|
|
|
|
Set<String> set = new LinkedHashSet<>(Arrays.asList(error.getMultipleIds().substring(1, error.getMultipleIds().length() - 1).split(", ")));
|
|
|
|
|
set.remove(objectiveQuestionId);
|
|
|
|
|
if(set.isEmpty()){
|
|
|
|
|
error.setMultipleIds(null);
|
|
|
|
@ -311,7 +307,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(Constant.OBJECTIVE_TYPE_JUDGE.equals(type)){
|
|
|
|
|
Set<String> set = new LinkedHashSet<>(Arrays.asList(error.getJudgeIds().substring(1, error.getJudgeIds().length() - 1).split(",")));
|
|
|
|
|
Set<String> set = new LinkedHashSet<>(Arrays.asList(error.getJudgeIds().substring(1, error.getJudgeIds().length() - 1).split(", ")));
|
|
|
|
|
set.remove(objectiveQuestionId);
|
|
|
|
|
if(set.isEmpty()){
|
|
|
|
|
error.setJudgeIds(null);
|
|
|
|
@ -329,6 +325,7 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
PageHelper.startPage(index, size);
|
|
|
|
|
StuTheoryExamExample example = new StuTheoryExamExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
|
|
|
|
example.setOrderByClause("exam_time desc");
|
|
|
|
|
List<StuTheoryExam> stuTheoryExams = theoryExamMapper.selectByExample(example);
|
|
|
|
|
PageInfo<StuTheoryExam> pageInfo = new PageInfo<>(stuTheoryExams);
|
|
|
|
|
return pageInfo;
|
|
|
|
@ -339,31 +336,71 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
StuTheoryExamWithBLOBs theoryExam = theoryExamMapper.selectByPrimaryKey(theoryExamId);
|
|
|
|
|
String singleIds = theoryExam.getSingleIds();
|
|
|
|
|
ArrayList<String> idsList = new ArrayList<>();
|
|
|
|
|
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(","));
|
|
|
|
|
List<String> singleIdList = Arrays.asList(singleIds.substring(1, singleIds.length() - 1).split(", "));
|
|
|
|
|
String multipleIds = theoryExam.getMultipleIds();
|
|
|
|
|
List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(","));
|
|
|
|
|
List<String> multipleIdList = Arrays.asList(multipleIds.substring(1, multipleIds.length() - 1).split(", "));
|
|
|
|
|
String judgeIds = theoryExam.getJudgeIds();
|
|
|
|
|
List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(","));
|
|
|
|
|
List<String> judgeIdList = Arrays.asList(judgeIds.substring(1, judgeIds.length() - 1).split(", "));
|
|
|
|
|
idsList.addAll(singleIdList);
|
|
|
|
|
idsList.addAll(multipleIdList);
|
|
|
|
|
idsList.addAll(judgeIdList);
|
|
|
|
|
ArrayList<String> answerList = new ArrayList<>();
|
|
|
|
|
List<String> singleStuAnswer =Arrays.asList(theoryExam.getSingleStuAnswer().substring(1, theoryExam.getSingleStuAnswer().length() - 1).split(","));
|
|
|
|
|
List<String> multipleStuAnswer = Arrays.asList(theoryExam.getMultipleStuAnswer().substring(1, theoryExam.getMultipleStuAnswer().length() - 1).split(","));
|
|
|
|
|
List<String> judgeStuAnswer = Arrays.asList(theoryExam.getJudgeStuAnswer().substring(1, theoryExam.getJudgeStuAnswer().length() - 1).split(","));
|
|
|
|
|
answerList.addAll(singleStuAnswer);
|
|
|
|
|
answerList.addAll(multipleStuAnswer);
|
|
|
|
|
answerList.addAll(judgeStuAnswer);
|
|
|
|
|
if(theoryExam.getSingleStuAnswer()!=null){
|
|
|
|
|
String[] singleSplit = theoryExam.getSingleStuAnswer().substring(1, theoryExam.getSingleStuAnswer().length() - 1).split(",");
|
|
|
|
|
for (String str : singleSplit) {
|
|
|
|
|
if (str.equals("") || str.equals(" ")) {
|
|
|
|
|
answerList.add(null);
|
|
|
|
|
} else {
|
|
|
|
|
answerList.add(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(theoryExam.getMultipleStuAnswer()!=null){
|
|
|
|
|
String[] multipleSplit = theoryExam.getMultipleStuAnswer().substring(1, theoryExam.getMultipleStuAnswer().length() - 1).split(",");
|
|
|
|
|
for (String str : multipleSplit) {
|
|
|
|
|
if (str.equals("") || str.equals(" ")) {
|
|
|
|
|
answerList.add(null);
|
|
|
|
|
} else {
|
|
|
|
|
String strSort = sortString(str);
|
|
|
|
|
answerList.add(strSort);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(theoryExam.getJudgeStuAnswer()!=null){
|
|
|
|
|
String[] judgeSplit = theoryExam.getJudgeStuAnswer().substring(1, theoryExam.getJudgeStuAnswer().length() - 1).split(",");
|
|
|
|
|
for (String str : judgeSplit) {
|
|
|
|
|
if (str.equals("") || str.equals(" ")) {
|
|
|
|
|
answerList.add(null);
|
|
|
|
|
} else {
|
|
|
|
|
answerList.add(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<StuTheoryExamDetailDto> detailDtos=new ArrayList<>();
|
|
|
|
|
if(answerList.size()==0){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < answerList.size(); i++) {
|
|
|
|
|
if(answerList.get(i)==null){
|
|
|
|
|
answerList.set(i,"空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
for (Integer i = (index-1)*size; i < (index-1)*size+size; i++) {
|
|
|
|
|
StuTheoryExamDetailDto detailDto = new StuTheoryExamDetailDto();
|
|
|
|
|
String objectiveQuestionId = idsList.get(i);
|
|
|
|
|
String stuAnswer = answerList.get(i);
|
|
|
|
|
String stuAnswer = answerList.get(i).trim();
|
|
|
|
|
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(objectiveQuestionId);
|
|
|
|
|
BigDecimal score = objectiveQuestion.getScore();
|
|
|
|
|
String content = objectiveQuestion.getContent();
|
|
|
|
|
String answer = objectiveQuestion.getAnswer();
|
|
|
|
|
if(answer.equals(stuAnswer)){
|
|
|
|
|
if(stuAnswer.equals("true")){
|
|
|
|
|
stuAnswer="对";
|
|
|
|
|
}
|
|
|
|
|
if(stuAnswer.equals("false")){
|
|
|
|
|
stuAnswer="错";
|
|
|
|
|
}
|
|
|
|
|
if(answer.replaceAll(",","").equals(stuAnswer)){
|
|
|
|
|
detailDto.setScore(String.valueOf(score));
|
|
|
|
|
detailDto.setStatus("正确");
|
|
|
|
|
}else {
|
|
|
|
@ -372,11 +409,9 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
detailDto.setContent(content);
|
|
|
|
|
detailDto.setMychoice(stuAnswer);
|
|
|
|
|
detailDto.setAnswer(answer);
|
|
|
|
|
detailDto.setAnswer(answer.replaceAll(",",""));
|
|
|
|
|
detailDtos.add(detailDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return detailDtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -403,5 +438,12 @@ public class TheoryTestServiceImpl implements ITheoryTestService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//字母排序
|
|
|
|
|
private static String sortString(String str) {
|
|
|
|
|
char[] charArray = str.toCharArray();
|
|
|
|
|
Arrays.sort(charArray);
|
|
|
|
|
return new String(charArray);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|