implemented basic Logic
This commit is contained in:
parent
d0f4266f53
commit
d294716316
@ -18,6 +18,14 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class AnswerTextController {
|
public class AnswerTextController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextArea predefinedAnswerArea;
|
||||||
|
@FXML
|
||||||
|
private Button correctBtn;
|
||||||
|
@FXML
|
||||||
|
private Button incorrectBtn;
|
||||||
|
@FXML
|
||||||
|
private TextArea userAnswerArea;
|
||||||
@FXML
|
@FXML
|
||||||
private ComboBox selectBox;
|
private ComboBox selectBox;
|
||||||
@FXML
|
@FXML
|
||||||
@ -25,8 +33,6 @@ public class AnswerTextController {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button showAnswerBtn;
|
private Button showAnswerBtn;
|
||||||
@FXML
|
@FXML
|
||||||
private TextArea textArea;
|
|
||||||
@FXML
|
|
||||||
private Label questionLabel;
|
private Label questionLabel;
|
||||||
|
|
||||||
private Question currentQuestion = null;
|
private Question currentQuestion = null;
|
||||||
@ -44,7 +50,8 @@ public class AnswerTextController {
|
|||||||
if (newValue == null) {
|
if (newValue == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.skipBtn.setDisable(false);
|
||||||
|
this.showAnswerBtn.setDisable(false);
|
||||||
try {
|
try {
|
||||||
this.questions = QuestionService.GetQuestionsFromCatalog(((QuestionCatalog) newValue).getId());
|
this.questions = QuestionService.GetQuestionsFromCatalog(((QuestionCatalog) newValue).getId());
|
||||||
this.showNextQuestion();
|
this.showNextQuestion();
|
||||||
@ -57,19 +64,39 @@ public class AnswerTextController {
|
|||||||
|
|
||||||
private void showNextQuestion()
|
private void showNextQuestion()
|
||||||
{
|
{
|
||||||
|
|
||||||
this.currentIdx = ++this.currentIdx >= questions.size() ? 0 : this.currentIdx;
|
this.currentIdx = ++this.currentIdx >= questions.size() ? 0 : this.currentIdx;
|
||||||
|
|
||||||
this.currentQuestion = this.questions.get(this.currentIdx);
|
this.currentQuestion = this.questions.get(this.currentIdx);
|
||||||
this.questionLabel.setText(this.currentQuestion.getQuestion());
|
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
|
@FXML
|
||||||
private void onShowAnwerBtnClick(ActionEvent actionEvent) {
|
private void onShowAnwerBtnClick(ActionEvent actionEvent) {
|
||||||
|
this.predefinedAnswerArea.setText(this.currentQuestion.getAnswer());
|
||||||
|
this.correctBtn.setDisable(false);
|
||||||
|
this.incorrectBtn.setDisable(false);
|
||||||
|
this.userAnswerArea.setEditable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onSkipBtnClick(ActionEvent actionEvent) {
|
private void onSkipBtnClick(ActionEvent actionEvent) {
|
||||||
this.showNextQuestion();
|
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>
|
<children>
|
||||||
<VBox spacing="20" alignment="CENTER">
|
<VBox spacing="20" alignment="CENTER">
|
||||||
<Label fx:id="questionLabel" text="Here goes your question" style="-fx-font-size: 18;"/>
|
<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"/>
|
<!-- User Input Box -->
|
||||||
<Button text="Skip" fx:id="skipBtn" onAction="#onSkipBtnClick"/>
|
<TextArea fx:id="userAnswerArea" promptText="Enter your answer here..." wrapText="true" prefHeight="100.0"
|
||||||
<Button text="Show Answer" fx:id="showAnswerBtn" onAction="#onShowAnwerBtnClick"/>
|
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>
|
</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>
|
</VBox>
|
||||||
<HBox alignment="TOP_RIGHT" spacing="10.0" AnchorPane.topAnchor="10.0" AnchorPane.rightAnchor="10.0">
|
<HBox alignment="TOP_RIGHT" spacing="10.0" AnchorPane.topAnchor="10.0" AnchorPane.rightAnchor="10.0">
|
||||||
<ComboBox fx:id="selectBox" promptText="Select a Catalog"/>
|
<ComboBox fx:id="selectBox" promptText="Select a Catalog"/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user