prevent gray details box from appearing if not needed

closes CNVS-24957

test plan:
- create an assignment, discussion, and quiz with none of the following:
  -Due Date
  -Lock Date
  -Unlock Date
  -Grading Type
  -Points Possible
  -Submission Type
- the gray details box should not appear in the ePub for these items

Change-Id: I26bf7e889ae54fae62653d9c10de6f435e2577be
Reviewed-on: https://gerrit.instructure.com/66926
Tested-by: Jenkins
Reviewed-by: John Corrigan <jcorrigan@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Cosme Salazar <cosme@instructure.com>
This commit is contained in:
Matthew Berns 2015-11-10 16:20:37 -06:00 committed by Matt Berns
parent 36e1315cf2
commit 85af1f321d
4 changed files with 26 additions and 16 deletions

View File

@ -74,5 +74,10 @@ module CC::Exporter::Epub
content
end
end
def item_details_present?(item)
details = [:due_at, :unlock_at, :lock_at, :grading_type, :points_possible, :submission_types]
details.any? { |detail| item[detail].present? }
end
end
end

View File

@ -1,12 +1,14 @@
<h2 id="<%="#{item[:identifier]}"%>"><%= item[:title] %></h2>
<p><%= convert_placeholder_paths_from_string!(item[:description]) %></p>
<div class="item_details">
<p><%= item[:due_at] ? I18n.t("Due at: %{time}",{time: friendly_date(item[:due_at])}) : nil%></p>
<p><%= item[:unlock_at] ? I18n.t("Unlock at: %{time}",{time: friendly_date(item[:unlock_at])}) : nil %></p>
<p><%= item[:lock_at] ? I18n.t("Lock at: %{time}",{time: friendly_date(item[:lock_at])}) : nil %></p>
<p><%= item[:grading_type] ? I18n.t("Grading Type: %{type}",{type: item[:grading_type]}) : nil %></p>
<p><%= item[:points_possible] ? I18n.t("Points: %{points}",{points: item[:points_possible]}) : nil %></p>
<% if item[:submission_types].try(:any?) %>
<p><%= I18n.t("Submitting: %{types}", { types: item[:submission_types].join(', ') }) %></p>
<% end %>
</div>
<% if item_details_present?(item) %>
<div class="item_details">
<p><%= item[:due_at] ? I18n.t("Due at: %{time}",{time: friendly_date(item[:due_at])}) : nil%></p>
<p><%= item[:unlock_at] ? I18n.t("Unlock at: %{time}",{time: friendly_date(item[:unlock_at])}) : nil %></p>
<p><%= item[:lock_at] ? I18n.t("Lock at: %{time}",{time: friendly_date(item[:lock_at])}) : nil %></p>
<p><%= item[:grading_type] ? I18n.t("Grading Type: %{type}",{type: item[:grading_type]}) : nil %></p>
<p><%= item[:points_possible] ? I18n.t("Points: %{points}",{points: item[:points_possible]}) : nil %></p>
<% if item[:submission_types].try(:any?) %>
<p><%= I18n.t("Submitting: %{types}", { types: item[:submission_types].join(', ') }) %></p>
<% end %>
</div>
<% end %>

View File

@ -1,7 +1,10 @@
<h2 id="<%="#{item[:identifier]}"%>"><%= item[:title] %></h2>
<p><%= convert_placeholder_paths_from_string!(item[:description]) %></p>
<div class="item_details">
<p><%= item[:due_at] ? I18n.t("Due at: %{time}",{time: friendly_date(item[:due_at])}) : nil%></p>
<p><%= item[:unlock_at] ? I18n.t("Unlock at: %{time}",{time: friendly_date(item[:unlock_at])}) : nil %></p>
<p><%= item[:lock_at] ? I18n.t("Lock at: %{time}",{time: friendly_date(item[:lock_at])}) : nil %></p>
</div>
<% if item_details_present?(item) %>
<div class="item_details">
<p><%= item[:due_at] ? I18n.t("Due at: %{time}",{time: friendly_date(item[:due_at])}) : nil%></p>
<p><%= item[:unlock_at] ? I18n.t("Unlock at: %{time}",{time: friendly_date(item[:unlock_at])}) : nil %></p>
<p><%= item[:lock_at] ? I18n.t("Lock at: %{time}",{time: friendly_date(item[:lock_at])}) : nil %></p>
<p><%= item[:points_possible] ? I18n.t("Points: %{points}",{points: item[:points_possible]}) : nil %></p>
</div>
<% end %>

View File

@ -1,6 +1,6 @@
<h2 id="<%="#{item[:identifier]}"%>"><%= item[:title] %></h2>
<p><%= convert_placeholder_paths_from_string!(item[:description]) %></p>
<% if item[:assignment] %>
<% if item[:assignment] && item_details_present?(item[:assignment]) %>
<div class="item_details">
<p><%= item[:assignment][:due_at] ? I18n.t("Due at: %{time}",{time: friendly_date(item[:assignment][:due_at])}) : nil%></p>
<p><%= item[:assignment][:unlock_at] ? I18n.t("Unlock at: %{time}",{time: friendly_date(item[:assignment][:unlock_at])}) : nil %></p>