From e11a52583f2ad565e9c841a6ef68aa2ac95ce7e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Jan 2020 20:48:32 +0100 Subject: [PATCH 1/3] 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; + } From 2971264e0a2216779afdceecbb6ddf4563cb41b4 Mon Sep 17 00:00:00 2001 From: s416122 Date: Thu, 16 Jan 2020 21:41:47 +0100 Subject: [PATCH 2/3] =?UTF-8?q?naprawiona=20edycja=20z=20ko=C5=82ami=20rat?= =?UTF-8?q?unkowymi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontEnd/src/app/tests/test-edit/test-edit.component.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/FrontEnd/src/app/tests/test-edit/test-edit.component.ts b/FrontEnd/src/app/tests/test-edit/test-edit.component.ts index 90dd866..8486481 100644 --- a/FrontEnd/src/app/tests/test-edit/test-edit.component.ts +++ b/FrontEnd/src/app/tests/test-edit/test-edit.component.ts @@ -15,7 +15,6 @@ export class TestEditComponent implements OnInit, OnDestroy { owner: Number = 0; title: String = ''; permission: Boolean = false; - test: Array = []; shown: Boolean = false; @@ -59,7 +58,8 @@ export class TestEditComponent implements OnInit, OnDestroy { question: d[i]['question'], time: d[i]['time'], answers: d[i]['answers'], - points: d[i]['points'] + points: d[i]['points'], + help: d[i]['help'] }, shortcut: short }; @@ -217,7 +217,8 @@ export class TestEditComponent implements OnInit, OnDestroy { time: this.test[i]['content']['time'], answers: this.test[i]['content']['answers'], points: this.test[i]['content']['points'], - id: this.test[i]['content']['id'] + id: this.test[i]['content']['id'], + help: this.test[i]['content']['help'] }); } toSend['body'] = body; From 30d5eb5dec346efe21968300d530b0d79efc519d Mon Sep 17 00:00:00 2001 From: s416122 Date: Thu, 16 Jan 2020 23:47:21 +0100 Subject: [PATCH 3/3] =?UTF-8?q?PUNKT-61=20Dodanie=20ko=C5=82a=20ratunkoweg?= =?UTF-8?q?o=20-=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question-view/question-view.component.html | 4 ++-- .../question-view/question-view.component.ts | 7 +++++++ .../single-choice/single-choice.component.html | 13 ++++++++++--- .../single-choice/single-choice.component.ts | 13 +++++++++++++ .../tests/test-details/test-details.component.html | 2 +- .../tests/test-details/test-details.component.ts | 5 +++++ 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/FrontEnd/src/app/tests/test-details/question-view/question-view.component.html b/FrontEnd/src/app/tests/test-details/question-view/question-view.component.html index a2824b3..8823dd7 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/question-view.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/question-view.component.html @@ -5,7 +5,7 @@
Pytanie jednokrotnego wyboru - +
Pytanie wielokrotnego wyboru @@ -23,4 +23,4 @@ Pytanie typu łączenie w pary
- \ No newline at end of file + diff --git a/FrontEnd/src/app/tests/test-details/question-view/question-view.component.ts b/FrontEnd/src/app/tests/test-details/question-view/question-view.component.ts index e22b177..3bcbbf2 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/question-view.component.ts +++ b/FrontEnd/src/app/tests/test-details/question-view/question-view.component.ts @@ -10,7 +10,10 @@ export class QuestionViewComponent implements OnInit { question; @Input() private questionIndex; + @Input() activeFifty; @Output() emitNextQuestionRequest = new EventEmitter(); + @Output() lifebuoyTest = new EventEmitter(); + constructor() { } @@ -22,6 +25,10 @@ export class QuestionViewComponent implements OnInit { this.nextQuestion(e); } + LifebuoyFifty(y) { + this.lifebuoyTest.emit(y); + } + ngOnInit() { } diff --git a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html index 14c8696..996c506 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html @@ -1,16 +1,23 @@
Pytanie za {{question.points}}pkt.
Czas: {{ timeLeft }} sek. Czas: bez limitu -
+
{{question.question}}
-
+
+
+
+ + + +
+
- + diff --git a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts index 32c02a2..d3130db 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts +++ b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts @@ -14,12 +14,16 @@ export class SingleChoiceComponent implements OnInit, OnDestroy { private _question; private answer; @Output() emitNextQuestionRequest = new EventEmitter(); + @Output() lifebuoy = new EventEmitter(); + @Input() activeFifty; private id; private verifyAnswerSubscription: ISubscription; interval: any; public timeLeft = 0; + public fifty: Boolean = false; @ViewChild('f') public form: NgForm; + constructor(private route: ActivatedRoute, private testsService: TestsService) { } nextQuestion(f) { @@ -35,6 +39,15 @@ export class SingleChoiceComponent implements OnInit, OnDestroy { }); } + fiftyFifty() { + this.fifty = true; + this.lifebuoy.emit(false); + } + + noHelp() { + this.fifty = false; + } + startTimer() { this.interval = setInterval(() => { if (this.timeLeft > 0) { diff --git a/FrontEnd/src/app/tests/test-details/test-details.component.html b/FrontEnd/src/app/tests/test-details/test-details.component.html index a42222f..c1e54cd 100644 --- a/FrontEnd/src/app/tests/test-details/test-details.component.html +++ b/FrontEnd/src/app/tests/test-details/test-details.component.html @@ -38,7 +38,7 @@
- +
diff --git a/FrontEnd/src/app/tests/test-details/test-details.component.ts b/FrontEnd/src/app/tests/test-details/test-details.component.ts index 6b62c03..c325cbc 100644 --- a/FrontEnd/src/app/tests/test-details/test-details.component.ts +++ b/FrontEnd/src/app/tests/test-details/test-details.component.ts @@ -19,6 +19,7 @@ export class TestDetailsComponent implements OnInit, OnDestroy { currentQuestionIndex = 0; isEnded = false; points = 0; + public lifebuoyTest: Boolean = true; maxPoints = 0; prevMaxResult = 0; prevAnswerResultBool; @@ -78,6 +79,10 @@ export class TestDetailsComponent implements OnInit, OnDestroy { ); } + LifebuoyFifty(y) { + this.lifebuoyTest = y; + } + getMaxResult() { if (this.currentUser) { this.getResultSubscription = this.testService.getResult(this.test.id, this.currentUser.username).subscribe(d => {