# Summary

This module provides flexible voting widgets for nodes and comments.

# Project URL

https://www.drupal.org/project/rate

# Where is the code?

https://cgit.drupalcode.org/rate

# Estimated completion date

Unknown

# Dependencies

  • Voting API is used for storage of voting results.

# Who's doing the port?

# What help do they need?

None for the moment.

# D8 roadmap

https://www.drupal.org/node/1843902

# Background and reference information

Unknown

CommentFileSizeAuthor
#9 NickNameVoted.png15.18 KBBoymix81
#9 Relationship.png44.76 KBBoymix81
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

legaudinier created an issue. See original summary.

pedrorocha’s picture

Voting API module already has an alpha version(https://www.drupal.org/node/2721819) and months of use in production, so it's stable, despite still open to feedback, feature suggestions and API changes.

If Rate 8.x is going to use it, is a good time to discuss.

brenk28’s picture

I started a D8 port here: https://github.com/brenk/rate It uses VotingAPI and currently borrowing from https://www.drupal.org/project/like_and_dislike to get started.

jhedstrom’s picture

Status: Active » Needs work

Changing status since a port is under way.

jhedstrom’s picture

Issue summary: View changes
Stephen Ollman’s picture

Just installed the D8 Rate module from #3

Feedback so far.

1. Whilst a node shows the thumbs up / thumbs down, when I select one of them nothing happens.
2. When I select the associated 'Undo' link I get the following error when AJAX is enabled.

Uncaught AjaxError:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /rate/undo/node/1?destination=/sample-page
StatusText: OK
ResponseText:

________________________ AND WHEN NOT ENABLED____________________

[Wed Sep 07 17:02:59.831121 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: Recoverable fatal error: Argument 1 passed to Drupal\\rate\\RateBotDetector::__construct() must be an instance of Drupal\\rate\\ConfigFactoryInterface, instance of Drupal\\Core\\Config\\ConfigFactory given, called in /docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 280 and defined in /docroot/modules/rate/src/RateBotDetector.php on line 69 #0 /docroot/core/includes/bootstrap.inc(546): _drupal_error_handler_real(4096, 'Argument 1 pass...', '/Users/Stephen/...', 69, Array), referer: /sample-page
[Wed Sep 07 17:02:59.831249 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #1 /docroot/modules/rate/src/RateBotDetector.php(69): _drupal_error_handler(4096, 'Argument 1 pass...', '/Users/Stephen/...', 69, Array), referer: /sample-page
[Wed Sep 07 17:02:59.831269 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #2 /docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(280): Drupal\\rate\\RateBotDetector->__construct(Object(Drupal\\Core\\Config\\ConfigFactory), Object(Drupal\\Core\\Database\\Driver\\mysql\\Connection), Object(GuzzleHttp\\Client), Object(Symfony\\Component\\HttpFoundation\\RequestStack)), referer: /sample-page
[Wed Sep 07 17:02:59.831281 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #3 /docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'rate.bot_detect...'), referer: /sample-page
[Wed Sep 07 17:02:59.831302 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #4 /docroot/modules/rate/src/Controller/VoteController.php(119): Drupal\\Component\\DependencyInjection\\Container->get('rate.bot_detect...'), referer: /sample-page
[Wed Sep 07 17:02:59.831313 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #5 /docroot/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\\rate\\Controller\\VoteController::create(Object(Drupal\\Core\\DependencyInjection\\Container)), referer: /sample-page
[Wed Sep 07 17:02:59.831321 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #6 /docroot/core/lib/Drupal/Core/Controller/ControllerResolver.php(123): Drupal\\Core\\DependencyInjection\\ClassResolver->getInstanceFromDefinition('Drupal\\\\rate\\\\Con...'), referer: /sample-page
[Wed Sep 07 17:02:59.831363 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #7 /docroot/core/lib/Drupal/Core/Controller/ControllerResolver.php(74): Drupal\\Core\\Controller\\ControllerResolver->createController('Drupal\\\\rate\\\\Con...'), referer: /sample-page
[Wed Sep 07 17:02:59.831373 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #8 /docroot/core/lib/Drupal/Core/Controller/ControllerResolver.php(91): Drupal\\Core\\Controller\\ControllerResolver->getControllerFromDefinition('Drupal\\\\rate\\\\Con...', '/rate/undo/node...'), referer: /sample-page
[Wed Sep 07 17:02:59.831379 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #9 /docroot/vendor/symfony/http-kernel/HttpKernel.php(127): Drupal\\Core\\Controller\\ControllerResolver->getController(Object(Symfony\\Component\\HttpFoundation\\Request)), referer: /sample-page
[Wed Sep 07 17:02:59.831384 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #10 /docroot/vendor/symfony/http-kernel/HttpKernel.php(62): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1), referer: /sample-page
[Wed Sep 07 17:02:59.831390 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #11 /docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: /sample-page
[Wed Sep 07 17:02:59.831395 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #12 /docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: /sample-page
[Wed Sep 07 17:02:59.831401 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #13 /docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: /sample-page
[Wed Sep 07 17:02:59.831406 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #14 /docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: /sample-page
[Wed Sep 07 17:02:59.831412 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #15 /docroot/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: /sample-page
[Wed Sep 07 17:02:59.831424 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #16 /docroot/core/lib/Drupal/Core/DrupalKernel.php(649): Stack\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true), referer: /sample-page
[Wed Sep 07 17:02:59.831430 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #17 /docroot/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request)), referer: /sample-page
[Wed Sep 07 17:02:59.831434 2016] [fcgid:warn] [pid 2318:tid 2986405888] [client 127.0.0.1:61031] mod_fcgid: stderr: #18 {main}, referer: /sample-page

3. On the 'Manage Display' page I can only show and hide the 'Rate Vote Widget', there is no other configuration available.
4. On the 'Rate settings' page I do not see any Node Display options, only content type, which I've selected.

So at the moment all I'm getting from the D8 module is a 0% TU 0% TD with an 'Undo' link on a node page, with no functionality happening.

What did I miss?

Boymix81’s picture

Issue tags: +template, +Fivestar

Hi,

for me widget Fivestar doesn't work.

I think discovered the bug, a wrong link to give the vote in the rate-template-fivestar.html.twig file. In the code ( rate.module ) I find star_link insted of vote_url , I substitute it and now for me it works.

Bye Boymix81.

@@ -21,7 +21,7 @@
           {% if has_voted or not can_vote %}
             <div{{ star.star_attributes }}>{{ 'Star'|t }}</div>
           {% else %}
-            <a {{ star.star_attributes }} href="{{ star.vote_url }}">{{ 'Star'|t }}</a>
+            <a {{ star.star_attributes }} href="{{ star.star_link }}">{{ 'Star'|t }}</a>
           {% endif %}
         </li>
       {% endfor %}
Boymix81’s picture

Issue tags: -template, -Fivestar +#views fivestar

Hi,

I configure "Voting API" module "Widget Type" with "Fivestar" type.
I select "User" like "Entity types with Rate widgets enabled" configuration and users could be voted by other users in their profiles (added "Rate Vote Widget" field).
I added votes from different users to other users but from the "Rate Voting Results" and "Rate Voting Summary" I have an empty result.
I analyse the view "Rate Voting Results" but I not to be able to find the way to get voted of users. The "Voted entity" always is "Content" why I cannot select "User" ?

I also try to show the field starting from "User" entity in a new "View" (Example List of users) but I non find the "Rate Vote Widget" field.

Could you help me, please ? I'm a newbe of Drupal.

Thank you.
Best Regards.
Bye Boymix81.

Boymix81’s picture

FileSize
44.76 KB
15.18 KB

Hi,

to solve the problem talked in the post before, I use the following hook :

/**
 *
 *  Extend Relationship with Entity different of Content like User Profile
 * 
 * @link https://api.drupal.org/api/drupal/core%21modules%21views%21views.api.php/function/hook_views_data_alter/8.2.x Drupal Core API
 * @author Maurizio Pianfetti<maurizio.pianfetti@occhioinformatico.it>
 * 
 */ 
function rate_views_data_alter(array &$data) {
  
  $config = \Drupal::config('rate.settings');
  $enabled_types_bundles = $config->get('enabled_types_bundles');  
  
  if(array_key_exists('user', $enabled_types_bundles))
  {
    $data['votingapi_vote']['entity_id']['relationship']['base'] = 'users_field_data';
    $data['votingapi_vote']['entity_id']['relationship']['base field'] = 'uid';
    $data['votingapi_vote']['entity_id']['relationship']['label'] = 'User Voted';
    $data['votingapi_vote']['entity_id']['relationship']['title'] = 'User Voted';    
  }
}

Do you think it is a good solution ?
Now I have the list of Users voted and votes .

Thank you.
Best Regards.
Boymix81.

Boymix81’s picture

Hi,

for me with "Widget Type" "Fivestar" the value setted is wrong because the value always is 1 for star1 , star2 , star3 , star4, star5 types .

I fixed this, I modify this Drupal\rate\RateVote class

@@ -120,7 +120,26 @@
         $vote->setVotedEntityId($entity_id);
         $vote->setVotedEntityType($entity_type_id);
         $vote->setValueType($vote_type->getValueType());
+        switch ($vote_type->id()) {
+          case 'star1':
         $vote->setValue(1);
+            break;
+          case 'star2':
+            $vote->setValue(2);
+            break;
+          case 'star3':
+            $vote->setValue(3);
+            break;
+          case 'star4':
+            $vote->setValue(4);
+            break;
+          case 'star5':
+            $vote->setValue(5);
+            break;
+          default:
+            $vote->setValue(1);
+            break;
+        }        
         $vote->save();
         $this->resultManager->recalculateResults($entity_type_id, $entity_id, $vote_type_id);

Now for example I voted users, I gave star5 to Boymix81 , star4 to Test2FR and star3 to Test4IT and I created a view NickName Classification with Numbers of vote and Average of Values (I also used the relationship like telled in my last post)

Fields
(User Voted) User: Name (NickName Voted)
COUNT(Vote: Value) (N.)
AVG(Vote: Value) (Value)

Sort criteria
AVG(Vote: Value) (desc)

and now I have the correct list.

NickName Voted N. Value
Boymix81 1 5
Test2FR 1 4
Test4IT 1 3

Bye Boymix81.

kevin.dutra’s picture

Assigned: Unassigned » kevin.dutra
Issue summary: View changes
lamp5’s picture

Assigned: kevin.dutra » Unassigned
Status: Needs work » Needs review
apaderno’s picture

Issue tags: -#views fivestar