Skip to content

Commit

Permalink
Add the ability to shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
gekoramy committed Aug 28, 2018
1 parent e054ace commit 97f5346
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -183,4 +186,8 @@ private void onRefresh() {
}
}
}

private void onShuffle() {
examStarter.shuffle();
}
}
10 changes: 10 additions & 0 deletions src/main/java/me/gekoramy/github/quiz/app/preview/preview.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
<Font size="35.0"/>
</font>
</Hyperlink>
<Hyperlink fx:id="btnShuffle">
<graphic>
<SVGPath
content="M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z"
scaleX="1.5" scaleY="1.5" style="-fx-fill: #424242;"/>
</graphic>
<font>
<Font size="35.0"/>
</font>
</Hyperlink>
<Hyperlink fx:id="btnStart">
<graphic>
<SVGPath content="M8 5v14l11-7z" scaleX="1.5" scaleY="1.5" style="-fx-fill: #424242;"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ protected Void call() {
}
};
}

public void shuffle() {
questionPool.shuffle();
}
}
5 changes: 4 additions & 1 deletion src/main/java/me/gekoramy/github/quiz/util/Pool.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public DoubleProperty progressProperty() {
public void revert() {
toDoList.clear();
toDoList.addAll(totalList);
Collections.shuffle(toDoList);
this.progress.set(1);
}

Expand All @@ -76,4 +75,8 @@ public List<T> retrieve(int many) {
public boolean isDone() {
return toDoList.size() == 0;
}

public void shuffle() {
Collections.shuffle(toDoList);
}
}

0 comments on commit 97f5346

Please sign in to comment.