cleanup modules view logic
test plan: - modules functionality should NOT have changed at all to the user refs CYOE-234 Change-Id: I02dee3ba4c0d9f8712c920e04cefe05b43434f7c Reviewed-on: https://gerrit.instructure.com/84327 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Alex Morris <amorris@instructure.com> Product-Review: Felix Milea-Ciobanu <fmileaciobanu@instructure.com>
This commit is contained in:
parent
3983e8da1c
commit
6fddd54915
|
@ -24,6 +24,8 @@ class ContextModulesController < ApplicationController
|
||||||
before_filter { |c| c.active_tab = "modules" }
|
before_filter { |c| c.active_tab = "modules" }
|
||||||
|
|
||||||
module ModuleIndexHelper
|
module ModuleIndexHelper
|
||||||
|
include ContextModulesHelper
|
||||||
|
|
||||||
def load_module_file_details
|
def load_module_file_details
|
||||||
attachment_tags = @context.module_items_visible_to(@current_user).where(content_type: 'Attachment').preload(:content => :folder)
|
attachment_tags = @context.module_items_visible_to(@current_user).where(content_type: 'Attachment').preload(:content => :folder)
|
||||||
attachment_tags.inject({}) do |items, file_tag|
|
attachment_tags.inject({}) do |items, file_tag|
|
||||||
|
@ -36,10 +38,23 @@ class ContextModulesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def modules_cache_key
|
||||||
|
@modules_cache_key ||= begin
|
||||||
|
visible_assignments = @current_user.try(:assignment_and_quiz_visibilities, @context)
|
||||||
|
cache_key_items = [@context.cache_key, @can_edit, 'all_context_modules_draft_8', collection_cache_key(@modules), Time.zone, Digest::MD5.hexdigest(visible_assignments.to_s)]
|
||||||
|
cache_key = cache_key_items.join('/')
|
||||||
|
cache_key = add_menu_tools_to_cache_key(cache_key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def load_modules
|
def load_modules
|
||||||
@modules = @context.modules_visible_to(@current_user)
|
@modules = @context.modules_visible_to(@current_user)
|
||||||
@collapsed_modules = ContextModuleProgression.for_user(@current_user).for_modules(@modules).select([:context_module_id, :collapsed]).select{|p| p.collapsed? }.map(&:context_module_id)
|
@collapsed_modules = ContextModuleProgression.for_user(@current_user).for_modules(@modules).select([:context_module_id, :collapsed]).select{|p| p.collapsed? }.map(&:context_module_id)
|
||||||
|
|
||||||
|
@can_edit = can_do(@context, @current_user, :manage_content)
|
||||||
|
|
||||||
|
modules_cache_key
|
||||||
|
|
||||||
@menu_tools = {}
|
@menu_tools = {}
|
||||||
placements = [:assignment_menu, :discussion_topic_menu, :file_menu, :module_menu, :quiz_menu, :wiki_page_menu]
|
placements = [:assignment_menu, :discussion_topic_menu, :file_menu, :module_menu, :quiz_menu, :wiki_page_menu]
|
||||||
tools = ContextExternalTool.all_tools_for(@context, placements: placements,
|
tools = ContextExternalTool.all_tools_for(@context, placements: placements,
|
||||||
|
@ -65,7 +80,6 @@ class ContextModulesController < ApplicationController
|
||||||
|
|
||||||
if @context.grants_right?(@current_user, session, :participate_as_student)
|
if @context.grants_right?(@current_user, session, :participate_as_student)
|
||||||
return unless tab_enabled?(@context.class::TAB_MODULES)
|
return unless tab_enabled?(@context.class::TAB_MODULES)
|
||||||
ActiveRecord::Associations::Preloader.new.preload(@modules, :content_tags)
|
|
||||||
@modules.each{|m| m.evaluate_for(@current_user) }
|
@modules.each{|m| m.evaluate_for(@current_user) }
|
||||||
session[:module_progressions_initialized] = true
|
session[:module_progressions_initialized] = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,6 +73,44 @@ module ContextModulesHelper
|
||||||
item.content.can_unpublish?
|
item.content.can_unpublish?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def preload_modules_content(modules, can_edit)
|
||||||
|
ActiveRecord::Associations::Preloader.new.preload(modules, :content_tags => :content)
|
||||||
|
preload_can_unpublish(@context, @modules) if can_edit
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_module_data(mod, is_cyoe_on = false, is_student = false, cyoe_data = nil)
|
||||||
|
# pre-calculated module view data can be added here
|
||||||
|
module_data = {
|
||||||
|
published_status: mod.published? ? 'published' : 'unpublished',
|
||||||
|
items: mod.content_tags_visible_to(@current_user).map
|
||||||
|
}
|
||||||
|
|
||||||
|
items_data = {}
|
||||||
|
module_data[:items].each do |item|
|
||||||
|
# pre-calculated module item view data can be added here
|
||||||
|
item_data = {
|
||||||
|
published_status: item.published? ? 'published' : 'unpublished'
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_cyoe_on && is_student
|
||||||
|
item_data[:is_trigger_assignment] = cyoe_data ? cyoe_data.has_key?(item.id) : false
|
||||||
|
item_data[:is_in_conditional] = false # TODO: check against cyoe_data
|
||||||
|
|
||||||
|
# FIXME: use CYOE data to figure out if
|
||||||
|
if item.graded?
|
||||||
|
item_data[:has_submission] = item.content.submissions.length > 0 if defined? item.content.submissions
|
||||||
|
item_data[:has_submission] = item.content.quiz_submissions.length > 0 if defined? item.content.quiz_submissions
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
items_data[item.id] = item_data
|
||||||
|
end
|
||||||
|
|
||||||
|
module_data[:items_data] = items_data
|
||||||
|
|
||||||
|
return module_data
|
||||||
|
end
|
||||||
|
|
||||||
def module_item_translated_content_type(item)
|
def module_item_translated_content_type(item)
|
||||||
return '' unless item
|
return '' unless item
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
<% @body_classes << 'padless-content' %>
|
|
||||||
<% course_home ||= false %>
|
|
||||||
<%
|
<%
|
||||||
|
@body_classes << 'padless-content'
|
||||||
|
course_home ||= false
|
||||||
js_env({
|
js_env({
|
||||||
:COLLAPSED_MODULES => @collapsed_modules,
|
:COLLAPSED_MODULES => @collapsed_modules,
|
||||||
:CAN_MANAGE_MODULES => can_do(@context, @current_user, :manage_content),
|
:CAN_MANAGE_MODULES => @can_edit,
|
||||||
:IS_STUDENT => can_do(@context, @current_user, :participate_as_student),
|
:IS_STUDENT => can_do(@context, @current_user, :participate_as_student),
|
||||||
:COURSE_ID => @context.id,
|
:COURSE_ID => @context.id,
|
||||||
:NO_MODULE_PROGRESSIONS => @context.large_roster,
|
:NO_MODULE_PROGRESSIONS => @context.large_roster,
|
||||||
})
|
})
|
||||||
|
js_bundle :context_modules
|
||||||
|
css_bundle :content_next
|
||||||
%>
|
%>
|
||||||
<% js_bundle :context_modules %>
|
|
||||||
<% css_bundle :content_next %>
|
|
||||||
|
|
||||||
<% if course_home %>
|
<% if course_home %>
|
||||||
<div class="screenreader-only"><%= @context.name %></div>
|
<div class="screenreader-only"><%= @context.name %></div>
|
||||||
<h2 class="context-modules-title screenreader-only"><%= t('headings.course_modules', %{Course Modules}) %></h2>
|
<h2 class="context-modules-title screenreader-only"><%= t('headings.course_modules', %{Course Modules}) %></h2>
|
||||||
|
@ -20,7 +19,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="header-bar">
|
<div class="header-bar">
|
||||||
<% if can_do(@context, @current_user, :manage_content) %>
|
<% if @can_edit %>
|
||||||
<div class="header-bar-right">
|
<div class="header-bar-right">
|
||||||
<a class="btn module_progressions_link" href="<%= progressions_course_context_modules_path(@context) %>"><%= t('links.student_progress', 'View Progress') %></a>
|
<a class="btn module_progressions_link" href="<%= progressions_course_context_modules_path(@context) %>"><%= t('links.student_progress', 'View Progress') %></a>
|
||||||
<button class="btn btn-primary add_module_link">
|
<button class="btn btn-primary add_module_link">
|
||||||
|
@ -32,7 +31,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if can_do(@context, @current_user, :manage_content) %>
|
<% if @can_edit %>
|
||||||
<div class="hidden-readable screenreader-only" aria-label="keyboard instructions">
|
<div class="hidden-readable screenreader-only" aria-label="keyboard instructions">
|
||||||
<%= t('modules_keyboard_hint_updated',
|
<%= t('modules_keyboard_hint_updated',
|
||||||
'Warning: For improved accessibility in reordering Modules (or Module items), please use the Move To Dialog option found in the menu.') %>
|
'Warning: For improved accessibility in reordering Modules (or Module items), please use the Move To Dialog option found in the menu.') %>
|
||||||
|
@ -59,27 +58,21 @@ TEXT
|
||||||
<div
|
<div
|
||||||
id="context_modules"
|
id="context_modules"
|
||||||
aria-label="<%= t('headings.course_modules', %{Course Modules}) %>"
|
aria-label="<%= t('headings.course_modules', %{Course Modules}) %>"
|
||||||
class="ig-list <%= 'editable' if can_do(@context, @current_user, :manage_content) %>"
|
class="ig-list <%= 'editable' if @can_edit %>"
|
||||||
>
|
>
|
||||||
<% editable = can_do(@context, @current_user, :manage_content) %>
|
<% cache(@modules_cache_key) do %>
|
||||||
<% visible_assignments = @current_user.try(:assignment_and_quiz_visibilities, @context) %>
|
<% preload_modules_content(@modules, @can_edit) %>
|
||||||
<% cache_key_items = [@context.cache_key, editable, 'all_context_modules_draft_9', collection_cache_key(@modules), Time.zone, Digest::MD5.hexdigest(visible_assignments.to_s)] %>
|
|
||||||
<% cache_key = cache_key_items.join('/') %>
|
|
||||||
<% cache_key = add_menu_tools_to_cache_key(cache_key) %>
|
|
||||||
<% cache(cache_key) do %>
|
|
||||||
<% ActiveRecord::Associations::Preloader.new.preload(@modules, :content_tags => :content) %>
|
|
||||||
<% preload_can_unpublish(@context, @modules) %>
|
|
||||||
<% @modules.each do |m| %>
|
<% @modules.each do |m| %>
|
||||||
<%= render :partial => 'context_modules/context_module_next', :object => m, :locals => {:editable => editable} %>
|
<%= render :partial => 'context_modules/context_module_next', :object => m, :as => :context_module, :locals => { :editable => @can_edit } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render :partial => 'context_modules/context_module_next', :object => nil %>
|
<%= render :partial => 'context_modules/context_module_next', :object => nil, :as => :context_module %>
|
||||||
<%= render :partial => 'context_modules/module_item_next', :object => nil, :locals => {:editable => editable } %>
|
<%= render :partial => 'context_modules/module_item_next', :object => nil, :as => :module_item, :locals => { :editable => @can_edit } %>
|
||||||
|
|
||||||
<% if can_do(@context, @current_user, :manage_content) %>
|
<% if @can_edit %>
|
||||||
<form id="move_context_module_form" style="display:none" class="form-dialog" title="Move Module">
|
<form id="move_context_module_form" style="display:none" class="form-dialog" title="Move Module">
|
||||||
<div class="form-dialog-content">
|
<div class="form-dialog-content">
|
||||||
<h2><%= t('move_module.place', "Place ") %> <span id="move_module_name"> </span></h2>
|
<h2><%= t('move_module.place', "Place ") %> <span id="move_module_name"> </span></h2>
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
|
|
||||||
<%
|
<%
|
||||||
context_module_next ||= nil
|
context_module_next ||= nil
|
||||||
context_module = context_module_next
|
context_module ||= context_module_next
|
||||||
|
module_data = context_module ? process_module_data(context_module) : { published_status: 'unpublished' }
|
||||||
editable ||= can_do(@context, @current_user, :manage_content)
|
editable ||= can_do(@context, @current_user, :manage_content)
|
||||||
workflow_state = context_module && context_module.workflow_state
|
workflow_state = context_module && context_module.workflow_state
|
||||||
published_status = context_module && context_module.published? ? 'published' : 'unpublished'
|
|
||||||
@modules ||= []
|
@modules ||= []
|
||||||
%>
|
%>
|
||||||
<% cache_if_module(context_module, editable, @current_user, @context) do %>
|
|
||||||
|
|
||||||
|
<% cache_if_module(context_module, editable, @current_user, @context) do %>
|
||||||
<div
|
<div
|
||||||
class="item-group-condensed context_module
|
class="item-group-condensed context_module
|
||||||
<%= 'editable_context_module' if editable %>
|
<%= 'editable_context_module' if editable %>
|
||||||
|
@ -112,15 +111,15 @@
|
||||||
data-module-type="module"
|
data-module-type="module"
|
||||||
data-id="<%= context_module && context_module.id %>"
|
data-id="<%= context_module && context_module.id %>"
|
||||||
data-course-id="<%= context_module && context_module.context_id %>"
|
data-course-id="<%= context_module && context_module.context_id %>"
|
||||||
data-published="<%= published_status == 'published' %>"
|
data-published="<%= module_data[:published_status] == 'published' %>"
|
||||||
data-publishable="<%= true %>"
|
data-publishable="<%= true %>"
|
||||||
data-publish-message="<%= t('Unpublished. Click to publish %{module_name}.', {module_name: context_module ? context_module.name : 'module'}) %>"
|
data-publish-message="<%= t('Unpublished. Click to publish %{module_name}.', {module_name: context_module ? context_module.name : 'module'}) %>"
|
||||||
data-unpublish-message="<%= t('Published. Click to unpublish %{module_name}.', {module_name: context_module ? context_module.name : 'module'}) %>"
|
data-unpublish-message="<%= t('Published. Click to unpublish %{module_name}.', {module_name: context_module ? context_module.name : 'module'}) %>"
|
||||||
title=""
|
title=""
|
||||||
data-tooltip
|
data-tooltip
|
||||||
class="publish-icon module <%= published_status %>"
|
class="publish-icon module <%= module_data[:published_status] %>"
|
||||||
>
|
>
|
||||||
<i class="icon-<%= published_status %>" alt="<%= published_status == 'published' ? t('published') : t('unpublished') %>"></i>
|
<i class="icon-<%= module_data[:published_status] %>" alt="<%= module_data[:published_status] == 'published' ? t('published') : t('unpublished') %>"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
@ -163,9 +162,9 @@
|
||||||
|
|
||||||
<div class="content" id="context_module_content_<%= context_module && context_module.id %>">
|
<div class="content" id="context_module_content_<%= context_module && context_module.id %>">
|
||||||
<ul class="ig-list items context_module_items <%= 'manageable' if editable %>">
|
<ul class="ig-list items context_module_items <%= 'manageable' if editable %>">
|
||||||
<% if context_module %>
|
<% if context_module && module_data[:items] %>
|
||||||
<% context_module.content_tags_visible_to(@current_user).each do |tag| %>
|
<% module_data[:items].each do |item| %>
|
||||||
<%= render :partial => 'context_modules/module_item_next', :object => tag, :locals => {:completion_criteria => context_module.completion_requirements, :editable => editable} %>
|
<%= render :partial => 'context_modules/module_item_next', :object => item, :as => :module_item, :locals => {:completion_criteria => context_module.completion_requirements, :item_data => module_data[:items_data][item.id], :editable => editable} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,38 +1,48 @@
|
||||||
<%
|
<%
|
||||||
module_item_next ||= nil
|
module_item_next ||= nil
|
||||||
module_item = module_item_next
|
module_item ||= module_item_next
|
||||||
published_status = (module_item && module_item.published?) ? 'published' : 'unpublished'
|
item_data ||= { published_status: 'unpublished' }
|
||||||
tag = module_item || nil; completion_criteria ||= nil; editable ||= false
|
completion_criteria ||= nil
|
||||||
@module_item_image_tags ||= {
|
editable ||= false
|
||||||
|
|
||||||
|
@module_item_image_tags ||= {
|
||||||
'indent' => "<i class='icon-arrow-right'></i>".html_safe,
|
'indent' => "<i class='icon-arrow-right'></i>".html_safe,
|
||||||
'outdent' => "<i class='icon-arrow-left'></i>".html_safe,
|
'outdent' => "<i class='icon-arrow-left'></i>".html_safe,
|
||||||
'edit' => "<i class='icon-edit'></i>".html_safe,
|
'edit' => "<i class='icon-edit'></i>".html_safe,
|
||||||
'delete' => "<i class='icon-end'></i>".html_safe,
|
'delete' => "<i class='icon-end'></i>".html_safe,
|
||||||
}
|
}
|
||||||
%>
|
|
||||||
<% criterion = completion_criteria && completion_criteria.find{|c| c[:id] == tag.id} %>
|
menu_type_to_class = {
|
||||||
|
:assignment_menu => Assignment,
|
||||||
|
:discussion_topic_menu => DiscussionTopic,
|
||||||
|
:file_menu => Attachment,
|
||||||
|
:quiz_menu => Quizzes::Quiz,
|
||||||
|
:wiki_page_menu => WikiPage
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion = completion_criteria && completion_criteria.find{|c| c[:id] == module_item.id}
|
||||||
|
%>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
id="context_module_item_<%= tag ? tag.id : "blank" %>"
|
id="context_module_item_<%= module_item ? module_item.id : "blank" %>"
|
||||||
style="<%= hidden unless module_item %>"
|
style="<%= hidden unless module_item %>"
|
||||||
class="
|
class="
|
||||||
context_module_item
|
context_module_item
|
||||||
<%= module_item.content_type_class if module_item %>
|
<%= module_item.content_type_class if module_item %>
|
||||||
<%= 'also_assignment' if module_item && module_item.graded? %>
|
<%= 'also_assignment' if module_item && module_item.graded? %>
|
||||||
indent_<%= tag.try_rescue(:indent) || '0' %>
|
indent_<%= module_item.try_rescue(:indent) || '0' %>
|
||||||
<%= 'progression_requirement' if criterion %>
|
<%= 'progression_requirement' if criterion %>
|
||||||
<%= criterion[:type] if criterion %>_requirement
|
<%= criterion[:type] if criterion %>_requirement
|
||||||
<%= module_item.item_class if module_item %>
|
<%= module_item.item_class if module_item %>
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div class="ig-row <%= 'with-completion-requirements' if criterion %> <%= 'ig-published' if module_item && module_item.published? %>">
|
<div class="ig-row <%= 'with-completion-requirements' if criterion %> <%= 'ig-published' if module_item && module_item.published? %>">
|
||||||
|
|
||||||
<a
|
<a
|
||||||
aria-label='<%= tag && tag.title %>'
|
aria-label='<%= module_item && module_item.title %>'
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
class="for-nvda"
|
class="for-nvda"
|
||||||
href="<%= context_url(@context, :context_url) %>/modules/items/<%= tag ? tag.id : "{{ id }}" %>">
|
href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>">
|
||||||
<%= tag && tag.title %>
|
<%= module_item && module_item.title %>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<% if editable || module_item.nil? %>
|
<% if editable || module_item.nil? %>
|
||||||
|
@ -58,23 +68,22 @@
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="ig-info">
|
<div class="ig-info">
|
||||||
|
|
||||||
<div class="module-item-title">
|
<div class="module-item-title">
|
||||||
<span class="item_name" aria-hidden="true">
|
<span class="item_name" aria-hidden="true">
|
||||||
<% if tag && tag.content_type == 'ExternalUrl' && tag.new_tab %>
|
<% if module_item && module_item.content_type == 'ExternalUrl' && module_item.new_tab %>
|
||||||
<a aria-label='<%= tag.title %>' class="title external_url_link" target="_blank" href="<%= tag.url %>"
|
<a aria-label='<%= module_item.title %>' class="title external_url_link" target="_blank" href="<%= module_item.url %>"
|
||||||
data-item-href="<%= context_url(@context, :context_url) %>/modules/items/<%= tag.id %>"><%= tag.title %></a>
|
data-item-href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item.id %>"><%= module_item.title %></a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a title="<%= tag && tag.title %>" class="ig-title title"
|
<a title="<%= module_item && module_item.title %>" class="ig-title title"
|
||||||
href="<%= context_url(@context, :context_url) %>/modules/items/<%= tag ? tag.id : "{{ id }}" %>"><%= tag && tag.title %></a>
|
href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>"><%= module_item && module_item.title %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<span title="<%= tag && tag.title %>" class="title locked_title"><%= tag && tag.title %></span>
|
<span title="<%= module_item && module_item.title %>" class="title locked_title"><%= module_item && module_item.title %></span>
|
||||||
<span class="points_possible" style="display: none;"><%= round_if_whole(tag.try_rescue(:assignment).try_rescue(:points_possible)) || nbsp %></span>
|
<span class="points_possible" style="display: none;"><%= round_if_whole(module_item.try_rescue(:assignment).try_rescue(:points_possible)) || nbsp %></span>
|
||||||
<span class="requirement" style="display: none;"> </span>
|
<span class="requirement" style="display: none;"> </span>
|
||||||
<span class="completion_requirement" style="display: none;"> </span>
|
<span class="completion_requirement" style="display: none;"> </span>
|
||||||
<span class="position" style="display: none;"><%= tag && tag.position %></span>
|
<span class="position" style="display: none;"><%= module_item && module_item.position %></span>
|
||||||
<span class="url" style="display: none;"><%= tag.try(:url) if editable %></span>
|
<span class="url" style="display: none;"><%= module_item.try(:url) if editable %></span>
|
||||||
<span class="new_tab" style="display: none;"><%= tag.try(:new_tab) ? '1' : '0' if editable %></span>
|
<span class="new_tab" style="display: none;"><%= module_item.try(:new_tab) ? '1' : '0' if editable %></span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -85,16 +94,14 @@
|
||||||
<span class="criterion_type" style="display: none;"><%= (criterion && criterion[:type]) || nbsp %></span>
|
<span class="criterion_type" style="display: none;"><%= (criterion && criterion[:type]) || nbsp %></span>
|
||||||
</span>
|
</span>
|
||||||
<!-- /dead code -->
|
<!-- /dead code -->
|
||||||
<span class="type" style="display: none;"><%= tag ? tag.content_type_class : nbsp %></span>
|
<span class="type" style="display: none;"><%= module_item ? module_item.content_type_class : nbsp %></span>
|
||||||
<span class="id" style="display: none;"><%= tag ? tag.id : nbsp %></span>
|
<span class="id" style="display: none;"><%= module_item ? module_item.id : nbsp %></span>
|
||||||
<span class="graded" style="display: none;"><%= tag && tag.graded? ? '1' : '0' %></span>
|
<span class="graded" style="display: none;"><%= module_item && module_item.graded? ? '1' : '0' %></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ig-details">
|
<div class="ig-details">
|
||||||
|
|
||||||
<div class="due_date_display ig-details__item"></div>
|
<div class="due_date_display ig-details__item"></div>
|
||||||
<div class="points_possible_display ig-details__item"></div>
|
<div class="points_possible_display ig-details__item"></div>
|
||||||
|
|
||||||
<div class="requirement-description ig-details__item">
|
<div class="requirement-description ig-details__item">
|
||||||
<span class="completion_requirement">
|
<span class="completion_requirement">
|
||||||
<span class="requirement_type min_score_requirement">
|
<span class="requirement_type min_score_requirement">
|
||||||
|
@ -158,64 +165,54 @@
|
||||||
<% if editable || module_item.nil? %>
|
<% if editable || module_item.nil? %>
|
||||||
<div class="ig-admin">
|
<div class="ig-admin">
|
||||||
<span
|
<span
|
||||||
data-module-item-name="<%= tag && tag.title %>"
|
data-module-item-name="<%= module_item && module_item.title %>"
|
||||||
data-module-type="<%= module_item && module_item.content_type_class %>"
|
data-module-type="<%= module_item && module_item.content_type_class %>"
|
||||||
data-content-id="<%= module_item && module_item.content_id %>"
|
data-content-id="<%= module_item && module_item.content_id %>"
|
||||||
data-id="<%= module_item_publishable_id(module_item) %>"
|
data-id="<%= module_item_publishable_id(module_item) %>"
|
||||||
data-course-id="<%= module_item && module_item.context_id %>"
|
data-course-id="<%= module_item && module_item.context_id %>"
|
||||||
data-module-id="<%= module_item && module_item.context_module_id %>"
|
data-module-id="<%= module_item && module_item.context_module_id %>"
|
||||||
data-module-item-id="<%= module_item && module_item.id %>"
|
data-module-item-id="<%= module_item && module_item.id %>"
|
||||||
data-published="<%= module_item && published_status == 'published' %>"
|
data-published="<%= module_item && item_data[:published_status] == 'published' %>"
|
||||||
data-publishable="<%= module_item_publishable?(module_item) %>"
|
data-publishable="<%= module_item_publishable?(module_item) %>"
|
||||||
data-unpublishable="<%= module_item_unpublishable?(module_item) %>"
|
data-unpublishable="<%= module_item_unpublishable?(module_item) %>"
|
||||||
data-publish-message="<%= t('Unpublished. Click to publish %{item_name}.', {item_name: tag && tag.title ? tag.title : ''}) %>"
|
data-publish-message="<%= t('Unpublished. Click to publish %{item_name}.', {item_name: module_item && module_item.title ? module_item.title : ''}) %>"
|
||||||
data-unpublish-message="<%= t('Published. Click to unpublish %{item_name}.', {item_name: tag && tag.title ? tag.title : ''}) %>"
|
data-unpublish-message="<%= t('Published. Click to unpublish %{item_name}.', {item_name: module_item && module_item.title ? module_item.title : ''}) %>"
|
||||||
title=""
|
title=""
|
||||||
data-tooltip
|
data-tooltip
|
||||||
class="publish-icon <%= published_status %>"
|
class="publish-icon <%= item_data[:published_status] %>"
|
||||||
>
|
>
|
||||||
<i class="icon-<%= published_status %>"></i>
|
<i class="icon-<%= item_data[:published_status] %>"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="inline-block cog-menu-container">
|
<div class="inline-block cog-menu-container">
|
||||||
<a class="al-trigger al-trigger-gray" role="button" tabindex="0" href="#">
|
<a class="al-trigger al-trigger-gray" role="button" tabindex="0" href="#">
|
||||||
<i class="icon-settings"></i><i class="icon-mini-arrow-down"></i>
|
<i class="icon-settings"></i><i class="icon-mini-arrow-down"></i>
|
||||||
<span class="screenreader-only"><%= t('Manage %{item_name}', {item_name: tag && tag.title ? tag.title : 'item'}) %></span>
|
<span class="screenreader-only"><%= t('Manage %{item_name}', {item_name: module_item && module_item.title ? module_item.title : 'item'}) %></span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<ul class="al-options">
|
<ul class="al-options">
|
||||||
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= tag ? tag.id : "{{ id }}" %>" class="outdent_item_link" title="<%= t('links.outdent_item', %{Decrease indent}) %>"><%= @module_item_image_tags['outdent'] %> <%= t('links.outdent', %{Decrease indent}) %></a></li>
|
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="outdent_item_link" title="<%= t('links.outdent_item', %{Decrease indent}) %>"><%= @module_item_image_tags['outdent'] %> <%= t('links.outdent', %{Decrease indent}) %></a></li>
|
||||||
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= tag ? tag.id : "{{ id }}" %>" class="indent_item_link" title="<%= t('links.indent_item', %{Increase indent}) %>"><%= @module_item_image_tags['indent'] %> <%= t('links.indent', %{Increase indent}) %></a></li>
|
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="indent_item_link" title="<%= t('links.indent_item', %{Increase indent}) %>"><%= @module_item_image_tags['indent'] %> <%= t('links.indent', %{Increase indent}) %></a></li>
|
||||||
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= tag ? tag.id : "{{ id }}" %>" class="edit_item_link edit_link" title="<%= t('links.edit_item_details', %{Edit item details}) %>"><%= @module_item_image_tags['edit'] %> <%= t('links.edit_item', %{Edit}) %></a></li>
|
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="edit_item_link edit_link" title="<%= t('links.edit_item_details', %{Edit item details}) %>"><%= @module_item_image_tags['edit'] %> <%= t('links.edit_item', %{Edit}) %></a></li>
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#<%= tag ? tag.id : "{{ id }}" %>"
|
<a href="#<%= module_item ? module_item.id : "{{ id }}" %>"
|
||||||
aria-label="<%= t('links.move_item_label', %{Move this item}) %>"
|
aria-label="<%= t('links.move_item_label', %{Move this item}) %>"
|
||||||
class="move_module_item_link icon-updown"
|
class="move_module_item_link icon-updown"
|
||||||
title="<%= t('links.move_item', %{Move this item}) %>"
|
title="<%= t('links.move_item', %{Move this item}) %>"
|
||||||
><%= t('modules_item_move_to', "Move to...") %></a>
|
><%= t('modules_item_move_to', "Move to...") %></a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= tag ? tag.id : "{{ id }}" %>" class="delete_item_link delete_link" title="<%= t('links.remove_item_from_module', %{Remove this item from the module}) %>"><%= @module_item_image_tags['delete'] %> <%= t('links.remove_item', %{Remove}) %></a></li>
|
<li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="delete_item_link delete_link" title="<%= t('links.remove_item_from_module', %{Remove this item from the module}) %>"><%= @module_item_image_tags['delete'] %> <%= t('links.remove_item', %{Remove}) %></a></li>
|
||||||
<% menu_type_to_class = {
|
|
||||||
:assignment_menu => Assignment,
|
|
||||||
:discussion_topic_menu => DiscussionTopic,
|
|
||||||
:file_menu => Attachment,
|
|
||||||
:quiz_menu => Quizzes::Quiz,
|
|
||||||
:wiki_page_menu => WikiPage
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<% menu_type_to_class.each do |menu_type, content_class| %>
|
<% menu_type_to_class.each do |menu_type, content_class| %>
|
||||||
<% if !tag || tag.content.is_a?(content_class) %>
|
<% if !module_item || module_item.content.is_a?(content_class) %>
|
||||||
<%
|
<%
|
||||||
launch_options = {}
|
launch_options = {}
|
||||||
if menu_type == :file_menu
|
if menu_type == :file_menu
|
||||||
launch_options[:files] = [tag ? tag.content_id : "{{ content_id }}"]
|
launch_options[:files] = [module_item ? module_item.content_id : "{{ content_id }}"]
|
||||||
else
|
else
|
||||||
launch_options[:module_items] = [tag ? tag.id : "{{ id }}"]
|
launch_options[:module_items] = [module_item ? module_item.id : "{{ id }}"]
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%= external_tools_menu_items(@menu_tools[menu_type], {link_class: "menu_tool_link", settings_key: menu_type, in_list: true, url_params: launch_options}) %>
|
<%= external_tools_menu_items(@menu_tools[menu_type], {link_class: "menu_tool_link", settings_key: menu_type, in_list: true, url_params: launch_options}) %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -37,14 +37,14 @@ describe "/context_modules/index" do
|
||||||
it "should show content_tags" do
|
it "should show content_tags" do
|
||||||
course
|
course
|
||||||
context_module = @course.context_modules.create!
|
context_module = @course.context_modules.create!
|
||||||
content_tag = context_module.add_item :type => 'context_module_sub_header'
|
module_item = context_module.add_item :type => 'context_module_sub_header'
|
||||||
content_tag.publish! if content_tag.unpublished?
|
module_item.publish! if module_item.unpublished?
|
||||||
view_context(@course, @user)
|
view_context(@course, @user)
|
||||||
assigns[:modules] = @course.context_modules.active
|
assigns[:modules] = @course.context_modules.active
|
||||||
render 'context_modules/index'
|
render 'context_modules/index'
|
||||||
expect(response).not_to be_nil
|
expect(response).not_to be_nil
|
||||||
page = Nokogiri('<document>' + response.body + '</document>')
|
page = Nokogiri('<document>' + response.body + '</document>')
|
||||||
expect(page.css("#context_module_item_#{content_tag.id}").length).to eq 1
|
expect(page.css("#context_module_item_#{module_item.id}").length).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should show unpublished content_tags" do
|
it "should show unpublished content_tags" do
|
||||||
|
@ -54,8 +54,8 @@ describe "/context_modules/index" do
|
||||||
wiki_page.save!
|
wiki_page.save!
|
||||||
|
|
||||||
context_module = @course.context_modules.create!
|
context_module = @course.context_modules.create!
|
||||||
content_tag = context_module.add_item(:type => 'wiki_page', :id => wiki_page.id)
|
module_item = context_module.add_item(:type => 'wiki_page', :id => wiki_page.id)
|
||||||
expect(content_tag.workflow_state).to eq 'unpublished'
|
expect(module_item.workflow_state).to eq 'unpublished'
|
||||||
|
|
||||||
view_context(@course, @user)
|
view_context(@course, @user)
|
||||||
assigns[:modules] = @course.context_modules.active
|
assigns[:modules] = @course.context_modules.active
|
||||||
|
@ -63,19 +63,19 @@ describe "/context_modules/index" do
|
||||||
|
|
||||||
expect(response).not_to be_nil
|
expect(response).not_to be_nil
|
||||||
page = Nokogiri('<document>' + response.body + '</document>')
|
page = Nokogiri('<document>' + response.body + '</document>')
|
||||||
expect(page.css("#context_module_item_#{content_tag.id}").length).to eq 1
|
expect(page.css("#context_module_item_#{module_item.id}").length).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not show deleted content_tags" do
|
it "should not show deleted content_tags" do
|
||||||
course
|
course
|
||||||
context_module = @course.context_modules.create!
|
context_module = @course.context_modules.create!
|
||||||
content_tag = context_module.add_item :type => 'context_module_sub_header'
|
module_item = context_module.add_item :type => 'context_module_sub_header'
|
||||||
content_tag.destroy
|
module_item.destroy
|
||||||
view_context(@course, @user)
|
view_context(@course, @user)
|
||||||
assigns[:modules] = @course.context_modules.active
|
assigns[:modules] = @course.context_modules.active
|
||||||
render 'context_modules/index'
|
render 'context_modules/index'
|
||||||
expect(response).not_to be_nil
|
expect(response).not_to be_nil
|
||||||
page = Nokogiri('<document>' + response.body + '</document>')
|
page = Nokogiri('<document>' + response.body + '</document>')
|
||||||
expect(page.css("#context_module_item_#{content_tag.id}").length).to eq 0
|
expect(page.css("#context_module_item_#{module_item.id}").length).to eq 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue