function advpoll_update_choices in Advanced Poll 7        
                          
                  
                        Same name and namespace in other branches
- 7.3 advpoll.module \advpoll_update_choices()
- 7.2 advpoll.module \advpoll_update_choices()
2 calls to advpoll_update_choices()
  - advpoll_display_borda_results in advpoll_ranking/advpoll_ranking.module
- advpoll_display_results in ./advpoll.module
File
 
   - ./advpoll.module, line 430
Code
function advpoll_update_choices($choices, $results) {
  $choiceSet = array();
  foreach ($choices as $choice) {
    $choiceSet[$choice['choice_id']] = $choice['choice'];
  }
  $final = array();
  foreach ($results as $result) {
    $final[] = array(
      'title' => $choiceSet[$result['index']],
      'percentage' => $result['percentage'],
      'votes' => $result['votes'],
      'tag' => $result['index'],
    );
    
    unset($choiceSet[$result['index']]);
  }
  
  if (count($choiceSet) > 0) {
    foreach ($choiceSet as $key => $choice) {
      $final[] = array(
        'title' => $choice,
        'percentage' => 0,
        'votes' => 0,
        'tag' => $key,
      );
    }
  }
  return $final;
}