|
|
@@ -24,9 +24,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author cst
|
|
|
@@ -133,4 +136,52 @@ public class QuizStudentAnswerServiceImpl implements QuizStudentAnswerService {
|
|
|
|
|
|
return QuizStudentAnswerStatisticVO.of(quizId, scores, submitNums);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户Pid查做题记录
|
|
|
+ * @author Sky
|
|
|
+ * */
|
|
|
+ @Override
|
|
|
+ public List<QuizStudentAnswerVO> getQuizStudentAnswersByStudentPid(Long studentPid) {
|
|
|
+ Optional<User> user = userDAO.findByPid(studentPid);
|
|
|
+ Long studentId = null;
|
|
|
+ if(user.isPresent()) {
|
|
|
+ studentId = (Long)user.get().getId();
|
|
|
+ return this.getQuizStudentAnswersByStudentId(studentId);
|
|
|
+ } else {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户Id查做题记录
|
|
|
+ * @author Sky
|
|
|
+ * */
|
|
|
+ @Override
|
|
|
+ public List<QuizStudentAnswerVO> getQuizStudentAnswersByStudentId(Long studentId) {
|
|
|
+ return quizStudentAnswerDAO.findByStudentId(studentId).stream().map(
|
|
|
+ qsadao -> new QuizStudentAnswerVO(qsadao,questionService.getQuestionsByIds(quizDAO.findQuizById(qsadao.getQuiz().getId()).getQuestions()))
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查所有做题记录
|
|
|
+ * @author Sky
|
|
|
+ * */
|
|
|
+ @Override
|
|
|
+ public List<QuizStudentAnswerVO> getAllQuizStudentAnswersByTime(String start, String end) { //TODO
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ try {
|
|
|
+ LocalDateTime startTime = LocalDateTime.parse(start, dtf);
|
|
|
+ LocalDateTime endTime = LocalDateTime.parse(end, dtf);
|
|
|
+ System.out.println(startTime + " " + endTime);
|
|
|
+ return quizStudentAnswerDAO.findBetweenTime(startTime, endTime).stream().map(
|
|
|
+ qsadao -> new QuizStudentAnswerVO(qsadao,questionService.getQuestionsByIds(quizDAO.findQuizById(qsadao.getQuiz().getId()).getQuestions()))
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ } catch (java.lang.IllegalArgumentException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return new LinkedList<>();
|
|
|
+ }
|
|
|
}
|