Added the randomiztaion of the answesr
parent
c474bc5ffb
commit
37f8893224
|
@ -19,6 +19,7 @@ import javax.imageio.ImageIO;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -57,7 +58,12 @@ class PicturesAnswersUpdater implements EventHandler{
|
|||
*/
|
||||
void UpdateAnswers(BallotQuestionUIElementOuterClass.BallotQuestionUIElement question) {
|
||||
this.RemoveAllAnswers();
|
||||
for (ByteString bytesAnswer : question.getAnswers().getAnswers().getAnswersList()) {
|
||||
List<ByteString> answers = new ArrayList<>(question.getAnswers().getAnswers().getAnswersList());
|
||||
|
||||
if (question.getRandomizeListOrder()) {
|
||||
Collections.shuffle(answers);
|
||||
}
|
||||
for (ByteString bytesAnswer : answers){
|
||||
try {
|
||||
this.allAvailableAnswers.add(bytesAnswer);
|
||||
this.AddAnswer(bytesAnswer);
|
||||
|
|
|
@ -10,6 +10,9 @@ import javafx.scene.layout.GridPane;
|
|||
import javafx.stage.Stage;
|
||||
import meerkat.protobuf.BallotQuestionUIElementOuterClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
|
@ -91,11 +94,18 @@ class StringsAnswersUpdater implements javafx.event.EventHandler{
|
|||
|
||||
/**
|
||||
* Gets all the answers from the ballot ui question and puts them into the answers container
|
||||
* @param question
|
||||
* Checks if the answers should be randomized, if they are then randomize them
|
||||
* @param question the questions that have all the information to be reporesneted
|
||||
*/
|
||||
void UpdateAnswers(BallotQuestionUIElementOuterClass.BallotQuestionUIElement question) {
|
||||
this.RemoveAllAnswers();
|
||||
for (ByteString bytesAnswer : question.getAnswers().getAnswers().getAnswersList()){
|
||||
|
||||
List<ByteString> answers = new ArrayList<>(question.getAnswers().getAnswers().getAnswersList());
|
||||
|
||||
if (question.getRandomizeListOrder()){
|
||||
Collections.shuffle(answers);
|
||||
}
|
||||
for (ByteString bytesAnswer : answers){
|
||||
this.AddAnswer(bytesAnswer.toStringUtf8());
|
||||
}
|
||||
this.currentStage.show();
|
||||
|
@ -103,7 +113,7 @@ class StringsAnswersUpdater implements javafx.event.EventHandler{
|
|||
|
||||
/**
|
||||
* Unchecks all the check boxes that are not target box
|
||||
* @param target
|
||||
* @param target the check box which wont be unchecked
|
||||
*/
|
||||
private void uncheckBoxes(CheckBox target){
|
||||
GridPane answersContainer = this.GetAnswersContainer();
|
||||
|
|
Loading…
Reference in New Issue