From adf59b03c196bcb08e3175076f8be38d355642ef Mon Sep 17 00:00:00 2001 From: TimonDB Date: Wed, 1 Sep 2021 11:37:41 +0200 Subject: [PATCH 1/4] Enable user search in evaluations --- app/controllers/evaluations_controller.rb | 2 ++ .../evaluations/_evaluation_grade_table.html.erb | 2 +- app/views/evaluations/show.html.erb | 11 ++++++++--- app/views/evaluations/show.js.erb | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 app/views/evaluations/show.js.erb diff --git a/app/controllers/evaluations_controller.rb b/app/controllers/evaluations_controller.rb index 754f386e15..3d5bd69f0a 100644 --- a/app/controllers/evaluations_controller.rb +++ b/app/controllers/evaluations_controller.rb @@ -12,6 +12,8 @@ class EvaluationsController < ApplicationController def show redirect_to add_users_evaluation_path(@evaluation) if @evaluation.users.count == 0 @feedbacks = @evaluation.evaluation_sheet + @users = apply_scopes(@evaluation.users) + @course_labels = CourseLabel.where(course: @course) @crumbs = [[@evaluation.series.course.name, course_url(@evaluation.series.course)], [@evaluation.series.name, breadcrumb_series_path(@evaluation.series, current_user)], [I18n.t('evaluations.show.evaluation'), '#']] @title = I18n.t('evaluations.show.evaluation') end diff --git a/app/views/evaluations/_evaluation_grade_table.html.erb b/app/views/evaluations/_evaluation_grade_table.html.erb index 6d4f6be660..51c79b9d28 100644 --- a/app/views/evaluations/_evaluation_grade_table.html.erb +++ b/app/views/evaluations/_evaluation_grade_table.html.erb @@ -30,7 +30,7 @@ - <% evaluation.users.order(last_name: :asc, first_name: :asc).each do |user| %> + <% users.order(last_name: :asc, first_name: :asc).each do |user| %> <% feedback_l = feedbacks[:feedbacks][user.id] %> <% average = feedbacks[:averages][user.id] %> diff --git a/app/views/evaluations/show.html.erb b/app/views/evaluations/show.html.erb index af9304b2cd..551cb6c9df 100644 --- a/app/views/evaluations/show.html.erb +++ b/app/views/evaluations/show.html.erb @@ -51,7 +51,10 @@

<%= t ".evaluation_details_info_html" %>

- <%= render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation %> + <%= render partial: 'layouts/searchbar', locals: { course_labels: @course_labels } %> +
+ <%= render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation %> +
<% if @evaluation.graded? %>
@@ -67,8 +70,10 @@
-

- <%= render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation %> + <%= render partial: 'layouts/searchbar', locals: { course_labels: @course_labels }%> +
+ <%= render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users %> +
<% end %> diff --git a/app/views/evaluations/show.js.erb b/app/views/evaluations/show.js.erb new file mode 100644 index 0000000000..bde3b106e9 --- /dev/null +++ b/app/views/evaluations/show.js.erb @@ -0,0 +1,2 @@ +$("#evaluation-table-wrapper").html("<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") +$("#evaluation-grade-table-wrapper").html("<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") From 7621dcbf54c49cf343e6d37c4e93e0c6e13b0279 Mon Sep 17 00:00:00 2001 From: TimonDB Date: Wed, 1 Sep 2021 12:05:26 +0200 Subject: [PATCH 2/4] Render correct table --- app/views/evaluations/show.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/evaluations/show.js.erb b/app/views/evaluations/show.js.erb index bde3b106e9..8747eddc02 100644 --- a/app/views/evaluations/show.js.erb +++ b/app/views/evaluations/show.js.erb @@ -1,2 +1,2 @@ -$("#evaluation-table-wrapper").html("<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") +$("#evaluation-table-wrapper").html("<%= escape_javascript(render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") $("#evaluation-grade-table-wrapper").html("<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") From d5caeb8d7ff7515d686c780e3ede2c7da662ca68 Mon Sep 17 00:00:00 2001 From: TimonDB Date: Wed, 1 Sep 2021 12:12:31 +0200 Subject: [PATCH 3/4] Correclty render evaluations table --- app/views/evaluations/_evaluation_table.html.erb | 2 +- app/views/evaluations/show.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/evaluations/_evaluation_table.html.erb b/app/views/evaluations/_evaluation_table.html.erb index 8ebd1a27f8..c92f8ef543 100644 --- a/app/views/evaluations/_evaluation_table.html.erb +++ b/app/views/evaluations/_evaluation_table.html.erb @@ -9,7 +9,7 @@ - <% evaluation.users.order(last_name: :asc, first_name: :asc).each do |user| %> + <% users.order(last_name: :asc, first_name: :asc).each do |user| %> <% feedback_l = feedbacks[:feedbacks][user.id] %> <%= link_to user.full_name, course_member_path(@evaluation.series.course, user), title: user.full_name, class: "ellipsis-overflow", target: "_blank" %> diff --git a/app/views/evaluations/show.html.erb b/app/views/evaluations/show.html.erb index 551cb6c9df..9cb8696af9 100644 --- a/app/views/evaluations/show.html.erb +++ b/app/views/evaluations/show.html.erb @@ -53,7 +53,7 @@

<%= t ".evaluation_details_info_html" %>

<%= render partial: 'layouts/searchbar', locals: { course_labels: @course_labels } %>
- <%= render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation %> + <%= render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users %>
<% if @evaluation.graded? %> From 0de1ed722679c998e20a0ccd2d6ca9b590ede093 Mon Sep 17 00:00:00 2001 From: TimonDB Date: Wed, 1 Sep 2021 14:15:19 +0200 Subject: [PATCH 4/4] Enable searching via course labels --- app/controllers/evaluations_controller.rb | 10 ++++++++-- app/views/evaluations/show.html.erb | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/evaluations_controller.rb b/app/controllers/evaluations_controller.rb index 3d5bd69f0a..3812a9c29b 100644 --- a/app/controllers/evaluations_controller.rb +++ b/app/controllers/evaluations_controller.rb @@ -7,13 +7,19 @@ class EvaluationsController < ApplicationController has_scope :by_institution, as: 'institution_id' has_scope :by_filter, as: 'filter' - has_scope :by_course_labels, as: 'course_labels', type: :array + has_scope :by_course_labels, as: 'course_labels', type: :array do |controller, scope, value| + if controller.params[:action] == 'show' + scope.by_course_labels(value, Evaluation.find(controller.params[:id]).series.course_id) + else + scope.by_course_labels(value) + end + end def show redirect_to add_users_evaluation_path(@evaluation) if @evaluation.users.count == 0 @feedbacks = @evaluation.evaluation_sheet @users = apply_scopes(@evaluation.users) - @course_labels = CourseLabel.where(course: @course) + @course_labels = CourseLabel.where(course: @evaluation.series.course) @crumbs = [[@evaluation.series.course.name, course_url(@evaluation.series.course)], [@evaluation.series.name, breadcrumb_series_path(@evaluation.series, current_user)], [I18n.t('evaluations.show.evaluation'), '#']] @title = I18n.t('evaluations.show.evaluation') end diff --git a/app/views/evaluations/show.html.erb b/app/views/evaluations/show.html.erb index 9cb8696af9..0d81a324e1 100644 --- a/app/views/evaluations/show.html.erb +++ b/app/views/evaluations/show.html.erb @@ -40,6 +40,7 @@
+ <%= render partial: 'layouts/searchbar', locals: { course_labels: @course_labels } %>
- <%= render partial: 'layouts/searchbar', locals: { course_labels: @course_labels }%>
<%= render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users %>