Feedback in the event-related views
This commit is contained in:
parent
b774cb9b11
commit
2d19046d35
|
@ -63,4 +63,24 @@ module ApplicationHelper
|
|||
|
||||
output.html_safe
|
||||
end
|
||||
|
||||
def rating_label_color(rating)
|
||||
case rating.round
|
||||
when (0...3) then 'danger'
|
||||
when 3 then 'warning'
|
||||
when 4 then 'info'
|
||||
when 5 then 'primary'
|
||||
when 6 then 'success'
|
||||
end
|
||||
end
|
||||
|
||||
def human_rating(rating)
|
||||
case rating.round
|
||||
when (0...3) then t('ratings.poor')
|
||||
when 3 then t('ratings.average')
|
||||
when 4 then t('ratings.good')
|
||||
when 5 then t('ratings.very_good')
|
||||
when 6 then t('ratings.excellent')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,8 @@ class Event < ActiveRecord::Base
|
|||
has_many :participants, through: :approved_participations
|
||||
has_many :participants_with_personal_profiles, through: :approved_participations, source: :participant_with_personal_profile
|
||||
has_many :conflict_counts, -> { order(number_of_conflicts: :desc) }, foreign_key: :left_id
|
||||
has_many :feedbacks, as: :feedback_receiving, dependent: :destroy
|
||||
has_many :feedbacks, as: :feedback_receiving
|
||||
has_many :feedbacks_with_comment, -> { where.not(comment: [nil, ""]) }, as: :feedback_receiving, class_name: 'Feedback'
|
||||
|
||||
belongs_to :event_type
|
||||
|
||||
|
@ -35,6 +36,14 @@ class Event < ActiveRecord::Base
|
|||
|
||||
accepts_nested_attributes_for :participations, allow_destroy: true
|
||||
|
||||
def average_rating
|
||||
feedbacks.average(:rating)
|
||||
end
|
||||
|
||||
def rated?
|
||||
feedbacks.size > 0
|
||||
end
|
||||
|
||||
def all_participants_have_profiles?
|
||||
participants_with_personal_profiles.all? { |participant| participant.has_personal_profile? }
|
||||
end
|
||||
|
|
|
@ -20,9 +20,12 @@
|
|||
.label.label-info
|
||||
= event.rank
|
||||
=< number_to_percentage(event.per_cent_of_votes, strip_insignificant_zeros: true, precision: 2)
|
||||
|
||||
|
||||
|
||||
- if event.rated?
|
||||
dt = t(".average_rating")
|
||||
dd
|
||||
=> human_rating(event.average_rating)
|
||||
.badge class="badge-#{rating_label_color(event.average_rating)}"
|
||||
= number_with_precision event.average_rating, precision: 2, strip_insignificant_zeros: true
|
||||
td.visible-md.visible-lg.visible-xl
|
||||
= links_to_event_participants_for(event)
|
||||
td.action
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
tr
|
||||
td.text-center
|
||||
.huge
|
||||
.label.label-info
|
||||
= feedback.rating
|
||||
td
|
||||
blockquote
|
||||
= simple_format feedback.comment
|
||||
- if feedback.author_email.present?
|
||||
footer = feedback.author_email
|
||||
- else
|
||||
footer = t(".anonymous")
|
|
@ -50,6 +50,8 @@
|
|||
tr
|
||||
th
|
||||
= Event.human_attribute_name :title
|
||||
th.text-center
|
||||
= t '.rating'
|
||||
th.text-center
|
||||
= Event.human_attribute_name :rank
|
||||
th
|
||||
|
@ -62,6 +64,11 @@
|
|||
- speaker.events_participated_in.where.not(id: @event.id).order(created_at: :desc).each do |event|
|
||||
tr
|
||||
td = event.title
|
||||
td.text-center
|
||||
- if event.rated?
|
||||
.large
|
||||
.label class="label-#{rating_label_color(event.average_rating)}"
|
||||
= number_with_precision event.average_rating, precision: 2, strip_insignificant_zeros: true
|
||||
td.text-center
|
||||
- if event.ranked?
|
||||
.large
|
||||
|
|
|
@ -65,6 +65,33 @@
|
|||
h3 = Event.human_attribute_name :participants
|
||||
= render partial: 'speaker', collection: @event.participants
|
||||
|
||||
.row
|
||||
.col-xs-12
|
||||
h3 = Event.human_attribute_name :feedbacks
|
||||
- if @event.rated?
|
||||
.row
|
||||
.col-md-10
|
||||
.panel.panel-default
|
||||
.panel-heading = t('.comments')
|
||||
- if @event.feedbacks_with_comment.size > 0
|
||||
table.table.table-striped
|
||||
tbody
|
||||
= render partial: 'feedback', collection: @event.feedbacks.where.not(comment: [nil, ''])
|
||||
- else
|
||||
.panel-body
|
||||
= t ('.no_comments_received')
|
||||
.col-md-2
|
||||
.panel.panel-info
|
||||
.panel-heading
|
||||
= t '.average_grade'
|
||||
.panel-body.text-right
|
||||
.huge
|
||||
= number_with_precision(@event.average_rating, precision: 2, strip_insignificant_zeros: true) || '–'
|
||||
= t('.total_feedback_grades', total_grades: @event.feedbacks.count, count: @event.feedbacks.count)
|
||||
- else
|
||||
p = t '.no_feedback_received'
|
||||
|
||||
|
||||
- if @conference.has_vote_results? or @conference.has_voting_endpoint?
|
||||
.row
|
||||
.col-xs-12
|
||||
|
|
|
@ -158,6 +158,7 @@ bg:
|
|||
rank: "Класиране"
|
||||
user: "Лектор"
|
||||
participants: "Участници"
|
||||
feedbacks: "Обратна връзка"
|
||||
event_type:
|
||||
description: "Описание"
|
||||
name: "Име"
|
||||
|
|
|
@ -67,6 +67,7 @@ en:
|
|||
title: Title
|
||||
track: Track
|
||||
user: Speaker
|
||||
feedbacks: Feedback
|
||||
event_type:
|
||||
description: Description
|
||||
name: Name
|
||||
|
|
|
@ -10,3 +10,13 @@ bg:
|
|||
backup: Резерва
|
||||
events:
|
||||
metadata: "%{type} на %{language} с продължителност %{length} минути"
|
||||
management:
|
||||
events:
|
||||
show:
|
||||
average_grade: Средна оценка
|
||||
total_feedback_grades:
|
||||
one: от %{total_grades} оценка
|
||||
other: от %{total_grades} оценки
|
||||
no_feedback_received: Все още няма обратна връзка
|
||||
no_comments_received: Все още няма коментари
|
||||
comments: Коментари
|
||||
|
|
|
@ -7,3 +7,13 @@ en:
|
|||
approved: Approved
|
||||
rejected: Rejected
|
||||
backup: Back-up
|
||||
management:
|
||||
events:
|
||||
show:
|
||||
average_grade: Average grade
|
||||
total_feedback_grades:
|
||||
one: out of %{total_grades} grade
|
||||
other: out of %{total_grades} grades
|
||||
no_feedback_received: No feedback received (yet)
|
||||
no_comments_received: No comments received (yet)
|
||||
comments: Comments
|
||||
|
|
Loading…
Reference in New Issue