separate announcements from discussion in ePub
closes CNVS-24761 test plan: - create an ePub from a course that has announcements - there should be an announcements section following the syllabus - this section should exist regardless of sorting method - if no announcements exist, the announcements section should state there are none for the course Change-Id: Id146eca5b4f62c914375beb845cd3d2e173ede22 Reviewed-on: https://gerrit.instructure.com/66396 Reviewed-by: John Corrigan <jcorrigan@instructure.com> Tested-by: Jenkins QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Cosme Salazar <cosme@instructure.com>
This commit is contained in:
parent
a9dc5a5077
commit
6ef7507513
|
@ -54,7 +54,7 @@ module CC::Exporter::Epub::Converters
|
|||
set_progress(20)
|
||||
@course[:assignments] = convert_assignments
|
||||
set_progress(30)
|
||||
@course[:topics] = convert_topics
|
||||
@course[:topics], @course[:announcements] = convert_topics
|
||||
set_progress(40)
|
||||
@course[:quizzes] = convert_quizzes
|
||||
set_progress(50)
|
||||
|
|
|
@ -4,6 +4,7 @@ module CC::Exporter::Epub::Converters
|
|||
|
||||
def convert_topics
|
||||
topics = []
|
||||
announcements = []
|
||||
|
||||
@manifest.css('resource[type=imsdt_xmlv1p1]').each do |res|
|
||||
cc_path = File.join @unzipped_file_path, res.at_css('file')['href']
|
||||
|
@ -17,10 +18,14 @@ module CC::Exporter::Epub::Converters
|
|||
end
|
||||
cc_doc = open_file_xml(cc_path)
|
||||
|
||||
topics << convert_topic(cc_doc, meta_node)
|
||||
if get_node_val(meta_node, 'type') != "announcement"
|
||||
topics << convert_topic(cc_doc, meta_node)
|
||||
else
|
||||
announcements << convert_announcement(cc_doc, meta_node)
|
||||
end
|
||||
end
|
||||
|
||||
topics
|
||||
[topics, announcements]
|
||||
end
|
||||
|
||||
def convert_topic(cc_doc, meta_doc)
|
||||
|
@ -29,7 +34,6 @@ module CC::Exporter::Epub::Converters
|
|||
topic[:title] = get_node_val(cc_doc, 'title')
|
||||
if meta_doc
|
||||
topic[:title] = get_node_val(meta_doc, 'title')
|
||||
topic[:type] = get_node_val(meta_doc, 'type')
|
||||
topic[:discussion_type] = get_node_val(meta_doc, 'discussion_type')
|
||||
topic[:pinned] = get_bool_val(meta_doc, 'pinned')
|
||||
topic[:posted_at] = get_time_val(meta_doc, 'posted_at')
|
||||
|
@ -45,5 +49,18 @@ module CC::Exporter::Epub::Converters
|
|||
|
||||
topic
|
||||
end
|
||||
|
||||
def convert_announcement(cc_doc, meta_doc)
|
||||
announcement = {}
|
||||
announcement[:description] = get_node_val(cc_doc, 'text')
|
||||
announcement[:title] = get_node_val(cc_doc, 'title')
|
||||
if meta_doc
|
||||
announcement[:posted_at] = get_time_val(meta_doc, 'posted_at')
|
||||
announcement[:identifier] = get_node_val(meta_doc, 'topic_id')
|
||||
announcement[:href] = "announcements.xhtml##{announcement[:identifier]}"
|
||||
end
|
||||
|
||||
announcement
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,7 @@ module CC::Exporter::Epub
|
|||
syllabus: "Syllabus",
|
||||
modules: "Modules",
|
||||
assignments: "Assignments",
|
||||
announcements: "Announcements",
|
||||
topics: "Discussion Topics",
|
||||
quizzes: "Quizzes",
|
||||
pages: "Wiki Pages"
|
||||
|
@ -36,9 +37,12 @@ module CC::Exporter::Epub
|
|||
files: cartridge_json[:files]
|
||||
}.tap do |hash|
|
||||
resources = filter_syllabus_for_modules ? module_ids : LINKED_RESOURCE_KEY.values
|
||||
hash.merge!(:syllabus => create_syllabus)
|
||||
hash.merge!(
|
||||
:syllabus => create_universal_template(:syllabus),
|
||||
:announcements => create_universal_template(:announcements)
|
||||
)
|
||||
resources.each do |resource_type|
|
||||
hash.merge!(resource_type => create_template(resource_type))
|
||||
hash.merge!(resource_type => create_content_template(resource_type))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -54,13 +58,13 @@ module CC::Exporter::Epub
|
|||
get_item(resource_type, identifier).merge!(updated_item)
|
||||
end
|
||||
|
||||
def create_syllabus
|
||||
syllabus_content = cartridge_json[:syllabus]
|
||||
syllabus_template = Exporter.resource_template(:syllabus)
|
||||
Template.new({resources: syllabus_content, reference: :syllabus}, syllabus_template, self)
|
||||
def create_universal_template(resource)
|
||||
template_content = cartridge_json[resource]
|
||||
template = Exporter.resource_template(resource)
|
||||
Template.new({resources: template_content, reference: resource}, template, self)
|
||||
end
|
||||
|
||||
def create_template(resource)
|
||||
def create_content_template(resource)
|
||||
resource_items = sort_by_content ? cartridge_json[resource] : filter_content_to_module(resource)
|
||||
Template.new({resources: resource_items, reference: resource}, base_template, self)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Announcements</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Announcements</h1>
|
||||
<ol>
|
||||
<% if content.length == 0 %>
|
||||
<p><%= I18n.t("There are no announcements for this course.") %></p>
|
||||
<% else %>
|
||||
<% content.each do |item| %>
|
||||
<li><a href="#<%= "#{item[:identifier]}" %>"><%= item[:title] %></a></li>
|
||||
<% end %>
|
||||
</ol>
|
||||
<div style="page-break-before:always;"></div>
|
||||
<% content.each do |item| %>
|
||||
<h2 id="<%="#{item[:identifier]}"%>"><%= item[:title] %></h2>
|
||||
<p><%= convert_placeholder_paths_from_string!(item[:description]) %></p>
|
||||
<hr/>
|
||||
<a href="announcements.xhtml"><%="Back to Announcements"%></a>
|
||||
<div style="page-break-before:always;"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue