jimie VIP
Total posts: 531
17 Nov 2014 14:21

Hello Sergey,

Do you think you can add a feature to allow calculating an overall rating for a user based on all reviews ( I`m using cobalt types as comments ) received on its articles from all sections ?

Rgds

Last Modified: 26 Jan 2015



Sergey
Total posts: 13,748
20 Nov 2014 11:11

You mean average rating of article? I think it is already there in adapter. It shows above the average rating of all reviews of the article.

What do you mean by user based?


jimie VIP
Total posts: 531
20 Nov 2014 11:37

I mean an average rating for all that user articles coming from all sections.


Sergey
Total posts: 13,748
24 Nov 2014 08:30

This is why I added rating API so that you can calculate any ratings.


jimie VIP
Total posts: 531
21 Jan 2015 09:52

I`m trying my head with this but can't find how to do it :(

So maybe you can give me hand, I was thinking to calculate this something like this:

( Section1 User articles overall rating + Section2 User articles overall rating + Section2 User articles overall rating ) / 3

And then display the result in user profile


Sergey
Total posts: 13,748
22 Jan 2015 15:04

Get user rating for each section

$rating1 = CobaltApi::renderRating($type1_id, $section1_id, 'r.user_id = '.$user_id);
$rating2 = CobaltApi::renderRating($type2_id, $section2_id, 'r.user_id = '.$user_id);
$rating2 = CobaltApi::renderRating($type2_id, $section2_id, 'r.user_id = '.$user_id);

$total = ($rating1['total'] + $rating2['total'] + $rating3['total']) / 3;

jimie VIP
Total posts: 531
22 Jan 2015 15:41

That does not work afraid, remember that my ratings are from reviews where I use cobalt type as comments with multirating


Sergey
Total posts: 13,748
26 Jan 2015 04:08

It is not copy/paste solution. It is jsut and expression of idea. Of course you as a developer what to check every returned value that it is correct. Look into renderRating too. That have to give you insite on how utilize this API appropriately.

Powered by Cobalt