mirror of
https://gitlab.com/kauron/jstudy
synced 2025-09-30 21:01:10 +02:00
Test: end and mark
This commit is contained in:
parent
379505e630
commit
7b24ed45dd
2 changed files with 17 additions and 5 deletions
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue