canvas_qti_to_learnosity_converter 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +659 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/canvas_qti_to_learnosity_converter.gemspec +38 -0
- data/lib/canvas_qti_to_learnosity_converter/convert.rb +221 -0
- data/lib/canvas_qti_to_learnosity_converter/version.rb +3 -0
- data/lib/canvas_qti_to_learnosity_converter.rb +6 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 468fdb5c7e1f611d3a65e0295dbacd9ace2dd408
|
4
|
+
data.tar.gz: 9554d4b90d981fdef71f9e99416caac8734ef923
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb1ef6a4b31b92179c36a67a7ab97710400c007f405cfbde8720201042469329f6c3d869b07569dbbf69e3f53b1e6f9b6cd9f1d2f9efc46c9cf80fbc30f14b33
|
7
|
+
data.tar.gz: 4fa5a5f4c12290a608f0688bfca1d27b40fd1dd247e8aa0163a9fe304aca654322394c3fac602b92b5a864cdb67ef392ad208eaec9a332fb8d7d329afc05612c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,659 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
Exclude:
|
4
|
+
- db/schema.rb
|
5
|
+
- config/initializers/devise.rb
|
6
|
+
- bin/*
|
7
|
+
- config.ru
|
8
|
+
- config/unicorn/*
|
9
|
+
- db/migrate/*
|
10
|
+
- spec/spec_helper.rb
|
11
|
+
|
12
|
+
Naming/AccessorMethodName:
|
13
|
+
Description: Check the naming of accessor methods for get_/set_.
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/Alias:
|
17
|
+
Description: 'Use alias_method instead of alias.'
|
18
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/ArrayJoin:
|
22
|
+
Description: 'Use Array#join instead of Array#*.'
|
23
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/AsciiComments:
|
27
|
+
Description: 'Use only ascii symbols in comments.'
|
28
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Naming/AsciiIdentifiers:
|
32
|
+
Description: 'Use only ascii symbols in identifiers.'
|
33
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/Attr:
|
37
|
+
Description: 'Checks for uses of Module#attr.'
|
38
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Metrics/BlockNesting:
|
42
|
+
Description: 'Avoid excessive block nesting'
|
43
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Style/CaseEquality:
|
47
|
+
Description: 'Avoid explicit use of the case equality operator(===).'
|
48
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Style/CharacterLiteral:
|
52
|
+
Description: 'Checks for uses of character literals.'
|
53
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Style/ClassAndModuleChildren:
|
57
|
+
Description: 'Checks style of children classes and modules.'
|
58
|
+
Enabled: false
|
59
|
+
EnforcedStyle: nested
|
60
|
+
|
61
|
+
Metrics/ClassLength:
|
62
|
+
Description: 'Avoid classes longer than 100 lines of code.'
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Metrics/ModuleLength:
|
66
|
+
Description: 'Avoid modules longer than 100 lines of code.'
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
Metrics/BlockLength:
|
70
|
+
Exclude:
|
71
|
+
- spec/**/**
|
72
|
+
- config/*
|
73
|
+
- lib/tasks/*
|
74
|
+
- Guardfile
|
75
|
+
|
76
|
+
Style/ClassVars:
|
77
|
+
Description: 'Avoid the use of class variables.'
|
78
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Style/CollectionMethods:
|
82
|
+
Enabled: true
|
83
|
+
PreferredMethods:
|
84
|
+
find: detect
|
85
|
+
inject: reduce
|
86
|
+
collect: map
|
87
|
+
find_all: select
|
88
|
+
|
89
|
+
Style/ColonMethodCall:
|
90
|
+
Description: 'Do not use :: for method call.'
|
91
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Style/CommentAnnotation:
|
95
|
+
Description: >-
|
96
|
+
Checks formatting of special comments
|
97
|
+
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
|
98
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
Metrics/AbcSize:
|
102
|
+
Description: >-
|
103
|
+
A calculated magnitude based on number of assignments,
|
104
|
+
branches, and conditions.
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
Metrics/CyclomaticComplexity:
|
108
|
+
Description: >-
|
109
|
+
A complexity metric that is strongly correlated to the number
|
110
|
+
of test cases needed to validate a method.
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
Rails/Delegate:
|
114
|
+
Description: 'Prefer delegate method for delegations.'
|
115
|
+
Enabled: false
|
116
|
+
|
117
|
+
Style/PreferredHashMethods:
|
118
|
+
Description: 'Checks for use of deprecated Hash methods.'
|
119
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
|
120
|
+
Enabled: false
|
121
|
+
|
122
|
+
Style/Documentation:
|
123
|
+
Description: 'Document classes and non-namespace modules.'
|
124
|
+
Enabled: false
|
125
|
+
|
126
|
+
Layout/DotPosition:
|
127
|
+
Description: 'Checks the position of the dot in multi-line method calls.'
|
128
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
|
129
|
+
EnforcedStyle: trailing
|
130
|
+
|
131
|
+
Style/DoubleNegation:
|
132
|
+
Description: 'Checks for uses of double negation (!!).'
|
133
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
Style/EachWithObject:
|
137
|
+
Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
Style/EmptyLiteral:
|
141
|
+
Description: 'Prefer literals to Array.new/Hash.new/String.new.'
|
142
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
|
143
|
+
Enabled: false
|
144
|
+
|
145
|
+
# Checks whether the source file has a utf-8 encoding comment or not
|
146
|
+
# AutoCorrectEncodingComment must match the regex
|
147
|
+
# /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
|
148
|
+
Style/Encoding:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
Style/EvenOdd:
|
152
|
+
Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
|
153
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
|
154
|
+
Enabled: false
|
155
|
+
|
156
|
+
Layout/ExtraSpacing:
|
157
|
+
Description: 'Do not use unnecessary spacing.'
|
158
|
+
Enabled: true
|
159
|
+
|
160
|
+
Layout/EmptyLinesAroundClassBody:
|
161
|
+
Description: 'Do not allow extra lines around class body.'
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
Layout/EmptyLinesAroundModuleBody:
|
165
|
+
Description: 'Do not allow extra lines around module body.'
|
166
|
+
Enabled: false
|
167
|
+
|
168
|
+
Style/BracesAroundHashParameters:
|
169
|
+
Enabled: false
|
170
|
+
|
171
|
+
Naming/FileName:
|
172
|
+
Description: 'Use snake_case for source file names.'
|
173
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
|
174
|
+
Enabled: false
|
175
|
+
|
176
|
+
Style/FrozenStringLiteralComment:
|
177
|
+
Description: >-
|
178
|
+
Add the frozen_string_literal comment to the top of files
|
179
|
+
to help transition from Ruby 2.3.0 to Ruby 3.0.
|
180
|
+
Enabled: false
|
181
|
+
|
182
|
+
Style/FlipFlop:
|
183
|
+
Description: 'Checks for flip flops'
|
184
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
Style/FormatString:
|
188
|
+
Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
|
189
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
Style/GlobalVars:
|
193
|
+
Description: 'Do not introduce global variables.'
|
194
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
|
195
|
+
Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
|
196
|
+
Enabled: false
|
197
|
+
|
198
|
+
Style/GuardClause:
|
199
|
+
Description: 'Check for conditionals that can be replaced with guard clauses'
|
200
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
|
201
|
+
Enabled: false
|
202
|
+
|
203
|
+
Style/IfUnlessModifier:
|
204
|
+
Description: >-
|
205
|
+
Favor modifier if/unless usage when you have a
|
206
|
+
single-line body.
|
207
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
|
208
|
+
Enabled: false
|
209
|
+
|
210
|
+
Style/IfWithSemicolon:
|
211
|
+
Description: 'Do not use if x; .... Use the ternary operator instead.'
|
212
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
|
213
|
+
Enabled: false
|
214
|
+
|
215
|
+
Style/InlineComment:
|
216
|
+
Description: 'Avoid inline comments.'
|
217
|
+
Enabled: false
|
218
|
+
|
219
|
+
Style/Lambda:
|
220
|
+
Description: 'Use the new lambda literal syntax for single-line blocks.'
|
221
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
|
222
|
+
Enabled: false
|
223
|
+
|
224
|
+
Style/LambdaCall:
|
225
|
+
Description: 'Use lambda.call(...) instead of lambda.(...).'
|
226
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
|
227
|
+
Enabled: false
|
228
|
+
|
229
|
+
Style/LineEndConcatenation:
|
230
|
+
Description: >-
|
231
|
+
Use \ instead of + or << to concatenate two string literals at
|
232
|
+
line end.
|
233
|
+
Enabled: false
|
234
|
+
|
235
|
+
Metrics/LineLength:
|
236
|
+
Description: 'Limit lines to 120 characters.'
|
237
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
|
238
|
+
Max: 120
|
239
|
+
Enabled: true
|
240
|
+
Exclude:
|
241
|
+
- Gemfile
|
242
|
+
- spec/support/webmock_requests.rb
|
243
|
+
- lib/tasks/*.rake
|
244
|
+
|
245
|
+
Metrics/MethodLength:
|
246
|
+
Description: 'Avoid methods longer than 10 lines of code.'
|
247
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
|
248
|
+
Enabled: false
|
249
|
+
|
250
|
+
Style/ModuleFunction:
|
251
|
+
Description: 'Checks for usage of `extend self` in modules.'
|
252
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
|
253
|
+
Enabled: false
|
254
|
+
|
255
|
+
Layout/MultilineOperationIndentation:
|
256
|
+
Description: >-
|
257
|
+
Checks indentation of binary operations that span more than
|
258
|
+
one line.
|
259
|
+
Enabled: true
|
260
|
+
EnforcedStyle: indented
|
261
|
+
|
262
|
+
Style/MultilineBlockChain:
|
263
|
+
Description: 'Avoid multi-line chains of blocks.'
|
264
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
|
265
|
+
Enabled: false
|
266
|
+
|
267
|
+
Layout/MultilineMethodCallIndentation:
|
268
|
+
Description: >-
|
269
|
+
Checks indentation of method calls with the dot operator
|
270
|
+
that span more than one line.
|
271
|
+
Enabled: true
|
272
|
+
EnforcedStyle: indented
|
273
|
+
|
274
|
+
Style/NegatedIf:
|
275
|
+
Description: >-
|
276
|
+
Favor unless over if for negative conditions
|
277
|
+
(or control flow or).
|
278
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
|
279
|
+
Enabled: false
|
280
|
+
|
281
|
+
Style/NegatedWhile:
|
282
|
+
Description: 'Favor until over while for negative conditions.'
|
283
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
|
284
|
+
Enabled: false
|
285
|
+
|
286
|
+
Style/Next:
|
287
|
+
Description: 'Use `next` to skip iteration instead of a condition at the end.'
|
288
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
|
289
|
+
Enabled: false
|
290
|
+
|
291
|
+
Style/NilComparison:
|
292
|
+
Description: 'Prefer x.nil? to x == nil.'
|
293
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
|
294
|
+
Enabled: false
|
295
|
+
|
296
|
+
Style/Not:
|
297
|
+
Description: 'Use ! instead of not.'
|
298
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
|
299
|
+
Enabled: false
|
300
|
+
|
301
|
+
Style/NumericLiterals:
|
302
|
+
Description: >-
|
303
|
+
Add underscores to large numeric literals to improve their
|
304
|
+
readability.
|
305
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
|
306
|
+
Enabled: false
|
307
|
+
|
308
|
+
Style/NumericPredicate:
|
309
|
+
Description: >-
|
310
|
+
This cop checks for usage of comparison operators
|
311
|
+
(`==`, `!=`, `>`, `<`) to test numbers as
|
312
|
+
zero, nonzero, positive, or negative.
|
313
|
+
These can be replaced by their respective predicate methods.
|
314
|
+
The cop can also be configured to do the reverse.
|
315
|
+
StyleGuide: 'http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/NumericPredicate'
|
316
|
+
Enabled: false
|
317
|
+
|
318
|
+
Style/OneLineConditional:
|
319
|
+
Description: >-
|
320
|
+
Favor the ternary operator(?:) over
|
321
|
+
if/then/else/end constructs.
|
322
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
|
323
|
+
Enabled: false
|
324
|
+
|
325
|
+
Naming/BinaryOperatorParameterName:
|
326
|
+
Description: 'When defining binary operators, name the argument other.'
|
327
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
|
328
|
+
Enabled: false
|
329
|
+
|
330
|
+
Metrics/ParameterLists:
|
331
|
+
Description: 'Avoid parameter lists longer than three or four parameters.'
|
332
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
|
333
|
+
Enabled: false
|
334
|
+
|
335
|
+
Style/PercentLiteralDelimiters:
|
336
|
+
Description: 'Use `%`-literal delimiters consistently'
|
337
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
|
338
|
+
Enabled: false
|
339
|
+
|
340
|
+
Style/PerlBackrefs:
|
341
|
+
Description: 'Avoid Perl-style regex back references.'
|
342
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
|
343
|
+
Enabled: false
|
344
|
+
|
345
|
+
Naming/PredicateName:
|
346
|
+
Description: 'Check the names of predicate methods.'
|
347
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
|
348
|
+
NamePrefixBlacklist:
|
349
|
+
- is_
|
350
|
+
Exclude:
|
351
|
+
- spec/**/*
|
352
|
+
|
353
|
+
Style/Proc:
|
354
|
+
Description: 'Use proc instead of Proc.new.'
|
355
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
|
356
|
+
Enabled: false
|
357
|
+
|
358
|
+
Style/RaiseArgs:
|
359
|
+
Description: 'Checks the arguments passed to raise/fail.'
|
360
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
|
361
|
+
Enabled: false
|
362
|
+
|
363
|
+
Style/RegexpLiteral:
|
364
|
+
Description: 'Use / or %r around regular expressions.'
|
365
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
|
366
|
+
Enabled: false
|
367
|
+
|
368
|
+
Style/SelfAssignment:
|
369
|
+
Description: >-
|
370
|
+
Checks for places where self-assignment shorthand should have
|
371
|
+
been used.
|
372
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
|
373
|
+
Enabled: false
|
374
|
+
|
375
|
+
Style/SingleLineBlockParams:
|
376
|
+
Description: 'Enforces the names of some block params.'
|
377
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
|
378
|
+
Enabled: false
|
379
|
+
|
380
|
+
Style/SingleLineMethods:
|
381
|
+
Description: 'Avoid single-line methods.'
|
382
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
|
383
|
+
Enabled: false
|
384
|
+
|
385
|
+
Style/SignalException:
|
386
|
+
Description: 'Checks for proper usage of fail and raise.'
|
387
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
|
388
|
+
Enabled: false
|
389
|
+
|
390
|
+
Style/SpecialGlobalVars:
|
391
|
+
Description: 'Avoid Perl-style global variables.'
|
392
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
|
393
|
+
Enabled: false
|
394
|
+
|
395
|
+
Style/StringLiterals:
|
396
|
+
Description: 'Checks if uses of quotes match the configured preference.'
|
397
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
|
398
|
+
EnforcedStyle: double_quotes
|
399
|
+
Enabled: true
|
400
|
+
|
401
|
+
Style/TrailingCommaInArguments:
|
402
|
+
Description: 'Checks for trailing comma in argument lists.'
|
403
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
404
|
+
EnforcedStyleForMultiline: comma
|
405
|
+
Enabled: true
|
406
|
+
|
407
|
+
Style/TrailingCommaInArrayLiteral:
|
408
|
+
Description: 'Checks for trailing comma in array literals.'
|
409
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
410
|
+
EnforcedStyleForMultiline: comma
|
411
|
+
Enabled: true
|
412
|
+
|
413
|
+
Style/TrailingCommaInHashLiteral:
|
414
|
+
Description: 'Checks for trailing comma in hash literals.'
|
415
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
416
|
+
EnforcedStyleForMultiline: comma
|
417
|
+
Enabled: true
|
418
|
+
|
419
|
+
Style/TrivialAccessors:
|
420
|
+
Description: 'Prefer attr_* methods to trivial readers/writers.'
|
421
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
|
422
|
+
Enabled: false
|
423
|
+
|
424
|
+
Style/VariableInterpolation:
|
425
|
+
Description: >-
|
426
|
+
Don't interpolate global, instance and class variables
|
427
|
+
directly in strings.
|
428
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
|
429
|
+
Enabled: false
|
430
|
+
|
431
|
+
Style/WhenThen:
|
432
|
+
Description: 'Use when x then ... for one-line cases.'
|
433
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
|
434
|
+
Enabled: false
|
435
|
+
|
436
|
+
Style/WhileUntilModifier:
|
437
|
+
Description: >-
|
438
|
+
Favor modifier while/until usage when you have a
|
439
|
+
single-line body.
|
440
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
|
441
|
+
Enabled: false
|
442
|
+
|
443
|
+
Style/WordArray:
|
444
|
+
Description: 'Use %w or %W for arrays of words.'
|
445
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
|
446
|
+
Enabled: false
|
447
|
+
|
448
|
+
Style/SymbolArray:
|
449
|
+
Description: 'Use `%i` or `%I` for an array of symbols'
|
450
|
+
StyleGuide: 'http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/SymbolArray'
|
451
|
+
Enabled: false
|
452
|
+
|
453
|
+
# Lint
|
454
|
+
|
455
|
+
Lint/AmbiguousOperator:
|
456
|
+
Description: >-
|
457
|
+
Checks for ambiguous operators in the first argument of a
|
458
|
+
method invocation without parentheses.
|
459
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
|
460
|
+
Enabled: false
|
461
|
+
|
462
|
+
Lint/AmbiguousRegexpLiteral:
|
463
|
+
Description: >-
|
464
|
+
Checks for ambiguous regexp literals in the first argument of
|
465
|
+
a method invocation without parenthesis.
|
466
|
+
Enabled: false
|
467
|
+
|
468
|
+
Lint/AssignmentInCondition:
|
469
|
+
Description: "Don't use assignment in conditions."
|
470
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
|
471
|
+
Enabled: false
|
472
|
+
|
473
|
+
Lint/CircularArgumentReference:
|
474
|
+
Description: "Don't refer to the keyword argument in the default value."
|
475
|
+
Enabled: false
|
476
|
+
|
477
|
+
Layout/ConditionPosition:
|
478
|
+
Description: >-
|
479
|
+
Checks for condition placed in a confusing position relative to
|
480
|
+
the keyword.
|
481
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
|
482
|
+
Enabled: false
|
483
|
+
|
484
|
+
Lint/DeprecatedClassMethods:
|
485
|
+
Description: 'Check for deprecated class method calls.'
|
486
|
+
Enabled: false
|
487
|
+
|
488
|
+
Lint/DuplicatedKey:
|
489
|
+
Description: 'Check for duplicate keys in hash literals.'
|
490
|
+
Enabled: false
|
491
|
+
|
492
|
+
Lint/EachWithObjectArgument:
|
493
|
+
Description: 'Check for immutable argument given to each_with_object.'
|
494
|
+
Enabled: false
|
495
|
+
|
496
|
+
Lint/ElseLayout:
|
497
|
+
Description: 'Check for odd code arrangement in an else block.'
|
498
|
+
Enabled: false
|
499
|
+
|
500
|
+
Lint/FormatParameterMismatch:
|
501
|
+
Description: 'The number of parameters to format/sprint must match the fields.'
|
502
|
+
Enabled: false
|
503
|
+
|
504
|
+
Lint/HandleExceptions:
|
505
|
+
Description: "Don't suppress exception."
|
506
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
|
507
|
+
Enabled: false
|
508
|
+
|
509
|
+
Layout/InitialIndentation:
|
510
|
+
Description: >-
|
511
|
+
Checks the indentation of the first non-blank non-comment line in a file.
|
512
|
+
Enabled: false
|
513
|
+
|
514
|
+
Lint/LiteralInInterpolation:
|
515
|
+
Description: 'Checks for literals used in interpolation.'
|
516
|
+
Enabled: false
|
517
|
+
|
518
|
+
Lint/Loop:
|
519
|
+
Description: >-
|
520
|
+
Use Kernel#loop with break rather than begin/end/until or
|
521
|
+
begin/end/while for post-loop tests.
|
522
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
|
523
|
+
Enabled: false
|
524
|
+
|
525
|
+
Lint/NestedMethodDefinition:
|
526
|
+
Description: 'Do not use nested method definitions.'
|
527
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
|
528
|
+
Enabled: false
|
529
|
+
|
530
|
+
Lint/NonLocalExitFromIterator:
|
531
|
+
Description: 'Do not use return in iterator to cause non-local exit.'
|
532
|
+
Enabled: false
|
533
|
+
|
534
|
+
Lint/ParenthesesAsGroupedExpression:
|
535
|
+
Description: >-
|
536
|
+
Checks for method calls with a space before the opening
|
537
|
+
parenthesis.
|
538
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
|
539
|
+
Enabled: false
|
540
|
+
|
541
|
+
Lint/RequireParentheses:
|
542
|
+
Description: >-
|
543
|
+
Use parentheses in the method call to avoid confusion
|
544
|
+
about precedence.
|
545
|
+
Enabled: false
|
546
|
+
|
547
|
+
Lint/UnderscorePrefixedVariableName:
|
548
|
+
Description: 'Do not use prefix `_` for a variable that is used.'
|
549
|
+
Enabled: false
|
550
|
+
|
551
|
+
Lint/Void:
|
552
|
+
Description: 'Possible use of operator/literal/variable in void context.'
|
553
|
+
Enabled: false
|
554
|
+
|
555
|
+
# Performance
|
556
|
+
|
557
|
+
Performance/CaseWhenSplat:
|
558
|
+
Description: >-
|
559
|
+
Place `when` conditions that use splat at the end
|
560
|
+
of the list of `when` branches.
|
561
|
+
Enabled: false
|
562
|
+
|
563
|
+
Performance/Count:
|
564
|
+
Description: >-
|
565
|
+
Use `count` instead of `select...size`, `reject...size`,
|
566
|
+
`select...count`, `reject...count`, `select...length`,
|
567
|
+
and `reject...length`.
|
568
|
+
Enabled: false
|
569
|
+
|
570
|
+
Performance/Detect:
|
571
|
+
Description: >-
|
572
|
+
Use `detect` instead of `select.first`, `find_all.first`,
|
573
|
+
`select.last`, and `find_all.last`.
|
574
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
|
575
|
+
Enabled: false
|
576
|
+
|
577
|
+
Performance/FlatMap:
|
578
|
+
Description: >-
|
579
|
+
Use `Enumerable#flat_map`
|
580
|
+
instead of `Enumerable#map...Array#flatten(1)`
|
581
|
+
or `Enumberable#collect..Array#flatten(1)`
|
582
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
|
583
|
+
Enabled: false
|
584
|
+
|
585
|
+
Performance/ReverseEach:
|
586
|
+
Description: 'Use `reverse_each` instead of `reverse.each`.'
|
587
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
|
588
|
+
Enabled: false
|
589
|
+
|
590
|
+
Performance/Sample:
|
591
|
+
Description: >-
|
592
|
+
Use `sample` instead of `shuffle.first`,
|
593
|
+
`shuffle.last`, and `shuffle[Fixnum]`.
|
594
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
|
595
|
+
Enabled: false
|
596
|
+
|
597
|
+
Performance/Size:
|
598
|
+
Description: >-
|
599
|
+
Use `size` instead of `count` for counting
|
600
|
+
the number of elements in `Array` and `Hash`.
|
601
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
|
602
|
+
Enabled: false
|
603
|
+
|
604
|
+
Performance/StringReplacement:
|
605
|
+
Description: >-
|
606
|
+
Use `tr` instead of `gsub` when you are replacing the same
|
607
|
+
number of characters. Use `delete` instead of `gsub` when
|
608
|
+
you are deleting characters.
|
609
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
|
610
|
+
Enabled: false
|
611
|
+
|
612
|
+
# Rails
|
613
|
+
|
614
|
+
Rails/ActionFilter:
|
615
|
+
Description: 'Enforces consistent use of action filter methods.'
|
616
|
+
Enabled: false
|
617
|
+
|
618
|
+
Rails/Date:
|
619
|
+
Description: >-
|
620
|
+
Checks the correct usage of date aware methods,
|
621
|
+
such as Date.today, Date.current etc.
|
622
|
+
Enabled: false
|
623
|
+
|
624
|
+
Rails/FindBy:
|
625
|
+
Description: 'Prefer find_by over where.first.'
|
626
|
+
Enabled: false
|
627
|
+
|
628
|
+
Rails/FindEach:
|
629
|
+
Description: 'Prefer all.find_each over all.find.'
|
630
|
+
Enabled: false
|
631
|
+
|
632
|
+
Rails/HasAndBelongsToMany:
|
633
|
+
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
634
|
+
Enabled: false
|
635
|
+
|
636
|
+
Rails/Output:
|
637
|
+
Description: 'Checks for calls to puts, print, etc.'
|
638
|
+
Enabled: false
|
639
|
+
|
640
|
+
Rails/ReadWriteAttribute:
|
641
|
+
Description: >-
|
642
|
+
Checks for read_attribute(:attr) and
|
643
|
+
write_attribute(:attr, val).
|
644
|
+
Enabled: false
|
645
|
+
|
646
|
+
Rails/ScopeArgs:
|
647
|
+
Description: 'Checks the arguments of ActiveRecord scopes.'
|
648
|
+
Enabled: false
|
649
|
+
|
650
|
+
Rails/TimeZone:
|
651
|
+
Description: 'Checks the correct usage of time zone aware methods.'
|
652
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
|
653
|
+
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
654
|
+
Enabled: false
|
655
|
+
|
656
|
+
Rails/Validation:
|
657
|
+
Description: 'Use validates :attribute, hash of validations.'
|
658
|
+
Enabled: false
|
659
|
+
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
canvas_qti_to_learnosity_converter (0.1.4)
|
5
|
+
nokogiri
|
6
|
+
rubyzip
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
byebug (10.0.2)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
mini_portile2 (2.3.0)
|
14
|
+
nokogiri (1.8.2)
|
15
|
+
mini_portile2 (~> 2.3.0)
|
16
|
+
rake (10.5.0)
|
17
|
+
rspec (3.7.0)
|
18
|
+
rspec-core (~> 3.7.0)
|
19
|
+
rspec-expectations (~> 3.7.0)
|
20
|
+
rspec-mocks (~> 3.7.0)
|
21
|
+
rspec-core (3.7.1)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-expectations (3.7.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-mocks (3.7.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.7.0)
|
29
|
+
rspec-support (3.7.1)
|
30
|
+
rubyzip (1.2.1)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bundler (~> 1.16)
|
37
|
+
byebug
|
38
|
+
canvas_qti_to_learnosity_converter!
|
39
|
+
rake (~> 10.0)
|
40
|
+
rspec (~> 3.0)
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Nick Benoit
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# CanvasQtiToLearnosityConverter
|
2
|
+
|
3
|
+
This gem is designed to facilitate the conversion of canvas quizzes exported as
|
4
|
+
qti 1.2, to the learnosity json format. It currently has support for converting
|
5
|
+
a single qti file, or converting an entire imscc export of qti quizzes. Be
|
6
|
+
aware that the CanvasQtiToLearnosityConverter makes assumptions about the
|
7
|
+
format of the qti that canvas exports as of 4/23/18, and will be sensitive
|
8
|
+
to spec compliant changes to the way that canvas exports qti.
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'canvas_qti_to_learnosity_converter'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install canvas_qti_to_learnosity_converter
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
#### Convert entire imscc export
|
31
|
+
|
32
|
+
```
|
33
|
+
# Convert All QTI Files in entire imscc
|
34
|
+
CanvasQtiToLearnosityConverter.convert_imscc_export(path)
|
35
|
+
# returns [
|
36
|
+
# {
|
37
|
+
# title: "Canvas Quiz Title",
|
38
|
+
# ident: "canvas_qti_export_id",
|
39
|
+
# items: [...converted_learnosity_questions... ]
|
40
|
+
# More information on learnosity question format: https://docs.learnosity.com/analytics/data/endpoints/itembank_endpoints#setQuestions
|
41
|
+
# }, ...
|
42
|
+
#]
|
43
|
+
```
|
44
|
+
|
45
|
+
#### Convert single qti string
|
46
|
+
|
47
|
+
```
|
48
|
+
# Convert single qti_string
|
49
|
+
CanvasQtiToLearnosityConverter.convert(qti_string)
|
50
|
+
# returns
|
51
|
+
# {
|
52
|
+
# title: "Canvas Quiz Title",
|
53
|
+
# ident: "canvas_qti_export_id",
|
54
|
+
# items: [...converted_learnosity_questions... ]
|
55
|
+
# More information on learnosity question format: https://docs.learnosity.com/analytics/data/endpoints/itembank_endpoints#setQuestions
|
56
|
+
# },
|
57
|
+
```
|
58
|
+
|
59
|
+
## Development
|
60
|
+
|
61
|
+
#### Specs
|
62
|
+
|
63
|
+
To run the tests
|
64
|
+
```rake spec```
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "canvas_qti_to_learnosity_converter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "canvas_qti_to_learnosity_converter/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "canvas_qti_to_learnosity_converter"
|
8
|
+
spec.version = CanvasQtiToLearnosityConverter::VERSION
|
9
|
+
spec.authors = ["Nick Benoit"]
|
10
|
+
spec.email = ["nick.benoit14@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Converts canvas qti to learnosity JSON}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
# else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
+
spec.add_development_dependency "byebug"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_dependency "nokogiri"
|
37
|
+
spec.add_dependency "rubyzip"
|
38
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require "forwardable"
|
3
|
+
require "ostruct"
|
4
|
+
require "zip"
|
5
|
+
|
6
|
+
module CanvasQtiToLearnosityConverter
|
7
|
+
class CanvasQuestionTypeNotSupportedError < RuntimeError
|
8
|
+
end
|
9
|
+
|
10
|
+
class CanvasQtiQuiz
|
11
|
+
extend Forwardable
|
12
|
+
def_delegators :@xml, :css
|
13
|
+
|
14
|
+
def initialize(qti_string:)
|
15
|
+
@xml = Nokogiri.XML(qti_string, &:noblanks)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class CanvasQtiQuizQuestion
|
20
|
+
extend Forwardable
|
21
|
+
def_delegators :@xml, :css
|
22
|
+
|
23
|
+
def initialize(qti_string:)
|
24
|
+
@xml = Nokogiri.XML(qti_string, &:noblanks)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class LearnosityQuestion < OpenStruct
|
29
|
+
end
|
30
|
+
|
31
|
+
class MultipleChoiceLearnosityQuestion < LearnosityQuestion
|
32
|
+
end
|
33
|
+
|
34
|
+
class MultipleAnswersLearnosityQuestion < LearnosityQuestion
|
35
|
+
end
|
36
|
+
|
37
|
+
class Learnosityitem
|
38
|
+
end
|
39
|
+
|
40
|
+
class LearnosityActivity
|
41
|
+
end
|
42
|
+
|
43
|
+
LEARNOSITY_TYPE_MAP = {
|
44
|
+
"mcq" => MultipleChoiceLearnosityQuestion
|
45
|
+
}
|
46
|
+
|
47
|
+
def self.read_file(path)
|
48
|
+
file = File.new path
|
49
|
+
file.read
|
50
|
+
ensure
|
51
|
+
file.close
|
52
|
+
# Do we need to unlink?
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.build_quiz_from_qti_string(qti_string)
|
56
|
+
CanvasQtiQuiz.new(qti_string: qti_string)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.build_quiz_from_file(path)
|
60
|
+
qti_file = File.new path
|
61
|
+
qti_string = qti_file.read
|
62
|
+
CanvasQtiQuiz.new(qti_string: qti_string)
|
63
|
+
ensure
|
64
|
+
qti_file.close
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.build_item_from_file(path, item_type = nil)
|
68
|
+
file = File.new path
|
69
|
+
file_val = JSON.parse(file.read)
|
70
|
+
type = item_type || LEARNOSITY_TYPE_MAP[file_val["type"]]
|
71
|
+
type.new(file_val)
|
72
|
+
ensure
|
73
|
+
file.close
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.extract_type(item)
|
77
|
+
item.css(%{ item > itemmetadata > qtimetadata >
|
78
|
+
qtimetadatafield > fieldlabel:contains("question_type")})
|
79
|
+
&.first&.next&.text&.to_sym
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.extract_mattext(mattext_node)
|
83
|
+
mattext_node.content
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.extract_stimulus(item)
|
87
|
+
mattext = item.css("item > presentation > material > mattext").first
|
88
|
+
extract_mattext(mattext)
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.extract_multiple_choice_options(item)
|
92
|
+
choices = item.css("item > presentation > response_lid > render_choice > response_label")
|
93
|
+
choices.map do |choice|
|
94
|
+
ident = choice.attribute("ident").value
|
95
|
+
{
|
96
|
+
"value" => ident,
|
97
|
+
"label" => extract_mattext(choice.css("material > mattext").first),
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.extract_response_id(item)
|
103
|
+
item.css("item > presentation > response_lid").attribute("ident").value
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.extract_multiple_choice_validation(item)
|
107
|
+
resp_conditions = item.css("item > resprocessing > respcondition")
|
108
|
+
correct_condition = resp_conditions.select do |condition|
|
109
|
+
setvar = condition.css("setvar")
|
110
|
+
setvar.length === 1 && setvar.text === "100"
|
111
|
+
end.first
|
112
|
+
|
113
|
+
|
114
|
+
# TODO check for more than 1 element
|
115
|
+
correct_value = correct_condition.css("varequal").text
|
116
|
+
{
|
117
|
+
"scoring_type" => "exactMatch",
|
118
|
+
"valid_response" => {
|
119
|
+
"value" => [correct_value],
|
120
|
+
},
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.extract_multiple_answers_validation(item)
|
125
|
+
correct_condition = item.css('item > resprocessing > respcondition[continue="No"] > conditionvar > and > varequal')
|
126
|
+
alt_responses = correct_condition.map(&:text)
|
127
|
+
{
|
128
|
+
"scoring_type" => "partialMatch",
|
129
|
+
"alt_responses" => alt_responses,
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.convert_multiple_choice(item)
|
134
|
+
MultipleChoiceLearnosityQuestion.new({
|
135
|
+
stimulus: extract_stimulus(item),
|
136
|
+
options: extract_multiple_choice_options(item),
|
137
|
+
multiple_responses: false,
|
138
|
+
response_id: extract_response_id(item),
|
139
|
+
type: "mcq",
|
140
|
+
validation: extract_multiple_choice_validation(item),
|
141
|
+
})
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.convert_multiple_answers(item)
|
145
|
+
MultipleAnswersLearnosityQuestion.new({
|
146
|
+
stimulus: extract_stimulus(item),
|
147
|
+
options: extract_multiple_choice_options(item),
|
148
|
+
multiple_responses: true,
|
149
|
+
response_id: extract_response_id(item),
|
150
|
+
type: "mcq",
|
151
|
+
validation: extract_multiple_answers_validation(item),
|
152
|
+
})
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.convert_item(qti_quiz)
|
156
|
+
type = extract_type(qti_quiz)
|
157
|
+
case type
|
158
|
+
when :multiple_choice_question
|
159
|
+
convert_multiple_choice(qti_quiz)
|
160
|
+
when :true_false_question
|
161
|
+
convert_multiple_choice(qti_quiz)
|
162
|
+
when :multiple_answers_question
|
163
|
+
convert_multiple_answers(qti_quiz)
|
164
|
+
else
|
165
|
+
raise CanvasQuestionTypeNotSupportedError
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.convert(qti)
|
170
|
+
quiz = CanvasQtiQuiz.new(qti_string: qti)
|
171
|
+
items = quiz.css("item").map do |item|
|
172
|
+
begin
|
173
|
+
quiz_item = CanvasQtiQuizQuestion.new(qti_string: item.to_html)
|
174
|
+
convert_item(quiz_item)
|
175
|
+
rescue CanvasQuestionTypeNotSupportedError
|
176
|
+
nil
|
177
|
+
end
|
178
|
+
end.compact
|
179
|
+
|
180
|
+
assessment = quiz.css("assessment")
|
181
|
+
{
|
182
|
+
title: assessment.attribute("title").value,
|
183
|
+
ident: assessment.attribute("ident").value,
|
184
|
+
items: items,
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.convert_qti_file(path)
|
189
|
+
file = File.new(path)
|
190
|
+
qti_string = file.read
|
191
|
+
convert(qti_string)
|
192
|
+
ensure
|
193
|
+
file.close
|
194
|
+
file.unlink
|
195
|
+
end
|
196
|
+
|
197
|
+
def self.imscc_quiz_paths(parsed_manifest)
|
198
|
+
parsed_manifest.css("resources > resource[type='imsqti_xmlv1p2'] > file").
|
199
|
+
map { |entry| entry.attribute("href").value }
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.to_native_types(activity)
|
203
|
+
clone = activity.clone
|
204
|
+
clone[:items] = activity[:items].map(&:to_h)
|
205
|
+
clone
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.convert_imscc_export(path)
|
209
|
+
Zip::File.open(path) do |zip_file|
|
210
|
+
entry = zip_file.find_entry("imsmanifest.xml")
|
211
|
+
manifest = entry.get_input_stream.read
|
212
|
+
parsed_manifest = Nokogiri.XML(manifest, &:noblanks)
|
213
|
+
paths = imscc_quiz_paths(parsed_manifest)
|
214
|
+
result = paths.map do |qti_path|
|
215
|
+
qti = zip_file.find_entry(qti_path).get_input_stream.read
|
216
|
+
to_native_types(convert(qti))
|
217
|
+
end
|
218
|
+
result
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: canvas_qti_to_learnosity_converter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Benoit
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubyzip
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- nick.benoit14@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".rubocop.yml"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- canvas_qti_to_learnosity_converter.gemspec
|
116
|
+
- lib/canvas_qti_to_learnosity_converter.rb
|
117
|
+
- lib/canvas_qti_to_learnosity_converter/convert.rb
|
118
|
+
- lib/canvas_qti_to_learnosity_converter/version.rb
|
119
|
+
homepage: ''
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.6.11
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Converts canvas qti to learnosity JSON
|
143
|
+
test_files: []
|