public RatingQuestionReport getRatingQuestionTotalRateOnRecord(
     VoteReportFilter voteReportFilter, RatingPollingQuestion question) {
   RatingQuestionReport ratingQuestionReport = new RatingQuestionReport();
   ratingQuestionReport.setQuestion(question);
   List<AbstractQuestionAnswer> questionAnswers =
       voteDao.findVoteQuestionAnswers(voteReportFilter, question);
   ratingQuestionReport.setCount(questionAnswers.size());
   float sumOfRates = 0;
   float sumOfMaxRates = 0;
   for (int i = 0; i < questionAnswers.size(); i++) {
     sumOfRates += ((RatingQuestionAnswer) questionAnswers.get(i)).getValue();
     RatingQuestionAnswer ratingQuestionAnswer = (RatingQuestionAnswer) questionAnswers.get(i);
     List<AbstractTemplateQuestion> templateQuestions =
         ratingQuestionAnswer.getVote().getPollingTemplate().getQuestionList();
     for (int j = 0; j < templateQuestions.size(); j++) {
       if (templateQuestions.get(j) instanceof MultipleChoiceTemplateQuestion) continue;
       if (templateQuestions.get(j).getQuestion().equals(question)) {
         sumOfMaxRates += ((RatingTemplateQuestion) templateQuestions.get(j)).getMaxValue();
         continue;
       }
     }
   }
   if (sumOfMaxRates != 0) {
     ratingQuestionReport.setTotalRate((sumOfRates / sumOfMaxRates));
   }
   return ratingQuestionReport;
 }
  public MultipleChoiceQuestionReport getMultipleChoiceQuestionTotalRateOnRecord(
      VoteReportFilter voteReportFilter, MultipleChoicePollingQuestion question) {
    MultipleChoiceQuestionReport multipleChoiceQuestionReport =
        new MultipleChoiceQuestionReport(voteDao.findOptions(question));
    multipleChoiceQuestionReport.setQuestion(question);

    List<AbstractQuestionAnswer> questionAnswers =
        voteDao.findVoteQuestionAnswers(voteReportFilter, question);
    multipleChoiceQuestionReport.setCount(questionAnswers.size());
    float questionTotalWeight = calculateOptionsTotalRate(question);
    float sumOfTotalRates = questionAnswers.size() * questionTotalWeight;

    float sumOfRates = 0;

    for (int i = 0; i < questionAnswers.size(); i++) {
      MultipleChoiceQuestionAnswer multipleChoiceQuestionAnswer =
          (MultipleChoiceQuestionAnswer) questionAnswers.get(i);
      List<PollingAnswerOption> optionList = multipleChoiceQuestionAnswer.getOptionList();
      for (int j = 0; j < optionList.size(); j++) {
        PollingAnswerOption pollingAnswerOption = optionList.get(j);
        MultipleChoiceQuestionReport.OptionInfo optionInfo =
            findOptionCount(
                multipleChoiceQuestionReport.getOptionCounts(),
                pollingAnswerOption.getPollingOption());
        optionInfo.setCount(optionInfo.getCount() + 1);
        float percent =
            (new Float(optionInfo.getCount()) / new Float(multipleChoiceQuestionReport.getCount()));
        optionInfo.setPercent(Math.round(percent * 10000) / 100);
        sumOfRates += pollingAnswerOption.getPollingOption().getWeight();
      }
    }
    //        multipleChoiceQuestionReport.setOp tionCounts(optionCounts);
    if (sumOfTotalRates != 0) {
      multipleChoiceQuestionReport.setTotalRate(sumOfRates / sumOfTotalRates);
    }
    return multipleChoiceQuestionReport;
  }