1
0
Fork 0
mirror of https://gitlab.com/kauron/jstudy synced 2024-11-13 07:33:44 +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;
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();
}
}