add media objects to qti exports
exporting qti was not setup to actually add media objects. this is very difficult to test locally because media objects/info is pulled from a 3rd party api called kaltura. this means we pull the file from kaltura and then put it in the zip file. fixes: ADMIN-2399 Test-Plan: - deploy this to some prod like env - this cannot be tested without integration with kultura - setup a quiz that has a question with embedded media (see repo) - run the export on just that quiz and ensure the media objects are there Change-Id: Ieb41f84d2204ea68e5d218ba73c128568c1760a0 Reviewed-on: https://gerrit.instructure.com/184419 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com> Product-Review: Rex Fleischer <rfleischer@instructure.com>
This commit is contained in:
parent
06a3629ab0
commit
5185a755e1
|
@ -21,7 +21,7 @@ module QTI
|
|||
include CC::CCHelper
|
||||
|
||||
attr_accessor :exporter
|
||||
delegate :add_error, :set_progress, :export_object?, :add_exported_asset, :qti_export?, :course, :user, :create_key, :to => :exporter
|
||||
delegate :add_error, :set_progress, :export_object?, :add_exported_asset, :for_course_copy, :qti_export?, :course, :user, :create_key, :to => :exporter
|
||||
delegate :referenced_files, :to => :@html_exporter
|
||||
|
||||
def initialize(exporter)
|
||||
|
@ -95,6 +95,11 @@ module QTI
|
|||
end
|
||||
end
|
||||
|
||||
begin
|
||||
Resource.new(self, manifest_node, resources).add_media_objects(@html_exporter)
|
||||
rescue
|
||||
add_error(I18n.t('course_exports.errors.resources', "Failed to link some resources."), $!)
|
||||
end
|
||||
end
|
||||
end #manifest
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ module CC
|
|||
delegate :add_error, :set_progress, :export_object?, :export_symbol?, :for_course_copy, :add_item_to_export, :add_exported_asset, :create_key, :to => :@manifest
|
||||
delegate :referenced_files, :to => :@html_exporter
|
||||
|
||||
def initialize(manifest, manifest_node)
|
||||
def initialize(manifest, manifest_node, resources=nil)
|
||||
@manifest = manifest
|
||||
@manifest_node = manifest_node
|
||||
@course = @manifest.course
|
||||
@user = @manifest.user
|
||||
@export_dir = @manifest.export_dir
|
||||
@resources = nil
|
||||
@resources = resources
|
||||
@zip_file = manifest.zip_file
|
||||
# if set to "flash video", this'll export the smaller, post-conversion
|
||||
# flv files rather than the larger original files.
|
||||
|
|
|
@ -203,7 +203,7 @@ module CC
|
|||
# check to make sure we don't export more than 4 gigabytes of media objects
|
||||
total_size = 0
|
||||
html_content_exporter.used_media_objects.each do |obj|
|
||||
next if @added_attachment_ids.include?(obj.attachment_id)
|
||||
next if @added_attachment_ids&.include?(obj.attachment_id)
|
||||
|
||||
info = html_content_exporter.media_object_infos[obj.id]
|
||||
next unless info && info[:asset] && info[:asset][:size]
|
||||
|
@ -221,7 +221,7 @@ module CC
|
|||
|
||||
tracks = {}
|
||||
html_content_exporter.used_media_objects.each do |obj|
|
||||
next if @added_attachment_ids.include?(obj.attachment_id)
|
||||
next if @added_attachment_ids&.include?(obj.attachment_id)
|
||||
begin
|
||||
migration_id = create_key(obj)
|
||||
info = html_content_exporter.media_object_infos[obj.id]
|
||||
|
@ -256,7 +256,7 @@ module CC
|
|||
end
|
||||
end
|
||||
|
||||
add_tracks(tracks)
|
||||
add_tracks(tracks) if @canvas_resource_dir
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -325,6 +325,65 @@ describe "Common Cartridge exporting" do
|
|||
expect(@zip_file.find_entry(path)).not_to be_nil
|
||||
end
|
||||
|
||||
it "should include media objects" do
|
||||
@q1 = @course.quizzes.create(:title => 'quiz1')
|
||||
@media_object = @course.media_objects.create!(
|
||||
:media_id => "some-kaltura-id",
|
||||
:media_type => "video"
|
||||
)
|
||||
|
||||
qq = @q1.quiz_questions.create!
|
||||
data = {
|
||||
:correct_comments => "",
|
||||
:question_type => "multiple_choice_question",
|
||||
:question_bank_name => "Quiz",
|
||||
:assessment_question_id => "9270",
|
||||
:migration_id => "QUE_1014",
|
||||
:incorrect_comments => "",
|
||||
:question_name => "test fun",
|
||||
:name => "test fun",
|
||||
:points_possible => 1,
|
||||
:question_text => "<p><a id=\"media_comment_some-kaltura-id\" class=\"instructure_inline_media_comment video_comment\" href=\"/media_objects/some-kaltura-id\"></a></p>",
|
||||
:answers => [{
|
||||
:migration_id => "QUE_1016_A1", :text => "True", :weight => 100, :id => 8080
|
||||
}, {
|
||||
:migration_id => "QUE_1017_A2", :text => "False", :weight => 0, :id => 2279
|
||||
}]
|
||||
}.with_indifferent_access
|
||||
qq.write_attribute(:question_data, data)
|
||||
qq.save!
|
||||
|
||||
@ce.export_type = ContentExport::QTI
|
||||
@ce.selected_content = { :all_quizzes => "1" }
|
||||
@ce.save!
|
||||
|
||||
allow(CC::CCHelper).to receive(:media_object_info).and_return({
|
||||
:asset => { :id => "some-kaltura-id", :size => 1234, :status => '2' },
|
||||
:filename => "some-kaltura-id"
|
||||
})
|
||||
allow(CanvasKaltura::ClientV3).to receive(:config).and_return({})
|
||||
allow(CanvasKaltura::ClientV3).to receive(:startSession)
|
||||
allow(CanvasKaltura::ClientV3).to receive(:flavorAssetGetPlaylistUrl).and_return("some-url")
|
||||
mock_http_response = Struct.new(:code) do
|
||||
def read_body(stream)
|
||||
stream.puts("lalala")
|
||||
end
|
||||
end
|
||||
allow(CanvasHttp).to receive(:get).and_yield(mock_http_response.new(200))
|
||||
|
||||
run_export
|
||||
|
||||
check_resource_node(@q1, CC::CCHelper::QTI_ASSESSMENT_TYPE)
|
||||
|
||||
doc = Nokogiri::XML.parse(@zip_file.read("#{mig_id(@q1)}/#{mig_id(@q1)}.xml"))
|
||||
expect(doc.at_css("presentation material mattext").text).to eq "<div><p><a id=\"media_comment_some-kaltura-id\" class=\"instructure_inline_media_comment video_comment\" href=\"%24IMS-CC-FILEBASE%24/media_objects/some-kaltura-id\"></a></p></div>"
|
||||
|
||||
resource_node = @manifest_doc.at_css("resource[identifier=#{mig_id(@media_object)}]")
|
||||
expect(resource_node).to_not be_nil
|
||||
path = resource_node['href']
|
||||
expect(@zip_file.find_entry(path)).not_to be_nil
|
||||
end
|
||||
|
||||
it "should export web content files properly when display name is changed" do
|
||||
@att = Attachment.create!(:filename => 'first.png', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course)
|
||||
@att.display_name = "not_actually_first.png"
|
||||
|
|
Loading…
Reference in New Issue