Skip to content

Stop clobbering bank names when there is more than one question #2347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/importers/assessment_question_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def self.process_migration(data, migration)
question_bank.migration_id = bank_mig_id
elsif data["assessment_question_banks"]
if (bank_hash = data["assessment_question_banks"].detect { |qb_hash| qb_hash["migration_id"] == question_bank.migration_id })
question_bank.title = bank_hash["title"] # we should update the title i guess?
question_bank.title = bank_hash["title"] if bank_hash["title"]
end
end

Expand Down
Binary file not shown.
Binary file not shown.
30 changes: 30 additions & 0 deletions gems/plugins/qti_exporter/spec_canvas/qti_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,36 @@
match_ignoring(data, respondus_questions, %w[id assessment_question_id match_id missing_links position prepped_for_import is_quiz_question_bank question_bank_migration_id quiz_question_id])
end

context "with learnosity qti 2.1 files" do
it "is able to import one question into a new named assessment question bank" do
setup_migration(File.expand_path("fixtures/learnosity_qti_one_question.zip", __dir__))
@migration.update_migration_settings(migration_ids_to_import: { copy: { all_quizzes: false, all_assessment_question_banks: true } })
@migration.update_migration_settings(question_bank_name: "question bank name 1")
@migration.save!
do_migration

expect(@course.quizzes.count).to eq 0
qb = @course.assessment_question_banks.last
expect(qb).to be_present
expect(qb.title).to eq "question bank name 1"
expect(qb.assessment_questions.size).to eq 1
end

it "is able to import two questions into a new named assessment question bank" do
setup_migration(File.expand_path("fixtures/learnosity_qti_two_questions.zip", __dir__))
@migration.update_migration_settings(migration_ids_to_import: { copy: { all_quizzes: false, all_assessment_question_banks: true } })
@migration.update_migration_settings(question_bank_name: "question bank name 2")
@migration.save!
do_migration

expect(@course.quizzes.count).to eq 0
qb = @course.assessment_question_banks.last
expect(qb).to be_present
expect(qb.title).to eq "question bank name 2"
expect(qb.assessment_questions.size).to eq 2
end
end

def match_ignoring(a, b, ignoring = []) # rubocop:disable Naming/MethodParameterName
case a
when Hash
Expand Down