From 62f56186583c014dc89214342aa7b3133516a4cc Mon Sep 17 00:00:00 2001 From: uo287545 Date: Fri, 26 Apr 2024 01:59:11 +0200 Subject: [PATCH] Removed unused code --- .../com/uniovi/services/QuestionService.java | 11 +------ .../services/impl/QuestionServiceImpl.java | 33 +------------------ 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/uniovi/services/QuestionService.java b/src/main/java/com/uniovi/services/QuestionService.java index 7eb7d422..b482cfd6 100644 --- a/src/main/java/com/uniovi/services/QuestionService.java +++ b/src/main/java/com/uniovi/services/QuestionService.java @@ -3,11 +3,10 @@ import com.uniovi.dto.QuestionDto; import com.uniovi.entities.Category; import com.uniovi.entities.Question; -import jakarta.transaction.Transactional; import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import org.springframework.data.domain.Pageable; import java.util.List; import java.util.Optional; @@ -97,12 +96,4 @@ public interface QuestionService { * @param id The id of the question to delete */ void deleteQuestion(Long id); - - /** - * Get some test questions - * - * @param num The number of questions to get - * @return The questions selected - */ - List testQuestions(int num); } diff --git a/src/main/java/com/uniovi/services/impl/QuestionServiceImpl.java b/src/main/java/com/uniovi/services/impl/QuestionServiceImpl.java index f0ec9f7e..f92f7958 100644 --- a/src/main/java/com/uniovi/services/impl/QuestionServiceImpl.java +++ b/src/main/java/com/uniovi/services/impl/QuestionServiceImpl.java @@ -12,20 +12,16 @@ import com.uniovi.services.QuestionService; import jakarta.persistence.EntityManager; import jakarta.transaction.Transactional; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.querydsl.QPageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.security.SecureRandom; -import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Random; -import org.springframework.data.domain.Pageable; @Service public class QuestionServiceImpl implements QuestionService { @@ -169,31 +165,4 @@ public void deleteQuestion(Long id) { questionRepository.delete(question); } } - - @Override - public List testQuestions(int num) { - List res = new ArrayList<>(); - Category c = new Category("Test category", "Test category"); - categoryService.addNewCategory(c); - for (int i = 0; i < num; i++) { - Question q = new Question(); - q.setStatement("Test question " + i); - q.setLanguage(LocaleContextHolder.getLocale().getLanguage()); - Associations.QuestionsCategory.addCategory(q, c); - List answers = new ArrayList<>(); - for (int j = 0; j < 4; j++) { - Answer a = new Answer(); - a.setText("Test answer " + j); - a.setCorrect(j == 0); - if(j==0) q.setCorrectAnswer(a); - answerService.addNewAnswer(a); - answers.add(a); - } - Associations.QuestionAnswers.addAnswer(q, answers); - addNewQuestion(q); - res.add(q); - } - return res; - } - }