canvas_qti_to_learnosity_converter 2.2.0 → 2.3.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: 2e102ffcbd4d59f3fb3e466bdfada0f614ed1ae8438e2e63322454d1585203f7
4
- data.tar.gz: 8f52c78fc0e604827e947095e4ca12ed2a1da248a2d97fa9ca18721da255e0c7
3
+ metadata.gz: '0867de4ed2c5e63c40847682b28902912b7feec791671ce552dd0ab10081e2ce'
4
+ data.tar.gz: 51897841e676a4aa65b9f46535844f9240b48df054cba20ab622aa83311411c5
5
5
  SHA512:
6
- metadata.gz: 96621e2221a06448c6a351cee7f460ef5067c470cc84102b9b2e37bab8d8d6e77c9ee81ca006d7336cffb42ac4d1972b3a957eb2e31f8f7f8fd2b3125ffc8d70
7
- data.tar.gz: e184a67f1c709ed6189bb2d7fe8aee3484d03a2f0a8ee25747fed902c3fbe78f62634f4f2aa878976624e70c5f97eef551e49dc7300981f4ba19a4b7b982ec69
6
+ metadata.gz: 9139a5fd21f743f3533a04e7e72519ba0bd3b3cda66436364a944a94cf83f6f14bdc55aa4e7cc5b65d26ca69669f52f1ee0c1b91d4663963f3852936c849afce
7
+ data.tar.gz: 3fb5146135643b8c7f1e3101b28147ca22e4271cd069e893aa9874aa1c210ec0d8b7aca68bceefcb79d10478f9bd452889120b0ad6c50a583a61e81d178bfc89
@@ -45,6 +45,11 @@ module CanvasQtiToLearnosityConverter
45
45
  }
46
46
 
47
47
  class CanvasQuestionTypeNotSupportedError < RuntimeError
48
+ attr_reader :question_type
49
+ def initialize(question_type)
50
+ @question_type = question_type.to_s
51
+ super("Unsupported question type #{@question_type}")
52
+ end
48
53
  end
49
54
 
50
55
  class CanvasQtiQuiz
@@ -106,7 +111,7 @@ module CanvasQtiToLearnosityConverter
106
111
  if question_class
107
112
  question = question_class.new(xml)
108
113
  else
109
- raise CanvasQuestionTypeNotSupportedError
114
+ raise CanvasQuestionTypeNotSupportedError.new(type)
110
115
  end
111
116
 
112
117
  [learnosity_type, question]
@@ -116,11 +121,12 @@ module CanvasQtiToLearnosityConverter
116
121
  title.gsub(/["']/, "")
117
122
  end
118
123
 
119
- def self.convert(qti, assets)
124
+ def self.convert(qti, assets, errors)
120
125
  quiz = CanvasQtiQuiz.new(qti_string: qti)
121
126
  assessment = quiz.css("assessment")
122
127
  ident = assessment.attribute("ident").value
123
128
  assets[ident] = {}
129
+ errors[ident] = []
124
130
 
125
131
  items = []
126
132
 
@@ -138,8 +144,19 @@ module CanvasQtiToLearnosityConverter
138
144
  path = [items.count - 1, :data]
139
145
 
140
146
  quiz_item.add_learnosity_assets(assets[ident], path)
141
- rescue CanvasQuestionTypeNotSupportedError
142
- nil
147
+ rescue CanvasQuestionTypeNotSupportedError => e
148
+ errors[ident].push({
149
+ index: index,
150
+ error_type: "unsupported_question",
151
+ question_type: e.question_type.to_s,
152
+ message: e.message,
153
+ })
154
+ rescue StandardError => e
155
+ errors[ident].push({
156
+ index: index,
157
+ error_type: e.class.to_s,
158
+ message: e.message,
159
+ })
143
160
  end
144
161
  end
145
162
 
@@ -172,14 +189,16 @@ module CanvasQtiToLearnosityConverter
172
189
  paths = imscc_quiz_paths(parsed_manifest)
173
190
 
174
191
  assets = {}
192
+ errors = {}
175
193
  converted_assesments = paths.map do |qti_path|
176
194
  qti = zip_file.find_entry(qti_path).get_input_stream.read
177
- convert(qti, assets)
195
+ convert(qti, assets, errors)
178
196
  end
179
197
 
180
198
  {
181
199
  assessments: converted_assesments,
182
200
  assets: assets,
201
+ errors: errors,
183
202
  }
184
203
  end
185
204
  end
@@ -1,3 +1,3 @@
1
1
  module CanvasQtiToLearnosityConverter
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.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.2.0
4
+ version: 2.3.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: 2018-08-13 00:00:00.000000000 Z
12
+ date: 2018-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler