The user can vote. The vote status text under the star icons shows that the vote is being saved and the vote is saved. However, when I load the content again it says vote is not casted yet!

Any suggestion?

Comments

ezra-g’s picture

Status: Active » Fixed

Please update to the latest dev snapshot release and re-open this issue if the problem persists.

udvranto’s picture

Status: Fixed » Active

Installed the latest dev snapshot. The problem still persists.

udvranto’s picture

Status: Active » Needs review

I found the problem. This is probably related to this voting api problem (and the fix I am using): http://drupal.org/node/768284 .

To fix it I had to modify the fivestar_get_votes function. I am using the following fixed version. Note how I had to get the count using the 'points' criteria:

function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) {
  global $user;

  if (!isset($uid)) {
    $uid = $user->uid;
  }

  $votes = array(
    'average' => array(),
    'count' => array(),
    'user' => array(),
  );

  $criteria = array(
    'content_type' => $type,
    'content_id' => $cid,
    'value_type' => 'points',
    'tag' => $tag,
  );

  $results = votingapi_select_results($criteria);
  foreach ($results as $result) {
    if ($result['function'] == 'count') {
      $votes['count'] = $result;
    }
  }

  $criteria['value_type'] = 'percent';

  $results = votingapi_select_results($criteria);
  foreach ($results as $result) {
    if ($result['function'] == 'average') {
      $votes['average'] = $result;
    }
  }

  if ($uid) {
    $user_vote = votingapi_select_votes($criteria += array('uid' => $uid));
    if ($user_vote) {
      $votes['user'] = $user_vote[0];
      $votes['user']['function'] = 'user';
    }
  }
  else {
    // If the user is anonymous, we never bother loading their existing votes.
    // Not only would it be hit-or-miss, it would break page caching. Safer to always
    // show the 'fresh' version to anon users.
    $votes['user'] = array('value' => 0);
  }

  return $votes;
}
StevenWill’s picture

subscribing

dgtlmoon’s picture

Yeah it kind of sort-of vaguely works when I try your method above, but it's still not right, under current 6.x dev it now says
Your rating: None Average: 0 (96 votes

hmm

udvranto’s picture

Not sure why this wouldn't work. You output looks exactly like the unpatched function output. Please, make sure you patched/updated the function correctly.

whiteph’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

Sorry, Drupal 6 is end of life, and is no longer supported.