<<

NAME

C4::Ratings - a module to manage user ratings of Koha biblios

DESCRIPTION

Ratings.pm provides simple functionality for a user to 'rate' a biblio, and to retrieve a biblio's rating info

the 4 subroutines allow a user to add, delete modify and retrieve rating info for a biblio.

The rating can be from 1 to 5 stars, (5 stars being the highest rating)

SYNOPSIS

Get a rating for a bib my $rating_hashref = GetRating( $biblionumber, undef ); my $rating_hashref = GetRating( $biblionumber, $borrowernumber );

Add a rating for a bib my $rating_hashref = AddRating( $biblionumber, $borrowernumber, $rating_value );

Mod a rating for a bib my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value );

Delete a rating for a bib my $rating_hashref = DelRating( $biblionumber, $borrowernumber );

All subroutines in Ratings.pm return a hashref which contain 4 keys

for example, after executing this statment below...

    my $rating_hashref = GetRating ( $biblionumber, $borrowernumber ) ;

$rating_hashref now contains a hashref that looks like this...

    $rating  = {
             rating_avg       => '2',
             rating_avg_int   => '2.3',
             rating_total     => '432',
             rating_value => '5'
    }

they 4 keys returned in the hashref are...

    rating_avg:            average rating of a biblio
    rating_avg_int:        average rating of a biblio, rounded to 1dp
    rating_total:          total number of ratings of a biblio
    rating_value:          logged-in user's rating of a biblio

BUGS

Please use bugs.koha-community.org for tracking bugs.

SOURCE AVAILABILITY

The source is available from the koha-community.org git server http://git.koha-community.org

AUTHOR

Original code: Mason James <mtj@kohaaloha.com>

COPYRIGHT

Copyright (c) 2011 Mason James <mtj@kohaaloha.com>

LICENSE

C4::Ratings is free software. You can redistribute it and/or modify it under the same terms as Koha itself.

CREDITS

 Mason James <mtj@kohaaloha.com>
 Koha Dev Team <http://koha-community.org>

GetRating

    GetRating($biblionumber, [$borrowernumber])

Get a rating for a bib my $rating_hashref = GetRating( $biblionumber, undef ); my $rating_hashref = GetRating( $biblionumber, $borrowernumber );

This returns the rating for the supplied biblionumber. It will also return the rating that the supplied user gave to the provided biblio. If a particular value can't be supplied, '0' is returned for that value.

RETURNS

A hashref containing:

AddRating

    my $rating_hashref = AddRating( $biblionumber, $borrowernumber, $rating_value );

Add a rating for a bib

This adds or updates a rating for a particular user on a biblio. If the value is 0, then the rating will be deleted. If the value is out of the range of 0-5, nothing will happen.

ModRating

    my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value );

Mod a rating for a bib

DelRating

    my $rating_hashref = DelRating( $biblionumber, $borrowernumber );

Delete a rating for a bib

<<