mirror of
https://gitlab.com/kauron/jstudy
synced 2024-12-22 16:33:33 +01:00
Test: end and mark
This commit is contained in:
parent
379505e630
commit
7b24ed45dd
2 changed files with 17 additions and 5 deletions
|
@ -6,6 +6,7 @@ import es.kauron.jstudy.model.TestItem;
|
|||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
@ -64,9 +65,7 @@ public class TestController implements Initializable {
|
|||
progress.setProgress(++done/(double)total);
|
||||
progressLabel.setText(done + "/" + total);
|
||||
if (list.size() == 0) {
|
||||
answer.setText("");
|
||||
answer.setDisable(true);
|
||||
question.setText("That's it!");
|
||||
onEndAction(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -84,4 +83,16 @@ public class TestController implements Initializable {
|
|||
question.setText(list.get(current).getQuestion());
|
||||
answer.requestFocus();
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void onEndAction(ActionEvent event) {
|
||||
answer.setText("");
|
||||
answer.setDisable(true);
|
||||
question.setText("That's it!");
|
||||
feedback.getChildren().clear();
|
||||
feedback.setSpacing(5);
|
||||
feedback.setPadding(new Insets(5, 5, 5, 5));
|
||||
feedback.getChildren().add(new Label("Mistakes: " + errors));
|
||||
feedback.getChildren().add(new Label(String.format("Mark: %.2f%%", (total - errors) / (double) total * 100)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,9 @@
|
|||
</VBox>
|
||||
<VBox alignment="TOP_RIGHT" spacing="10.0" GridPane.columnIndex="1">
|
||||
<children>
|
||||
<Button defaultButton="true" focusTraversable="false" mnemonicParsing="false" onAction="#onNextAction" prefWidth="70.0" text="Next" />
|
||||
<Button cancelButton="true" focusTraversable="false" mnemonicParsing="false" onAction="#onSkipAction" prefWidth="70.0" text="Skip" />
|
||||
<Button defaultButton="true" focusTraversable="false" onAction="#onNextAction" prefWidth="110.0" text="_Next" />
|
||||
<Button cancelButton="true" focusTraversable="false" onAction="#onSkipAction" prefWidth="110.0" text="_Skip question" />
|
||||
<Button cancelButton="true" focusTraversable="false" layoutX="10.0" layoutY="48.0" onAction="#onEndAction" prefWidth="110.0" text="_End test" />
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" GridPane.columnSpan="2147483647" GridPane.rowIndex="1">
|
||||
|
|
Loading…
Reference in a new issue