Bugzilla – Attachment 102938 Details for
Bug 25110
Allow patrons to add star ratings to titles on their summary/checkout page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25110: Allow patrons to add star ratings to titles on their summary/checkout page
Bug-25110-Allow-patrons-to-add-star-ratings-to-tit.patch (text/plain), 10.77 KB, created by
Owen Leonard
on 2020-04-14 18:06:59 UTC
(
hide
)
Description:
Bug 25110: Allow patrons to add star ratings to titles on their summary/checkout page
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2020-04-14 18:06:59 UTC
Size:
10.77 KB
patch
obsolete
>From 738713cf1e881a47b8bf4eb4f28ad4044dcc3c54 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 14 Apr 2020 16:31:28 +0000 >Subject: [PATCH] Bug 25110: Allow patrons to add star ratings to titles on > their summary/checkout page > >This patch adds the ability for logged-in patrons to add star ratings to >titles in their list of current checkouts and on the reading history >page. > >The reading history page previously only showed existing ratings. Now it >will allow the entry of ratings as well. > >The JS and markup for the feature are in separate include files to >facilitate re-use. > >To test, apply the patch and set the OpacStarRatings to all, "results, >details, and user" pages. > > - Log in to the OPAC as a user with checkouts. > - On the "your summary" page, test the features of setting star > ratings: > - Any title with existing ratings should show the rating and the > average rating number. > - Set a rating. Confirm that it shows a message with your rating. > - Click the "cancel rating" link, and confirm that your rating is > removed. > - Set a rating and reload the page. Confirm that the rating was > saved. > - Test the "cancel rating" link on the title you set before you > reloaded the page. The rating should be cancelled. > - Test the same functionality on the "your reading history" page. > - Test these pages with the OpacStarRatings preference set to "only > details" or "no." The pages should function correctly. >--- > .../prog/en/modules/admin/preferences/opac.pref | 2 +- > .../bootstrap/en/includes/user-star-ratings.inc | 41 ++++++++++++++++++++++ > .../bootstrap/en/modules/opac-readingrecord.tt | 28 ++++++--------- > .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 11 ++++++ > opac/opac-user.pl | 7 ++++ > 5 files changed, 70 insertions(+), 19 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index c705a288c3..0bd9ecedcb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -56,7 +56,7 @@ OPAC: > - "Show star-ratings on" > - pref: OpacStarRatings > choices: >- all: "results and details" >+ all: "results, details, and user" > disable: "no" > details: "only details" > - "pages." >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc >new file mode 100644 >index 0000000000..c258c88380 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc >@@ -0,0 +1,41 @@ >+<form method="post" action="/cgi-bin/koha/opac-ratings.pl"> >+ <div class="results_summary ratings" id="rating-[% item.itemnumber | html %]"> >+ >+ [% SET rating_avg = item.ratings.get_avg_rating() %] >+ [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] >+ >+ <select class="star_rating" id="star_rating-[% item.itemnumber | html %]" name="rating" autocomplete="off" data-biblionumber="[% item.biblionumber | html %]" data-context="rating-[% item.itemnumber | html %]"> >+ >+ [% IF ( rating_avg_int == 0 ) %] >+ <option value="" selected="selected"></option> >+ [% END %] >+ [% FOREACH i IN [ 1 2 3 4 5 ] %] >+ [% IF rating_avg_int == i %] >+ <option value="[% i | html %]" selected="selected">[% i | html %]</option> >+ [% ELSE %] >+ <option value="[% i | html %]">[% i | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ <img id="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" /> >+ >+ <!-- define some hidden vars for ratings --> >+ >+ <input type="hidden" name="biblionumber" value="[% item.biblionumber | html %]" /> >+ <input type="hidden" name="rating_value" class="rating_value" value="[% item.my_rating.rating_value | html %]" /> >+ >+ <input name="rate_button" type="submit" value="Rate me" /> >+ >+ [% IF item.my_rating %] >+ <div> >+ <span class="rating_value_text">Your rating: [% item.my_rating.rating_value | html %].</span> >+ <span class="cancel_rating_text"><a href="#" data-context="star_rating-[% item.itemnumber | html %]"><i class="fa fa-remove"></i> Cancel rating</a>.</span> >+ </div> >+ [% ELSE %] >+ <span class="rating_value_text"></span> >+ <span class="cancel_rating_text" style="display:none;"><a href="#" data-context="star_rating-[% item.itemnumber | html %]"><i class="fa fa-remove"></i> Cancel rating</a>.</span> >+ [% END %] >+ >+ <div class="rating_text">Average rating: [% rating_avg | html %] ([% item.ratings.count | html %] votes)</div> >+ </div> >+</form> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >index 1f3dadcff5..3b95b586ed 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >@@ -145,24 +145,9 @@ > [% END %] > <p class="results-summary item-details">[% issue.author | html %]</p> > >- [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' && issue.my_rating ) %] >- <div class="results_summary ratings"> >- <div class="br-wrapper br-theme-fontawesome-stars"> >- <div class="br-widget br-readonly"> >- [% FOREACH i IN [ 1 2 3 4 5 ] %] >- [% IF issue.my_rating.rating_value == i %] >- <a href="#" class="br-selected br-current"></a> >- [% ELSIF issue.my_rating.rating_value > i %] >- <a href="#" class="br-selected"></a> >- [% ELSE %] >- <a href="#"></a> >- [% END %] >- [% END %] >- </div> >- </div> >- Rated on [% issue.my_rating.timestamp | $KohaDates %] >- </div> <!-- / .results_summary --> >- [% END # / IF OpacStarRatings %] >+ [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' ) %] >+ [% INCLUDE 'user-star-ratings.inc' item=issue %] >+ [% END %] > > </td> > <td> >@@ -235,5 +220,12 @@ > } > }); > }); >+ var borrowernumber = "[% borrowernumber | html %]"; >+ var MSG_YOUR_RATING = _("Your rating: %s, "); >+ var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)"); > </script> >+ [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %] >+ [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] >+ [% Asset.js("js/ratings.js") | $raw %] >+ [% END %] > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index 256262818d..7d26a5a23b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -294,6 +294,10 @@ > <td class="title"> > <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ISSUE.biblionumber | html %]">[% INCLUDE 'biblio-title.inc' biblio=ISSUE %]</a> > [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron | html %][% END %] >+ >+ [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %] >+ [% INCLUDE 'user-star-ratings.inc' item=ISSUE %] >+ [% END %] > </td> > > <td class="author">[% ISSUE.author | html %]</td> >@@ -963,7 +967,14 @@ > } > }); > //]]> >+ var borrowernumber = "[% borrowernumber | html %]"; >+ var MSG_YOUR_RATING = _("Your rating: %s, "); >+ var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)"); > </script> >+ [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %] >+ [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %] >+ [% Asset.js("js/ratings.js") | $raw %] >+ [% END %] > [% IF Koha.Preference('OverDriveCirculation') %] > [% Asset.js("js/overdrive.js") | $raw %] > <script> >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index d94d3d0e2b..6d967c8803 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -43,6 +43,7 @@ use Koha::Patrons; > use Koha::Patron::Messages; > use Koha::Patron::Discharge; > use Koha::Patrons; >+use Koha::Ratings; > use Koha::Token; > > use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; >@@ -267,6 +268,12 @@ if ( $pending_checkouts->count ) { # Useless test > $issue->{'description'} = $itemtypes->{$itemtype}->{'description'}; > } > >+ if ( C4::Context->preference('OpacStarRatings') eq 'all' ) { >+ my $ratings = Koha::Ratings->search({ biblionumber => $issue->{biblionumber} }); >+ $issue->{ratings} = $ratings; >+ $issue->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef; >+ } >+ > $issue->{biblio_object} = Koha::Biblios->find($issue->{biblionumber}); > push @issuedat, $issue; > $count++; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25110
:
102938
|
103017
|
103080
|
103081
|
103365
|
103405
|
103718
|
103719