Hi, I have a big problem with Views & VotingApi: (I'm using Extra Voting Forms module)

The average of 2 ratings 17 and 16 have a result of 17.0.5 instead of 16.5, why?
ex: node A
user1 rates node A 17
user2 rates node A 16
node A has an average result of 17.0.5 instead of 16.5
This is strange, doesn"t it?

ex average

11.6667 I've got this display: 12.0.6667

I don't know if it's a bug with EVF, or VotingAPI....

CommentFileSizeAuthor
#4 votingapi_cache.GIF22.96 KBJunro
#4 affiche_views.GIF4.38 KBJunro
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mercmobily’s picture

Hi,

It smells like a bug in VotingAPI.
Extra Voting Forms doesn't touch the way the average and the sum are calculated.

However... please add more information. In this case, please show the result of the relevant SELECT SQL statements after each vote, showing how the average is being calculated wrongly in the _cache table.

I will have a look... but I will most definitely ask you to move this onto VotingAPI.

Bye,

Merc.

Junro’s picture

Project: Extra Voting Forms » Voting API
Version: 6.x-1.x-dev » 6.x-2.0-beta6

As soon as I find how to have this information, i'll show you. I'm a newbie in code, so... I'm going to make some research... ^^

mercmobily’s picture

Hi,

I thought you'd wait before moving this issue to VotingAPI... However, while I am here: Eaton, I am 98% sure this has nothing to do with EVFf since I don't touch _any_ of the calculation hooks in EVF.

Bye!

Merc.

Junro’s picture

FileSize
4.38 KB
22.96 KB

Hi Merc,well I think this is not VotingApi either, it's Views who doesn't display the VotingApi average result good.
However, I put you what I found in these two files, one is the votinapi_cache et the other the display of my view with everything.

So, do you think I have to move this onto Views?

mercmobily’s picture

Hi,

I honestly don't know. I would honestly wait and see what Eaton says :-)
(The maintainer of VotingAPI!)

Bye,

Merc.

Junro’s picture

Hi, Problem not fixe with the new version of Views (6.x-2.0-rc2) and Votingapi (6.x-2.0-beta7).
Waiting Eaton takes a look ^^

eaton’s picture

This looks really funky. I have *NO* idea how it would be adding double periods and such in there; I'll take a look at the vote formatting functions to see what might be happening. Is there any way you can post an export of the view in question, too?

Junro’s picture

Hello^^

Sure, I put it in attach file, don't esitate if you want something else.

Junro’s picture

Hello Eaton, did you find to fixe the bug?

Junro’s picture

Title: View not displaying well the votingapi average result » Bug with average votingapi in View
Project: Views (for Drupal 7) » Voting API
Version: 6.x-2.1 » 6.x-2.0-beta6
Priority: Critical » Normal

Hello, I find something I didn't see before.

the display 12.0.6667 = 11.6667
the display 12.0.2223 = 12.2223 NOT 11.2223 LIKE I PUT IN THE PREVIOUS POST

If decimal >500 Integer = +1 (the display of the Integer is +1 of the good integer)
If decimal <500 Integer is good

I add this code below in the views-view-table.tpl but sure It's just hidding the bug, not resolve it.

 $recalcul=explode(".",$content);
            $sortie=$recalcul[1].".".$recalcul[2];
            switch($sortie){
            case $sortie >=0.5:
          $recalculf=$recalcul[0]-1 .".".$recalcul[2];$recalculf=sprintf("%01.1f", $recalculf);$recalculf=strtr($recalculf,array("."=>","));
          break;
          case $sortie < 0.5 && $sortie>0:
          $recalculf=$recalcul[0].".".$recalcul[2]; $recalculf=sprintf("%01.1f", $recalculf);$recalculf=strtr($recalculf,array("."=>","));
          break;
           case $sortie ==0:
          $recalculf=$content;
          break;
          }
           $fields[$field]=="value"?print $recalculf:print $content; 

I hope this bug will be resolve, so I will put off the .tpl code.

I call this bug: the bug "IP" due to the funny display of values (14.0.6667)

Thanks to Dickson for adding this code ^^

Junro’s picture

PS: I think this bug has nothing to do with VotingApi but with View.
View doesn't seem to understand the votingapi result.
I'm not using Fivestar, Maybe is the reason. I'm using Extra Voting Form with rating from 0 to 20.

Junro’s picture

Project: Voting API » Views (for Drupal 7)
Version: 6.x-2.0-beta6 » 6.x-2.1
Priority: Normal » Critical

Hi Merlin, I'm sorry putting this bug in VotingApi before, I'm sure it's a bug with Views... and I'm sure You know because you had took off one of the code error.
The Bug "IP" (I call it IP) has change with the new version 2.1, and It's always wrong. You has took off just the "0.", I explain you:

with old version
11.6667 = 12.0.6667
12.2223 = 12.0.2223

with new version
11.6667 = 12.6667
12.2223 = 12.2223

I think you will understand just with this exemple lol.

So I rectified again my code to have the code result.

I hope this post will help you to change your code. If you need something to better understant the bug "IP", don't hesitate, ask me ^^ :)

Junro’s picture

Title: Bug with average votingapi in View » View not displaying well the votingapi average result

just changing the title of the post ^^

kwemart’s picture

new code for debuging views's displaying of result;

 if(is_numeric($content)){ $recalcul=explode(".",$content);}
            $sortie="0.".$recalcul[1];
            switch($sortie){
            case $sortie >=0.5:
         $recalculf=$recalcul[0]-1+$sortie; $recalculf=sprintf("%01.1f", $recalculf);
          break;
          case $sortie < 0.5 && $sortie>0:
          
          $recalculf=$recalcul[0]+$sortie; $recalculf=sprintf("%01.1f", $recalculf);
          break;
           case $sortie ==0:
        $recalculf=$content;
          break;
          
            }
           $fields[$field]=="value"?print $recalculf:print $content; 

merlinofchaos’s picture

Title: Bug with average votingapi in View » View not displaying well the votingapi average result
Project: Voting API » Views (for Drupal 7)
Version: 6.x-2.0-beta6 » 6.x-2.1
Priority: Normal » Critical
Status: Active » Fixed

Fixed in CVS.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.