Hi,
For those who might be interested, I've found an easy way to modify the poll block in oder get the results that I was looking for...
After standard poll block has been installed successfully:
(a) Edit block_poll.php as follow:
Change:
function poll_get_results(&$results, $sort = true) {
foreach ($this->options as $option) {
$responses = get_records('block_poll_response', 'optionid', $option->id);
$results[$option->optiontext] = (!$responses ? '0' : count($responses));
}
if ($sort) { poll_sort_results($results); }
}
With:
function poll_get_results(&$results, $sort = true) {
$totalvotes = 0;
foreach ($this->options as $option) {
$responses = get_records('block_poll_response', 'optionid', $option->id);
$totalvotes = $totalvotes + (!$responses ? '0' : count($responses));
}
foreach ($this->options as $option) {
$responses = get_records('block_poll_response', 'optionid', $option->id);
$results[$option->optiontext] = (!$responses ? '0' : round(count($responses)/$totalvotes*100,0))."%";
}
if ($sort) { poll_sort_results($results); }
}
Change:
$func = 'poll_print_' . (!$response && $this->poll_user_eligible() ? 'options' : 'results');
With:
session_start();
if(isset($_SESSION['re-submit_poll'])) {
$func = 'poll_print_results';
} else {
$func = 'poll_print_options';
}
(b) Edit poll_action.php as follow:
Change:
case 'respond':
if (!get_record('block_poll_response', 'pollid', $pid, 'userid', $USER->id)) {
$response = new Object();
$response->id = 0;
$response->pollid = $pid;
$response->optionid = required_param('rid', PARAM_INTEGER);
$response->userid = $USER->id;
$response->submitted = time();
insert_record('block_poll_response', $response);
}
With:
case 'respond':
$response = new Object();
$response->id = 0;
$response->pollid = $pid;
$response->optionid = required_param('rid', PARAM_INTEGER);
$response->userid = $USER->id;
$response->submitted = time();
insert_record('block_poll_response', $response);
session_start();
$_SESSION['re-submit_poll'] = 1;
Users (guests or already authentificated) would be able to vote multiple times, as soon as their current sessions are terminated/closed and they start a new one.
Hope it helps for you.
-Cesar R