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 @@
  • <%= link_to learning_path_topic, class: 'link-overlay' do %> -

    <%= learning_path_topic.title %>

    +
    +

    <%= learning_path_topic.title %>

    +
    + +
    + <% competency = display_difficulty_level(learning_path_topic.difficulty_level) %> + <% if competency %> + <%= competency %> + <% end %> + <%= pluralize(learning_path_topic.materials.count, 'materials') %> +
    <%= render_sanitized_markdown truncate(learning_path_topic.description, length: 300, separator: ' ') %> diff --git a/app/views/learning_path_topics/show.html.erb b/app/views/learning_path_topics/show.html.erb index 8034a1d48..8d151812e 100644 --- a/app/views/learning_path_topics/show.html.erb +++ b/app/views/learning_path_topics/show.html.erb @@ -1,6 +1,6 @@
    - + - + + + diff --git a/app/views/learning_paths/_form.html.erb b/app/views/learning_paths/_form.html.erb index fdb529d07..9e1cf7f33 100644 --- a/app/views/learning_paths/_form.html.erb +++ b/app/views/learning_paths/_form.html.erb @@ -55,6 +55,12 @@ <%= f.multi_input :target_audience, label: 'Target audiences', errors: @learning_path.errors[:target_audience], title: t('events.hints.targets'), visibility_toggle: TeSS::Config.feature['learning_paths_disabled'] %> + + <%= f.input :difficulty_level, collection: DifficultyDictionary.instance.options_for_select, + prompt: 'Select a difficulty level...', + errors: @learning_path.errors[:difficulty_level], input_html: { title: t('learning_paths.hints.difficulty') }, + visibility_toggle: TeSS::Config.feature['learning_paths_disabled'] %> + <%= f.input :prerequisites, as: :markdown_area, input_html: { rows: '3', title: t('learning_paths.hints.prerequisites') }, diff --git a/app/views/learning_paths/_learning_path.html.erb b/app/views/learning_paths/_learning_path.html.erb index 64c87a277..f486137dc 100644 --- a/app/views/learning_paths/_learning_path.html.erb +++ b/app/views/learning_paths/_learning_path.html.erb @@ -1,38 +1,47 @@ -
  • - <%= link_to learning_path, class: 'link-overlay' do %> - <%= item_order_badge(collection_item) if defined? collection_item %> +<% cache(learning_path, expires_in: 1.hour) do %> +
  • + <%= link_to learning_path, class: 'link-overlay' do %> + <%= item_order_badge(collection_item) if defined? collection_item %> -
    -
    - <% if current_user&.is_admin? %> - <%= missing_icon(learning_path) %> - <%= scrape_status_icon(learning_path) %> - <%= suggestion_icon(learning_path) %> - <% end %> -
    -
    - <%= display_attribute_no_label(learning_path, :learning_path_type) %> -
    -

    <%= learning_path.title %>

    -
    +
    +
    + <% if current_user&.is_admin? %> + <%= missing_icon(learning_path) %> + <%= scrape_status_icon(learning_path) %> + <%= suggestion_icon(learning_path) %> + <% end %> +
    +
    + <%= display_attribute_no_label(learning_path, :learning_path_type) %> +
    +

    <%= learning_path.title %>

    + <%= rand %> -
    -
    - <% if controller_name != 'content_providers' && learning_path.content_provider %> - <%= image_tag(learning_path.content_provider.image.url, class: 'provider-avatar') %> - <% end %>
    -
    - <%= pluralize(learning_path.topics.count, 'topic') %> - <%= pluralize(learning_path.topics_materials.count, 'materials') %> -
    +
    +
    + <% if controller_name != 'content_providers' && learning_path.content_provider %> + <%= image_tag(learning_path.content_provider.image.url, class: 'provider-avatar') %> + <% end %> +
    -
    - <%= keywords_and_topics(learning_path, limit: 10) %> +
    + <% competency = display_difficulty_level(learning_path.difficulty_level) %> + <% if competency %> + <%= competency %> + <% end %> + <%= pluralize(learning_path.topics.count, 'topic') %> + <%= pluralize(learning_path.topics_materials.count, 'materials') %> +
    + +
    + <%= keywords_and_topics(learning_path, limit: 10) %> +
    -
    - <%= item_comment(collection_item) if defined? collection_item %> - <% end %> -
  • + <%= item_comment(collection_item) if defined? collection_item %> + <% end %> + +<% end %> + diff --git a/app/views/learning_paths/show.html.erb b/app/views/learning_paths/show.html.erb index b107a72e9..6be659567 100644 --- a/app/views/learning_paths/show.html.erb +++ b/app/views/learning_paths/show.html.erb @@ -66,8 +66,9 @@
    <%= lpt.order %>

    <%= lpt.topic.title %>

    - <% if lpt.topic.difficulty_level.present? %> - <%= display_difficulty_level(lpt.topic) %> + <% competency = display_difficulty_level(lpt.topic.difficulty_level) %> + <% if competency %> + <%= competency %> <% end %> <%= pluralize(lpt.topic.material_items.count, 'material') %> diff --git a/app/views/materials/_form.html.erb b/app/views/materials/_form.html.erb index 22eb23b4e..6c994e3a0 100644 --- a/app/views/materials/_form.html.erb +++ b/app/views/materials/_form.html.erb @@ -93,7 +93,7 @@ <%= f.input :difficulty_level, collection: DifficultyDictionary.instance.options_for_select, - label: 'Competency level', prompt: 'Select a difficulty level...', field_lock: true, + prompt: 'Select a difficulty level...', field_lock: true, errors: @material.errors[:difficulty_level], input_html: { title: t('materials.hints.difficulty') }, visibility_toggle: TeSS::Config.feature['materials_disabled'] %> diff --git a/app/views/materials/_material.html.erb b/app/views/materials/_material.html.erb index 776d5a42a..a1a09d4ed 100644 --- a/app/views/materials/_material.html.erb +++ b/app/views/materials/_material.html.erb @@ -34,7 +34,10 @@ <% end %>
    -
    <%= display_difficulty_level(material) %>
    + <% competency = display_difficulty_level(material.difficulty_level) %> + <% if competency %> +
    <%= competency %>
    + <% end %> <%= keywords_and_topics(material, limit: 10) %> diff --git a/app/views/workflows/_workflow.html.erb b/app/views/workflows/_workflow.html.erb index 2fedb82bb..a5b42e18a 100644 --- a/app/views/workflows/_workflow.html.erb +++ b/app/views/workflows/_workflow.html.erb @@ -11,6 +11,11 @@ + <% competency = display_difficulty_level(workflow.difficulty_level) %> + <% if competency %> +
    <%= competency %>
    + <% end %> +
    <%= render_sanitized_markdown truncate(workflow.description, length: 300, separator: ' ') %>
    diff --git a/config/locales/en.yml b/config/locales/en.yml index 482522214..00d00d8ea 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -73,6 +73,14 @@ en: default_language: 'Default language' person: name: 'Name' + material: + difficulty_level: Competency level + learning_path: + difficulty_level: Competency level + learning_path_topic: + difficulty_level: Competency level + workflow: + difficulty_level: Competency level about: headings: events: Events @@ -840,8 +848,9 @@ en: user: Owner organizer: Organiser titles: - language: 'Language' - date_added: 'Date added' + language: Language + date_added: Date added + difficulty_level: Competency level languages: # Only needed to override default names from I18nData el: 'Greek' errors: