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:
parent
6aa43d2157
commit
b5d8b622dd
1 changed files with 15 additions and 11 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue