Implement Event Ratings

This commit is contained in:
shlok007 2016-09-22 20:06:46 -04:00 committed by Shlok Srivastava
parent 5be1ad52ee
commit 20f4853487
67 changed files with 1298 additions and 378 deletions

View file

@ -42,10 +42,6 @@
Yes
- else
No
%dt
Rating Levels
%dd#rating
= @program.rating
.row
.col-md-12.text-right
= link_to(edit_admin_conference_program_cfp_path(@conference.short_title), class: 'btn btn-primary') do

View file

@ -168,8 +168,8 @@
%b Description
%td= simple_format(@event.description)
- if @conference.program && @conference.program.rating && @conference.program.rating > 0
= render partial: 'voting'
- if @votable_fields.present?
= render partial: 'voting'
.row
= link_to "Comments (#{@comment_count})", '#', id: 'event-comment-link'

View file

@ -1,80 +1,32 @@
%table.table#myrating
- if @program.show_voting?
%tr
%td.col-md-2
%b Rating
%td
- if @event.average_rating.to_f > 0
#{@event.average_rating}/#{@program.rating}
- else
Rating: 0/#{@program.rating}
- @program.rating.times do |counter|
- if @event.average_rating.to_f.round == counter + 1
= label_tag 'label_rating', '', class: 'avgrating', avgrate: true
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag 'label_rating', '', class: 'avgrating'
%tr
%td
%b Voters
%td
= @event.voters.length
- if @event.voters.length > 0
(
= @ratings.map {|x| "#{x.name}"}.join ', '
)
%tr
%td.col-md-2
%b Your vote
%td
- if @program.voting_period?
- @program.rating.times do |counter|
- if @event.voted?(current_user) && @event.user_rating(current_user) == counter + 1
= link_to '', vote_admin_conference_program_event_path(@conference.short_title, @event, rating: counter + 1), remote: true, id: "label#{counter + 1}", class: 'myrating', voted: true
- else
= link_to '', vote_admin_conference_program_event_path(@conference.short_title, @event, rating: counter + 1), remote: true, id: "label#{counter + 1}", class: 'myrating'
%br
- else
- @conference.program.rating.times do |counter|
- if @event.voted?(current_user) && @event.user_rating(current_user) == counter + 1
= label_tag "label#{counter + 1}", '', class: 'othersrating', voted: true
= javascript_tag "$('label[voted=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag "label#{counter + 1}", '', class: 'othersrating'
(#{voting_open_or_close(@program)})
- if @program.show_voting?
- if @ratings.length > 0
- @ratings.each do |rate|
- unless rate.user_id == current_user.id
%hr
- if @program.rating_enabled
- if @program.voting_period?
- if @program.show_voting?
%table.table
%thead
%td.col-md-2
%b Overall Votes
- @votable_fields.each do |field|
%tr
%td.col-md-2
= field.title
%td
= rating_for @event, field.title, disable: true, star: field.stars
%tr
%td
= rate.name
Voters
%td
- @conference.program.rating.times do |counter|
- if @event.voted?(rate.user) && @event.user_rating(rate.user) == counter + 1
= label_tag "label#{counter + 1}", "", class: 'othersrating', voted: true
= javascript_tag "$('label[voted=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag "label#{counter + 1}", "", class: 'othersrating'
:javascript
$(function () {
var checkedId = $("a[voted='true']").attr('id');
$('a[id=' + checkedId + ']').prevAll().andSelf().addClass('bright');
});
$(".myrating").hover(
function() { // mouseover
$(this).prevAll().andSelf().addClass('glow');
},
function() { // mouseout
$(this).siblings().andSelf().removeClass('glow');
}
);
$(".myrating").click(function() {
$(this).siblings().removeClass("bright");
$(this).prevAll().andSelf().addClass("bright");
});
= raters(@votable_fields)
%table.table
%thead
%td.col-md-2
%b Your Votes
- @votable_fields.each do |field|
%tr
%td.col-md-2
= field.title
%td
= rating_for_user @event, current_user, field.title, star: field.stars
- else
%b
= voting_open_or_close(@program)

View file

@ -1,19 +0,0 @@
- if @program.show_voting?
#{event.average_rating}/#{@program.rating}
%br
#{pluralize(event.voters.length, 'voter')}
%br
- @program.rating.times do |counter|
- if event.average_rating.to_f.round == counter + 1
= label_tag 'label_rating', '', class: 'avgrating', avgrate: true
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag 'label_rating', '', class: 'avgrating'
%br
- if event.voted?(current_user)
%span.label.label-success
Your rating: #{ event.user_rating(current_user) }
- else
%span.label.label-danger
Not rated

View file

@ -50,9 +50,6 @@
%b ID
%th
%b Title
- if @program.rating_enabled?
%th
%b Rating
%th
%b Submitter
%th
@ -80,11 +77,6 @@
= event.id
%td
= link_to event.title, admin_conference_program_event_path(@conference.short_title, event)
- if @program.rating_enabled?
%td.col-md-1{ 'data-order' => "#{event.average_rating}" }
= render partial: 'voting_index', locals: { event: event }
- if event.submitter && event.submitter.registrations && event.submitter.registrations.count < 1
- bgcolor = '#F7819F'
- else

View file

@ -36,10 +36,6 @@
= event_change_description(version)
= "event #{@event.title}"
- elsif version.item_type == 'Vote'
= vote_change_description(version)
= "event #{@event.title}"
- else
= general_change_description(version)
= link_to 'commercial',

View file

@ -1 +0,0 @@
$('table#myrating').replaceWith("<%= escape_javascript(render :partial => 'voting') %>");

View file

@ -7,11 +7,11 @@
= semantic_form_for(@program, url: admin_conference_program_path(@conference.short_title), html: {multipart: true}) do |f|
= f.input :schedule_public, label: 'Show Schedule on the home and splash page'
= f.input :schedule_fluid, label: 'Allow submitters to change their event after it is scheduled'
= f.input :rating, hint: 'Enter the number of different rating levels you want to have for voting on proposals. Enter 0 if you do not want to vote on proposals.'
= f.input :languages, hint: "Enter the languages allowed for events as values of #{link_to('ISO 639-1', 'http://www.loc.gov/standards/iso639-2/php/code_list.php', target: "_blank")} language codes separated with commas. The first language would be the default language. Leave it blank if you do not want to specify languages.".html_safe
= f.input :schedule_interval, hint: "It is the minimal time interval of your schedule. The value should be 5, 6, 10, 12, 15, 20, 30 or 60. Warning! Some events could be unscheduled when changing this value."
= f.input :blind_voting, hint: 'Enable this feature if you do not want to show voting results and voters prior to user submitting a vote. For the feature to work you need to set the voting dates below as well'
= f.input :voting_start_date, as: :string, input_html: { id: 'datetimepicker-voting_start_date', readonly: true, value: (f.object.voting_start_date.to_formatted_s(:db_without_seconds) unless f.object.voting_start_date.nil?) }
= f.input :voting_end_date, as: :string, input_html: { id: 'datetimepicker-voting_start_date', readonly: true, value: (f.object.voting_end_date.to_formatted_s(:db_without_seconds) unless f.object.voting_end_date.nil?) }
= f.input :rating_enabled, label: 'Enable voting', hint: 'To enable voting you need to set voting dates as well'
= f.input :blind_voting, hint: 'Enable this feature if you do not want to show voting results and voters prior to user submitting a vote. For the feature to work you need to set the voting dates below as well', input_html: { class: 'voting_fields' }
= f.input :voting_start_date, as: :string, input_html: { id: 'datetimepicker-voting_start_date', readonly: true, value: (f.object.voting_start_date.to_formatted_s(:db_without_seconds) unless f.object.voting_start_date.nil?),class: 'voting_fields' }
= f.input :voting_end_date, as: :string, input_html: { id: 'datetimepicker-voting_start_date', readonly: true, value: (f.object.voting_end_date.to_formatted_s(:db_without_seconds) unless f.object.voting_end_date.nil?),class: 'voting_fields' }
%p.text-right
= f.action :submit, as: :button, button_html: {class: 'btn btn-primary'}

View file

@ -57,11 +57,12 @@
%h3 Voting Options
%hr
%dt
Rating Levels
%dd#rating
= @program.rating
%dt Voting enabled?
%dd
- if @program.rating_enabled
Yes
- else
No
%dt Blind Voting
%dd#blind_voting
= @program.blind_voting

View file

@ -11,7 +11,6 @@
%th Title
%th State
%th Type
%th Rating
%th Created At
%tbody
- @user.events.each do |event|
@ -21,12 +20,4 @@
%td= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event)
%td= event.state
%td= "#{event.event_type.title} (#{show_time(event.event_type.length)})"
%td
- if event.program && event.program.rating && event.program.rating > 0
- event.program.rating.times do |counter|
- if event.average_rating.to_f.round == counter+1
= label_tag 'label_rating', '', class: 'avgrating', avgrate: true
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag 'label_rating', '', class: 'avgrating'
%td= event.created_at

View file

@ -42,7 +42,7 @@
= link_to 'commercial',
admin_conference_commercials_path(conference_id: Conference.find(version.conference_id).short_title)
- when 'EventsRegistration', 'Comment', 'Vote', 'Event'
- when 'EventsRegistration', 'Comment', 'Event'
= 'event'
- object = current_or_last_object_state(version.item_type, version.item_id)
- event_id = object.try(:event_id) || object.try(:commentable_id) || object.id

View file

@ -35,9 +35,6 @@
- when 'Comment'
= comment_change_description(version)
- when 'Vote'
= vote_change_description(version)
- when 'User'
= user_change_description(version)

View file

@ -0,0 +1,16 @@
.row
.col-md-12
.page-header
%h1
- if @votable_field.new_record?
New
Votable Field
.row
.col-md-8
= semantic_form_for(@votable_field, :url => (@votable_field.new_record? ? admin_conference_votable_fields_path : admin_conference_votable_field_path(@conference.short_title, @votable_field))) do |f|
= f.input :title
= f.input :votable_type, collection: options_for_select(['Event'])
= f.input :stars, label: 'Add the total number of stars for the field'
= f.input :for_admin, label: 'Add this field for voting in admin side only'
%p.text-right
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -0,0 +1,42 @@
.row
.col-md-12
.page-header
%h1 Votable Fields
%p.text-muted
Select the criteria of rating in conference
- if @conference.votable_fields.any?
.row
.col-md-12
%table.table.table-striped.table-bordered.table-hover.datatable
%thead
%th Enabled?
%th Title
%th Votable Type
%th Actions
%tbody
- @conference.votable_fields.each do |votable_field|
%tr
%td
- if can? :update, votable_field
= check_box_tag @conference.short_title, votable_field.id , votable_field.enabled,
method: :patch, url: "/admin/conferences/#{@conference.short_title}/votable_fields/#{votable_field.id}?votable_field[enabled]=",
class: 'switch-checkbox', readonly: false, data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
- else
= check_box_tag @conference.short_title, votable_field.id , votable_field.enabled,
method: :patch, url: "/admin/conferences/#{@conference.short_title}/votable_fields/#{votable_field.id}?votable_field[enabled]=",
class: 'switch-checkbox', readonly: true,data: { size: 'small', on_color: 'success', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
%td
= votable_field.title
%td
= votable_field.votable_type
%td
.btn-group
= link_to 'Edit', edit_admin_conference_votable_field_path(@conference.short_title, votable_field),
method: :get, class: 'btn btn-primary', disabled: !(can? :update, votable_field)
= link_to 'Delete', admin_conference_votable_field_path(@conference.short_title, votable_field),
method: :delete, class: 'btn btn-danger', disabled: !(can? :destroy, votable_field),
data: { confirm: "Do you really want to delete #{votable_field.title}?" }
.row
.col-md-12
= link_to 'Add Votable Field', new_admin_conference_votable_field_path, class: 'btn btn-success pull-right', disabled: !(can? :create, @conference.votable_fields.new)

View file

@ -0,0 +1 @@
= render 'form'