diff --git a/src/main/java/at/ionas999/questioncatalog/controller/AnswerTextController.java b/src/main/java/at/ionas999/questioncatalog/controller/AnswerTextController.java index 3284880..6d3230e 100644 --- a/src/main/java/at/ionas999/questioncatalog/controller/AnswerTextController.java +++ b/src/main/java/at/ionas999/questioncatalog/controller/AnswerTextController.java @@ -18,6 +18,14 @@ import java.util.ArrayList; public class AnswerTextController { + @FXML + private TextArea predefinedAnswerArea; + @FXML + private Button correctBtn; + @FXML + private Button incorrectBtn; + @FXML + private TextArea userAnswerArea; @FXML private ComboBox selectBox; @FXML @@ -25,8 +33,6 @@ public class AnswerTextController { @FXML private Button showAnswerBtn; @FXML - private TextArea textArea; - @FXML private Label questionLabel; private Question currentQuestion = null; @@ -44,7 +50,8 @@ public class AnswerTextController { if (newValue == null) { return; } - + this.skipBtn.setDisable(false); + this.showAnswerBtn.setDisable(false); try { this.questions = QuestionService.GetQuestionsFromCatalog(((QuestionCatalog) newValue).getId()); this.showNextQuestion(); @@ -57,19 +64,39 @@ public class AnswerTextController { private void showNextQuestion() { - this.currentIdx = ++this.currentIdx >= questions.size() ? 0 : this.currentIdx; this.currentQuestion = this.questions.get(this.currentIdx); this.questionLabel.setText(this.currentQuestion.getQuestion()); + + this.incorrectBtn.setDisable(true); + this.correctBtn.setDisable(true); + this.predefinedAnswerArea.setText(""); + this.userAnswerArea.setText(""); + this.userAnswerArea.setEditable(true); } @FXML private void onShowAnwerBtnClick(ActionEvent actionEvent) { + this.predefinedAnswerArea.setText(this.currentQuestion.getAnswer()); + this.correctBtn.setDisable(false); + this.incorrectBtn.setDisable(false); + this.userAnswerArea.setEditable(false); } @FXML private void onSkipBtnClick(ActionEvent actionEvent) { this.showNextQuestion(); } + + @FXML + private void onCorrectBtnClick(ActionEvent actionEvent) { + //TODO: make a stat of how many time correct and how many times wrong + showNextQuestion(); + } + + @FXML + private void onIncorrectBtnClick(ActionEvent actionEvent) { + showNextQuestion(); + } } diff --git a/src/main/resources/at/ionas999/questioncatalog/answerText.fxml b/src/main/resources/at/ionas999/questioncatalog/answerText.fxml index 966b1b8..98b89f8 100644 --- a/src/main/resources/at/ionas999/questioncatalog/answerText.fxml +++ b/src/main/resources/at/ionas999/questioncatalog/answerText.fxml @@ -9,11 +9,25 @@