canvas_qti_to_learnosity_converter 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2f612956cbc00ab89e47a628c2c7d9007053f1533f5ec5cf5d6f6066b5d0b95
4
- data.tar.gz: 196ec2ae80fee84fd92812a7d720218efc9219c7f97fb11c04b79681b093657f
3
+ metadata.gz: 367e7235a2a58b7fd63af3999e63cb960e34f46fa7f459c08d3608470d55b6c0
4
+ data.tar.gz: 9e33eabe1f9ddecf970ee13fec9e9dc93e5062f658e5122dc90ea3c0a37a8677
5
5
  SHA512:
6
- metadata.gz: 8289a948c65d4506923e9097c1bfbef83cd1e7b89f2a2d80ce6bd86eb86b416948883ef81a693a574b09a4187d37c7a6fb73259e838c5a7296c917d952f78c65
7
- data.tar.gz: 2a4a8d92ec9a9739cb4048c7698e61af46c0ad9691a4d154f49573c1ce6e38c3d0c3b12e25db1cea931c017303f58bd6b04afac42c58a34e1bfffcf235cbc208
6
+ metadata.gz: 62c09c119cab2a055a09f89dbfbb961d1a05f8922475940a86b276d77c16252b9ee56ff8f32aba4a52d9e2e87c2c0c7eeeced67bc0b98d59b11c117a4081589e
7
+ data.tar.gz: 1735c52bf62ae1708e3a1a4eb72af38127eaebd7489e51a206496fa3207e7f350e7bd57e628c4eb8c32f59d4d435246216c61362f683785adfb40b5c67144448
@@ -42,6 +42,12 @@ module CanvasQtiToLearnosityConverter
42
42
  text_only_question: TextOnlyQuestion,
43
43
  numerical_question: NumericalQuestion,
44
44
  calculated_question: CalculatedQuestion,
45
+
46
+ "cc.multiple_choice.v0p1": MultipleChoiceQuestion,
47
+ "cc.multiple_response.v0p1": MultipleAnswersQuestion,
48
+ "cc.fib.v0p1": ShortAnswerQuestion,
49
+ "cc.true_false.v0p1": MultipleChoiceQuestion,
50
+ "cc.essay.v0p1": EssayQuestion,
45
51
  }
46
52
 
47
53
  class CanvasQuestionTypeNotSupportedError < RuntimeError
@@ -84,7 +90,7 @@ module CanvasQtiToLearnosityConverter
84
90
 
85
91
  def self.add_files_to_assets(assets, path, text)
86
92
  text.scan(/(%24|\$)IMS-CC-FILEBASE\1\/([^"]+)/) do |_delimiter, asset_path|
87
- decoded_path = CGI.unescape(asset_path)
93
+ decoded_path = URI::DEFAULT_PARSER.unescape(asset_path)
88
94
  assets[decoded_path] ||= []
89
95
  assets[decoded_path].push(path)
90
96
  end
@@ -93,7 +99,10 @@ module CanvasQtiToLearnosityConverter
93
99
  def self.extract_type(xml)
94
100
  xml.css(%{ item > itemmetadata > qtimetadata >
95
101
  qtimetadatafield > fieldlabel:contains("question_type")})
96
- &.first&.next&.text&.to_sym
102
+ &.first&.next&.text&.to_sym ||
103
+ xml.css(%{ item > itemmetadata > qtimetadata >
104
+ qtimetadatafield > fieldlabel:contains("cc_profile")})
105
+ &.first&.next&.text&.to_sym
97
106
  end
98
107
 
99
108
  def self.convert_item(qti_string:)
@@ -132,7 +141,9 @@ module CanvasQtiToLearnosityConverter
132
141
 
133
142
  quiz.css("item").each.with_index do |item, index|
134
143
  begin
135
- item_title = item.attribute("title").value
144
+ next if item.children.length == 0
145
+
146
+ item_title = item.attribute("title")&.value || ''
136
147
  learnosity_type, quiz_item = convert_item(qti_string: item.to_html)
137
148
 
138
149
  item = {
@@ -179,8 +190,22 @@ module CanvasQtiToLearnosityConverter
179
190
  end
180
191
 
181
192
  def self.imscc_quiz_paths(parsed_manifest)
182
- parsed_manifest.css("resources > resource[type='imsqti_xmlv1p2'] > file").
183
- map { |entry| entry.attribute("href").value }
193
+ resources = parsed_manifest.css("resources > resource[type^='imsqti_xmlv1p2']")
194
+ resources.map do |entry|
195
+ resource_path(parsed_manifest, entry)
196
+ end
197
+ end
198
+
199
+ def self.resource_path(parsed_manifest, entry)
200
+ # Use the Canvas non_cc_assignment qti path when possible. This works for both classic and new quizzes
201
+ entry.css("dependency").each do |dependency|
202
+ ref = dependency.attribute("identifierref").value
203
+ parsed_manifest.css(%{resources > resource[identifier="#{ref}"] > file}).each do |file|
204
+ path = file.attribute("href").value
205
+ return path if path.match?(/^non_cc_assessments/)
206
+ end
207
+ end
208
+ entry.css("file").first&.attribute("href")&.value
184
209
  end
185
210
 
186
211
  def self.convert_imscc_export(path)
@@ -1,3 +1,3 @@
1
1
  module CanvasQtiToLearnosityConverter
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_qti_to_learnosity_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atomic Jolt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-10-31 00:00:00.000000000 Z
12
+ date: 2024-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.3.15
150
+ rubygems_version: 3.4.10
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: Converts canvas qti to learnosity JSON