From 97f5346d6805feddc35e5a984d15215265f826fa Mon Sep 17 00:00:00 2001 From: gekoramy Date: Tue, 28 Aug 2018 19:49:19 +0200 Subject: [PATCH] Add the ability to shuffle --- .../github/quiz/app/preview/PreviewPresenter.java | 7 +++++++ .../me/gekoramy/github/quiz/app/preview/preview.fxml | 10 ++++++++++ .../me/gekoramy/github/quiz/service/ExamStarter.java | 4 ++++ src/main/java/me/gekoramy/github/quiz/util/Pool.java | 5 ++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/gekoramy/github/quiz/app/preview/PreviewPresenter.java b/src/main/java/me/gekoramy/github/quiz/app/preview/PreviewPresenter.java index 35e6220..28382a4 100755 --- a/src/main/java/me/gekoramy/github/quiz/app/preview/PreviewPresenter.java +++ b/src/main/java/me/gekoramy/github/quiz/app/preview/PreviewPresenter.java @@ -50,6 +50,8 @@ public class PreviewPresenter implements Initializable { @FXML private Hyperlink btnRefresh; @FXML + private Hyperlink btnShuffle; + @FXML private Hyperlink btnDownload; @FXML private Hyperlink btnStart; @@ -111,6 +113,7 @@ public void initialize(URL location, ResourceBundle resources) { btnStore.setOnAction(e -> onStore()); btnDownload.setOnAction(e -> onDownload()); btnRefresh.setOnAction(e -> onRefresh()); + btnShuffle.setOnAction(e -> onShuffle()); btnStart.setOnAction(e -> onStart()); } @@ -183,4 +186,8 @@ private void onRefresh() { } } } + + private void onShuffle() { + examStarter.shuffle(); + } } diff --git a/src/main/java/me/gekoramy/github/quiz/app/preview/preview.fxml b/src/main/java/me/gekoramy/github/quiz/app/preview/preview.fxml index 2ee8615..f96cd06 100755 --- a/src/main/java/me/gekoramy/github/quiz/app/preview/preview.fxml +++ b/src/main/java/me/gekoramy/github/quiz/app/preview/preview.fxml @@ -51,6 +51,16 @@ + + + + + + + + diff --git a/src/main/java/me/gekoramy/github/quiz/service/ExamStarter.java b/src/main/java/me/gekoramy/github/quiz/service/ExamStarter.java index fea628d..0064cb3 100755 --- a/src/main/java/me/gekoramy/github/quiz/service/ExamStarter.java +++ b/src/main/java/me/gekoramy/github/quiz/service/ExamStarter.java @@ -47,4 +47,8 @@ protected Void call() { } }; } + + public void shuffle() { + questionPool.shuffle(); + } } diff --git a/src/main/java/me/gekoramy/github/quiz/util/Pool.java b/src/main/java/me/gekoramy/github/quiz/util/Pool.java index b5cf157..c7eb61b 100755 --- a/src/main/java/me/gekoramy/github/quiz/util/Pool.java +++ b/src/main/java/me/gekoramy/github/quiz/util/Pool.java @@ -54,7 +54,6 @@ public DoubleProperty progressProperty() { public void revert() { toDoList.clear(); toDoList.addAll(totalList); - Collections.shuffle(toDoList); this.progress.set(1); } @@ -76,4 +75,8 @@ public List retrieve(int many) { public boolean isDone() { return toDoList.size() == 0; } + + public void shuffle() { + Collections.shuffle(toDoList); + } }