From 7b24ed45dd4acade7690755da54a093eb96c75c8 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Sun, 12 Jun 2016 17:16:26 +0200 Subject: [PATCH] Test: end and mark --- .../jstudy/controller/TestController.java | 17 ++++++++++++++--- .../resources/es/kauron/jstudy/view/test.fxml | 5 +++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/es/kauron/jstudy/controller/TestController.java b/src/main/java/es/kauron/jstudy/controller/TestController.java index d532946..c5c7491 100644 --- a/src/main/java/es/kauron/jstudy/controller/TestController.java +++ b/src/main/java/es/kauron/jstudy/controller/TestController.java @@ -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))); + } } diff --git a/src/main/resources/es/kauron/jstudy/view/test.fxml b/src/main/resources/es/kauron/jstudy/view/test.fxml index 0c9d276..e0a0937 100644 --- a/src/main/resources/es/kauron/jstudy/view/test.fxml +++ b/src/main/resources/es/kauron/jstudy/view/test.fxml @@ -64,8 +64,9 @@ -