added basic lti links to common cartridge export
refs #3396 Change-Id: Ia56a2dad35ec79e3fbc21cad6a573b3fc249825f Reviewed-on: https://gerrit.instructure.com/2925 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
e0eed5ad75
commit
1b1eb9785b
|
@ -0,0 +1,91 @@
|
|||
#
|
||||
# Copyright (C) 2011 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
module Canvas::CC
|
||||
module BasicLTILinks
|
||||
def create_basic_lti_links
|
||||
return nil unless @manifest.basic_ltis.length > 0
|
||||
|
||||
@manifest.basic_ltis.each do |ct| # These are content tags
|
||||
|
||||
migration_id = CCHelper::create_key(ct)
|
||||
|
||||
lti_file_name = "#{migration_id}.xml"
|
||||
lti_path = File.join(@export_dir, lti_file_name)
|
||||
lti_file = File.new(lti_path, 'w')
|
||||
lti_doc = Builder::XmlMarkup.new(:target=>lti_file, :indent=>2)
|
||||
lti_doc.instruct!
|
||||
|
||||
lti_doc.cartridge_basiclti_link("xmlns" => "http://www.imsglobal.org/xsd/imslticc_v1p0",
|
||||
"xmlns:blti" => 'http://www.imsglobal.org/xsd/imsbasiclti_v1p0',
|
||||
"xmlns:lticm" => 'http://www.imsglobal.org/xsd/imslticm_v1p0',
|
||||
"xmlns:lticp" => 'http://www.imsglobal.org/xsd/imslticp_v1p0',
|
||||
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
|
||||
"xsi:schemaLocation"=> "http://www.imsglobal.org/xsd/imslticc_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticc_v1p0.xsd
|
||||
http://www.imsglobal.org/xsd/imsbasiclti_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imsbasiclti_v1p0.xsd
|
||||
http://www.imsglobal.org/xsd/imslticm_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticm_v1p0.xsd
|
||||
http://www.imsglobal.org/xsd/imslticp_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticp_v1p0.xsd"
|
||||
) do |blti_node|
|
||||
blti_node.tag! "blti:title", ct.title
|
||||
if ct.url =~ %r{http://}
|
||||
blti_node.launch_url ct.url
|
||||
elsif ct.url =~ %r{https://}
|
||||
blti_node.secure_launch_url ct.url
|
||||
end
|
||||
end
|
||||
lti_file.close
|
||||
|
||||
@resources.resource(
|
||||
:identifier => migration_id,
|
||||
"type" => CCHelper::BASIC_LTI
|
||||
) do |res|
|
||||
res.file(:href=>lti_file_name)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def create_external_tools
|
||||
return nil unless @course.context_external_tools.count > 0
|
||||
|
||||
lti_file = File.new(File.join(@canvas_resource_dir, CCHelper::EXTERNAL_TOOLS), 'w')
|
||||
rel_path = File.join(CCHelper::COURSE_SETTINGS_DIR, CCHelper::EXTERNAL_TOOLS)
|
||||
document = Builder::XmlMarkup.new(:target=>lti_file, :indent=>2)
|
||||
document.instruct!
|
||||
document.externalTools(
|
||||
"xmlns" => CCHelper::CANVAS_NAMESPACE,
|
||||
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
|
||||
"xsi:schemaLocation"=> "#{CCHelper::CANVAS_NAMESPACE} #{CCHelper::XSD_URI}"
|
||||
) do |et_node|
|
||||
@course.context_external_tools.each do |tool|
|
||||
migration_id = CCHelper.create_key(tool)
|
||||
et_node.externalTool(:identifier=>migration_id) do |t_node|
|
||||
t_node.title tool.name
|
||||
t_node.description tool.description unless tool.description.blank?
|
||||
t_node.url tool.url unless tool.url.blank?
|
||||
t_node.domain tool.domain unless tool.domain.blank?
|
||||
t_node.privacy_level tool.workflow_state
|
||||
t_node.comment! "The Consumer Key and Shared Secret will need to be configured within Canvas"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
lti_file.close
|
||||
rel_path
|
||||
end
|
||||
end
|
||||
end
|
|
@ -45,6 +45,7 @@ module Canvas::CC
|
|||
resources << create_grading_standards
|
||||
resources << create_learning_outcomes
|
||||
resources << create_rubrics
|
||||
resources << create_external_tools
|
||||
|
||||
@resources.resource(
|
||||
:identifier => migration_id,
|
||||
|
|
|
@ -39,6 +39,7 @@ module CCHelper
|
|||
#WEB_LINK = "imswl_xmlv1p1"
|
||||
WEB_LINK = "imswl_xmlv1p0"
|
||||
WEBCONTENT = "webcontent"
|
||||
BASIC_LTI = 'imsbasiclti_xmlv1p0'
|
||||
|
||||
# substitution tokens
|
||||
OBJECT_TOKEN = "$CANVAS_OBJECT_REFERENCE$"
|
||||
|
@ -60,6 +61,7 @@ module CCHelper
|
|||
MANIFEST = 'imsmanifest.xml'
|
||||
MODULE_META = "module_meta.xml"
|
||||
RUBRICS = "rubrics.xml"
|
||||
EXTERNAL_TOOLS = "external_tools.xml"
|
||||
SYLLABUS = "syllabus.html"
|
||||
WEB_RESOURCES_FOLDER = 'web_resources'
|
||||
WIKI_FOLDER = 'wiki_content'
|
||||
|
|
|
@ -19,13 +19,14 @@ module Canvas::CC
|
|||
class Manifest
|
||||
include CCHelper
|
||||
|
||||
attr_accessor :exporter, :weblinks
|
||||
attr_accessor :exporter, :weblinks, :basic_ltis
|
||||
|
||||
def initialize(exporter)
|
||||
@exporter = exporter
|
||||
@file = nil
|
||||
@document = nil
|
||||
@weblinks = []
|
||||
@basic_ltis = []
|
||||
end
|
||||
|
||||
def course
|
||||
|
|
|
@ -64,6 +64,10 @@ module Canvas::CC
|
|||
:url => ct.url}
|
||||
@manifest.weblinks << link
|
||||
attributes[:identifierref] = link[:migration_id]
|
||||
elsif ct.content_type == 'ContextExternalTool'
|
||||
attributes[:identifierref] = attributes[:identifier]
|
||||
attributes[:identifier] = CCHelper.create_key(ct, "module_item")
|
||||
@manifest.basic_ltis << ct
|
||||
end
|
||||
module_node.item(attributes) do |tag_node|
|
||||
tag_node.title ct.title
|
||||
|
|
|
@ -194,7 +194,7 @@ module Canvas::CC
|
|||
:title => group['name']
|
||||
) do |section_node|
|
||||
section_node.selection_ordering do |so_node|
|
||||
section_node.selection do |sel_node|
|
||||
so_node.selection do |sel_node|
|
||||
if group[:assessment_question_bank_id]
|
||||
if bank = @course.assessment_question_banks.find(group[:assessment_question_bank_id])
|
||||
sel_node.sourcebank_ref create_key(bank)
|
||||
|
|
|
@ -250,7 +250,7 @@ module Canvas::CC
|
|||
def item_feedback(node, id, message)
|
||||
node.itemfeedback(:ident=>id) do |f_node|
|
||||
f_node.flow_mat do |flow_node|
|
||||
f_node.material do |m_node|
|
||||
flow_node.material do |m_node|
|
||||
m_node.mattext(message, :texttype=>'text')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,7 @@ module Canvas::CC
|
|||
include TopicResources
|
||||
include WebResources
|
||||
include WebLinks
|
||||
include BasicLTILinks
|
||||
|
||||
def initialize(manifest, manifest_node)
|
||||
@manifest = manifest
|
||||
|
@ -49,8 +50,8 @@ module Canvas::CC
|
|||
add_web_links
|
||||
add_course_files
|
||||
QTI::QTIGenerator.generate_qti(@manifest, resources)
|
||||
create_basic_lti_links
|
||||
#todo download kaltura videos?
|
||||
#todo basic LTI links
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -379,5 +379,34 @@
|
|||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="externalTools">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="externalTool" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:all minOccurs="0">
|
||||
<xs:element name="title" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="url" type="xs:anyURI" minOccurs="0"/>
|
||||
<xs:element name="description" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="domain" type="xs:string" minOccurs="0"/>
|
||||
|
||||
<xs:element name="privacy_level" minOccurs="1" default="full">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="name_only"/>
|
||||
<xs:enumeration value="public"/>
|
||||
<xs:enumeration value="anonymous"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
|
||||
</xs:all>
|
||||
<xs:attribute name="identifier" type="xs:ID" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:schema>
|
Loading…
Reference in New Issue