How to display an average rating with the Star Rating plugin
In this Bubble.io tutorial video we demonstrate the extra steps you'll need to take in order to display an average star ratings value that users can return to and update using the Bootstrap Star Rating Input visual element.
Unlock the power of star ratings: Learn how to display accurate averages and handle user inputs like a pro!
Master Bubble's database magic: Discover how to create a robust rating system that updates dynamically with each user interaction.
Transform your app's UX: Implement a dual star rating display that showcases both individual and average ratings effortlessly.
Understanding the Star Rating Plugin in Bubble
Welcome to part two of our mini-series on how to use the star rating visual element in Bubble. In the previous video, we covered how to select this element from the Bubble plugin catalog, insert it into a page, and set it up so that a user can input a value (e.g., three and a half stars) which is then saved into the database and displayed on the page when it reloads.
Limitations of the Basic Star Rating Implementation
The shortcomings of this approach are that if another user were to come along and rate it one and a half stars, that value is saved into the database and becomes the rating, whereas we really want to display an average. We could use a "make rating into a list" approach, so we could have had the 4.5 value and the 2.5 value in that list and then displayed an average. However, the reason that's not ideal is that when a user changes their value, there's no way in Bubble to match the value that the user gave and then update that, so we would just end up with another value added to the ratings.
Creating a New Data Type for Ratings
To solve this, we need to create another data type. We'll call this "rating," and it only needs to have a few fields: the user who created it, the value (which is a number), and the product (of type product).
Setting Up the Workflow
Let's look at the workflow we currently have. This just saves the change into the database. We need to start somewhere, so when the star rating's value is changed, we need to create a new data type. We'll set the product to the current page product, and the rating value to the star rating's value.
Implementing Conditional Rating Creation
To prevent multiple ratings from the same user, we can add an "only when" statement. We'll do a search for ratings where the product equals the current page product and created by equals the current user. We'll only create a new rating if the count of this search is zero.
Updating Existing Ratings
For the case where a user is updating their existing rating, we'll create another workflow. This time, we'll update the rating when the count is not zero. We'll search for the rating where the product equals the current page product and created by equals the current user, then change the value to the new star rating value.
Displaying the Average Rating
To display the average rating on the front end, we'll need two star ratings: one that displays the average and one that displays what individual users have input. For the average rating, we'll disable it so users don't get confused. We'll set its initial content to do a search for ratings where the product equals the current page product, then take each item's value and average it.
Testing the Implementation
Let's test our implementation. When we change the rating to four stars, the average updates to four. When we change it back to 0.5 stars, the average becomes 0.5. This setup means that when other users come along and update the bottom value, the top value will accurately display an average of all the ratings for that product.
Conclusion
By implementing this system, we've created a more robust and accurate star rating feature in our Bubble app. Remember to label the two star ratings clearly to avoid confusion for your users. This approach allows for individual user ratings while maintaining an accurate average display for all users.
Ready to Transform Your App Idea into Reality?
Access 3 courses, 400+ tutorials, and a vibrant community to support every step of your app-building journey.
Start building with total confidence
No more delays. With 30+ hours of expert content, you’ll have the insights needed to build effectively.
Find every solution in one place
No more searching across platforms for tutorials. Our bundle has everything you need, with 400+ videos covering every feature and technique.
Dive deep into every detail
Get beyond the basics with comprehensive, in-depth courses & no code tutorials that empower you to create a feature-rich, professional app.
Valued at $80
Valued at $85
Valued at $30
Valued at $110
Valued at $45
14-Day Money-Back Guarantee
We’re confident this bundle will transform your app development journey. But if you’re not satisfied within 14 days, we’ll refund your full investment—no questions asked.
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Frequently Asked Questions
Find answers to common questions about our courses, tutorials & content.
Not at all. Our courses are designed for beginners and guide you step-by-step in using Bubble to build powerful web apps—no coding required.
Forever. You’ll get lifetime access, so you can learn at your own pace and revisit materials anytime.
Our supportive community is here to help. Ask questions, get feedback, and learn from fellow no-coders who’ve been where you are now.
Absolutely. If you’re not satisfied within 14 days, just reach out, and we’ll issue a full refund. We stand by the value of our bundle.
Yes, this is a special limited-time offer. The regular price is $350, so take advantage of the discount while it lasts!