Rating Average
Posted: 23 April 2008 02:54 PM   [ Ignore ]
Newbie
Rank
Total Posts:  10
Joined  2005-07-19

Hi there,

I am using the review module to obtain user reviews on restaurants. Within each review the user rates the restaurant on 4 criteria - food, service, ambience and value. Each user has a profile page on the web site which details all the content they have contributed to the site. I have managed to list the reviews for a specific user using rating_author_id="1" but the problem I have is that I can not figure out how to display the overall star rating which is an average of the 4 criteria previously mentioned.

Here is my code as it stands, but it does not display the average star rating.

{exp:rating:entries form_name="restaurants" rating_author_id="1" theme="black14" limit="20" dynamic="off"}
<li><div class="stars">{stars}{rating}{/stars}</div>{title}</li>
{/exp:rating:entries}

I have tried {stars}{rating}{/stars} as above, {stars}{avg_rating}{/stars} and all sorts, without success.

Any ideas?

Thanks
Martin

Profile
 
 
Posted: 24 April 2008 01:01 AM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  10
Joined  2005-07-19

Ok, eventually realised after looking at the sql that the variable I was after was {rating_avg} (could have sworn I tried that first!)

But I have now run into another issue. Perhaps i’m doing something stupid but I can’t see it. My code as is stands is:

{exp:rating:entries form_name="restaurants" rating_author_id="1" theme="black14" limit="20" dynamic="off"}
<li><div class="stars">{stars}{rating_avg}{/stars}</div> {rating_avg} <a href="/eating-out/details/{url_title}">{title}</a> <span class="meta">&mdash; {rating_date format='%l  %d.%m.%y'}</span></li>
{/exp:rating:entries}

The problem is that it does not display the stars correctly, mysteriously adding an extra star sometimes. See attached screen shot.

My first thought was it was something to do with precision so I tried the precision parameter but that didn’t help.

Any ideas?

Thanks
Martin

Image Attachments
Picture 1.png
Profile
 
 
Posted: 24 April 2008 07:03 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

Hmmm… it appears only the ratings with Decimals are generating the extra star…

Give this parameter a whirl and see what happens:

precision="0"

 Signature 
Profile
 
 
Posted: 24 April 2008 09:37 AM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  10
Joined  2005-07-19

precision="0" does not work or anything else. It would appear having a quick look under the hood at the code that {stars}{/stars} simply does not handle decimals. Looks like a bug/oversight and some code needs to be copied from the section invoked by {stars_overall_avg} (which does handle decimals).

Profile
 
 
Posted: 24 April 2008 11:29 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  10
Joined  2005-07-19

I should also say that even if precision = “0” did solve the extra star problem, which it doesn’t, then that would still not give the desired effect as I display half stars elsewhere when using {stars_overall_avg} within the exp:rating:stats. Obviously I can not use exp:rating:stats in this case due to the context.

Profile
 
 
Posted: 25 April 2008 07:53 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

Thanks for the Bug Fix email smile

 Signature 
Profile