// load the quiz
@Override
    public void initialize(URL location, ResourceBundle resources) {
        // load the quiz
        for (Question question : quiz.questions) {
            questionsList.getItems().add(question.title);
        }
        populateView();
        questionTextField.setOnKeyReleased(e -> {
            questionsList.getItems().set(currentQuestionIndex, questionTextField.getText());
            quiz.questions.get(currentQuestionIndex).title = questionTextField.getText();
            saved = false;
        });
        newAnswerButton.setOnMouseClicked(e -> {
            quiz.questions.get(currentQuestionIndex).options.add(new Option(""));
            addAnswer(questionsTilePane.getChildren().size());
            saved = false;
        });
        rightAnswerComboBox.setOnAction(e -> {
            if (rightAnswerComboBox.getItems().size() > 0) {
                currentQuestion.answer = rightAnswerComboBox.getSelectionModel().getSelectedIndex();
            }
            saved = false;
        });
        questionsList.setOnMouseClicked(e -> {
            int selectedIndex = questionsList.getSelectionModel().getSelectedIndex();
            if (selectedIndex < quiz.questions.size() && selectedIndex >= 0) {
                currentQuestionIndex = selectedIndex;
                currentQuestion = quiz.questions.get(selectedIndex);
            }
            populateView();
            saved = false;
        });
        newQuestionButton.setOnAction(e -> {
            newQuestion();
            questionsList.getItems().add("");
            currentQuestion = this.quiz.questions.get(currentQuestionIndex);
            populateView();
            saved = false;
        });
        deleteQuestionButton.setOnAction(e -> removeQuestion());
        quizOptionsButton.setOnAction(e -> {
            Stage stage = new Stage();
            Window win = new Window(window.getApp(), stage, "Settings for '" + quiz.name + "'");
            win.openView(new QuizSettingsPopupControl(quiz));
            saved = false;
        });
        maxPointsTextInput.addEventFilter(KeyEvent.KEY_TYPED, e -> {
            if (e.getCharacter().matches("[\\D]")) {
                e.consume();
            }
        });
        maxPointsTextInput.setOnKeyReleased(e -> {
            if (!maxPointsTextInput.getText().isEmpty()) {
                currentQuestion.maxReward = Integer.parseInt(maxPointsTextInput.getText());
            } else {
                currentQuestion.maxReward = 50; // TODO un hardcode this
            }
            saved = false;
        });
        FileMenu.getItems().get(2).setOnAction(e -> {
            if (!saved) {
                askForSave();
                closeApp = false;
            } else {
                window.openView(new ChooseQuizScreenControl(true));
            }
        });
        FileMenu.getItems().get(0).setOnAction(e -> InitSave());
        FileMenu.getItems().get(1).setOnAction(e -> {
            openSaveDialog();
        });
        window.getStage().setOnCloseRequest(e -> {
            if (!saved) {
                e.consume();
                askForSave();
                closeApp = true;
            }
        });
    }
@Override
public void initialize(URL location, ResourceBundle resources) {
// load the quiz
for (Question question : quiz.questions) {
questionsList.getItems().add(question.title);
@Override
public void initialize(URL location, ResourceBundle resources) {
// load the quiz
for (Question question : quiz.questions) {
questionsList.getItems().add(question.title);
}
populateView();
questionTextField.setOnKeyReleased(e -> {
questionsList.getItems().set(currentQuestionIndex, questionTextField.getText());
quiz.questions.get(currentQuestionIndex).title = questionTextField.getText();
saved = false;
});
newAnswerButton.setOnMouseClicked(e -> {
@Override
public void initialize(URL location, ResourceBundle resources) {
// load the quiz
for (Question question : quiz.questions) {
questionsList.getItems().add(question.title);
}
populateView();
questionTextField.setOnKeyReleased(e -> {
questionsList.getItems().set(currentQuestionIndex, questionTextField.getText());
quiz.questions.get(currentQuestionIndex).title = questionTextField.getText();
saved = false;
});
newAnswerButton.setOnMouseClicked(e -> {
quiz.questions.get(currentQuestionIndex).options.add(new Option(""));
addAnswer(questionsTilePane.getChildren().size());
saved = false;
});
rightAnswerComboBox.setOnAction(e -> {
if (rightAnswerComboBox.getItems().size() > 0) {
currentQuestion.answer = rightAnswerComboBox.getSelectionModel().getSelectedIndex();
}
saved = false;
});