|
|
@@ -46,8 +46,8 @@ public class QuizServiceImpl implements QuizService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Quiz CreateQuiz(String name, Integer uid, SlideState quizTime,
|
|
|
- Integer slideId, List<String> questions){
|
|
|
+ public Quiz CreateQuiz(String name, Long uid, SlideState quizTime,
|
|
|
+ Long slideId, List<String> questions){
|
|
|
User teacher =new User();
|
|
|
teacher.setId(uid);
|
|
|
Slide slide = slideDAO.findSlideById(slideId);
|
|
|
@@ -92,11 +92,11 @@ public class QuizServiceImpl implements QuizService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Quiz> getAllBasicQuizByUser(Pageable pageable, QuizState state, Integer uid) {
|
|
|
+ public Page<Quiz> getAllBasicQuizByUser(Pageable pageable, QuizState state, Long uid) {
|
|
|
User user=userDAO.findUserById(uid);
|
|
|
//todo: 这里写的太狗屎了,可以用重写sql或者用实例查询
|
|
|
if(user.getType().equals(UserType.STUDENT)){
|
|
|
- final Set<Integer> courseIdsByStudentId = chooseDAO.findCourseIdsByStudentId(uid);
|
|
|
+ final Set<Long> courseIdsByStudentId = chooseDAO.findCourseIdsByStudentId(uid);
|
|
|
final Set<Course> collect = courseIdsByStudentId.stream().map(i -> {
|
|
|
Course c = new Course();
|
|
|
c.setId(i);
|
|
|
@@ -125,7 +125,7 @@ public class QuizServiceImpl implements QuizService {
|
|
|
if(quiz.getState()!=QuizState.CLOSED){throw new RuntimeException("测试未关闭,无法得到测试结果");}
|
|
|
List<QuizResultVO> retList=new ArrayList<>();
|
|
|
final List<StudentScore> studentScoreList = quiz.getStudentScore();
|
|
|
- Map<Integer,List<QuizStudentAnswer>> IdQuizStudentAnswerMap=new HashMap<>();
|
|
|
+ Map<Long,List<QuizStudentAnswer>> IdQuizStudentAnswerMap=new HashMap<>();
|
|
|
for(QuizStudentAnswer qsa:quizStudentAnswerDAO.findAllByQuiz(quiz)){
|
|
|
IdQuizStudentAnswerMap.computeIfAbsent(qsa.getStudent().getId(), k -> new ArrayList<>());
|
|
|
IdQuizStudentAnswerMap.get(qsa.getStudent().getId()).add(qsa);
|
|
|
@@ -146,7 +146,7 @@ public class QuizServiceImpl implements QuizService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Integer upStudentAnswer(Long quizId, Integer uid, List<QuestionStudentAnswerDTO> answers) {
|
|
|
+ public Integer upStudentAnswer(Long quizId, Long uid, List<QuestionStudentAnswerDTO> answers) {
|
|
|
Assert.notNull(quizId,"错误的测试!");
|
|
|
final Quiz quiz = quizDAO.findQuizById(quizId);
|
|
|
if(quiz.getState()!=QuizState.ONGOING){throw HelperException.of(ExceptionType.FORBIDDEN,"不能提交尚未开始的作业!");}
|
|
|
@@ -184,7 +184,7 @@ public class QuizServiceImpl implements QuizService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Quiz> getAllBasicQuizBySlide(Integer slideId, Pageable pageable, QuizState state, Integer uid) {
|
|
|
+ public Page<Quiz> getAllBasicQuizBySlide(Long slideId, Pageable pageable, QuizState state, Long uid) {
|
|
|
Assert.notNull(slideId,"错误的幻灯片!");
|
|
|
Slide slide=new Slide();
|
|
|
slide.setId(slideId);
|
|
|
@@ -214,7 +214,7 @@ public class QuizServiceImpl implements QuizService {
|
|
|
if(quiz.getState().equals(QuizState.CLOSED)){return QuizState.CLOSED;}
|
|
|
quiz.setState(QuizState.CLOSED);
|
|
|
Set<QuizStudentAnswer> QuizAnswers = quizStudentAnswerDAO.findAllByQuiz(quiz);
|
|
|
- final Set<Integer> studentIds = chooseDAO.findStudentIdsByCourseId(slide.getCourseId());
|
|
|
+ final Set<Long> studentIds = chooseDAO.findStudentIdsByCourseId(slide.getCourseId());
|
|
|
Student2_QuestionId2Answer triadMap = new Student2_QuestionId2Answer(studentIds, quiz.getQuestions().size());
|
|
|
//将已经作答的学生答案加入
|
|
|
for (QuizStudentAnswer answers : QuizAnswers) {
|
|
|
@@ -233,16 +233,16 @@ public class QuizServiceImpl implements QuizService {
|
|
|
return quiz.getState();
|
|
|
}
|
|
|
@Override
|
|
|
- public QuizState checkQuizState(Long quizId, Integer slideId){
|
|
|
+ public QuizState checkQuizState(Long quizId, Long slideId){
|
|
|
Quiz quiz=quizDAO.findQuizById(quizId);
|
|
|
Slide slide=slideDAO.findSlideById(slideId);
|
|
|
return checkQuizState(quiz,slide);
|
|
|
}
|
|
|
private class Student2_QuestionId2Answer{
|
|
|
- Map<Integer,Map<String,QuizStudentAnswer>> Student2_QuestionId2Answer;
|
|
|
- Student2_QuestionId2Answer(Set<Integer> studentIds, Integer quizQuestionSize) {
|
|
|
+ Map<Long,Map<String,QuizStudentAnswer>> Student2_QuestionId2Answer;
|
|
|
+ Student2_QuestionId2Answer(Set<Long> studentIds, Integer quizQuestionSize) {
|
|
|
Student2_QuestionId2Answer =new LinkedHashMap<>(studentIds.size());
|
|
|
- for(Integer studentId:studentIds){
|
|
|
+ for(Long studentId:studentIds){
|
|
|
Map<String,QuizStudentAnswer> QuestionId2Answer= new LinkedHashMap<>(quizQuestionSize);
|
|
|
Student2_QuestionId2Answer.put(studentId,QuestionId2Answer);
|
|
|
}
|
|
|
@@ -291,7 +291,7 @@ public class QuizServiceImpl implements QuizService {
|
|
|
}
|
|
|
List<QuizStudentAnswer> getAll(){
|
|
|
List<QuizStudentAnswer> list=new ArrayList<>();
|
|
|
- for(Integer sid:Student2_QuestionId2Answer.keySet()){
|
|
|
+ for(Long sid:Student2_QuestionId2Answer.keySet()){
|
|
|
list.addAll(Student2_QuestionId2Answer.get(sid).values());
|
|
|
}
|
|
|
return list;
|
|
|
@@ -305,7 +305,7 @@ public class QuizServiceImpl implements QuizService {
|
|
|
return new QuizVO(quizById,questionVOS);
|
|
|
}
|
|
|
@Override
|
|
|
- public QuizVO combineQuizWithAnswer(Long quizId, Integer uid,UserType userType){
|
|
|
+ public QuizVO combineQuizWithAnswer(Long quizId, Long uid,UserType userType){
|
|
|
Assert.notNull(quizId,"错误的测试!");
|
|
|
final Quiz quizById = quizDAO.findQuizById(quizId);
|
|
|
User student =new User();
|