This commit is contained in:
unknown 2020-01-16 20:48:32 +01:00
parent 4de7f29290
commit e11a52583f
4 changed files with 9 additions and 10 deletions

View File

@ -91,8 +91,9 @@ public class TestController {
(o1, o2) -> o1.getId().compareTo(o2.getId())); (o1, o2) -> o1.getId().compareTo(o2.getId()));
} }
} }
if (testToReturn.getHelp()){
for (Question question : testToReturn.getQuestions()) { for (Question question : testToReturn.getQuestions()) {
if (question.getHelp()){
if (question instanceof QuestionChoices){ if (question instanceof QuestionChoices){
QuestionChoices questionChoices = (QuestionChoices) question; QuestionChoices questionChoices = (QuestionChoices) question;
List<AnswerChoices> answers = questionChoices.getAnswers(); List<AnswerChoices> answers = questionChoices.getAnswers();
@ -146,7 +147,7 @@ public class TestController {
} }
List<AnswerChoices> helpers = new ArrayList<>(); List<AnswerChoices> helpers = new ArrayList<>();
if (question.getType().equals("single-choice")) { if (question.getType().equals("single-choice")) {
if (test.get().getHelp()){ if (question.getHelp()){
List<AnswerChoices> answers = answersDTOs; List<AnswerChoices> answers = answersDTOs;
if (answers.size() > 2) { if (answers.size() > 2) {
for (AnswerChoices answerChoices : answers){ for (AnswerChoices answerChoices : answers){
@ -369,8 +370,6 @@ public class TestController {
test.setAddDate(); test.setAddDate();
test.setEditDate(); test.setEditDate();
test.setGrade(); test.setGrade();
if (testDTO.getHelp() != null)
test.setHelp(testDTO.getHelp());
// Badge for creating first test // Badge for creating first test
if(userBadgeRepository.findByIdAndUser((long)4, user.getId()).isEmpty()) { if(userBadgeRepository.findByIdAndUser((long)4, user.getId()).isEmpty()) {
@ -551,8 +550,6 @@ public class TestController {
// System.out.println("usuwam "+oldquestion.getId()); // System.out.println("usuwam "+oldquestion.getId());
} }
} }
if (testDTO.getHelp() != null)
test.setHelp(testDTO.getHelp());
testRepository.save(test); testRepository.save(test);
for (Long a : deletea) for (Long a : deletea)

View File

@ -66,8 +66,7 @@ public class Test {
@Nullable @Nullable
private Long availableTo = null; private Long availableTo = null;
@Column(columnDefinition = "TINYINT(1)")
private Boolean help = false;
public void setAddDate() { public void setAddDate() {

View File

@ -31,8 +31,6 @@ public class TestCreateDTO {
@ApiModelProperty(value = "Default value for note", required = true,example = "public") @ApiModelProperty(value = "Default value for note", required = true,example = "public")
private String permission; private String permission;
private Boolean help = false;
@JsonIgnore @JsonIgnore
private Long grade; private Long grade;
@JsonProperty("body") @JsonProperty("body")

View File

@ -68,4 +68,9 @@ public abstract class Question {
@Setter @Setter
private int time; private int time;
@Getter
@Setter
@Column(columnDefinition = "TINYINT(1)")
private Boolean help = false;
} }