From b5d8b622dd037332dff519cbe11e05a39913331a Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Sun, 12 Jun 2016 13:18:37 +0200 Subject: [PATCH] Test: remove item if the reponse was right or !repeatWrong --- .../jstudy/controller/TestController.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/es/kauron/jstudy/controller/TestController.java b/src/main/java/es/kauron/jstudy/controller/TestController.java index 5f72636..b97f55e 100644 --- a/src/main/java/es/kauron/jstudy/controller/TestController.java +++ b/src/main/java/es/kauron/jstudy/controller/TestController.java @@ -1,6 +1,7 @@ package es.kauron.jstudy.controller; import com.jfoenix.controls.JFXTextField; +import es.kauron.jstudy.model.AppConfig; import es.kauron.jstudy.model.TestItem; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -46,7 +47,16 @@ public class TestController implements Initializable { correctAnswer.setVisible(!right); correctLabel.setVisible(!right); - list.remove(current); + // Remove the question from the pool if the question was correctly answered or there is no repetition + if (right || !AppConfig.repeatWrong) { + list.remove(current); + if (list.size() == 0) { + answer.setText(""); + answer.setDisable(true); + question.setText("That's it!"); + return; + } + } progress.setProgress(progress.getProgress() + 1.0/total); progressLabel.setText((int) (progress.getProgress() * total) + "/" + total); onSkipAction(event); @@ -54,15 +64,9 @@ public class TestController implements Initializable { @FXML private void onSkipAction(ActionEvent event) { - if (list.size() == 0) { - answer.setText(""); - answer.setDisable(true); - question.setText("That's it!"); - } else { - answer.setText(""); - current = (int) (Math.random() * list.size()); - question.setText(list.get(current).getQuestion()); - answer.requestFocus(); - } + answer.setText(""); + current = (int) (Math.random() * list.size()); + question.setText(list.get(current).getQuestion()); + answer.requestFocus(); } }