fix moodle 1.9 file importing

test plan:
* import a moodle 1.9 package with files in the
"course files" directory
* all the files should all be imported

closes #CNVS-14872

Change-Id: I90df086eac2873e05d1a9a26fb30f71464dd9814
Reviewed-on: https://gerrit.instructure.com/39511
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
This commit is contained in:
James Williams 2014-08-19 05:55:55 -06:00
parent d0c590f402
commit e33e0c5d0f
3 changed files with 13 additions and 37 deletions

View File

@ -1,3 +1,3 @@
gem 'moodle2cc', '0.2.14' gem 'moodle2cc', '0.2.15'
gem 'happymapper', '0.4.1' gem 'happymapper', '0.4.1'
gem 'thor', '0.18.1' gem 'thor', '0.18.1'

BIN
vendor/plugins/moodle2cc/spec_canvas/fixtures/moodle_backup_1_9.zip vendored Executable file → Normal file

Binary file not shown.

View File

@ -2,34 +2,36 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Moodle::Converter do describe Moodle::Converter do
before(:all) do before :once do
fixture_dir = File.dirname(__FILE__) + '/fixtures' fixture_dir = File.dirname(__FILE__) + '/fixtures'
archive_file_path = File.join(fixture_dir, 'moodle_backup_1_9.zip') archive_file_path = File.join(fixture_dir, 'moodle_backup_1_9.zip')
unzipped_file_path = File.join(File.dirname(archive_file_path), "moodle_#{File.basename(archive_file_path, '.zip')}", 'oi') unzipped_file_path = File.join(File.dirname(archive_file_path), "moodle_#{File.basename(archive_file_path, '.zip')}", 'oi')
converter = Moodle::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path) converter = Moodle::Converter.new(:export_archive_path=>archive_file_path, :course_name=>'oi', :base_download_dir=>unzipped_file_path)
converter.export converter.export
@base_course_data = converter.course.with_indifferent_access
@course_data = converter.course.with_indifferent_access
@course = Course.create(:name => "test course")
@cm = ContentMigration.create(:context => @course)
Importers::CourseContentImporter.import_content(@course, @course_data, nil, @cm)
converter.delete_unzipped_archive converter.delete_unzipped_archive
if File.exists?(unzipped_file_path) if File.exists?(unzipped_file_path)
FileUtils::rm_rf(unzipped_file_path) FileUtils::rm_rf(unzipped_file_path)
end end
end end
before(:each) do
# make a deep copy
@course_data = Marshal.load(Marshal.dump(@base_course_data))
@course = Course.create(:name => "test course")
@cm = ContentMigration.create(:context => @course)
end
it "should successfully import the course" do it "should successfully import the course" do
Importers::CourseContentImporter.import_content(@course, @course_data, nil, @cm)
allowed_warnings = ["Multiple Dropdowns question may have been imported incorrectly", allowed_warnings = ["Multiple Dropdowns question may have been imported incorrectly",
"Possible answers will need to be regenerated for Formula question", "Possible answers will need to be regenerated for Formula question",
"Missing links found in imported content"] "Missing links found in imported content"]
@cm.old_warnings_format.all?{|w| allowed_warnings.find{|aw| w[0].start_with?(aw)}}.should == true @cm.old_warnings_format.all?{|w| allowed_warnings.find{|aw| w[0].start_with?(aw)}}.should == true
end end
it "should import files" do
@course.attachments.count.should == 1
@course.attachments.first.full_display_path.should == "course files/images/facepalm.png"
end
it "should add at most 2 warnings per bank for problematic questions" do it "should add at most 2 warnings per bank for problematic questions" do
converter = Moodle::Converter.new({:no_archive_file => true}) converter = Moodle::Converter.new({:no_archive_file => true})
test_course = {:assessment_questions => {:assessment_questions => [ test_course = {:assessment_questions => {:assessment_questions => [
@ -61,12 +63,6 @@ describe Moodle::Converter do
end end
context "discussion topics" do context "discussion topics" do
before(:each) do
#These need to be ran twice because they can reference each other
Importers::DiscussionTopicImporter.process_migration(@course_data, @cm)
Importers::DiscussionTopicImporter.process_migration(@course_data, @cm)
end
it "should convert discussion topics" do it "should convert discussion topics" do
@course.discussion_topics.count.should == 2 @course.discussion_topics.count.should == 2
@ -81,12 +77,6 @@ describe Moodle::Converter do
end end
context "assignments" do context "assignments" do
before(:each) do
#These need to be ran twice because they can reference each other
Importers::AssignmentImporter.process_migration(@course_data, @cm)
Importers::AssignmentImporter.process_migration(@course_data, @cm)
end
it "should convert assignments" do it "should convert assignments" do
@course.assignments.count.should == 6 @course.assignments.count.should == 6
@ -107,12 +97,6 @@ describe Moodle::Converter do
end end
context "wiki pages" do context "wiki pages" do
before(:each) do
#These need to be ran twice because they can reference each other
Importers::WikiPageImporter.process_migration(@course_data, @cm)
Importers::WikiPageImporter.process_migration(@course_data, @cm)
end
it "should convert wikis" do it "should convert wikis" do
wiki = @course.wiki wiki = @course.wiki
wiki.should_not be_nil wiki.should_not be_nil
@ -138,14 +122,6 @@ describe Moodle::Converter do
context "quizzes" do context "quizzes" do
before(:each) do before(:each) do
pending if !Qti.qti_enabled? pending if !Qti.qti_enabled?
question_data = Importers::AssessmentQuestionImporter.process_migration(@course_data, @cm)
Importers::GroupImporter.process_migration(@course_data, @cm)
Importers::LearningOutcomeImporter.process_migration(@course_data, @cm)
Importers::RubricImporter.process_migration(@course_data, @cm)
Importers::AssignmentGroupImporter.process_migration(@course_data, @cm)
Importers::ExternalFeedImporter.process_migration(@course_data, @cm)
Importers::GradingStandardImporter.process_migration(@course_data, @cm)
Importers::QuizImporter.process_migration(@course_data, @cm, question_data)
end end
it "should convert quizzes" do it "should convert quizzes" do