<?php if (isset($vars['entity'])) { $poll = $vars['entity']; //set up our variables $question = $poll->question; $tags = $poll->tags; $access_id = $poll->access_id; } else { register_error(elgg_echo("polls:blank")); forward('polls/all'); } //convert $responses to radio inputs for form display $responses = polls_get_choice_array($poll); if ($poll->multiple_choices == 'enabled') { $response_inputs = elgg_view('input/checkboxes', array('name' => 'response', 'options' => $responses)); } else { $response_inputs = elgg_view('input/radio', array('name' => 'response', 'options' => $responses)); } // add "add response" box if ($poll->add_response == 'enabled') { $add_response_input = elgg_view('input/hidden', array('name' => 'number_of_choices', 'id' => 'number_of_choices', 'value' => 0)); $add_response_input .= elgg_view('input/hidden', array('name' => 'poll_guid', 'id' => 'poll_guid', 'value' => $poll->guid)); $add_response_input .= '<div id="new_choices_area"></div>'; $add_response_input .= elgg_view('input/button', array('id' => 'add_choice', 'value' => elgg_echo('polls:add_choice'), 'type' => 'button')); $add_response_input .= elgg_view('input/submit', array('name' => 'add_choice-submit', 'value' => elgg_echo('polls:validate_new_choices'))); } $submit_input = '<br />' . elgg_view('input/submit', array('name' => 'vote-submit', 'value' => elgg_echo('polls:vote'))); if (isset($vars['entity'])) { $entity_hidden = elgg_view('input/hidden', array('name' => 'guid', 'value' => $poll->guid)); $entity_hidden .= elgg_view('input/hidden', array('name' => 'callback', 'value' => $vars['callback']));
<?php /** * Elgg polls plugin * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 */ if (isset($vars['entity'])) { //set img src $img_src = elgg_get_site_url() . "mod/polls/graphics/poll.gif"; $question = $vars['entity']->question; //get the array of possible responses $responses = polls_get_choice_array($vars['entity']); //get the array of user responses to the poll $user_responses = $vars['entity']->getAnnotations('vote', 9999, 0, 'desc'); //get the count of responses $user_responses_count = $vars['entity']->countAnnotations('vote'); //create new array to store response and count //$response_count = array(); ?> <p><h3> <?php echo elgg_echo('polls:totalvotes') . $user_responses_count; ?> </h3></p><hr> <?php //populate array foreach ($responses as $response) { //get count per response $response_count = polls_get_response_count($response, $user_responses); //calculate % if ($response_count && $user_responses_count) {