Dataform - star ratings

Dataform - star ratings

by Martyn Colliver -
Number of replies: 3

On the documentation you have a screenshot showing star ratings for entries: 

I've found how you can do the ratings (and show average etc) - just a quick query as to how the stars were done. Is this built into dataform (couldn't find it) or a bit of javascript and/or css ??

Thanks,

Martyn


Average of ratings: -
In reply to Martyn Colliver

Re: Dataform - star ratings

by Itamar Tzadok -

This was experimental and I decided that it should better be a specialized plugin type. But most of the code is still there. If you want to make it work and can hack the code, all you need to do is add to the list of patterns in dataformfield_ratingmdl_renderer::patterns(), around line 400 in mod/dataform/field/ratingmdl/classes/renderer.php, the following patterns:

$patterns["[[$fieldname:avg:bar] ]"] = array(true, $fieldname);
$patterns["[[$fieldname:avg:star] ]"] = array(true, $fieldname);

(remove the redundant space between the closing brackets)

As the pattern name suggest, the star rating works on the average of ratings.

The number of stars is determined by the scale. So 5 points scale will display 5 stars. The styles are inline so may be difficult to change the look, but again it was just a quick experiment and need to be redone in an orderly manner.

hth smile

In reply to Itamar Tzadok

Re: Dataform - star ratings

by Martyn Colliver -

Thanks for this - but when I try to implement I can't seem to get the coloured stars.

Also when a student (or anybody else looks) they don't actually see any stars at all.....

My view (you can see the calculated current average, then the stars, then my rating)


What others see (you can see the calculated average, no stars, then count of ratings)


Any ideas what is going on.....?

In reply to Martyn Colliver

Re: Dataform - star ratings

by Itamar Tzadok -

Requires system capability rating view (for aggregates in own entry) and rating view any (for aggregates in others' entries) before the star rating can be displayed. The condition can probably be removed. You can try commenting it out in mod/dataform/field/ratingmdl/classes/renderer.php around lines 360-362. smile