1
0
Fork 0
mirror of https://gitlab.com/kauron/jstudy synced 2024-12-23 00:43:32 +01:00

Test: remove item if the reponse was right or !repeatWrong

This commit is contained in:
Carlos Galindo 2016-06-12 13:18:37 +02:00
parent 6aa43d2157
commit b5d8b622dd
Signed by: kauron
GPG key ID: 83E68706DEE119A3

View file

@ -1,6 +1,7 @@
package es.kauron.jstudy.controller; package es.kauron.jstudy.controller;
import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXTextField;
import es.kauron.jstudy.model.AppConfig;
import es.kauron.jstudy.model.TestItem; import es.kauron.jstudy.model.TestItem;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -46,7 +47,16 @@ public class TestController implements Initializable {
correctAnswer.setVisible(!right); correctAnswer.setVisible(!right);
correctLabel.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); progress.setProgress(progress.getProgress() + 1.0/total);
progressLabel.setText((int) (progress.getProgress() * total) + "/" + total); progressLabel.setText((int) (progress.getProgress() * total) + "/" + total);
onSkipAction(event); onSkipAction(event);
@ -54,15 +64,9 @@ public class TestController implements Initializable {
@FXML @FXML
private void onSkipAction(ActionEvent event) { private void onSkipAction(ActionEvent event) {
if (list.size() == 0) { answer.setText("");
answer.setText(""); current = (int) (Math.random() * list.size());
answer.setDisable(true); question.setText(list.get(current).getQuestion());
question.setText("That's it!"); answer.requestFocus();
} else {
answer.setText("");
current = (int) (Math.random() * list.size());
question.setText(list.get(current).getQuestion());
answer.requestFocus();
}
} }
} }