@Override public void removeUserAnswerForCurrentQuiz(Quiz quiz) { List<UserAnswer> userAnswersForRemove = userAnswerRepository.findByQuiz(quiz); for (UserAnswer userAnswer : userAnswersForRemove) { removeUserAnswer(userAnswer); } }
@Override @Caching(evict = {@CacheEvict(value = "userAnswers", key = "#id")}) public void removeUserAnswer(Long id) { userAnswerRepository.delete(id); }
@Override @Caching(evict = {@CacheEvict(value = "userAnswers", key = "#userAnswer.id")}) public void removeUserAnswer(UserAnswer userAnswer) { userAnswerRepository.delete(userAnswer); }
@Override @Cacheable(value = "userAnswers") public UserAnswer getUserAnswer(Long id) { return userAnswerRepository.findOne(id); }
@Override @Caching(put = {@CachePut(value = "userAnswers", key = "#userAnswer.id")}) public UserAnswer updateUserAnswer(UserAnswer userAnswer) { return userAnswerRepository.saveAndFlush(userAnswer); }
@Transactional @Override public List<UserAnswer> findByUserAndAnswerIsNullDistinctQuiz(User user) { return userAnswerRepository.findByUserAndAnswerIsNullDistinctQuiz(user); }
@Override public List<UserAnswer> findByQuestion(Question question) { return userAnswerRepository.findByQuestion(question); }
@Override public List<UserAnswer> findByUserAndAnswerIsNullOrderByQuestionIndex(User user) { return userAnswerRepository.findByUserAndAnswerIsNullOrderByQuestionIndex(user); }
@Override public List<UserAnswer> findByUserAndQuestionAndQuiz(User user, Question question, Quiz quiz) { return userAnswerRepository.findByUserAndQuestionAndQuiz(user, question, quiz); }
@Override public List<UserAnswer> findByUser(User user) { return userAnswerRepository.findByUser(user); }
@Override public List<TagStatistic> passingTagStatistic(User user) { return userAnswerRepository.statisticOfPassingQuestionsByTag(user); }
@Override public int countOfCorrectAnsweredQuestions(User user) { if (userAnswerRepository.countOfCorrectAnsweredQuestionsByUser(user) != null) return userAnswerRepository.countOfCorrectAnsweredQuestionsByUser(user); else return 0; }
@Override public int countOfAnsweredQuestionsByQuiz(User user, Quiz quiz) { if (userAnswerRepository.countOfAnsweredQuestionsByUserAndQuiz(user, quiz) != null) return userAnswerRepository.countOfAnsweredQuestionsByUserAndQuiz(user, quiz); else return 0; }
private List<UserAnswer> findByUserAndScore(User user, int score) { return userAnswerRepository.findByUserAndScore(user, score); }