How to get an accurate average rating?

By: John Bosley | Asked: 09/21/2022
ForumsCategory: General questionsHow to get an accurate average rating?
John Bosley asked 2 years ago

I am trying to get an average rating for a submission to a particular field, but end up getting an average for all submitted entries.

For example:  

Review 1 - Product A=3 stars

Review 2 - Product A=5 stars

Review 3 - Product B=1 star  

When I display the average rating for Product A, I get 3 stars (average of 1, 3, 5) instead of 4 stars (average of 3,5). 

When I display the average rating for Product B, I also get 3 stars.  

 

I am using [frm-stats id=product_name_field type=average]  

What do I need to add to display the average rating only for Product X? My search results are using params if that helps.  

Thanks!

Bobby Clapp replied 2 years ago

Something like this:
[frm-stats id=product_name_field product_name_field="Product A" type=average]
[frm-stats id=product_name_field product_name_field="Product B" type=average]

John Bosley replied 2 years ago

Thanks for the suggestion, Bobby. That didn't work (or I didn't do it correctly). I may have oversimplified my example for what I'm actually doing.

I'm using one form (Form 1) to create the products a user can rate, so let's say I create Parent Category A, (Product z, Product y), (option 1, option 2, option 3).

On a different form (Form 2) I let the user choose a product to review with a lookup field that gets options from Form 1. Let's say they leave these ratings:

Product z, option 1:
Variable 1 - 5 stars
Variable 2 - 4 stars

Product z, option 2:
Variable 1 - 4 stars
Variable 2 - 5 stars

I'm trying to let someone search for ratings based on Parent Category, which will return all Products in that Parent Category with the average variable rating for each individual Product (which takes us back to the above example).

So search results may look like: user selects Parent Category A, search results return

Product z, option 1:
Variable 1 - average rating across all Product z, option 1 reviews
Variable 2 - average rating across all Product z, option 2 reviews

Product z, option 2:
Variable 1 - average rating across all Product z, option 2 reviews
Variable 2 - average rating across all Product z, option 2 reviews

A real-world example would be Shoes (Parent Category), Mens (Product)... search results:
Mens Nike Shoes
Comfort - 5
Cost - 4

Mens Reebok Shoes
Comfort - 4
Cost - 5

My views are currently set up to display lookup fields from Form 1 and pass ratings from Form 2 and the search results are giving me what I want, except for the actual rating that's displayed.

To add on to what I initially posted, I can get the average of all reviews (of all Products) by using [frm-stats id=product_name_field type=average].

I can also get the individual Product option reviews by using [frm-stats id=product_name_field type=star entry="[id]"], but it only shows one review, not the average.

Bobby Clapp replied 2 years ago

I can't wrap my head around it without seeing it. Can you send me an email with a simple export of the application with a few entries to test on my side?

2 Answers
Best Answer
Bobby Clapp answered 2 years ago
You're going to have to introduce the entry id parameter into the shortcode to get individualized values I'm thinking. Try this for sound: [frm-stats id=s9al2 type=star entry=[id]]
Venue Llama answered 2 years ago

Dear homeslices, I am having the same issue. I think. Users provide 5 star ratings for several categories per 'entry' -- in this case, the entry being a theater, not a product. There is a star rating field for  sound, entry process, smoking policy, etc   When I try to have the average star ratings for each of these categories, for each theater/entry display -- it just displays the same star average for all entries/theaters on the listing page. Every theatre winds up having the exact same star ratings for all categories :(.  The code i'm using on 'listing' page is...   Sound: [frm-stats id=s9al2 type=star]<BR> Smoking Policy: [frm-stats id=ecmji type=star]<BR> Entry Process: [frm-stats id=229yi  type=star]<BR>   I'm using the star rating field id for the id. And  in the form being referenced/providing the data, i created a hidden field as per FF documentation with the [get param=entry] added to the default value.   If there's anything further on this, would appreciate sharing the knowledge. Thank you so much!
your pal, llama  

Bobby Clapp replied 2 years ago

Can you share a link to where the output is?

Venue Llama replied 2 years ago

Sure. Here's the draft: https://venuellama.com/dev/venues
thanks!

Bobby Clapp replied 2 years ago

You're going to have to introduce the entry id parameter into the shortcode to get individualized values I'm thinking. Try this for sound: [frm-stats id=s9al2 type=star entry=[id]]

Venue Llama replied 2 years ago

<p>Bobby Clapp bringing the heat! Thanks! The averages are now different from each entry, so it looks like it worked! I'll run some tests then apply to the other categories. Thank you!!!!</p>

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right