/**
   * Get ratings and feedbacks
   *
   * @return list of ratings and feedbacks in Rating objects
   * @throws SQLException
   */
  public ArrayList<Rating> getRatingsAndFeedbacks() throws SQLException {
    String sql = "SELECT * FROM Rating";

    try {
      Statement statement = (Statement) connection.createStatement();
      ResultSet rs = statement.executeQuery(sql);
      ArrayList<Rating> list = new ArrayList<>();

      while (rs.next()) {
        Rating rating = new Rating();
        rating.setCID(rs.getInt("cID"));
        rating.setFeedback(rs.getString("feedback"));
        rating.setStars(rs.getInt("stars"));

        list.add(rating);
      }

      if (statement != null) {
        statement.close();
      }
      return list;
    } catch (SQLException e) {
      e.printStackTrace();
      System.out.println("Error! Cannot get ratings and feedbacks");
      return null;
    }
  }
  @FXML
  private void ratingButtonClicked(ActionEvent event) throws SQLException {
    configureButtons();
    ratingButton.setGraphic(ratingSelectedIMV);

    // clear old content
    contentPane.getChildren().clear();

    // set up
    titleLabel.setText("Rating and Feedback");

    // rating box
    HBox ratingBox = new HBox();
    ratingBox.setAlignment(Pos.CENTER);
    ratingBox.setSpacing(20);
    ratingBox.setPadding(new Insets(10, 0, 10, 0));

    // Rating label
    Label ratingTitle = new Label("Average Rating: ");
    ratingTitle.setFont(new Font("System", 24));

    // 5 stars
    String yellowStarURL = "Graphics/StarYellow.png";
    String blankStarURL = "Graphics/StarBlank.png";

    ImageView starBlank1 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank2 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank3 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank4 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank5 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));

    Button star1 = new Button();
    star1.setGraphic(starBlank1);
    star1.setStyle("-fx-background-color: transparent");
    Button star2 = new Button();
    star2.setGraphic(starBlank2);
    star2.setStyle("-fx-background-color: transparent");
    Button star3 = new Button();
    star3.setGraphic(starBlank3);
    star3.setStyle("-fx-background-color: transparent");
    Button star4 = new Button();
    star4.setGraphic(starBlank4);
    star4.setStyle("-fx-background-color: transparent");
    Button star5 = new Button();
    star5.setGraphic(starBlank5);
    star5.setStyle("-fx-background-color: transparent");

    // get average rating
    double avgRating = 0;
    try {
      avgRating = operation.getAverageRating();
    } catch (SQLException e) {
      e.printStackTrace();
      ratingTitle.setText("Error! Can't get average rating");
    }

    Button[] buttonlist = new Button[5];
    buttonlist[0] = star1;
    buttonlist[1] = star2;
    buttonlist[2] = star3;
    buttonlist[3] = star4;
    buttonlist[4] = star5;

    for (int i = 0; i < Math.floor(avgRating); i++) {
      ImageView image = new ImageView(new Image(getClass().getResourceAsStream(yellowStarURL)));
      buttonlist[i].setGraphic(image);
    }

    // feedback box
    VBox feedBackBox = new VBox();
    feedBackBox.setAlignment(Pos.CENTER);
    feedBackBox.setSpacing(20);

    // Feedback title
    Label feedBackLabel = new Label("Feedback:");
    feedBackLabel.setFont(new Font("System", 24));

    // get feedback string
    String feedback = "";
    ArrayList<Rating> list = operation.getRatingsAndFeedbacks();

    for (Rating r : list) {
      feedback += r.getFeedback() + "\n\n";
    }

    Text feedbackText = new Text(feedback);
    feedbackText.setFont(new Font("System", 14));

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(feedbackText);

    // Add children nodes to appropriate boxes
    ratingBox.getChildren().addAll(ratingTitle, star1, star2, star3, star4, star5);
    feedBackBox.getChildren().addAll(feedBackLabel, scrollPane);

    // main box
    VBox mainBox = new VBox();
    mainBox.setSpacing(40);
    mainBox.getChildren().addAll(ratingBox, feedBackBox);

    contentPane.getChildren().add(mainBox);
  }