Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
uo287545 committed Apr 25, 2024
1 parent 8f4f72d commit 62f5618
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 42 deletions.
11 changes: 1 addition & 10 deletions src/main/java/com/uniovi/services/QuestionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<Question> testQuestions(int num);
}
33 changes: 1 addition & 32 deletions src/main/java/com/uniovi/services/impl/QuestionServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -169,31 +165,4 @@ public void deleteQuestion(Long id) {
questionRepository.delete(question);
}
}

@Override
public List<Question> testQuestions(int num) {
List<Question> 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<Answer> 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;
}

}

0 comments on commit 62f5618

Please sign in to comment.