Package com.dotmarketing.cms.polls.business

Examples of com.dotmarketing.cms.polls.business.PollsAPI


   * @param questionId
   * @param showVotes
   * @return
   */
  public PollsAjax.VoteAnswer displayPollResults(String questionId, boolean showVotes) {
    PollsAPI pollsAPI = APILocator.getPollAPI();
    NumberFormat numberFormat = NumberFormat.getNumberInstance();
    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    StringBuffer htmlResult = new StringBuffer(512);
    htmlResult.ensureCapacity(128);

    int totalVotes = pollsAPI.getTotalVotes(questionId);
    PollsQuestion question = pollsAPI.getQuestion(questionId);

    List choices = pollsAPI.getChoices(questionId);

    htmlResult.append("<div id='result" + questionId + "'>");
    //htmlResult.append("<h2>" + question.getDescription() + "</h2>");
    htmlResult.append("<table class='poll-result-table'>");

    for (int i = 0; i < choices.size(); i++) {
      PollsChoice choice = (PollsChoice) choices.get(i);

      int choiceVotes = pollsAPI.getChoiceVotes(questionId, choice
          .getChoiceId());

      double votesPercent = 0.0;
      if (totalVotes > 0) {
        votesPercent = (double) choiceVotes / totalVotes;
View Full Code Here

TOP

Related Classes of com.dotmarketing.cms.polls.business.PollsAPI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.