rspec 3-ify moodle2cc

refs CNVS-16239

Change-Id: Id010885bcb854fdaa3c3a2aec6db4f4ed4a46c06
Reviewed-on: https://gerrit.instructure.com/42707
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <braden@instructure.com>
Product-Review: Braden Anderson <braden@instructure.com>
QA-Review: Braden Anderson <braden@instructure.com>
This commit is contained in:
Cody Cutrer 2014-10-13 20:45:45 -06:00
parent 19f44adc18
commit 999082daf3
2 changed files with 133 additions and 133 deletions

View File

@ -24,12 +24,12 @@ describe Moodle::Converter do
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 expect(@cm.old_warnings_format.all?{|w| allowed_warnings.find{|aw| w[0].start_with?(aw)}}).to eq true
end end
it "should import files" do it "should import files" do
@course.attachments.count.should == 1 expect(@course.attachments.count).to eq 1
@course.attachments.first.full_display_path.should == "course files/images/facepalm.png" expect(@course.attachments.first.full_display_path).to eq "course files/images/facepalm.png"
end 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
@ -52,280 +52,280 @@ describe Moodle::Converter do
converter.add_question_warnings converter.add_question_warnings
converted_course = converter.instance_variable_get(:@course) converted_course = converter.instance_variable_get(:@course)
questions = converted_course[:assessment_questions][:assessment_questions] questions = converted_course[:assessment_questions][:assessment_questions]
questions[0]['import_warnings'].should == ["There are 3 Multiple Dropdowns questions in this bank that may have been imported incorrectly"] expect(questions[0]['import_warnings']).to eq ["There are 3 Multiple Dropdowns questions in this bank that may have been imported incorrectly"]
questions[1]['import_warnings'].should == ["Possible answers will need to be regenerated for Formula question"] expect(questions[1]['import_warnings']).to eq ["Possible answers will need to be regenerated for Formula question"]
questions[2]['import_warnings'].should == ["Multiple Dropdowns question may have been imported incorrectly"] expect(questions[2]['import_warnings']).to eq ["Multiple Dropdowns question may have been imported incorrectly"]
questions[3]['import_warnings'].should == ["There are 4 Formula questions in this bank that will need to have their possible answers regenerated"] expect(questions[3]['import_warnings']).to eq ["There are 4 Formula questions in this bank that will need to have their possible answers regenerated"]
[4, 5, 6, 7, 8].each do |idx| [4, 5, 6, 7, 8].each do |idx|
questions[idx]['import_warnings'].should be_nil expect(questions[idx]['import_warnings']).to be_nil
end end
end end
context "discussion topics" do context "discussion topics" do
it "should convert discussion topics" do it "should convert discussion topics" do
@course.discussion_topics.count.should == 2 expect(@course.discussion_topics.count).to eq 2
dt = @course.discussion_topics.first dt = @course.discussion_topics.first
dt.title.should == "General Forum" expect(dt.title).to eq "General Forum"
dt.message.should == "<p>General Forum Introduction</p>" expect(dt.message).to eq "<p>General Forum Introduction</p>"
dt = @course.discussion_topics.last dt = @course.discussion_topics.last
dt.title.should == "News forum" expect(dt.title).to eq "News forum"
dt.message.should == "<p>General news and announcements</p>" expect(dt.message).to eq "<p>General news and announcements</p>"
end end
end end
context "assignments" do context "assignments" do
it "should convert assignments" do it "should convert assignments" do
@course.assignments.count.should == 6 expect(@course.assignments.count).to eq 6
assignment = @course.assignments.find_by_title 'Create a Rails site' assignment = @course.assignments.find_by_title 'Create a Rails site'
assignment.should_not be_nil expect(assignment).not_to be_nil
assignment.description.should == "<p>Use `rails new` to create your first Rails site</p>" expect(assignment.description).to eq "<p>Use `rails new` to create your first Rails site</p>"
end end
it "should convert Moodle Workshop to peer reviewed assignment" do it "should convert Moodle Workshop to peer reviewed assignment" do
assignment = @course.assignments.find_by_title 'My Workshop' assignment = @course.assignments.find_by_title 'My Workshop'
assignment.should_not be_nil expect(assignment).not_to be_nil
assignment.description.should == "<p>My Workshop Description</p>" expect(assignment.description).to eq "<p>My Workshop Description</p>"
assignment.peer_reviews.should be_true expect(assignment.peer_reviews).to be_truthy
assignment.automatic_peer_reviews.should be_true expect(assignment.automatic_peer_reviews).to be_truthy
#assignment.anonymous_peer_reviews.should be_false #assignment.anonymous_peer_reviews.should be_false
assignment.peer_review_count.should == 5 expect(assignment.peer_review_count).to eq 5
end end
end end
context "wiki pages" do context "wiki pages" do
it "should convert wikis" do it "should convert wikis" do
wiki = @course.wiki wiki = @course.wiki
wiki.should_not be_nil expect(wiki).not_to be_nil
wiki.wiki_pages.count.should == 3 expect(wiki.wiki_pages.count).to eq 3
page = wiki.wiki_pages.find_by_title 'My Wiki' page = wiki.wiki_pages.find_by_title 'My Wiki'
page.should_not be_nil expect(page).not_to be_nil
page.url.should == 'my-wiki-my-wiki' expect(page.url).to eq 'my-wiki-my-wiki'
html = Nokogiri::HTML(page.body) html = Nokogiri::HTML(page.body)
href = html.search('a').first.attributes['href'].value href = html.search('a').first.attributes['href'].value
href.should == "/courses/#{@course.id}/#{@course.wiki.path}/my-wiki-link" expect(href).to eq "/courses/#{@course.id}/#{@course.wiki.path}/my-wiki-link"
page = wiki.wiki_pages.find_by_title 'link' page = wiki.wiki_pages.find_by_title 'link'
page.should_not be_nil expect(page).not_to be_nil
page.url.should == 'my-wiki-link' expect(page.url).to eq 'my-wiki-link'
page = wiki.wiki_pages.find_by_title 'New Wiki' page = wiki.wiki_pages.find_by_title 'New Wiki'
page.should_not be_nil expect(page).not_to be_nil
page.url.should == 'new-wiki-new-wiki' expect(page.url).to eq 'new-wiki-new-wiki'
end end
end end
context "quizzes" do context "quizzes" do
before(:each) do before(:each) do
pending if !Qti.qti_enabled? skip if !Qti.qti_enabled?
end end
it "should convert quizzes" do it "should convert quizzes" do
@course.quizzes.count.should == 3 expect(@course.quizzes.count).to eq 3
end end
it "should convert Moodle Quiz module to a quiz" do it "should convert Moodle Quiz module to a quiz" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
quiz.should_not be_nil expect(quiz).not_to be_nil
quiz.description.should match /Pop quiz hot shot/ expect(quiz.description).to match /Pop quiz hot shot/
quiz.quiz_questions.count.should == 9 expect(quiz.quiz_questions.count).to eq 9
end end
it "should convert Moodle Calculated Question to Canvas calculated_question" do it "should convert Moodle Calculated Question to Canvas calculated_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[0] question = quiz.quiz_questions[0]
question.question_data[:question_name].should == "Calculated Question" expect(question.question_data[:question_name]).to eq "Calculated Question"
question.question_data[:question_text].should == "How much is [a] + [b] ?" expect(question.question_data[:question_text]).to eq "How much is [a] + [b] ?"
question.question_data[:question_type].should == 'calculated_question' expect(question.question_data[:question_type]).to eq 'calculated_question'
question.question_data[:neutral_comments].should == 'Calculated Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'Calculated Question General Feedback'
# add warnings because these question types seem to be ambiguously structured in moodle # add warnings because these question types seem to be ambiguously structured in moodle
warnings = @cm.migration_issues.select{|w| warnings = @cm.migration_issues.select{|w|
w.description == "Possible answers will need to be regenerated for Formula question" && w.description == "Possible answers will need to be regenerated for Formula question" &&
w.fix_issue_html_url.include?("question_#{question.assessment_question_id}") w.fix_issue_html_url.include?("question_#{question.assessment_question_id}")
} }
warnings.count.should == 1 expect(warnings.count).to eq 1
end end
it "should convert Moodle Description Question to Canvas text_only_question" do it "should convert Moodle Description Question to Canvas text_only_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[1] question = quiz.quiz_questions[1]
question.question_data[:question_name].should == "Description Question" expect(question.question_data[:question_name]).to eq "Description Question"
question.question_data[:question_text].should == "Description Question Text" expect(question.question_data[:question_text]).to eq "Description Question Text"
question.question_data[:question_type].should == 'text_only_question' expect(question.question_data[:question_type]).to eq 'text_only_question'
end end
it "should convert Moodle Essay Question to Canvas essay_question" do it "should convert Moodle Essay Question to Canvas essay_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[2] question = quiz.quiz_questions[2]
question.question_data[:question_name].should == "Essay Question" expect(question.question_data[:question_name]).to eq "Essay Question"
question.question_data[:question_text].should == "Essay Question Text" expect(question.question_data[:question_text]).to eq "Essay Question Text"
question.question_data[:question_type].should == 'essay_question' expect(question.question_data[:question_type]).to eq 'essay_question'
question.question_data[:neutral_comments].should == 'Essay Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'Essay Question General Feedback'
end end
it "should convert Moodle Matching Question to Canvas matching_question" do it "should convert Moodle Matching Question to Canvas matching_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[3] question = quiz.quiz_questions[3]
question.question_data[:question_name].should == "Matching Question" expect(question.question_data[:question_name]).to eq "Matching Question"
question.question_data[:question_text].should == "Matching Question Text" expect(question.question_data[:question_text]).to eq "Matching Question Text"
question.question_data[:question_type].should == 'matching_question' expect(question.question_data[:question_type]).to eq 'matching_question'
question.question_data[:neutral_comments].should == 'Matching Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'Matching Question General Feedback'
end end
it "should convert Moodle Embedded Answers Question to Canvas essay_question" do it "should convert Moodle Embedded Answers Question to Canvas essay_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[4] question = quiz.quiz_questions[4]
question.question_data[:question_name].should == "Embedded Answers Question" expect(question.question_data[:question_name]).to eq "Embedded Answers Question"
question.question_data[:question_text].should match /Embedded Answers Question Text/ expect(question.question_data[:question_text]).to match /Embedded Answers Question Text/
question.question_data[:question_type].should == 'essay_question' expect(question.question_data[:question_type]).to eq 'essay_question'
question.question_data[:neutral_comments].should == 'Embedded Answers Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'Embedded Answers Question General Feedback'
end end
it "should convert Moodle Multiple Choice Question to Canvas multiple_choice_question" do it "should convert Moodle Multiple Choice Question to Canvas multiple_choice_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[5] question = quiz.quiz_questions[5]
question.question_data[:question_name].should == "Multiple Choice Question" expect(question.question_data[:question_name]).to eq "Multiple Choice Question"
question.question_data[:question_text].should == "Multiple Choice Question Text" expect(question.question_data[:question_text]).to eq "Multiple Choice Question Text"
question.question_data[:question_type].should == 'multiple_choice_question' expect(question.question_data[:question_type]).to eq 'multiple_choice_question'
question.question_data[:neutral_comments].should == 'Multiple Choice Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'Multiple Choice Question General Feedback'
end end
it "should convert Moodle Numerical Question to Canvas numerical_question" do it "should convert Moodle Numerical Question to Canvas numerical_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[6] question = quiz.quiz_questions[6]
question.question_data[:question_name].should == "Numerical Question" expect(question.question_data[:question_name]).to eq "Numerical Question"
question.question_data[:question_text].should == "Numerical Question Text" expect(question.question_data[:question_text]).to eq "Numerical Question Text"
question.question_data[:question_type].should == 'numerical_question' expect(question.question_data[:question_type]).to eq 'numerical_question'
question.question_data[:neutral_comments].should == 'Numerical Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'Numerical Question General Feedback'
end end
it "should convert Moodle Short Answer Question to Canvas short_answer_question" do it "should convert Moodle Short Answer Question to Canvas short_answer_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[7] question = quiz.quiz_questions[7]
question.question_data[:question_name].should == "Short Answer Question" expect(question.question_data[:question_name]).to eq "Short Answer Question"
question.question_data[:question_text].should == "Short Answer Question Text" expect(question.question_data[:question_text]).to eq "Short Answer Question Text"
question.question_data[:question_type].should == 'short_answer_question' expect(question.question_data[:question_type]).to eq 'short_answer_question'
question.question_data[:neutral_comments].should == 'Short Answer Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'Short Answer Question General Feedback'
end end
it "should convert Moodle True/False Question to Canvas true_false_question" do it "should convert Moodle True/False Question to Canvas true_false_question" do
quiz = @course.quizzes.find_by_title "First Quiz" quiz = @course.quizzes.find_by_title "First Quiz"
question = quiz.quiz_questions[8] question = quiz.quiz_questions[8]
question.question_data[:question_name].should == "True or False Question" expect(question.question_data[:question_name]).to eq "True or False Question"
question.question_data[:question_text].should == "True or False Question Text" expect(question.question_data[:question_text]).to eq "True or False Question Text"
question.question_data[:question_type].should == 'true_false_question' expect(question.question_data[:question_type]).to eq 'true_false_question'
question.question_data[:neutral_comments].should == 'True or False Question General Feedback' expect(question.question_data[:neutral_comments]).to eq 'True or False Question General Feedback'
end end
it "should convert Moodle Questionnaire module to a quiz" do it "should convert Moodle Questionnaire module to a quiz" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
quiz.should_not be_nil expect(quiz).not_to be_nil
quiz.description.should match /Questionnaire Summary/ expect(quiz.description).to match /Questionnaire Summary/
quiz.quiz_type.should == 'survey' expect(quiz.quiz_type).to eq 'survey'
quiz.quiz_questions.count.should == 10 expect(quiz.quiz_questions.count).to eq 10
end end
it "should convert Moodle Questionnaire Check Boxes Question to Canvas multiple_answers_question" do it "should convert Moodle Questionnaire Check Boxes Question to Canvas multiple_answers_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[0] question = quiz.quiz_questions[0]
question.question_data[:question_name].should == "Check Boxes Question" expect(question.question_data[:question_name]).to eq "Check Boxes Question"
question.question_data[:question_text].should == "Check Boxes Question Text" expect(question.question_data[:question_text]).to eq "Check Boxes Question Text"
question.question_data[:question_type].should == 'multiple_answers_question' expect(question.question_data[:question_type]).to eq 'multiple_answers_question'
end end
it "should convert Moodle Questionnaire Date Question to Canvas essay_question" do it "should convert Moodle Questionnaire Date Question to Canvas essay_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[1] question = quiz.quiz_questions[1]
question.question_data[:question_name].should == "Date Question" expect(question.question_data[:question_name]).to eq "Date Question"
question.question_data[:question_text].should == "Date Question Text" expect(question.question_data[:question_text]).to eq "Date Question Text"
question.question_data[:question_type].should == 'essay_question' expect(question.question_data[:question_type]).to eq 'essay_question'
end end
it "should convert Moodle Questionnaire Dropdown Box Question to Canvas multiple_choice_question" do it "should convert Moodle Questionnaire Dropdown Box Question to Canvas multiple_choice_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[2] question = quiz.quiz_questions[2]
question.question_data[:question_name].should == "Dropdown Box Question" expect(question.question_data[:question_name]).to eq "Dropdown Box Question"
question.question_data[:question_text].should == "Dropdown Box Question Text" expect(question.question_data[:question_text]).to eq "Dropdown Box Question Text"
question.question_data[:question_type].should == 'multiple_choice_question' expect(question.question_data[:question_type]).to eq 'multiple_choice_question'
end end
it "should convert Moodle Questionnaire Essay Box Question to Canvas essay_question" do it "should convert Moodle Questionnaire Essay Box Question to Canvas essay_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[3] question = quiz.quiz_questions[3]
question.question_data[:question_name].should == "Essay Box Question" expect(question.question_data[:question_name]).to eq "Essay Box Question"
question.question_data[:question_text].should == "Essay Box Question Text" expect(question.question_data[:question_text]).to eq "Essay Box Question Text"
question.question_data[:question_type].should == 'essay_question' expect(question.question_data[:question_type]).to eq 'essay_question'
end end
it "should convert Moodle Questionnaire Label to Canvas text_only_question" do it "should convert Moodle Questionnaire Label to Canvas text_only_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[4] question = quiz.quiz_questions[4]
question.question_data[:question_name].should == "" expect(question.question_data[:question_name]).to eq ""
question.question_data[:question_text].should == "Label Text" expect(question.question_data[:question_text]).to eq "Label Text"
question.question_data[:question_type].should == 'text_only_question' expect(question.question_data[:question_type]).to eq 'text_only_question'
end end
it "should convert Moodle Questionnaire Numeric Question to Canvas numerical_question" do it "should convert Moodle Questionnaire Numeric Question to Canvas numerical_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[5] question = quiz.quiz_questions[5]
question.question_data[:question_name].should == "Numeric Question" expect(question.question_data[:question_name]).to eq "Numeric Question"
question.question_data[:question_text].should == "Numeric Question Text" expect(question.question_data[:question_text]).to eq "Numeric Question Text"
question.question_data[:question_type].should == 'numerical_question' expect(question.question_data[:question_type]).to eq 'numerical_question'
end end
it "should convert Moodle Questionnaire Radio Buttons Question to Canvas multiple_choice_question" do it "should convert Moodle Questionnaire Radio Buttons Question to Canvas multiple_choice_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[6] question = quiz.quiz_questions[6]
question.question_data[:question_name].should == "Radio Buttons Question" expect(question.question_data[:question_name]).to eq "Radio Buttons Question"
question.question_data[:question_text].should == "Radio Buttons Question Text" expect(question.question_data[:question_text]).to eq "Radio Buttons Question Text"
question.question_data[:question_type].should == 'multiple_choice_question' expect(question.question_data[:question_type]).to eq 'multiple_choice_question'
end end
it "should convert Moodle Questionnaire Rate Scale 1..5 Question to Canvas multiple_dropdowns_question" do it "should convert Moodle Questionnaire Rate Scale 1..5 Question to Canvas multiple_dropdowns_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[7] question = quiz.quiz_questions[7]
question.question_data[:question_name].should == "Rate Scale 1..5 Question" expect(question.question_data[:question_name]).to eq "Rate Scale 1..5 Question"
question.question_data[:question_text].should == "Rate Scale 1..5 Question Text\nquestion1 [response1]\nquestion2 [response2]\nquestion3 [response3]" expect(question.question_data[:question_text]).to eq "Rate Scale 1..5 Question Text\nquestion1 [response1]\nquestion2 [response2]\nquestion3 [response3]"
question.question_data[:question_type].should == 'multiple_dropdowns_question' expect(question.question_data[:question_type]).to eq 'multiple_dropdowns_question'
# add warnings because these question types seem to be ambiguously structured in moodle # add warnings because these question types seem to be ambiguously structured in moodle
warnings = @cm.migration_issues.select{|w| warnings = @cm.migration_issues.select{|w|
w.description == "Multiple Dropdowns question may have been imported incorrectly" && w.description == "Multiple Dropdowns question may have been imported incorrectly" &&
w.fix_issue_html_url.include?("question_#{question.assessment_question_id}") w.fix_issue_html_url.include?("question_#{question.assessment_question_id}")
} }
warnings.count.should == 1 expect(warnings.count).to eq 1
end end
it "should convert Moodle Questionnaire Text Box Question to Canvas essay_question" do it "should convert Moodle Questionnaire Text Box Question to Canvas essay_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[8] question = quiz.quiz_questions[8]
question.question_data[:question_name].should == "Text Box Question" expect(question.question_data[:question_name]).to eq "Text Box Question"
question.question_data[:question_text].should == "Text Box Question Text" expect(question.question_data[:question_text]).to eq "Text Box Question Text"
question.question_data[:question_type].should == 'essay_question' expect(question.question_data[:question_type]).to eq 'essay_question'
end end
it "should convert Moodle Questionnaire Yes/No Question to Canvas true_false_question" do it "should convert Moodle Questionnaire Yes/No Question to Canvas true_false_question" do
quiz = @course.quizzes.find_by_title "My Questionnaire" quiz = @course.quizzes.find_by_title "My Questionnaire"
question = quiz.quiz_questions[9] question = quiz.quiz_questions[9]
question.question_data[:question_name].should == "Yes No Question" expect(question.question_data[:question_name]).to eq "Yes No Question"
question.question_data[:question_text].should == "Yes No Question Text" expect(question.question_data[:question_text]).to eq "Yes No Question Text"
question.question_data[:question_type].should == 'true_false_question' expect(question.question_data[:question_type]).to eq 'true_false_question'
end end
it "should convert Moodle Choice module to a quiz" do it "should convert Moodle Choice module to a quiz" do
quiz = @course.quizzes.find_by_title "My Choice" quiz = @course.quizzes.find_by_title "My Choice"
quiz.should_not be_nil expect(quiz).not_to be_nil
quiz.description.should match /Which one will you choose\?/ expect(quiz.description).to match /Which one will you choose\?/
quiz.quiz_type.should == 'survey' expect(quiz.quiz_type).to eq 'survey'
quiz.quiz_questions.count.should == 1 expect(quiz.quiz_questions.count).to eq 1
question = quiz.quiz_questions.first question = quiz.quiz_questions.first
question.question_data[:question_name].should == "My Choice" expect(question.question_data[:question_name]).to eq "My Choice"
question.question_data[:question_text].should == "Which one will you choose?" expect(question.question_data[:question_text]).to eq "Which one will you choose?"
end end
end end
end end

View File

@ -24,66 +24,66 @@ describe Moodle::Converter do
allowed_warnings = ["Multiple Dropdowns question may have been imported incorrectly", allowed_warnings = ["Multiple Dropdowns question may have been imported incorrectly",
"There are 3 Formula questions in this bank that will need to have their possible answers regenerated", "There are 3 Formula questions in this bank that will need to have their possible answers regenerated",
"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 expect(@cm.old_warnings_format.all?{|w| allowed_warnings.find{|aw| w[0].start_with?(aw)}}).to eq true
end end
context "discussion topics" do context "discussion topics" do
it "should convert discussion topics" do it "should convert discussion topics" do
@course.discussion_topics.count.should == 2 expect(@course.discussion_topics.count).to eq 2
dt = @course.discussion_topics.first dt = @course.discussion_topics.first
dt.title.should == "Hidden Forum" expect(dt.title).to eq "Hidden Forum"
dt.message.should == "<p>Description of hidden forum</p>" expect(dt.message).to eq "<p>Description of hidden forum</p>"
dt.unpublished?.should == true expect(dt.unpublished?).to eq true
dt2 = @course.discussion_topics.last dt2 = @course.discussion_topics.last
dt2.title.should == "News forum" expect(dt2.title).to eq "News forum"
dt2.message.should == "<p>General news and announcements</p>" expect(dt2.message).to eq "<p>General news and announcements</p>"
end end
end end
context "assignments" do context "assignments" do
it "should convert assignments" do it "should convert assignments" do
@course.assignments.count.should == 2 expect(@course.assignments.count).to eq 2
assignment2 = @course.assignments.find_by_title 'Hidden Assignmnet' assignment2 = @course.assignments.find_by_title 'Hidden Assignmnet'
assignment2.description.should == "<p>This is a hidden assignment</p>" expect(assignment2.description).to eq "<p>This is a hidden assignment</p>"
assignment2.unpublished?.should == true expect(assignment2.unpublished?).to eq true
end end
end end
context "wiki pages" do context "wiki pages" do
it "should convert wikis" do it "should convert wikis" do
wiki = @course.wiki wiki = @course.wiki
wiki.should_not be_nil expect(wiki).not_to be_nil
wiki.wiki_pages.count.should == 12 expect(wiki.wiki_pages.count).to eq 12
page1 = wiki.wiki_pages.find_by_title 'Hidden Section' page1 = wiki.wiki_pages.find_by_title 'Hidden Section'
page1.body.should == '<p>This is a Hidden Section, with hidden items</p>' expect(page1.body).to eq '<p>This is a Hidden Section, with hidden items</p>'
page1.unpublished?.should == true expect(page1.unpublished?).to eq true
end end
end end
context "quizzes" do context "quizzes" do
before(:each) do before(:each) do
pending if !Qti.qti_enabled? skip if !Qti.qti_enabled?
end end
it "should convert quizzes" do it "should convert quizzes" do
@course.quizzes.count.should == 2 expect(@course.quizzes.count).to eq 2
end end
it "should convert Moodle Quiz module to a quiz" do it "should convert Moodle Quiz module to a quiz" do
quiz = @course.quizzes.find_by_title "Quiz Name" quiz = @course.quizzes.find_by_title "Quiz Name"
quiz.description.should match /Quiz Description/ expect(quiz.description).to match /Quiz Description/
quiz.quiz_questions.count.should == 11 expect(quiz.quiz_questions.count).to eq 11
end end
it "should convert Moodle Questionnaire module to a quiz" do it "should convert Moodle Questionnaire module to a quiz" do
quiz = @course.quizzes.find_by_title "Questionnaire Name" quiz = @course.quizzes.find_by_title "Questionnaire Name"
quiz.description.should match /Sumary/ expect(quiz.description).to match /Sumary/
quiz.quiz_type.should == 'survey' expect(quiz.quiz_type).to eq 'survey'
quiz.quiz_questions.count.should == 10 expect(quiz.quiz_questions.count).to eq 10
end end
end end
end end