答题情况统计调整、考试报名修改

main
liuyiliang 2 months ago
parent e05a324fd3
commit ee359d7f25
  1. 29
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExOpenUserService.java
  2. 33
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExOpenUserServiceImpl.java
  3. 2
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamService.java
  4. 62
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamServiceImpl.java
  5. 4
      ccic-exam/src/main/java/com/ccic/safeliab/support/BaseService.java
  6. 34
      ccic-exam/src/main/java/com/ccic/safeliab/support/BaseServiceImpl.java
  7. 8
      ccic-exam/src/main/java/com/ccic/safeliab/web/ExamController.java
  8. 77
      ccic-exam/src/main/resources/mappers/ExamScheduleMapper.xml

@ -0,0 +1,29 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ccic.safeliab.service;
import com.ccic.safeliab.entity.ExOpenUser;
import com.ccic.safeliab.support.BaseService;
/**
* 服务类
*
* @author edwong
*/
public interface ExOpenUserService extends BaseService<ExOpenUser> {
}

@ -0,0 +1,33 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ccic.safeliab.service;
import com.ccic.safeliab.dao.OpenUserMapper;
import com.ccic.safeliab.entity.ExOpenUser;
import com.ccic.safeliab.support.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author edwong
*/
@Service
public class ExOpenUserServiceImpl extends BaseServiceImpl<OpenUserMapper, ExOpenUser> implements ExOpenUserService {
}

@ -29,6 +29,6 @@ public interface ExamService {
R saveUserAnswers(UserAnswersVO userAnswersVO);
boolean checkExamCaptcha(Long examId, String captcha);
R examRegist(Long examId, String captcha, String name, String phoneNumber);
}

@ -16,14 +16,8 @@
package com.ccic.safeliab.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ccic.safeliab.dao.AnswersMapper;
import com.ccic.safeliab.dao.ExamInfoMapper;
import com.ccic.safeliab.dao.ExamScouresMapper;
import com.ccic.safeliab.dao.QuestionMapper;
import com.ccic.safeliab.entity.ExAnswers;
import com.ccic.safeliab.entity.ExExamInfo;
import com.ccic.safeliab.entity.ExExamScoures;
import com.ccic.safeliab.entity.ExamPapers;
import com.ccic.safeliab.dao.*;
import com.ccic.safeliab.entity.*;
import com.ccic.safeliab.vo.ExamPageDataVO;
import com.ccic.safeliab.vo.PageQuestionCategoriesVO;
import com.ccic.safeliab.vo.UserAnswersVO;
@ -33,6 +27,8 @@ import org.springframework.stereotype.Service;
import java.util.List;
import com.ccic.safeliab.util.R;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
/**
@ -62,6 +58,9 @@ public class ExamServiceImpl implements ExamService {
@Autowired
private ExamPaperService paperService;
@Autowired
private ExOpenUserService exOpenUserService;
@Override
public R findExamPageData(Long examId) {
QueryWrapper<ExExamInfo> examScouresWrapper = new QueryWrapper<>();
@ -91,7 +90,11 @@ public class ExamServiceImpl implements ExamService {
examPageDataVO.setPaperId(examInfo.getPaperId());
examPageDataVO.setPaperName(examPapers.getPaperName());
examPageDataVO.setTotalScore(examPapers.getTotalScore());
examPageDataVO.setExamDuration(examPapers.getExamDuration());
if (examPapers.getDurationType() == 1) {
examPageDataVO.setExamDuration(examPapers.getExamDuration() * 60 );
} else {
examPageDataVO.setExamDuration(examPapers.getExamDuration() * 60 * 60 );
}
examPageDataVO.setPaperContent(examPapers.getPaperContent());
examPageDataVO.setQuestionCount(examPapers.getQuestionCount());
examPageDataVO.setQuestionCategoriesList(pageQuestionCategoriesList);
@ -100,7 +103,6 @@ public class ExamServiceImpl implements ExamService {
@Override
public R saveUserAnswers(UserAnswersVO userAnswersVO) {
userAnswersVO.setUserId(Long.parseLong("1"));
QueryWrapper<ExAnswers> answersQueryWrapper = new QueryWrapper<>();
answersQueryWrapper.lambda().eq(ExAnswers::getUserId, userAnswersVO.getUserId());
answersQueryWrapper.lambda().eq(ExAnswers::getExamId, userAnswersVO.getExamId());
@ -120,7 +122,7 @@ public class ExamServiceImpl implements ExamService {
exAnswers.setPaperId(userAnswersVO.getPaperId());
}
}
answersService.saveBatch(answersList);
answersService.saveBatchByExam(answersList, userAnswersVO.getUserId());
QueryWrapper<ExExamScoures> examScouresQueryWrapper = new QueryWrapper<>();
examScouresQueryWrapper.lambda().eq(ExExamScoures::getUserId, userAnswersVO.getUserId());
examScouresQueryWrapper.lambda().eq(ExExamScoures::getExamId, userAnswersVO.getExamId());
@ -134,21 +136,47 @@ public class ExamServiceImpl implements ExamService {
examScoures.setPaperId(userAnswersVO.getPaperId());
examScoures.setExamId(userAnswersVO.getExamId());
examScoures.setTotalScore(totalScore);
examScoures.setExamTimeSpent(userAnswersVO.getExamTimeSpent());
examScouresService.save(examScoures);
int examTimeSpentInMinutes = (int) Math.ceil((double) userAnswersVO.getExamTimeSpent() / 60);
examScoures.setExamTimeSpent(examTimeSpentInMinutes);
examScouresService.saveByExam(examScoures, userAnswersVO.getUserId());
Integer leadValue = examScouresMapper.getLeadValue(userAnswersVO.getExamId(), userAnswersVO.getPaperId(), totalScore);
return R.ok().data(leadValue);
}
@Override
public boolean checkExamCaptcha(Long examId, String captcha) {
public R examRegist(Long examId, String captcha, String name, String phoneNumber) {
ExExamInfo examInfo = examInfoMapper.selectById(examId);
if (examInfo != null) {
ModelMap map = new ModelMap();
if (examInfo != null && examInfo.getPublishStatus() == 1) {
if (captcha.equals(examInfo.getCaptcha())) {
return true;
QueryWrapper<ExOpenUser> qw = new QueryWrapper<>();
qw.lambda().eq(ExOpenUser::getPhoneNumber, phoneNumber);
qw.lambda().eq(ExOpenUser::getNickname, name);
ExOpenUser openUser = exOpenUserService.getOne(qw);
Long openUserId = null;
if (openUser == null) {
ExOpenUser newOpenUser = new ExOpenUser();
newOpenUser.setPhoneNumber(phoneNumber);
newOpenUser.setNickname(name);
exOpenUserService.save(newOpenUser);
openUserId = newOpenUser.getId();
} else {
openUserId = openUser.getId();
}
map.put("status", 200);
map.put("msg", "进入考试");
map.put("examOpenUserId", openUserId.toString());
return R.ok().data(map);
} else {
map.put("status", 999);
map.put("msg", "考试码错误");
return R.ok().data(map);
}
}
return false;
map.put("status", 999);
map.put("msg", "获取考试信息失败");
return R.ok().data(map);
}
}

@ -8,4 +8,8 @@ public interface BaseService<T> extends IService<T> {
boolean deleteLogic(List<Long> ids);
boolean saveBatch(List<T> list);
boolean saveByExam(T entity, Long examUserId);
boolean saveBatchByExam(List<T> list, Long examUserId);
}

@ -77,5 +77,39 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
return super.saveBatch(list);
}
public boolean saveByExam(T entity, Long examUserId) {
entity.setCreatedBy(examUserId);
entity.setUpdatedBy(examUserId);
Date now = new Date();
entity.setCreatedAt(now);
entity.setUpdatedAt(now);
if (entity.getStatus() == null) {
entity.setStatus(1);
}
entity.setIsDeleted(0);
return super.save(entity);
}
public boolean saveBatchByExam(List<T> list, Long examUserId) {
if (list == null || list.isEmpty()) {
return false;
}
Date now = new Date();
for (T entity : list) {
if (entity != null) {
entity.setCreatedBy(examUserId);
entity.setUpdatedBy(examUserId);
entity.setCreatedAt(now);
entity.setUpdatedAt(now);
if (entity.getStatus() == null) {
entity.setStatus(1);
}
entity.setIsDeleted(0);
}
}
return super.saveBatch(list);
}
}

@ -63,14 +63,14 @@ public class ExamController {
}
/**
* 验证考试码
* 考试报名
* @param examId
* @param captcha
* @return
*/
@GetMapping("/checkExamCaptcha")
public R checkExamCaptcha(Long examId, String captcha) {
return R.ok().data(examService.checkExamCaptcha(examId, captcha));
@GetMapping("/examRegist")
public R examRegist(Long examId, String captcha, String name, String phoneNumber) {
return examService.examRegist(examId, captcha, name, phoneNumber);
}

@ -66,58 +66,51 @@
</select>
<select id="getExamParticipation" resultType="java.util.Map">
SELECT
openuser.id as key,
openuser.nickname as name,
openuser.phone_number as phoneNumber ,
sc.total_score as score,
STRING_AGG ( questions.question_number, '、' ORDER BY TO_NUMBER(questions.question_number) ASC) as wrongQuestionIds
usr.ID AS KEY,
usr.nickname AS name,
usr.phone_number AS phoneNumber,
sco.total_score AS score,
STRING_AGG (pq.question_number, '、' ORDER BY TO_NUMBER(pq.question_number) ASC) AS wrongQuestionIds
FROM
ex_exam_info info
LEFT JOIN ex_exam_scores sc ON info.paper_id = sc.paper_id
AND info.ID = sc.exam_id
LEFT JOIN ex_answers ans ON info.paper_id = ans.paper_id
AND sc.user_id = ans.user_id
AND ans.exam_id = info.ID
AND ans.is_correct = 0
LEFT JOIN ex_open_user openuser ON openuser.ID = sc.user_id
LEFT JOIN ex_paper_questions questions ON questions.question_id = ans.question_id
AND info.paper_id = ans.paper_id
ex_exam_info info
LEFT JOIN ex_exam_papers paper ON info.paper_id = paper.id and paper.is_deleted = 0
LEFT JOIN ex_paper_questions pq ON paper.id = pq.paper_id and pq.is_deleted = 0
LEFT JOIN ex_answers ans ON ans.question_id = pq.question_id and ans.is_deleted = 0
LEFT JOIN ex_open_user usr ON usr.id = ans.user_id and usr.is_deleted = 0
LEFT JOIN ex_exam_scores sco ON usr.id = sco.user_id and sco.is_deleted = 0
WHERE
info.is_deleted = 0
AND info.ID = #{exam_id}
info.ID = #{exam_id}
and ans.is_correct = 0
and info.is_deleted = 0
GROUP BY
openuser.id,
openuser.nickname,
openuser.phone_number,
sc.total_score
usr.ID,
usr.nickname,
usr.phone_number,
sco.total_score
ORDER BY
openuser.nickname,
openuser.phone_number
usr.nickname,
usr.phone_number
</select>
<select id="getExamAnswerDetails" resultType="java.util.Map">
SELECT
questions.question_number as key,
questions.question_number as questionNumber,
SUM ( CASE WHEN ans.is_correct = 0 THEN 1 ELSE 0 END ) AS wrongPeopleCount,
STRING (
ROUND( SUM ( CASE WHEN ans.is_correct = 0 THEN 1 ELSE 0 END ) / COUNT ( 0 ) * 100, 0 )
) AS wrongPeopleRatio
pq.question_number AS key,
pq.question_number AS questionNumber,
SUM(CASE WHEN ans.is_correct = 0 THEN 1 ELSE 0 END) AS wrongPeopleCount,
STRING (
ROUND(SUM(CASE WHEN ans.is_correct = 0 THEN 1 ELSE 0 END) / COUNT(0) * 100, 0)) AS wrongPeopleRatio
FROM
ex_exam_info info
LEFT JOIN ex_exam_scores sc ON info.paper_id = sc.paper_id
AND info.ID = sc.exam_id
LEFT JOIN ex_answers ans ON info.paper_id = ans.paper_id
AND sc.user_id = ans.user_id
AND info.ID = ans.exam_id
LEFT JOIN ex_open_user openuser ON openuser.ID = ans.user_id
LEFT JOIN ex_paper_questions questions ON questions.question_id = ans.question_id
AND info.paper_id = ans.paper_id
ex_paper_questions pq
LEFT JOIN ex_exam_papers paper ON pq.paper_id = paper.ID
AND paper.is_deleted = 0
LEFT JOIN ex_exam_info info ON paper.ID = info.paper_id
AND info.is_deleted = 0
LEFT JOIN ex_answers ans ON ans.question_id = pq.question_id and ans.is_deleted = 0
WHERE
info.is_deleted = 0
AND info.ID = #{exam_id}
info.ID = #{exam_id}
AND pq.is_deleted = 0
GROUP BY
questions.question_number
pq.question_number
ORDER BY
questions.question_number
pq.question_number
</select>
</mapper>
Loading…
Cancel
Save