Skip to content

Commit

Permalink
Enable searching via course labels
Browse files Browse the repository at this point in the history
  • Loading branch information
TimonDB authored and bmesuere committed Sep 2, 2021
1 parent d5caeb8 commit 0de1ed7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions app/controllers/evaluations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 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,6 @@
<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 partial: 'layouts/searchbar', locals: { course_labels: @course_labels } %>
<div id="evaluation-table-wrapper">
<%= render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users %>
</div>
Expand All @@ -70,7 +70,6 @@
</div>
</div>
</div>
<%= render partial: 'layouts/searchbar', locals: { course_labels: @course_labels }%>
<div id="evaluation-grade-table-wrapper">
<%= render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users %>
</div>
Expand Down

0 comments on commit 0de1ed7

Please sign in to comment.