diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb index f31cdc6ea3..847c808ac2 100644 --- a/app/helpers/activity_helper.rb +++ b/app/helpers/activity_helper.rb @@ -99,6 +99,14 @@ def compare_solutions(a, b) end end + def activity_icon(activity, size = 18) + if activity.exercise? + content_tag(:i, '', class: "mdi mdi-#{activity.programming_language&.icon} mdi-#{size}", title: t('activities.index.type.exercise_language', language: activity.programming_language&.name&.titleize)) + elsif activity.content_page? + content_tag(:i, '', class: "mdi mdi-book-open-variant mdi-#{size}", title: t('activities.index.type.content')) + end + end + class DescriptionRenderer require 'nokogiri' include Rails.application.routes.url_helpers diff --git a/app/views/activities/_activities_table.html.erb b/app/views/activities/_activities_table.html.erb index a8539015ca..5993562456 100644 --- a/app/views/activities/_activities_table.html.erb +++ b/app/views/activities/_activities_table.html.erb @@ -51,11 +51,7 @@ - <% if activity.exercise? %> - " title="<%= "#{t "activities.index.type.exercise_language", language: activity.programming_language&.name&.titleize}" %>"> - <% elsif activity.content_page? %> - "> - <% end %> + <%= activity_icon(activity) %> diff --git a/app/views/activities/_series_activities_add_table.html.erb b/app/views/activities/_series_activities_add_table.html.erb index 2133371422..c0765a484a 100644 --- a/app/views/activities/_series_activities_add_table.html.erb +++ b/app/views/activities/_series_activities_add_table.html.erb @@ -21,8 +21,7 @@ <%= raw "" if activity.access_private? %> <%= raw "" if activity.removed? %> <%= raw "" if activity.not_valid? %> - <%= raw "" if activity.exercise? %> - <%= raw "" if activity.content_page? %> + <%= activity_icon(activity) %> diff --git a/app/views/activities/_series_activities_table.html.erb b/app/views/activities/_series_activities_table.html.erb index 47aba42e1c..de2c7777b8 100644 --- a/app/views/activities/_series_activities_table.html.erb +++ b/app/views/activities/_series_activities_table.html.erb @@ -46,11 +46,7 @@ - <% if activity.exercise? %> - " title="<%= "#{t "activities.index.type.exercise_language", language: activity.programming_language&.name&.titleize}" %>"> - <% elsif activity.content_page? %> - "> - <% end %> + <%= activity_icon(activity) %> diff --git a/app/views/activities/edit.html.erb b/app/views/activities/edit.html.erb index 4f5d516319..8520a4aa5f 100644 --- a/app/views/activities/edit.html.erb +++ b/app/views/activities/edit.html.erb @@ -3,7 +3,11 @@
-

<%= @activity.name %>

+

+ <%= activity_icon(@activity, 24) %> +   + <%= @activity.name %> +

<%= render 'application/fab_button', form: "edit_activity_#{@activity.id}", icon: 'check' %>
diff --git a/app/views/activities/info.html.erb b/app/views/activities/info.html.erb index a61d044c39..b02f90df4f 100644 --- a/app/views/activities/info.html.erb +++ b/app/views/activities/info.html.erb @@ -11,7 +11,11 @@
-

<%= @activity.name %>

+

+ <%= activity_icon(@activity, 24) %> +   + <%= @activity.name %> +

diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 5581d2bfda..6c8f6ad3c0 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -38,6 +38,8 @@ end %>

+ <%= activity_icon(@activity, 24) %> +   <%= @activity.name %>

<% if @series.present? %> diff --git a/app/views/evaluations/_exercises_progress_table.html.erb b/app/views/evaluations/_exercises_progress_table.html.erb index 26ee861123..e3a312c750 100644 --- a/app/views/evaluations/_exercises_progress_table.html.erb +++ b/app/views/evaluations/_exercises_progress_table.html.erb @@ -12,7 +12,7 @@ <% local_assigns[:metadata][:per_exercise].each do |meta| %> - " title="<%= "#{t "activities.index.type.exercise_language", language: meta[:exercise].programming_language&.name&.titleize}" %>"> + <%= activity_icon(meta[:exercise]) %> diff --git a/app/views/evaluations/_exercises_table.html.erb b/app/views/evaluations/_exercises_table.html.erb index 57a318ccdf..29c65c92f7 100644 --- a/app/views/evaluations/_exercises_table.html.erb +++ b/app/views/evaluations/_exercises_table.html.erb @@ -11,7 +11,7 @@ <% local_assigns[:exercises].each do |exercise| %> - " title="<%= "#{t "activities.index.type.exercise_language", language: exercise.programming_language&.name&.titleize}" %>"> + <%= activity_icon(exercise) %>