Hi guys.

I would love to have the option to rate in half star increments. So there would be 10 options all together for 5 stars. These being

0.5 - 1.0 - 1.5 - 2.0 - 2.5 - 3.0 - 3.5 - 4.0 - 4.5 - 5.0

I guess I don't actually need it to rate like that, if there is a way to use the 10 star option, but graphically make it look like you are rating in half star increments that will do fine too.

These guys have some none drupal ideas on it

http://examples.learningjquery.com/rating/

Cheers.

Comments

vzey’s picture

I really need this, but don't know how to make it work.

What if there was a way to use the 10 star option, and have each alternative star show up as half, and just put each pair close together to give the illussion of having five stars? There must be some smart cookie out there who can make this happen :)

quicksketch’s picture

Yup, there's an 'even' and 'odd' CSS class put on every star, so you just have to write the css necessary to display the first half of a star on every odd star and the second half of a star on the second have and then you'll have voting in halves.

moshe weitzman’s picture

you can setup a 1-10 schema with css as quicksketch suggests. so it will look like you can vote with half stars. but unless you fiddle some more, your ratings will be recorded as with scores up to 10, and not 5. so appearance fiddling is not enough I think. needs some code changes.

domesticat’s picture

Agreed. This would be useful to me as well. I'm considering offering to help someone convert his movie-reviews site to drupal, and he rates in half-star increments. I fear this not having this feature will be a deal-breaker.

quicksketch’s picture

All results are stored in VotingAPI from 1-100, so the number of stars you use doesn't affect the data storage. In a 5 star system, 1 star is stored as 20. In a 10 star system, 2 stars are stored as 20 (3 stars as 30). No code changes should be necessary other than CSS changes.

Anonymous’s picture

Version: 5.x-1.7 » 6.x-1.13

The module would have to be modified if you wanted to use half star ratings. Using Css you can successfully change the stars to look like half stars and it functions pretty well but the first problem I ran into is when the average is calculated for the stars. When the average is calculated the fivestar.js adds a style="width: 50%" which will make your stars 1/2 smaller and when they are already 1/2 smaller it will make them 1/4 the size destroying appearance. Also you would have to change the code that displays the averages because using a css only method would store the vote as an 8 when it is supposed to be a 4. And a vote of 4.5 would be stored as a 9 and when 8 and 9 are average together the average that is displayed is 8.5.

Flying Drupalist’s picture

Version: 6.x-1.13 » 6.x-1.14

I haven't tried this yet but this sounds like a big problem: When the average is calculated the fivestar.js adds a style="width: 50%" which will make your stars 1/2 smaller and when they are already 1/2 smaller it will make them 1/4 the size destroying appearance.

Anyone have some css to share in general?

angusmccloud’s picture

Last night i ended up implementing this.

What I did was create two different sets of stars (the right half and the left half) -- then I used the Craft stars as a base because they were the only one that was using different images for each star. I then changed which images are referenced so all the odd numbers use the left side, the even numbers use the right side. (there was a little more with changing the width so they're all the same, etc).

Pretty simple once I figured out what I was trying to do...

Sotek’s picture

Hello everyone,

It seems that it only takes a modification of the .css to get half star increments.

I use it for reviewing books and movies, so user don't vote.

May you please be so kind as to share the code that should be changed or added in the .css ?

It would be very much appreciated!

Thank you.

paganwinter’s picture

Subscribing...
Have done this... Will post the css tomorrow, if anyone's still interested.

paganwinter’s picture

This did the trick for me.

Used 10 stars for rating my nodes (stars as cck field), but wanted visitors to see just 5.
Haven't yet seen what happens on stars that are already half (avg.) because I am using this as a CCK field, and not for rating by users, yet...

Assuming your images are of size 16x16 (each star - on, off, hover) (Ref: http://drupal.org/node/234391)

div.fivestar-widget-static .star {
  width: 8px !important;
}
div.fivestar-widget-static .star-even {
  background-position: -8px;
}
div.fivestar-widget-static .star-even span.on {
  background-position: -8px -32px;
}
div.fivestar-widget-static .star-even span.off {
  background-position: -8px 0;
}
buzzman’s picture

Hi angusmccloud:
If possible, can you plz share the code with which you were able to achieve this?
cheers

fitter’s picture

Subscribing as well. A possible solution may be the way the node author inputs the rating (instead of selecting stars, the node author can input a integer value out of /100, as it seems all the ratings are converted to a 100 point scale in the long run [I could be wrong?]). However this will be an ugly solution for viewer ratings, and being able to actually select half stars would be a proper solution.

gtsongi’s picture

Can someone give a detailed explanation how to do this?? It's urgent!

izmeez’s picture

subscribing

silencery’s picture

Subscribing

fitter’s picture

Would treating the CCK rating field as a multi axis rating (i.e. giving it a axis name of overall) work? What I mean is setting the stars as 10 for the CCK field then outputting that field on the theme with only 5 stars.

Like so:

$rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'overall', 'function' => 'average'));
print theme('fivestar_static', $rating[0]['value'], '5');

Right now this isn't displaying anything form me and it could just be my code.

Any ideas?

*EDIT*

Doing the above didn't work for me, but doing the below did.

Fixed it for my instance.

Using a 10 star CCK field rating then outputting it on the theme as:

print theme('fivestar_static', $node->field_rating[0]['rating'], '5');

Where $node->field_rating is your CCK field's name and where 5 is the number of stars you want

It essentially just halves the 10 star rating to fit 5 stars. :-) This doesn't mess with CSS due to the fact that if I did the CSS solution it would destroy my user ratings that I have on my site that are already half ratings.

quicksketch’s picture

It essentially just halves the 10 star rating to fit 5 stars.

No matter how many stars you use, Fivestar ALWAYS converts them to a score of 100. If displaying 5 stars, each star is worth 20. If displaying 10 stars, each one is worth 10. Setting the main configuration to 10 stars and then theming it to display 5 is in no way different from just configuring it to display 5 stars to begin with. You can always convert from 5 to 10 stars at any time and the stars will automatically be adjusted, since no matter what they're always working with a score out of 100 anyway.

I've said it before. There is NO REASON why you can't have half-star increments right now. Apparently no one knows how to write CSS anymore. Look at how star sets like "Craft" already have separate icons for every star. All you need is to theme one half of the star on "odd" classes and the other half on "even" ones. That's it.

fitter’s picture

Wouldn't that mess with user ratings which are already half stars via average?

quicksketch’s picture

Seems paganwinter already added some CSS above. His approach is just what I meant. You shouldn't need to do any PHP to accomplish half-stars. Set the number of stars to 10 and then add the above CSS to a custom fivestar.css file.

fitter’s picture

When applying the solutions CSS does not effect user vote averaging for anyone also trying to do this. CSS would be the best solution as quicksketch says.

rahadgp’s picture

The css is not working for me. the html structure is like :

<div class="fivestar-widget clearfix fivestar-widget-5">
<div class="star star-1 odd star-first on">
<a title="Give it 1/5" href="#20">Give it 1/5</a>
</div>

<div class="star star-2 even on">
<a title="Give it 2/5" href="#40">Give it 2/5</a>
</div>

<div class="star star-3 odd on">
<a title="Give it 3/5" href="#60">Give it 3/5</a>
</div>

<div class="star star-4 even on">
<a title="Give it 4/5" href="#80">Give it 4/5</a>
</div>

<div class="star star-5 odd star-last">
<a title="Give it 5/5" href="#100">Give it 5/5</a>
</div>

</div>

Please help...

xbrianx’s picture

Issue summary: View changes

The issue here for me is not CSS, but what if you are creating your own personal ratings so there is only 1 vote, but you want to display a rating of 8.5. I don't see an option of how to set ratings such as this.

GemVinny’s picture

Did anyone come up with a solution for this?

I have a taxonomy page thats listing stars - the css works but it only properly works for 1.5 stars.

If there's anymore then it shows as star / half star / start /half star - where obviously only the half should show at the end.

I suppose we need a bit of js for this?

GemVinny’s picture

I tried something like this:

  if( $('.node-teaser .fivestar-widget-static').length > 0 ) {
    $(".node-teaser .fivestar-widget-static").each(function() {
      $(this).children(".star .on:last").addClass('last-active-star');
    });
  }

I was going to do something like that and hide if it wasn't the last one, but that didn't work so back to square one.

dahousecat’s picture

I've created a module to alter Fivestar to allow voting with half stars.

I'm currently going though the review process to get access to release full projects so it is only a sandbox project at present:

Halfstar

I hope it should provide a definitive solution to this problem.

whiteph’s picture

Status: Active » Closed (won't fix)

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