Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Reviews Question

Quote Reply
Reviews Question
I'm new to the reviews in Links SQL, and am a little confused. Are the simple ratings from the Rate It link (1 - 10) separate from the review ratings Review It link (1 - 5)? It seems like they are, but I can't figure out why that would be. I was hoping that it would be possible to come up with an average rating for a specific link (averaging both the simple number ratings, and the review ratings) and then display that as an image (stars) on the link.html template, in addition to linking to the review page (i.e. domain.com/links/review.cgi?ID=25) showing all of the individual review information/stats, etc. on the reviews page. Does anyone know if that's even possible?

-Katy L.
Quote Reply
Re: [katy] Reviews Question In reply to
I do this on my site. However, it is not straightforward. It does involve editing the core code which you will need to redo everytime your Links version. If you still want to do this let me know and I'll try to find all the mods needed.

Laura.
The UK High Street
Quote Reply
Re: [afinlr] Reviews Question In reply to
Thanks very much for letting me know about this. I understand what you mean that core code would need to get modified (and re-modified for any new Links SQL versions). If you are able to post your mods here to make this work that would be wonderful.

--Katy L.
Quote Reply
Re: [katy] Reviews Question In reply to
I thought about this afterwards - I think you could do this without modifying the code if you keep the review ratings as 1 to 5 but I just thought this was a bit inconsistent. I wanted to make them all equivalent so I changed all the review ratings to 1 - 10.

To change these you need to:

1. Change the regex in the properties of the rating field for the Reviews table

^\d{1,2}$

2. In Review.pm change all the 5s to 10.

3. In Review.pm find this line and change the * to {1,2}

# Make sure we have a valid rating.
unless (($input->{Review_Rating} =~ /^\d{1,2}$/) and ($input->{Review_Rating} >= 1) and ($input->{Review_Rating} <= 10))

4. Add this global called average_rating

sub {
my $rec = shift;
my $reviews = $DB->table('Reviews');
my ($review_stats,$review_count);
%$review_stats = map {$_ => $reviews->count({ Review_LinkID => $rec->{ID}, Review_Rating => $_, Review_Validated => 'Yes'})} (1..10);
$review_count = $reviews->count({ Review_LinkID => $rec->{ID}, Review_Validated => 'Yes'} );
my $average=0;
if ($review_count) {
for (1..10) {
$average=($average+($review_stats->{$_}*$_));
}
$rec->{'Rating'}=(($rec->{'Rating'}*$rec->{'Votes'})+ $average)/($review_count + $rec->{'Votes'});
$rec->{'Votes'}=($rec->{'Votes'}+$review_count);
}
return $rec;
}

5. In your link and detailed templates (and any others you might have created which show the rating) add <%average_rating%> somewhere in the template before you use <%Rating%> or <%Votes%>.

I think that's about it but I may have forgotten something.

Edit: I did forget! Obviously you need to change the review templates to allow the user to choose a rating of 1 to 10.

Edit2: There's also an error message which needs changing at Build>Language>Reviews

Laura.
The UK High Street

Last edited by:

afinlr: Apr 27, 2003, 1:55 PM
Quote Reply
Re: [afinlr] Reviews Question In reply to
Thank you! I followed your directions and was able to get the average rating onto the link template. I think I'll just add some conditional statements on the link.html template to display the various options for star rating graphics. I really appreciate your help! Smile

-Katy
Quote Reply
Re: [afinlr] Reviews Question In reply to
Hi I was just sifting through posts and looking fro stuff about using images instead of the simple average number and stumbled across your post. I had been thinking about looking for this kind of modification and "voilą". Smile
I'm actually using the latest 2.2.0 version that I'm trying to fine tune to my needs. Do you know if the modifications you so kindly share here work with the 2.2.0 version ?

Also I was wondering, do you implement weighting for review rating as opposed to guest rating or is the global average a straight forward average.
Is there a system/a mod that you know of that enables editors to vote for a link and this be weighted and or simply included in the average ?

Thanks, John
Significant Media
Quote Reply
Re: [Jag] Reviews Question In reply to
Hi,

I think that these modifications should work with the new version.
I'm using a straightforward average but you could easily modify the global to create a weighted average.

I'm not sure about the editors' rating - I'm sure this has been discussed before but I don't use editors on my site so it isn't something I've investigated.
Quote Reply
Re: [afinlr] Reviews Question In reply to
Hi,

Thanks for your response. I've just tried editing the different parts as you explain. However I'm not sure about the result. I'm not getting anything in the <%average_rating%> Is this normal, shouldn't it display a number or something ?

I've attached what I did to Review.pm and I added the <%average_rating%> to globals.

At the moment in the admin panel the review I can see is set at 5 when through the review_add I gave it 8 !?

I wasn't sure what you meant in 3. where you put : "3. In Review.pm find this line and change the * to {1,2} " What does "*" refer to ? The only "*" I could find was line 161 :
$review_stats->{'p'.$_} = ($review_stats->{$_}*150)/$review_count;
and it doesn't seem to make sense to replace it here.

Any Ideas,

Thanks

John
Significant Media
Quote Reply
Re: [Jag] Reviews Question In reply to
All your changes look correct.

I can't really see how your review can have been given a rating of 5 if you selected 8 - unless when you were adding the extra radio fields in the template, you just copied the last one and didn't remember to change the value?

You won't get anything where you put the average_rating tag - this is just to convert the Votes and Rating tags to the correct average values. You need to put it somewhere in the template before you use <%Votes%> or <%Rating%>
Quote Reply
Re: [afinlr] Reviews Question In reply to
Hi,

I've just tried with a new link Review Rating of 4 and Vote of 8, Average 6. Which is OK, (me and maths Unsure) Then I read your response and this it what I had done wrong (value pasting without modifying as you guessed):

<input type="radio" name="Review_Rating" value="1"> 1
<input type="radio" name="Review_Rating" value="2"> 2
<input type="radio" name="Review_Rating" value="3"> 3
<input type="radio" name="Review_Rating" value="4"> 4
<input type="radio" name="Review_Rating" value="5"> 5
<input type="radio" name="Review_Rating" value="5"> 6
<input type="radio" name="Review_Rating" value="5"> 7
<input type="radio" name="Review_Rating" value="5"> 8
<input type="radio" name="Review_Rating" value="5"> 9
<input type="radio" name="Review_Rating" value="5"> 10

Sorry to have been an idiot ! Blush

It's now working. Thanks for your help

John
Significant Media
Quote Reply
Re: [afinlr] Reviews Question In reply to
Hi there -

I had to redo my whole site Pirate which had all of the bells and whistles, lucky for me most of them are now out of the box from Andy's plugin pack.
Well, I had it set up like you have written but need to redo with the new version 3.2.

Have you upgraded your site and used this mod? I need to install it again.

Thanks Much!