Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable user search in evaluations #3058

Merged
merged 4 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/controllers/evaluations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +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: @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
Expand Down
2 changes: 1 addition & 1 deletion app/views/evaluations/_evaluation_grade_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</tr>
</thead>
<tbody>
<% 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] %>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/evaluations/_evaluation_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</tr>
</thead>
<tbody>
<% 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] %>
<tr>
<td class="user-name ellipsis-overflow"><%= link_to user.full_name, course_member_path(@evaluation.series.course, user), title: user.full_name, class: "ellipsis-overflow", target: "_blank" %></td>
Expand Down
10 changes: 7 additions & 3 deletions app/views/evaluations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</div>
<div class="card">
<div class="card-supporting-text">
<%= render partial: 'layouts/searchbar', locals: { course_labels: @course_labels } %>
<div class="card-tab">
<ul id="user-tabs" class="nav nav-tabs" role="tablist">
<li role="presentation">
Expand All @@ -51,7 +52,9 @@
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="evaluation-details">
<p class="help-block"><%= t ".evaluation_details_info_html" %></p>
<%= render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation %>
<div id="evaluation-table-wrapper">
<%= render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users %>
</div>
</div>
<% if @evaluation.graded? %>
<div role="tabpanel" class="tab-pane" id="grading-details">
Expand All @@ -67,8 +70,9 @@
</div>
</div>
</div>
<p class="help-block"></p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help paragraph was removed. @niknetniko can you remember if we used this for something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a mistake, and can be safely removed.

<%= render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation %>
<div id="evaluation-grade-table-wrapper">
<%= render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users %>
</div>
</div>
<% end %>
</div>
Expand Down
2 changes: 2 additions & 0 deletions app/views/evaluations/show.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$("#evaluation-table-wrapper").html("<%= escape_javascript(render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be optimized to only update the visible table, but it would leave it like this for now.

$("#evaluation-grade-table-wrapper").html("<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>")