function advpoll_ranking_process_rows in Advanced Poll 7.2
Same name and namespace in other branches
- 7.3 advpoll_ranking/advpoll_ranking.module \advpoll_ranking_process_rows()
- 7 advpoll_ranking/advpoll_ranking.module \advpoll_ranking_process_rows()
1 call to advpoll_ranking_process_rows()
- advpoll_ranking_votes_page in advpoll_ranking/
advpoll_ranking.module - Display the overridden votes page. Uses almost the same output but allows grouping for borda and instant-runoff.
File
- advpoll_ranking/
advpoll_ranking.module, line 686
Code
function advpoll_ranking_process_rows($rows) {
$users = array();
$sorted = array();
$votes = array();
$final = array();
// get selections by user and put a single row of data in the sorted list by user.
foreach ($rows as $row) {
$user = strip_tags($row['data'][0]);
// store choices with index being the value assigned to that choice
$votes[$user][$row['data'][3]] = $row['data'][2];
if (!in_array($user, $users)) {
$users[] = $user;
// remove vote value column since we do not want to display it in the table.
unset($row['data'][3]);
$sorted[] = $row;
}
}
// Now match up and rank user selections with the user's unique row.
foreach ($sorted as $row) {
$user = strip_tags($row['data'][0]);
$choices = $votes[$user];
rsort($choices);
$choice = implode(' > ', $choices);
$row['data'][2] = $choice;
$final[] = $row;
}
$rows = $final;
return $rows;
}