implemented basic Logic
This commit is contained in:
parent
d0f4266f53
commit
d294716316
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,11 +9,25 @@
|
||||
<children>
|
||||
<VBox spacing="20" alignment="CENTER">
|
||||
<Label fx:id="questionLabel" text="Here goes your question" style="-fx-font-size: 18;"/>
|
||||
<HBox alignment="CENTER">
|
||||
<TextArea fx:id="textArea" promptText="Type your answer here..." prefHeight="100.0" prefWidth="300.0"/>
|
||||
<Button text="Skip" fx:id="skipBtn" onAction="#onSkipBtnClick"/>
|
||||
<Button text="Show Answer" fx:id="showAnswerBtn" onAction="#onShowAnwerBtnClick"/>
|
||||
|
||||
<!-- User Input Box -->
|
||||
<TextArea fx:id="userAnswerArea" promptText="Enter your answer here..." wrapText="true" prefHeight="100.0"
|
||||
prefWidth="300.0"/>
|
||||
|
||||
<HBox spacing="10" alignment="CENTER">
|
||||
<Button text="Show Answer" disable="true" fx:id="showAnswerBtn" onAction="#onShowAnwerBtnClick"/>
|
||||
<Button text="Skip" disable="true" fx:id="skipBtn" onAction="#onSkipBtnClick"/>
|
||||
</HBox>
|
||||
|
||||
<VBox spacing="10" alignment="CENTER">
|
||||
<Label text="Predefined Answer:" style="-fx-font-size: 14;"/>
|
||||
<TextArea fx:id="predefinedAnswerArea" editable="false" wrapText="true" prefHeight="100.0"
|
||||
prefWidth="300.0"/>
|
||||
<HBox spacing="10" alignment="CENTER">
|
||||
<Button text="Correct" disable="true" fx:id="correctBtn" onAction="#onCorrectBtnClick"/>
|
||||
<Button text="Incorrect" disable="true" fx:id="incorrectBtn" onAction="#onIncorrectBtnClick"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
</VBox>
|
||||
<HBox alignment="TOP_RIGHT" spacing="10.0" AnchorPane.topAnchor="10.0" AnchorPane.rightAnchor="10.0">
|
||||
<ComboBox fx:id="selectBox" promptText="Select a Catalog"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user