Discussion about this feature is already done in this thread: http://drupal.org/node/126681.

The usercase is where you want to have *multiple* fivestar widgets (similar to the single widget that is enabled on the content type page) to enable users to rate a node, on several criterias.

Eaton mentioned some implementation directions at this comment: http://drupal.org/node/126681#comment-253997

Comments

KentBye’s picture

Assigned: Unassigned » KentBye
Priority: Normal » Critical

I looked into this a while ago and discovered that the VotingAPI module had no way to determine which tags to recalculate whenever a vote was made. So if there were two axes -- vote1 and vote2, and you voted on just vote1, then both vote1 and vote2 would be recalculated because the $tag isn't passed in as an argument to the votingapi_recalculate_results() function.

This seemed to be one roadblock for being able to vote on multiple axes for a single node, and I filed an issue for it here: http://drupal.org/node/138358

But after an IRC discussion, Eaton said that there were hooks that allowed other modules to trigger the recalculation process, which made it more difficult to be granular.

I'll have to read through this full issue here http://drupal.org/node/126681 & take a look.

I'd love for this to get into the 1.9 release, and so I'm marking it critical and will investigate it a bit more today.

KentBye’s picture

Here's another VotingAPI bug that came up regarding multiple-axis voting: http://drupal.org/node/138353

@quicksketch: Any estimate for when you're shooting for an updated official release?

@eaton: Is there going to be another official VotingAPI release soon as well?

quicksketch’s picture

Priority: Critical » Normal

The 1.9 release should be released after I finish up with the interface improvements. We'll see if we can get your hover descriptions in there also. So probably within the next few weeks. Multi-axis CCK voting will be included, though straight-up direct rating on multiple axis will not. As Eaton has pointed out, multi-axis voting while possible is not efficient.

The new VotingAPI does fix this, but I doubt we'll see a backport to Drupal 5. So in short, we probably won't see multi-axis voting for Fivestar (at least in an efficient manner). But who knows?

This feature will not be included in the 1.9 release. But no worries, I'm not opposed to putting into the next one which probably won't be far away either.

ferrangil’s picture

Cool, I'll look forward to use that new feature.
Even if its not efficient, I imagine people is not going to add 40 sets of fivestars for each node... In my case, I just need two sets for each node, that's why maybe the inefficient mode works fine for me.
For me, will be perfect to have the inefficient option in the next release, as it seems to be easy to accomplish.
Anyway, I'll follow your progress.
Thanks quicksketch and Eaton for both modules.

KentBye’s picture

So I started to dig through the required API changes to allow voting on multiple axes -- specifically passing $tag = 'vote' in as an additional default argument into various places.

The good news is that most of the foundation for this has slowly been creeping in over time -- like with $tag being included as an argument for fivestar_vote($type, $cid, $value, $tag = 'vote') & _fivestar_cast_vote($type, $cid, $value, $tag);. It's even in votingapi_add_vote($type, $cid, $value, 'percent', $tag, $uid);

Where it still needs to go into as an argument is here:
fivestar_widget_form($node)

then here:
drupal_get_form('fivestar_form_node_' . $node->nid, 'node', $node->nid);

then here:
fivestar_form($content_type, $content_id)

and then ultimately in these three lines where a variable $tag would replace the hardcoded 'vote':

  $current_avg = votingapi_get_voting_result($content_type, $content_id, 'percent', 'vote', 'average');
  $current_count = votingapi_get_voting_result($content_type, $content_id, 'percent', 'vote', 'count');
  if ($user->uid) {
    $user_vote = votingapi_get_vote($content_type, $content_id, 'percent', 'vote', $user->uid);
  }

Another possibility would be to pass in the variable $star_id =1 or 2 into these form functions where the appropriate $tag could be retrieved if you knew it was the primary or secondary rating for that particular $content_type.

So the actual API changes on the fivestar side look fairly straight forward at this point.

And without seeing any actual benchmarking numbers on the performance of votingapi side with two stars yet, then I'm not completely convinced that it'd be that much more horribly different. After all, there are already two different content types enabled with fivestar -- node and comment. So I'd like to see what the performance hit for having two $tags would be before saying that it's too bad to be worth it.

So to me the biggest challenges look like the UI around customizing the labels. My initial thought would be to have a tabbed approach where adding an additional star requires a save and continuing edit to regenerate the form. Dynamically hiding the additional form textboxes for the labels depending on the number of stars was the approach taken for the labels, and I think this would work in this case if it fivestar capped the number of widgets per node to 2. But if you go through the trouble to allow more than one rating widget, then why stop at two? So going to multiple star widgets might require a "save & continue" type of workaround on the admin form in order to regenerate additional options, labels and tabs for the other widgets.

But before tackling the UI issue, I'm going to dive in and see if I can get a node type working to at least have two rating widgets.

But at this point, I'm cautiously optimistic.

KentBye’s picture

Version: 5.x-1.7 » 5.x-1.x-dev

I forgot to mention that there are probably a number of other unintended changes to the theming of the widgets that would probably have to include the $tag as another XHTML id dimension. I'll be digging into that as well.

But the other thought that I had is that this type of framework could possibly allow independent control of the comment rating labels and star counts and theming. At this point the comment ratings seem tied to the node body ratings, but going down this path could open the possibility of having Up / Down votes on the comments with fivestars on the content types.

Another common use case would be to use a one-star fivestar widget as a "Favorites" rating. Either way, I see a lot of potential ways that having multiple star widgets dimensions per node could be interesting and useful.

KentBye’s picture

Status: Active » Needs review
StatusFileSize
new12.33 KB

Okay.
Here's a rough patch that makes most of the API changes necessary to be able to have multiple voting widgets per node.
Nothing has been added on the admin yet -- which could be another issue altogether.

But this patch successfully adds the voting $tag variable almost all of the necessary places.

You can apply the patch and test it by created a blog type with a PHP input filter and adding in this code:

<?php
  $node->nid = 5;
  print fivestar_widget_form($node, 'vote');
  print fivestar_widget_form($node, 'vote2');
?>

There's also a temporary line in the patch that makes the blog content_type default $tag 'vote2' instead of 'vote' for testing purposes.

The immediate TODO is to add the $tag to the admin variable 'fivestar_labels_'. $content_type so that you can have custom labels for each widget.

The next TODO is to dig into the admin for adding multiple widgets and changing the labels.

Another TODO with the views integration function of fivestar_views_value_display_handler() -- it calls the static version, and there should probably be a way to feed in the $tag as a variable into the returned value of theme('fivestar_static', $value, $stars);

Any preliminary feedback on this would be great.

stuartgoff’s picture

I am interested in this as well. I will be testing the patch and I was wondering when this might get rolled into the module.

KentBye’s picture

StatusFileSize
new12.9 KB

Attached is a re-rolled patch to the current DRUPAL-5 branch of fivestar.
This still just has the necessary API changes in order to have multiple-axis voting from the theme layer, which can be tested with the following PHP snippet for a node w/ fivestar enabled.

<?php
$node->nid = 5;
print fivestar_widget_form($node, 'vote');
print fivestar_widget_form($node, 'vote2');
?>

quicksketch and I also talked more about the admin UI aspect of this issue this afternoon.
What seems to make the most sense is to create a separate multi-axis fivestar tab on the example.com/content/types/story admin page.

The default $tag would still be 'vote' -- and would still be configurable in the "Fivestar ratings" collapsible fieldset that currently appears on the example.com/content/types/story admin page.

Additional form elements that would need to be added to the default "Fivestar ratings" collapsible fieldset are:
* Number of voting widgets
* Voting axis tag name, which would default for 'vote' for 1-star. And probably 'vote2' for 2 stars, 'vote3' for 3 stars, etc.

quicksketch’s picture

I'm going to hold off these changes until we can get 1.11 out the door, which seems to have plenty of problems yet to fix :/

Guevara’s picture

There are any news for rating nodes on multiple axis?
Does it work with the patch by KentBye?

develcuy’s picture

Guevara, there is another working alternative at #213967: Multiaxis and new stuff contribution (without CCK). It has some dependencies with karma at #211803: Contributed source code.
Blessing!

Guevara’s picture

ok, thanks, but... it does not work...

I get the following error message:

* user warning: Table 'd006a7b4.fivestar_node_cache' doesn't exist query: SELECT fnc_reviews reviews FROM fivestar_node_cache fnc WHERE fnc_node_id = 26 in /www/htdocs/w0093df9/cubaworld/drupal/includes/database.mysql.inc on line 172.
* user warning: Table 'd006a7b4.fivestar_node_cache' doesn't exist query: SELECT fnc_reviews reviews FROM fivestar_node_cache fnc WHERE fnc_node_id = 26 in /www/htdocs/w0093df9/cubaworld/drupal/includes/database.mysql.inc on line 172.

develcuy’s picture

Guevara, in order to get fivestar-multiaxis working, you have to uninstall(via drupal) your current fivestar and then install fivestar-multiaxis.

Guevara’s picture

Hello develCuy,

sure, I´ve uninstalled my fivestar version and then installed the fivestar-multiaxis, but there is the same error message...

najibx’s picture

This multiaxis feature is a great addition. yeahhh ...the 5.x-1.11-beta4 is out today. Is it there yet?
develCuy appreciate your effort with fivestar-multiaxis, but I am thinking of going along with fivestar-cck-multiaxis...

quicksketch’s picture

No new (large) features are being added to the 1.11 version before release of the next stable version. Multiaxis as well as the 4-5 new star sets currently in the queue will be added after 1.11 final is released.

While I'm interested to see what develCuy has put together (I did watch the screencast), I simply cannot implement any of these features unless the changes are submitted as patches. I'd discourage anyone from using a forked copy of the module as you're likely to be left behind in a version that will not receive the new features and bug fixes as the main branch of development, not to mention ported to Drupal 6.

develcuy’s picture

quicksketch, I've just tried to help others to get working what I've developed. I'm waiting for an stable release to put all this stuff in single patches, the problem at this moment is with my availability, I'm very busy until middle March with subscriptions_og. Anyhow, this and other issues provided nice suggestions that I want to work on. Please sorry for any confusion.

Blessings!

dawoo’s picture

I am getting the same message and I have completely uninstalled previous versions.

* user warning: Table 'd006a7b4.fivestar_node_cache' doesn't exist query: SELECT fnc_reviews reviews FROM fivestar_node_cache fnc WHERE fnc_node_id = 26 in /www/htdocs/w0093df9/cubaworld/drupal/includes/database.mysql.inc on line 172.
* user warning: Table 'd006a7b4.fivestar_node_cache' doesn't exist query: SELECT fnc_reviews reviews FROM fivestar_node_cache fnc WHERE fnc_node_id = 26 in /www/htdocs/w0093df9/cubaworld/drupal/includes/database.mysql.inc on line 172.

quicksketch’s picture

Thanks for the explanation develCuy, looking forward to those patches :D

quicksketch’s picture

StatusFileSize
new10.17 KB

Yay, I finally got 1.11 out the door :)

I've rolled an update to the latest version, but seems there must be something missing. New votes aren't being recorded. I'll revisit this soon, or Kent if you're up for reroll, please see what you can do. Thanks!

I've taken out most "TODO" items. We can handle these things in time.

BarisW’s picture

Hi quicksketch,

I installed 1.11 and followed all instructions on multi-axis voting.
I created a node-type 'Review' which contains 5 fivestar-fields.

I used the field Node ID to return the parent nid. But still no votes are being registered in the database. Even installing your patch didn't solve this. Can it have anything to do with your comment 'New votes aren't being recorded. I'll revisit this soon'?

We are a week after this comment. Any updates yet? I have to finish my site next week and really need multi-axis voting (without the use of Node Comment).

Thanks for all your good work!

quicksketch’s picture

Sixcolored, please open a support request for your issue. Multi-axis support through normal comments or the direct rating widget are not yet supported (that's what we're trying to accomplish here).

ferrangil’s picture

quicksketch, could you give a date for the release of that functionality? Just to get an idea... It could be in a few weeks, or at least several months...
Thanks!

P.S: "Never" could be an answer also... hope not!

Fayna’s picture

Subscribing to this issue!

Encarte’s picture

Subscribing.

batje’s picture

subscribe

najibx’s picture

how about ....using Node Comments?
Advanced Reviews - Multiple Voting Axis per Node Comment - documented in http://drupal.org/node/234681
other than making comments as node, in term of "functionality", the objective is achieved right? What's the drawback of this method?

quicksketch’s picture

I also submitted a patch to Node Reviews that allows you to use Fivestar within that module (it's the module that powers http://www.drupalmodules.com). The modules a little rough around the edges, but it's a much lighter-weight solution that using Node Comment.

After implementing Fivestar into another solution, I think it's starting to make a lot more sense to remove the Comment functionality from Fivestar directly (maybe included in the download, but as a separate module). When there are many options to using Fivestar within various modules, I think it'd be better to make it so you can turn off the ones you don't want.

najibx’s picture

Great. The patched you mentioned is already committed in nodereview 5.x-1.x-dev April 21, 2008 - 20:09.

Question, If I don't put anything on review axes in /admin/content/nodereview/, add CCK fivestar, the CCK Fivestar will not show up and cannot review node. If I put both, or at least one at review axes, ...both show up? What's the different there. And what's the different on what is trying to be achieved in this issue?

You would still put this in "Target Node ID" text box ?

if (arg(0) == 'node' && arg(1) == 'add' && is_numeric(arg(3))) {
  return arg(3);
}

if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit') {
  $node = node_load(arg(1));
  return $node->field_rating[0]['target'];
}

if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) != 'edit') {
  return arg(1);
}

drupal_set_message('An error occurred saving your review, no target was specified.', 'error');
return 0;

quicksketch’s picture

najibx, please open a separate issue for your request about CCK integration.

Edit:
Using Node Comment and Fivestar,
Using NodeReview,
or Using the multiaxis comments/direct rating discussed in this issuee.

They're all different ways of approaching the same issue. VotingAPI, along with the VotingAPI implementations in CCK and NodeReview, support for voting on Multi-axis already. What's being discussed here is making it so that Fivestar can vote on Multiaxis directly though it's direct rating widget or comment support.

patchak’s picture

quicksketch, I would like to sponsor something to get this functionnality into the module asap. Would you be (or anyone else for that matter) interested in taking the job and allowing multiple rating widgets for one node.... or even better allow the fivestar cck fields to be actually voted on by the users??

For example I would like to have several fields in one group (cck fields) and let users vote on those fields, not only the node author.

Anyone interested in getting payed to get this up and running before may 1st??

Thanks,
Patchak

cacciaresi’s picture

Hello, any news about this feature request?

Please, if someone can tell me another solution to this problem, i'll be glad!

Did anyone solve this with a different approach?

I just need to vote on three differents aspects on a node... :(

Thanks a lot!

cacciaresi’s picture

no news? I've some time to spend working with this issue, if someone can guide me i can try to implement the rest of the functionality.

value’s picture

Is there any progress here? I tried the patches and didn't get much luck. I got it to work but the widget takes on the wrong tag no matter what I do.

I really need this functionality and I can not move to Node Comments. So I'm praying there is a development soon with workable mutli-axis support.

kennyb’s picture

Hi quicksketch and KentBye...

I've installed the patch provided by quicksketch in comment #21 (ontop of version 5.x-1.11) but as specified in that comment, the votes don't register.

I'm displaying two widgets using:
print fivestar_widget_form($node,'vote');
print fivestar_widget_form($node,'vote2');

It looks like this is SO close to giving me the functionality I need, but I'm not at home enough looking at the code to work out whats wrong. Any chance you guys could have another quick look at updating this patch or pointing me in the right direction to try to fix it.

Any input greatly appreciated!
Cheers...

krutipatel’s picture

Priority: Normal » Critical
altparty’s picture

There's a new module with the same specs in development: http://drupal.org/project/criteria_rating.

Maybe joint effort could help us out here...

ddyrr’s picture

I need this as well, but for d6. It seems like the cck field version would be the easiest way to add the new stars (and includes the name of each widget, which is needed), but the main content type settings allow you to set all of the rollover text and other options, which I also need. It would be great to have it all for all types of stars (live node rating, comment rating, and review rating).

Can't we just add all the other options for the live rating to the cck fields, then add a setting for whether that field should show as a live rating form instead of the static average? Then it could probably be displayed the same way it is now, except that the nid would be the current node in live mode instead of pulling from the php code as in a review. In fact, one field could probably be used both ways... allow live voting, and the nid would be the current node in live mode, but used in a form (as a review), it would pull the nid from the php in the cck field.

ddyrr’s picture

I was able to create the beginnings of something like this by:

1. Adding the additional label fields to the cck field version. This part was easy, and actually works fine. This doesn't have to do with the live voting, but with what I said above about having all options for all the different widgets.

2. For having multiple live voting widgets, I simply added multiple Fivestar sections to the content type form. The first one stays the same, and each one after that is simply counted (Ex fivestar2, fivestar3). This count is added to each field so that each value is unique. I got it working on the content type form, so I suppose all that would need to be added is the axis.

3. After I put in the axis, then when theming everything out, I will just need to create an array of settings and values to send to the theme functions.

Unfortunately, I don't have the time to do all this (maybe later), but I think it could work just fine, and give us multiple ways of using the widget... then you could have multiple axis in reviews, comments, and for live voting on the nodes, and each one would have all options, such as the labels.

quicksketch’s picture

StatusFileSize
new10.75 KB

Here's a reroll for the latest 5.x dev, and actually saves the votes properly. Note that this still doesn't actually give you an interface at all for setting different axis. I'm still a bit stuck on how this should possibly look.

Fayna’s picture

Well NodeReview already does multi-axes by displaying a text field for each axis... why not have Fivestar do it a bit differently, one review text field and multiple star widgets (one for each axis?). Then users could define a description for each axis next to the star widget.

quicksketch’s picture

Sorry, the question is: how should the interface look for configuring the multiple axis, not how should it be displayed to the end user. NodeReview does it's job just fine, but it doesn't provided direct rating widgets for the viewing users to rate content (which is what this patch would provide). You can also use CCK with Fivestar to make multi-axis rating right now (NodeReview has Fivestar support also). The only thing you can't do is this idea of "direct rating", where end-users can immediately rate something while viewing it.

All things considered, I'm thinking I might apply this patch to make that sort of advanced rating available users that are experienced themers, but not implement the UI for configuration. If you're building a review site, I'd recommend using either CCK or NodeReview anyway. The Fivestar support for comments was to make a "simple" rating solution. Comments really aren't made for extensive functionality like ratings.

ddyrr’s picture

The only thing I can think of is to have them first enter the number of axes, then it would give you that many Fivestar sections, each with it's own labels, settings, and axis.

quicksketch’s picture

Thanks ddyrr, that's a good suggestion. It would yield a *huge* form of course, but Fivestar simply has a lot of available customization. Hence, the reason why I think we should simply try to steer people away from using the built-in mechanism for multi-axis, and use CCK node references, NodeReview, or Node Comments instead. Basically, if you want multi-axis reviews, you should be using nodes. That's what I think it comes down to.

develcuy’s picture

Just to enforce what quicksketch said, remember I have done a fork wich provides multi-axis: http://drupal.org/node/213967, but time let me understand that fivestar is a WIDGET which works with VOTING API. So, don't force a widget to provide multiple widget (multi-axis).
If there are at least 3 know working options to get multi-axis with fivestar widgets, and they use fivestar as it is intended to be: a WIDGET, so please don't waste your time.

Where to go from here?
http://drupal.org/project/cck
http://drupal.org/project/nodereview
http://drupal.org/project/nodecomment

Please try that options and choose the better for your needs.

Blessings!

quicksketch’s picture

While thinking about these problems, I made creating a review using node references a much easier task by providing support for them directly from Fivestar field configuration: #277045: Make Node Reference Targets Easier

Note: I still think this patch should probably be applied as-is. It still enhances the functionality to allow for multi-axis voting, but the rating widgets need to be rendered manually instead of through a UI.

value’s picture

Im eagerly awaiting the multi axis voting as well.

Though I disagree about using nodes. And maybe Im just misunderstanding the use or implementation intended.

My intended use is as follows

http://www.site.com/listings/item1

Listings is a content type that accepts data much like IMDB would have

Now on that node is a listing of all Item 1's information and a overall rating. All news reviews etc based on taxonomy and relational browsing per keywords.

Now lets say Item 1 is a movie or album.

It would be nice to be able to rate it for not just overall quality but on axis like Acting, Script, or Vocals, and Mixing etc.

Currently just using a CCK field does not tally a vote it just takes the last value given to it. If 500 people rated it a 10 and the last person rates it a 0 for Acting the rating will take the 0 value. My community members must be able to rate on these axis as well.

Now heres my issue with just using various nodes to accomplish this. You would not want a new node for every axis of every entry you will be making. I will easily have over 1000 entries in this "database" content type right at the start and have atleast 5-10 axis to rate each one on. That increases the fields in _node tables by 5-10 times. Especially when the nodes are only being used to store a vote and have no real content.

We are in a soft launch holding pattern while I wait for this feature because frankly I think it is too important not to incorporate for our initial version of this database.

quicksketch’s picture

@value, Yes I think there is a general misunderstanding of the use of nodes as reviews using Fivestar. Here's the setup you'd need.

You have Item 1 (a movie or album node).

Now, create a content type "review" with the following fields:
-Node Reference (referencing either movie or album nodes)
-Fivestar (axis = "plot")
-Fivestar (axis = "music")
-Fivestar (axis = "overall")

Each of the Fivestar fields are setup to use the Node Reference field to cast a vote, making it so when a user submits a new "Review" piece of content, it casts 3 votes on the "Movie" piece of content. The votes are added up and calculated as more people submit reviews.

I should completely clarify, what THIS issue is about, is creating "Direct Rating Widgets", where the user can view the Movie piece of content, and click 3 times on stars and NOT create a review of any sort. They just submit votes right away while viewing the content, just as they do now for the overall voting when you turn on Fivestar for a content type.

I don't particularly think that Fivestar's comment support should rate on multiple axis, because comments weren't really made to handle additional data. I was pushing it enough already by putting on a single set of stars. Nodes are much better suited to additional data, and if you're adding on multiple axis, you'll probably want to start theming this information (the "overall" rating set of stars might be displayed larger than "plot" and "music" axis). Manipulating this information within comments starts getting a little messy while nodes are meant to handle large amount of properties.

So, yes, you would create 1 additional node for every review, but definitely not another node for every axis, that's what makes CCK so great and what we'd have to essentially duplicate in Fivestar to support multiple axis. If this patch were committed as-is though, it would enable multi-axis "direct" rating, but not put in the interface. So you could in theory do multi-axis rating as such:

print fivestar_widget_form($node, 'plot');
print fivestar_widget_form($node, 'music');
print fivestar_widget_form($node, 'overall');

However, the trouble being all these forms would use the same "Average" label, when in truth you'd probably want them to be "Plot", "Musical Score", and "Overall Rating". Hence, where this patch falls short and I'm really thinking that if you need multi-axis, go with nodes as reviews.

kennyb’s picture

Hi quicksketch,

Thanks for doing the re-roll patch you provided in comment #41 - I've now tried it and its working just fine! Got round the problem of "Average" displaying above the stars by disabling this in the content types fivestar settings, and then displaying the criteria name beside the stars.

UI:
My feeling is that you probably don't need to provide the admin interface, as 'most' users won't be using fivestar in this way and for those that are they can achieve it without the admin UI - e.g. by using print fivestar_widget_form($node, 'music'); etc.

Multi-axis direct rating:
I want users to be able to rate nodes on a number of criteria without having to create a new 'review' node in order to do so. So, yes, I believe multi-axis direct rating is an important piece of functionality.

Thanks again.

value’s picture

OK I follow now about the nodes and for a review system that certainly does make sense. I was actually using Node Review previously but our users refused to use it. They much prefer the comments.

What I'm hoping for is the direct rating widgets right on the Item's node. I understand the challenge you face. The label doesn't bother me so much because I can control most of the output through a custom tpl which Im already using for the node.

The Overall Rating comes from the User Comments which would basically be their review of the node for all intents, and the other axis would be available to them to rate up and down should they choose to.

Ive tried to get the patch working but must have missed something, I was doing it by hand on my lunch break :)

All in all I love this module either way.

chrisshattuck’s picture

I just re-created this patch, glad I found the original before embarrassing myself with a duplicate post. :)

Here's my use case, in case it's helpful in determining whether to roll in the patch or not:

I will be using fivestar for contests. The content with the highest rating gets a prize. The contests will be frequent and will overlap each other, so having a throw-away axis / tag, as opposed to adding a CCK field for each one, seems better. Once the contest is over, we can clear the database, or keep the data in for antiquity's sake. A CCK field seems like it might be unwieldy for the task, and would be harder to set up as a dynamic component. A external module could easily supply a unique tag, but it would have a more difficult time and potentially break layouts by adding a new CCK field.

Thanks!

chrisshattuck’s picture

What are the chances of this patch getting rolled in? I'm developing a module right now that could use it, but it would only make sense to offer it in contrib if I'm not using a hacked version of fivestar ;)

Thanks!
Chris

jun’s picture

Version: 5.x-1.x-dev » 5.x-1.12
Priority: Critical » Normal
StatusFileSize
new11.43 KB

Hi there,

Here's an updated patch for version 1.12 of FiveStar with the same caveats outlined by quicksketch: no admin interface, widget needs to be added manually, with the proper $tag variable, in the theme or a custom module...

Our use case is slightly different than allowing multiaxis voting, in fact we simply use the $tag variable to be able to differentiate different phases of voting.

Remember to still activate fivestar for your content type and deactivate the display, which will be handled by your theme modifications.

One thing I'm not sure about, and hopefully someone can enlighten me, is whether the average and number of votes are calculated correctly? It seems that they are in the widget but I see in the code some hardcoded 'vote' tags in fivestar_views_widget_handler() for instance, am I missing something?

Cheers,

Jun.

dirkson’s picture

Any chance we could get this thingie ported over to Drupal6? I've been taking a look myself, but it's way beyond my meager skills.

dirkson’s picture

Also, the most recent patch references ../fivestarnew , which confuses the crap out of me. No idea what's going on there.

dirkson’s picture

Started a new thread here, to discuss my Quixotic attempts to convert this thing into v6: http://drupal.org/node/295215

maop’s picture

Hi,

where do I have to write these lines of code?

print fivestar_widget_form($node, 'plot');
print fivestar_widget_form($node, 'music');
print fivestar_widget_form($node, 'overall');
najibx’s picture

maop, those code is to put at your node-Your_content_type.tpl.php

<?php
print "Value for money";
print fivestar_widget_form($node, 'value');
print "Level of difficulty";
print fivestar_widget_form($node, 'level');
print "Overall";
print fivestar_widget_form($node, 'overall');
?>

As mentioned in #51, you fix the "Average" label by adding a text, enabling the Fivestar rating for that particular content type, but unchecked "Show widget title". and put hidden in "Full node display".

The overall is actually what you expect the user to click, not what being calculated. Anyone?

momper’s picture

subscribe

bsherwood’s picture

+ subscribing

I would love to see this. I guess my use case would be to create 3 or 4 fivestar fields that allow users to rate a node (without editing it via /node/edit) and then have a mechanism to tabulate the votes and show a rating.

Example:
Using 5 stars
Field 1: user selects 4
Field 2: user selects 4
Field 3: user selects 2
Total: 3.33

Granted it is only simply finding out the averages but I didn't want to get into number weighting. Views intergration is a plus too. You could set something up like:

Node Title Field 1 Field 2 Field 3 Total Rank

I hope this gets implemented soon, this would spawn a ton of review sites using Drupal.

najibx’s picture

I was testing this and getting 'some' averaging ... however, when I tried to do manually, some result are not correctly display by Views when there are 2 votes of multiaxis. I posted in http://drupal.org/node/86510, and since no reply, wondering if Only one VotingAPI: Voting results per view.

I was using the following but, I get weird result whenever I refresh the page. Although in #59 I specify the axis value, but the vote now change to the first one, instead of keeping the value being cast. Multiaxis issue here?

<?php
print "Calculated Overall Average";
$current_rating = votingapi_get_voting_result('node', $node->nid, 'percent', 'vote', 'average');
print theme('fivestar_static', $current_rating->value);
?>

netbear’s picture

Hello! I've just applied patch given for drupal-5 to drupal-6. But had no time to test it. I attach the whole patched module if someone has time to test it. If interested the attached file is in this post: http://drupal.org/node/295215

netbear’s picture

Allready tested, it works. Can use if needed.

fluxline’s picture

since this node has become the hold all for multi-axis questions and ideas i thought i would give the question a shot here. when implementing 2 voting widgets, is there a way to have the 'other' widget disabled when 1 is used? i've found the fivestar-widget name differs by only a dash ( #fivestar-form-node-1325-1 vs. #fivestar-form-node-1325--1 ) but i'm not really sure the best way to disable it it in the js. any ideas?

netbear’s picture

For now different widgets are created through the theme in a way:

print fivestar_widget_form($node, 'plot');
print fivestar_widget_form($node, 'music');
print fivestar_widget_form($node, 'overall');

so to disable one of the widgets you need just disable for example print fivestar_widget_form($node, 'plot');
another words to print

print fivestar_widget_form($node, 'music');
print fivestar_widget_form($node, 'overall');

If you have a condition then in your template do some
thing like:

if("condition here") {
  print fivestar_widget_form($node, 'plot');
}
print fivestar_widget_form($node, 'music');
print fivestar_widget_form($node, 'overall');

Nothing to change in js.
But access rules are equal -user_access('rate content') so if somebody is allowed to vote- he can vote on every tag though widget is absent on the page.

fluxline’s picture

maybe i didn't make myself clear because i don't see how this would work. if i have 2 ratings on a node when the user first loads the node:

(content)

Good 1 2 3 4 5 Bad 1 2 3 4 5

if the user then selects that they believe the content of the node is Bad with a level of 2, i would like the Good 12345 to either be disabled or hidden. i don't want the user to be able to vote both 'Good' and 'Bad'. The node would then look like this after the vote is recorded:

(content)

Bad (1) (2)

i thought this would need to happen on the client side in the js. I can see your solution after the user has voted or some conditional on the server, but not on the client as a function of the user voting. let me know if my assumption is wrong though and thanks for the reply.

netbear’s picture

You can add more reaction on click event for the stars in the fivestar.js file, for example $("#your_div_wrapper_for_first_widget").hide() when stars on the second widget was clicked and $("#your_div_wrapper_for_first_widget").show() when cancel button on the second widget was clicked and the same do for the $("#your_div_wrapper_for_second_widget").

fluxline’s picture

thanks for the reply. based on a suggestion by quicksketch in another post i started to dig into jquery and put together something to take care of it with that. the last coding i did, netscape still had 75% of the browser market ... was good for me. took me a bit to get my head around id, class, div, element, ... span, ... but once that was done jquery was easy. again thanks.

Eli Baskin’s picture

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

(subscribing)

Are there any news on multiple-axis voting for Fivestar? When it is due? I can't wait, this is so exciting :)

daniorama’s picture

Version: 6.x-1.13 » 6.x-1.x-dev

Me too, any chance this would happen in the official version? Any date? Thanks!

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new8.17 KB
new8.35 KB

I've put in a slightly trimmed down version of the last patch. Here's the "preliminary" approach for multi-axis rating. In this case, I simply created a PHP node that contains the code, ideally you'd probably put this into the theme layer somewhere.


  $nid = arg(1);
  $output = '';
  $tags = array(
    'quality' => t('Quality'),
    'color' => t('Color'),
    'vote' => t('Overall'),
  );

  foreach ($tags as $tag => $title) {
    $votes = fivestar_get_votes('node', $nid, $tag);
  
    $values = array(
      'user' => isset($votes['user']['value']) ? $votes['user']['value'] : NULL,
      'average' => isset($votes['average']['value']) ? $votes['average']['value'] : NULL,
      'count' => isset($votes['count']['value']) ? $votes['count']['value'] : NULL,
    );
  
    $settings = array(
      'stars' => 5,
      'allow_clear' => TRUE,
      'style' => 'average',
      'text' => 'dual',
      'content_type' => 'node',
      'content_id' => $nid,
      'tag' => $tag,
      'autosubmit' => TRUE,
      'title' => $title,
      'feedback_enable' => TRUE,
      'labels_enable' => TRUE,
      'labels' => array(t('Poor'), t('Okay'), t('Good'), t('Great'), t('Awesome')),
    );
  
    $output .= drupal_get_form('fivestar_custom_widget', $values, $settings);
  }

  print $output;

As you can see, there are a lot of settings that you can configure for Fivestar widgets, hence why the UI has been such a problem for this patch. Also, make sure that Fivestar rating is enabled for the content type that is being rated, even if you manually print out the widgets using the above approach.

I'm marking this particular issue as fixed, as it's gotten quite long. Let's open new issues for any further improvements.

alippai’s picture

This solution doesn't work for me - it displays the widget, but it can't load the values for the widget.

Can we add a dynamic formatter for fivestar CCK fields, based on this patch? Fivestar CCK Field should allow voting for users (so it turns into a multiple field instead of the current).

alippai’s picture

Status: Fixed » Active
daniorama’s picture

Title: Let users rate on multiple axis » Rate on multiple axis without admin UI (D5&6 Patch)

As quicksketch said, I think it's better two write here about problems with this particulary approach and create another issue for different ones. It's ok?

quicksketch’s picture

Title: Rate on multiple axis without admin UI (D5&6 Patch) » Let users rate on multiple axis
Status: Active » Closed (fixed)

Please open a new ticket for ANY reason. This thread is too long and winding to effectively follow.

benmirkhah’s picture

Issue tags: +widget display style

#72 worked great using 6.2.dev, thank you
I even made mine work in multilingual environment adding
$nid = $node->tnid ? $node->tnid : $node->nid; //only rate the translation source

my only remaining challenge is to theme each axis differently,
lets say one using stars, one using hearts, one using flames...

I saw http://codebaboon.com/tutorial-different-icons-fivestar-cck-fields

but that's using the CCK fields and not calling it through code, any pointers?

benmirkhah’s picture

Overriding theme_fivestar_widget in my template.php to add
an element ID did the trick for using different icons on each axis:

function phptemplate_fivestar_widget($form) {
  // Only print out the summary if text is being displayed or using rollover text.
  if (empty($form['vote']['#description']) && strpos($form['vote']['#prefix'], 'fivestar-labels-hover') === FALSE) {
    unset($form['vote']['#description']);
  }

  $class = 'fivestar-form';
  $class .= '-'. (isset($form['vote']['#tag']) ? $form['vote']['#tag'] : 'vote');
  $class .= '-'. (isset($form['content_id']['#value']) ? $form['content_id']['#value'] : 0);
  //Add an ID to distinguish different multi-axis tags
  $tagid = 'fivestar-'. (isset($form['vote']['#tag']) ? $form['vote']['#tag'] : 'vote'); 
  $output  = '';
  $output .= '<div id="'.$tagid.'" class="'. $class .' clear-block">';
  $output .= drupal_render($form);
  $output .= '</div>';
  return $output;
}

and adding css rules for each axis tag id...

#fivestar-youraxis div.fivestar-widget .star,
#fivestar-youraxis div.fivestar-widget .star a { background: transparent url(../img/youraxis.png) no-repeat 0 0; }

#fivestar-youraxis div.fivestar-widget .on a { background: transparent url(../img/youraxis.png) no-repeat 0 -16px; }

#fivestar-youraxis div.fivestar-widget .hover a { background: transparent url(../img/youraxis.png)  no-repeat 0 -32px; }

div.fivestar-widget .cancel,
div.fivestar-widget .cancel a { background: transparent url(../img/yourcancel.png)  no-repeat 0 0; }

#fivestar-youraxis div.fivestar-widget div.cancel a:hover { background: transparent url(../img/yourcancel.png)  no-repeat 0 -16px; }

Took me a minute to figure it out so hope it'll save time for someone else!

user654’s picture

.

user654’s picture

Version: 6.x-1.x-dev » 7.x-2.0-alpha3
Issue summary: View changes
Status: Closed (fixed) » Active
sbydrupal’s picture

Is there D7 version for multi axis voting ? +1

asb’s picture

Is there any substantial reason why this 11 year old issue is still active?

From documentation: Fivestar 7.x-2.0 : create review system with multi-axis average rating

develcuy’s picture

@asb, first of all, this is a feature request, so it can stay open for as long the module is under maintenance. Second, the feature we always wanted here is to have one field providing a multi-axis voting widget. Not the same as having multiple fields, each with a fivestar widget. For this purpose, I have used field collection in the past, so that I can add the field collection straight into any content type I wish. But it was very complex for theming. I think this functionality is similar to a single checkbox vs. a group of checkboxes, they are now native widgets in Drupal and we need something similar first in Voting API and to have it supported by widgets like fivestar.