I recently wrote about developer maturity. Specifically, I said we should not be afraid to use third-party solutions when possible.
This doesn’t mean we should piecemeal every project together. That isn’t development. That’s implementation (but that’s another post).
Anyway, Andy and I just finished up a project which demonstrates this point quite well. Part of the project called for providing a rating of certain criteria.
As such, we used jQuery Raty for laying the foundation of the rating system.
The Considerations For Ratings
Any developer who’s had to build a rating system knows the challenges that this can present. I’m not claiming it’s particularly difficult, but there are certain things to consider.
- Are you going to display an the average of all ratings?
- If so, how are you going to store the total number of votes and them calculate the average? On the fly, on serialization, or on retrieval?
- Are you going to allow for partial ratings or are you going to round up?
- Can a person vote more than once or do you need to restrict them from doing so?
Depending on the complexity of your solution, there’s more to consider. Regardless, jQuery Raty makes introducing ratings easy.
jQuery Raty For Ratings
The description of the plugin is about as simple as it gets:
A star rating plugin
To get going, it’s a matter of including it in your project and then setting the required parameters. From there, there are plenty of options that you can use to provide your solution.
For example, our project called for the following:
- Display ratings hooked to custom values defined in the WordPress Dashboard.
- Enable users to vote on a single aspect of the displaying product.
- Store the rating and ensure they can only vote once.
With jQuery Raty and WordPress’ APIs, we setup a system quicker than had we built the entire system on our own. All that to say, the plugin is a fantastic resource should you need to build a rating system. It’s also another example of how to be pragmatic when building solutions for others.