From e11a52583f2ad565e9c841a6ef68aa2ac95ce7e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Jan 2020 20:48:32 +0100 Subject: [PATCH] fix --- .../studycaverestservice/controller/TestController.java | 9 +++------ .../studycave/studycaverestservice/model/test/Test.java | 3 +-- .../model/test/dto/TestCreateDTO.java | 2 -- .../model/test/question/Question.java | 5 +++++ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/BackEnd/src/main/java/studycave/studycaverestservice/controller/TestController.java b/BackEnd/src/main/java/studycave/studycaverestservice/controller/TestController.java index 9ed7ef4..da7e86b 100644 --- a/BackEnd/src/main/java/studycave/studycaverestservice/controller/TestController.java +++ b/BackEnd/src/main/java/studycave/studycaverestservice/controller/TestController.java @@ -91,8 +91,9 @@ public class TestController { (o1, o2) -> o1.getId().compareTo(o2.getId())); } } - if (testToReturn.getHelp()){ + for (Question question : testToReturn.getQuestions()) { + if (question.getHelp()){ if (question instanceof QuestionChoices){ QuestionChoices questionChoices = (QuestionChoices) question; List answers = questionChoices.getAnswers(); @@ -146,7 +147,7 @@ public class TestController { } List helpers = new ArrayList<>(); if (question.getType().equals("single-choice")) { - if (test.get().getHelp()){ + if (question.getHelp()){ List answers = answersDTOs; if (answers.size() > 2) { for (AnswerChoices answerChoices : answers){ @@ -369,8 +370,6 @@ public class TestController { test.setAddDate(); test.setEditDate(); test.setGrade(); - if (testDTO.getHelp() != null) - test.setHelp(testDTO.getHelp()); // Badge for creating first test if(userBadgeRepository.findByIdAndUser((long)4, user.getId()).isEmpty()) { @@ -551,8 +550,6 @@ public class TestController { // System.out.println("usuwam "+oldquestion.getId()); } } - if (testDTO.getHelp() != null) - test.setHelp(testDTO.getHelp()); testRepository.save(test); for (Long a : deletea) diff --git a/BackEnd/src/main/java/studycave/studycaverestservice/model/test/Test.java b/BackEnd/src/main/java/studycave/studycaverestservice/model/test/Test.java index 1c56b2d..431bbab 100644 --- a/BackEnd/src/main/java/studycave/studycaverestservice/model/test/Test.java +++ b/BackEnd/src/main/java/studycave/studycaverestservice/model/test/Test.java @@ -66,8 +66,7 @@ public class Test { @Nullable private Long availableTo = null; - @Column(columnDefinition = "TINYINT(1)") - private Boolean help = false; + public void setAddDate() { diff --git a/BackEnd/src/main/java/studycave/studycaverestservice/model/test/dto/TestCreateDTO.java b/BackEnd/src/main/java/studycave/studycaverestservice/model/test/dto/TestCreateDTO.java index 47f4a88..c0f495c 100644 --- a/BackEnd/src/main/java/studycave/studycaverestservice/model/test/dto/TestCreateDTO.java +++ b/BackEnd/src/main/java/studycave/studycaverestservice/model/test/dto/TestCreateDTO.java @@ -31,8 +31,6 @@ public class TestCreateDTO { @ApiModelProperty(value = "Default value for note", required = true,example = "public") private String permission; - private Boolean help = false; - @JsonIgnore private Long grade; @JsonProperty("body") diff --git a/BackEnd/src/main/java/studycave/studycaverestservice/model/test/question/Question.java b/BackEnd/src/main/java/studycave/studycaverestservice/model/test/question/Question.java index f4390d0..aaa5990 100644 --- a/BackEnd/src/main/java/studycave/studycaverestservice/model/test/question/Question.java +++ b/BackEnd/src/main/java/studycave/studycaverestservice/model/test/question/Question.java @@ -68,4 +68,9 @@ public abstract class Question { @Setter private int time; + @Getter + @Setter + @Column(columnDefinition = "TINYINT(1)") + private Boolean help = false; + }