diff --git a/app/helpers/materials_helper.rb b/app/helpers/materials_helper.rb index d7b72b8fc..5cc6749f9 100644 --- a/app/helpers/materials_helper.rb +++ b/app/helpers/materials_helper.rb @@ -50,17 +50,20 @@ def target_audience_title_for_label(label) TargetAudienceDictionary.instance.lookup_value(label, 'title') || label end - def display_difficulty_level(resource) - value = resource.send('difficulty_level') + def display_difficulty_level(value) + data = DifficultyDictionary.instance.lookup(value) + return nil if data.nil? || value == 'notspecified' if value == 'beginner' - '• ' + value + text = '• ' + data['title'] elsif value == 'intermediate' - '•• ' + value + text = '•• ' + data['title'] elsif value == 'advanced' - '••• ' + value + text = '••• ' + data['title'] else - '' + text = data['title'] end + + content_tag(:span, text, title: data['description']) end def display_attribute(resource, attribute, show_label: true, title: nil, markdown: false, list: false, expandable: false) diff --git a/app/views/common/_extra_metadata.html.erb b/app/views/common/_extra_metadata.html.erb index 7c7a5f965..d9d752daa 100644 --- a/app/views/common/_extra_metadata.html.erb +++ b/app/views/common/_extra_metadata.html.erb @@ -4,6 +4,7 @@ <%= display_attribute(resource, :licence) { |value| licence_name_for_abbreviation(value) } if resource.respond_to?(:licence) %> <%= display_attribute(resource, :contact) if resource.respond_to?(:contact) %> <%= display_attribute(resource, :keywords) { |values| values.join(', ') } %> +<%= display_attribute(resource, :difficulty_level) { |value| display_difficulty_level(value) } if resource.respond_to?(:difficulty_level) %> <% if resource.is_a?(Material) %> <%= display_attribute(resource, :fields) { |values| values.join(', ') } %> diff --git a/app/views/learning_path_topics/_form.html.erb b/app/views/learning_path_topics/_form.html.erb index 9f11f20d9..c795ed424 100644 --- a/app/views/learning_path_topics/_form.html.erb +++ b/app/views/learning_path_topics/_form.html.erb @@ -10,7 +10,7 @@ <%= f.input :difficulty_level, collection: DifficultyDictionary.instance.options_for_select, - label: 'Competency level', prompt: 'Select a difficulty level...', + prompt: 'Select a difficulty level...', errors: @learning_path_topic.errors[:difficulty_level], input_html: { title: t('learning_paths.hints.difficulty') } %> diff --git a/app/views/learning_path_topics/_learning_path_topic.html.erb b/app/views/learning_path_topics/_learning_path_topic.html.erb index fceb037d4..66ffe4523 100644 --- a/app/views/learning_path_topics/_learning_path_topic.html.erb +++ b/app/views/learning_path_topics/_learning_path_topic.html.erb @@ -1,6 +1,16 @@