diff --git a/src/main/java/com/uniovi/services/QuestionGeneratorService.java b/src/main/java/com/uniovi/services/QuestionGeneratorService.java index ac6052ef..91ee1725 100644 --- a/src/main/java/com/uniovi/services/QuestionGeneratorService.java +++ b/src/main/java/com/uniovi/services/QuestionGeneratorService.java @@ -42,10 +42,13 @@ public class QuestionGeneratorService { private Logger log = LoggerFactory.getLogger(InsertSampleDataService.class); + private boolean started; + public QuestionGeneratorService(QuestionService questionService) { this.questionService = questionService; ((QuestionServiceImpl)questionService).setQuestionGeneratorService(this); parseQuestionTypes(); + this.started = true; } private void parseQuestionTypes() { @@ -67,6 +70,10 @@ private void parseQuestionTypes() { } } + @Scheduled(fixedRate = 86400000, initialDelay = 86400000) + public void generateAllQuestions(){ + } + @Scheduled(fixedRate = 150000) @Transactional public void generateQuestions() throws IOException { @@ -74,6 +81,11 @@ public void generateQuestions() throws IOException { return; } + if (started){ + started = false; + questionService.deleteAllQuestions(); + } + if (Arrays.stream(environment.getActiveProfiles()).anyMatch(env -> (env.equalsIgnoreCase("test")))) { log.info("Test profile active, skipping sample data insertion"); return;