From 29554247c0319d042ced960926e94528bbd71ad4 Mon Sep 17 00:00:00 2001 From: law39 Date: Wed, 29 Apr 2020 16:49:17 +0100 Subject: [PATCH] Updated user prompt at end of assessment At the end of assessment, the user will be prompted to ask if they wish to continue assessment, or if they would like to stop. This dialogue box now appears with Yes/No options rather than Okay/Cancel. --- .../selfassessment/AssessmentGenerator.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java index 214a452..67a916f 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java @@ -167,17 +167,24 @@ public class AssessmentGenerator { .append(Question.correctAnswers + Question.wrongAnswers) .append("\n Would you like to test yourself again?"); + ButtonType yesBtn = new ButtonType("Yes"); + ButtonType noBtn = new ButtonType("No"); + + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("You finished the tests"); alert.setHeaderText("You finished the tests\n Well Done!"); alert.setResizable(false); alert.setContentText(sb.toString()); - Optional result = alert.showAndWait(); - ((Button) alert.getDialogPane().lookupButton(ButtonType.OK)).setText("Yes"); - ((Button) alert.getDialogPane().lookupButton(ButtonType.CANCEL)).setText("No"); + alert.getButtonTypes().clear(); + alert.getButtonTypes().addAll(yesBtn, noBtn); - if (result.isEmpty() || result.get() == ButtonType.CANCEL) { + Optional result = alert.showAndWait(); + + + + if (result.isEmpty() || result.get() == noBtn) { currentAssessment=0; Question.resetScore(); ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene);