Skip to content

Commit

Permalink
Move count to front & only show if > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed Oct 1, 2020
1 parent 0b0a898 commit 3a5e259
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ def questions
.order(updated_at: :desc)
.includes(:user, :last_updated_by, submission: [:exercise])
.paginate(page: parse_pagination_param(params[:answered_page]), per_page: 10)
@title = I18n.t('courses.questions.questions.page_title', count: @course.unanswered_questions.count)
count = @course.unanswered_questions.count
@title = if count == 0
I18n.t('courses.questions.questions.title')
else
I18n.t('courses.questions.questions.page_title', count: count)
end
@dot_icon.push(:questions) if @unanswered.any?
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/courses/questions.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ document.querySelector(".question-table-answered").innerHTML = "<%= escape_javas
<% else %>
document.getElementById("questions-in-progress").classList.remove("hidden");
<% end %>
dodona.setDocumentTitle("Dodona - <%= @title %>");
dodona.setDocumentTitle("<%= @title %> - Dodona");
<% if @unanswered.any? %>
dodona.dotManager.requestDot("questions");
<% else %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/views/courses/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ en:
open: "Unanswered questions"
in_progress: "Questions in progress"
closed: "Answered questions"
page_title: "Questions (%{count})"
page_title: "(%{count}) Questions"
title: "Questions"
auto_refresh: Automatically refresh questions
ago: "%{when} ago"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/views/courses/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ nl:
in_progress: "Vragen in behandeling"
closed: "Beantwoorde vragen"
title: "Vragen"
page_title: "Vragen (%{count})"
page_title: "(%{count}) Vragen"
auto_refresh: Vragen automatisch vernieuwen
ago: "%{when} geleden"
last_edited_by:
Expand Down

0 comments on commit 3a5e259

Please sign in to comment.