canvas_cc 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/canvas_cc/canvas_cc/cartridge_creator.rb +1 -0
- data/lib/canvas_cc/canvas_cc/models/course.rb +2 -1
- data/lib/canvas_cc/canvas_cc/models/outcome.rb +11 -0
- data/lib/canvas_cc/canvas_cc/models/rating.rb +5 -0
- data/lib/canvas_cc/canvas_cc/outcome_writer.rb +40 -0
- data/lib/canvas_cc/canvas_cc/rating_writer.rb +27 -0
- data/lib/canvas_cc/version.rb +1 -1
- data/lib/canvas_cc.rb +4 -0
- data/spec/moodle2cc/canvas_cc/models/outcome_spec.rb +12 -0
- data/spec/moodle2cc/canvas_cc/models/page_spec.rb +1 -3
- data/spec/moodle2cc/canvas_cc/models/rating_spec.rb +9 -0
- data/spec/moodle2cc/canvas_cc/outcome_writer_spec.rb +46 -0
- data/spec/moodle2cc/canvas_cc/rating_writer_spec.rb +29 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e278cfc9b75f8c345086fa2d354d14feb5a44501
|
4
|
+
data.tar.gz: 9ad3871e6e8a73c4f44e0652dba1641730c8c8d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4193e0b211dbafdab20a6ec6314249a4d5c325f80b745a7171aac48ced6345f45638f633ed9e7029bac86ba8651e2135b84a588776d66a446058a733a99458bf
|
7
|
+
data.tar.gz: f6a0226e896598af99e45ffd61ee7f3abcc3926915a498763d5271c2d17bfe0b0099f3a7e81327d4ea0580047ec4280d2a4689956671f09b8aa797f1c04697c8
|
@@ -51,6 +51,7 @@ module CanvasCc::CanvasCC
|
|
51
51
|
CanvasCc::CanvasCC::AssignmentWriter.new(dir, *@course.assignments).write
|
52
52
|
CanvasCc::CanvasCC::QuestionBankWriter.new(dir, *@course.question_banks).write
|
53
53
|
CanvasCc::CanvasCC::AssessmentWriter.new(dir, *@course.assessments).write
|
54
|
+
CanvasCc::CanvasCC::OutcomeWriter.new(dir, *@course.outcomes).write
|
54
55
|
end
|
55
56
|
|
56
57
|
def zip_dir(out_file, dir)
|
@@ -2,7 +2,7 @@ module CanvasCc::CanvasCC::Models
|
|
2
2
|
class Course
|
3
3
|
|
4
4
|
attr_accessor :format, :identifier, :copyright, :settings, :resources, :canvas_modules, :files, :pages, :discussions,
|
5
|
-
:assignments, :assessments, :question_banks, :assignment_groups, :folders, :syllabus
|
5
|
+
:assignments, :assessments, :question_banks, :assignment_groups, :folders, :syllabus, :outcomes
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@settings = {}
|
@@ -16,6 +16,7 @@ module CanvasCc::CanvasCC::Models
|
|
16
16
|
@assessments = []
|
17
17
|
@question_banks = []
|
18
18
|
@assignment_groups = []
|
19
|
+
@outcomes = []
|
19
20
|
end
|
20
21
|
|
21
22
|
def start_at
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module CanvasCc::CanvasCC
|
2
|
+
class OutcomeWriter
|
3
|
+
LEARNING_OUTCOMES_FILE = 'learning_outcomes.xml'
|
4
|
+
|
5
|
+
def initialize(work_dir, *outcomes)
|
6
|
+
@work_dir = work_dir
|
7
|
+
@outcomes = outcomes
|
8
|
+
end
|
9
|
+
|
10
|
+
def write
|
11
|
+
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
12
|
+
write_outcomes(xml) do |xml|
|
13
|
+
@outcomes.each do |outcome|
|
14
|
+
xml.learningOutcome(identifier: outcome.identifier) do
|
15
|
+
xml.title outcome.title
|
16
|
+
xml.description outcome.description
|
17
|
+
xml.points_possible outcome.points_possible
|
18
|
+
xml.mastery_points outcome.mastery_points
|
19
|
+
xml << CanvasCc::CanvasCC::RatingWriter.new(*outcome.ratings).write
|
20
|
+
xml.is_global_outcome outcome.is_global_outcome
|
21
|
+
xml.external_identifier outcome.external_identifier if outcome.external_identifier
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end.to_xml
|
26
|
+
File.open(File.join(@work_dir, CanvasCc::CanvasCC::CartridgeCreator::COURSE_SETTINGS_DIR, LEARNING_OUTCOMES_FILE), 'w') { |f| f.write(xml) }
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def write_outcomes(xml)
|
31
|
+
xml.learningOutcomes(
|
32
|
+
'xmlns' => 'http://canvas.instructure.com/xsd/cccv1p0',
|
33
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
34
|
+
'xsi:schemaLocation' => 'http://canvas.instructure.com/xsd/cccv1p0 http://canvas.instructure.com/xsd/cccv1p0.xsd'
|
35
|
+
) {
|
36
|
+
yield xml
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CanvasCc::CanvasCC
|
2
|
+
class RatingWriter
|
3
|
+
|
4
|
+
def initialize(*ratings)
|
5
|
+
@ratings = ratings
|
6
|
+
end
|
7
|
+
|
8
|
+
# It is assumed that ratings will be written only within the context of another object,
|
9
|
+
# such as learning outcomes or rubrics
|
10
|
+
def write
|
11
|
+
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
12
|
+
xml.ratings do |xml|
|
13
|
+
@ratings.each do |rating|
|
14
|
+
xml.rating do
|
15
|
+
xml.id rating.id
|
16
|
+
xml.description rating.description
|
17
|
+
xml.points rating.points
|
18
|
+
xml.criterion_id rating.criterion_id
|
19
|
+
xml.long_description rating.long_description
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end.to_xml
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/canvas_cc/version.rb
CHANGED
data/lib/canvas_cc.rb
CHANGED
@@ -54,6 +54,8 @@ module CanvasCc
|
|
54
54
|
autoload :AssignmentWriter, 'canvas_cc/canvas_cc/assignment_writer'
|
55
55
|
autoload :AssignmentGroupWriter, 'canvas_cc/canvas_cc/assignment_group_writer'
|
56
56
|
autoload :CourseSyllabusWriter, 'canvas_cc/canvas_cc/course_syllabus_writer'
|
57
|
+
autoload :OutcomeWriter, 'canvas_cc/canvas_cc/outcome_writer'
|
58
|
+
autoload :RatingWriter, 'canvas_cc/canvas_cc/rating_writer'
|
57
59
|
|
58
60
|
autoload :QuestionWriter, 'canvas_cc/canvas_cc/question_writer'
|
59
61
|
autoload :CalculatedQuestionWriter, 'canvas_cc/canvas_cc/calculated_question_writer'
|
@@ -97,6 +99,8 @@ module CanvasCc
|
|
97
99
|
autoload :Range, 'canvas_cc/canvas_cc/models/range'
|
98
100
|
autoload :ModulePrerequisite, 'canvas_cc/canvas_cc/models/module_prerequisite'
|
99
101
|
autoload :ModuleCompletionRequirement, 'canvas_cc/canvas_cc/models/module_completion_requirement'
|
102
|
+
autoload :Outcome, 'canvas_cc/canvas_cc/models/outcome'
|
103
|
+
autoload :Rating, 'canvas_cc/canvas_cc/models/rating'
|
100
104
|
end
|
101
105
|
end
|
102
106
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CanvasCc::CanvasCC::Models::Outcome do
|
4
|
+
it_behaves_like 'it has an attribute for', :identifier
|
5
|
+
it_behaves_like 'it has an attribute for', :title
|
6
|
+
it_behaves_like 'it has an attribute for', :description
|
7
|
+
it_behaves_like 'it has an attribute for', :points_possible
|
8
|
+
it_behaves_like 'it has an attribute for', :mastery_points
|
9
|
+
it('has an attribute for ratings') { expect(subject.ratings).to eql [] }
|
10
|
+
it_behaves_like 'it has an attribute for', :is_global_outcome
|
11
|
+
it_behaves_like 'it has an attribute for', :external_identifier
|
12
|
+
end
|
@@ -11,8 +11,6 @@ module CanvasCc::CanvasCC::Models
|
|
11
11
|
it_behaves_like 'it has an attribute for', :body
|
12
12
|
it_behaves_like 'it has an attribute for', :title
|
13
13
|
|
14
|
-
its(:type) { should eq 'webcontent' }
|
15
|
-
|
16
14
|
it "hashes the identifier" do
|
17
15
|
page.identifier = 3
|
18
16
|
expect(page.identifier).to eq 3
|
@@ -31,4 +29,4 @@ module CanvasCc::CanvasCC::Models
|
|
31
29
|
end
|
32
30
|
|
33
31
|
end
|
34
|
-
end
|
32
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CanvasCc::CanvasCC::Models::Rating do
|
4
|
+
it_behaves_like 'it has an attribute for', :id
|
5
|
+
it_behaves_like 'it has an attribute for', :description
|
6
|
+
it_behaves_like 'it has an attribute for', :points
|
7
|
+
it_behaves_like 'it has an attribute for', :criterion_id
|
8
|
+
it_behaves_like 'it has an attribute for', :long_description
|
9
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CanvasCc::CanvasCC::OutcomeWriter do
|
4
|
+
let(:outcome) do
|
5
|
+
outcome = CanvasCc::CanvasCC::Models::Outcome.new
|
6
|
+
outcome.identifier = SecureRandom.hex
|
7
|
+
outcome.points_possible = 5
|
8
|
+
outcome.mastery_points = 5
|
9
|
+
outcome.is_global_outcome = false
|
10
|
+
outcome
|
11
|
+
end
|
12
|
+
let(:tmpdir) { Dir.mktmpdir }
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
Dir.mkdir(File.join(tmpdir, CanvasCc::CanvasCC::CartridgeCreator::COURSE_SETTINGS_DIR))
|
16
|
+
end
|
17
|
+
|
18
|
+
after :each do
|
19
|
+
FileUtils.rm_r tmpdir
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'xml contains the correct schema' do
|
23
|
+
xml = write_xml(outcome)
|
24
|
+
|
25
|
+
valid_schema = File.read(fixture_path(File.join('common_cartridge', 'schema', 'cccv1p0.xsd')))
|
26
|
+
xsd = Nokogiri::XML::Schema(valid_schema)
|
27
|
+
expect(xsd.validate(xml)).to be_truthy
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'writes an outcome' do
|
31
|
+
xml = write_xml(outcome)
|
32
|
+
node = xml.at_xpath('//xmlns:learningOutcomes/xmlns:learningOutcome')
|
33
|
+
expect(node.attr(:identifier)).to eql outcome.identifier
|
34
|
+
expect(node.at_xpath('xmlns:points_possible').text).to eql '5'
|
35
|
+
expect(node.at_xpath('xmlns:mastery_points').text).to eql '5'
|
36
|
+
expect(node.at_xpath('xmlns:is_global_outcome').text).to eql 'false'
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def write_xml(outcome)
|
41
|
+
CanvasCc::CanvasCC::OutcomeWriter.new(tmpdir, outcome).write
|
42
|
+
path = File.join(tmpdir, CanvasCc::CanvasCC::CartridgeCreator::COURSE_SETTINGS_DIR,
|
43
|
+
CanvasCc::CanvasCC::OutcomeWriter::LEARNING_OUTCOMES_FILE)
|
44
|
+
Nokogiri::XML(File.read(path))
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CanvasCc::CanvasCC::RatingWriter do
|
4
|
+
let(:rating) do
|
5
|
+
tmp_rating = CanvasCc::CanvasCC::Models::Rating.new
|
6
|
+
tmp_rating.id = '123'
|
7
|
+
tmp_rating.description = 'a rating'
|
8
|
+
tmp_rating.points = 5
|
9
|
+
tmp_rating.criterion_id = '123'
|
10
|
+
tmp_rating.long_description = 'a longer description'
|
11
|
+
tmp_rating
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'writes ratings' do
|
15
|
+
xml = write_xml rating
|
16
|
+
node = xml.at_xpath('//ratings/rating')
|
17
|
+
expect(node.at_xpath('id').text).to eql rating.id
|
18
|
+
expect(node.at_xpath('description').text).to eql rating.description
|
19
|
+
expect(node.at_xpath('points').text).to eql rating.points.to_s
|
20
|
+
expect(node.at_xpath('criterion_id').text).to eql rating.criterion_id
|
21
|
+
expect(node.at_xpath('long_description').text).to eql rating.long_description
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def write_xml(rating)
|
26
|
+
writer = CanvasCc::CanvasCC::RatingWriter.new rating
|
27
|
+
Nokogiri::XML(writer.write)
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_cc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -282,11 +282,13 @@ files:
|
|
282
282
|
- lib/canvas_cc/canvas_cc/models/module_prerequisite.rb
|
283
283
|
- lib/canvas_cc/canvas_cc/models/multiple_dropdowns_question.rb
|
284
284
|
- lib/canvas_cc/canvas_cc/models/numerical_question.rb
|
285
|
+
- lib/canvas_cc/canvas_cc/models/outcome.rb
|
285
286
|
- lib/canvas_cc/canvas_cc/models/page.rb
|
286
287
|
- lib/canvas_cc/canvas_cc/models/question.rb
|
287
288
|
- lib/canvas_cc/canvas_cc/models/question_bank.rb
|
288
289
|
- lib/canvas_cc/canvas_cc/models/question_group.rb
|
289
290
|
- lib/canvas_cc/canvas_cc/models/range.rb
|
291
|
+
- lib/canvas_cc/canvas_cc/models/rating.rb
|
290
292
|
- lib/canvas_cc/canvas_cc/models/resource.rb
|
291
293
|
- lib/canvas_cc/canvas_cc/models/syllabus.rb
|
292
294
|
- lib/canvas_cc/canvas_cc/models/web_content.rb
|
@@ -298,10 +300,12 @@ files:
|
|
298
300
|
- lib/canvas_cc/canvas_cc/multiple_choice_question_writer.rb
|
299
301
|
- lib/canvas_cc/canvas_cc/multiple_dropdowns_question_writer.rb
|
300
302
|
- lib/canvas_cc/canvas_cc/numerical_question_writer.rb
|
303
|
+
- lib/canvas_cc/canvas_cc/outcome_writer.rb
|
301
304
|
- lib/canvas_cc/canvas_cc/page_writer.rb
|
302
305
|
- lib/canvas_cc/canvas_cc/question_bank_writer.rb
|
303
306
|
- lib/canvas_cc/canvas_cc/question_group_writer.rb
|
304
307
|
- lib/canvas_cc/canvas_cc/question_writer.rb
|
308
|
+
- lib/canvas_cc/canvas_cc/rating_writer.rb
|
305
309
|
- lib/canvas_cc/canvas_cc/short_answer_question_writer.rb
|
306
310
|
- lib/canvas_cc/canvas_cc/text_only_question_writer.rb
|
307
311
|
- lib/canvas_cc/canvas_cc/true_false_question_writer.rb
|
@@ -345,8 +349,10 @@ files:
|
|
345
349
|
- spec/moodle2cc/canvas_cc/models/discussion_spec.rb
|
346
350
|
- spec/moodle2cc/canvas_cc/models/discussion_topic_spec.rb
|
347
351
|
- spec/moodle2cc/canvas_cc/models/module_item_spec.rb
|
352
|
+
- spec/moodle2cc/canvas_cc/models/outcome_spec.rb
|
348
353
|
- spec/moodle2cc/canvas_cc/models/page_spec.rb
|
349
354
|
- spec/moodle2cc/canvas_cc/models/question_spec.rb
|
355
|
+
- spec/moodle2cc/canvas_cc/models/rating_spec.rb
|
350
356
|
- spec/moodle2cc/canvas_cc/models/resource_spec.rb
|
351
357
|
- spec/moodle2cc/canvas_cc/models/web_content_spec.rb
|
352
358
|
- spec/moodle2cc/canvas_cc/models/web_link_spec.rb
|
@@ -356,9 +362,11 @@ files:
|
|
356
362
|
- spec/moodle2cc/canvas_cc/multiple_choice_question_writer_spec.rb
|
357
363
|
- spec/moodle2cc/canvas_cc/multiple_dropdowns_question_writer_spec.rb
|
358
364
|
- spec/moodle2cc/canvas_cc/numerical_question_writer_spec.rb
|
365
|
+
- spec/moodle2cc/canvas_cc/outcome_writer_spec.rb
|
359
366
|
- spec/moodle2cc/canvas_cc/page_writer_spec.rb
|
360
367
|
- spec/moodle2cc/canvas_cc/question_bank_writer_spec.rb
|
361
368
|
- spec/moodle2cc/canvas_cc/question_writer_spec.rb
|
369
|
+
- spec/moodle2cc/canvas_cc/rating_writer_spec.rb
|
362
370
|
- spec/moodle2cc/canvas_cc/short_answer_question_writer_spec.rb
|
363
371
|
- spec/moodle2cc/canvas_cc/text_only_question_writer_spec.rb
|
364
372
|
- spec/moodle2cc/canvas_cc/true_false_question_writer_spec.rb
|
@@ -452,8 +460,10 @@ test_files:
|
|
452
460
|
- spec/moodle2cc/canvas_cc/models/discussion_spec.rb
|
453
461
|
- spec/moodle2cc/canvas_cc/models/discussion_topic_spec.rb
|
454
462
|
- spec/moodle2cc/canvas_cc/models/module_item_spec.rb
|
463
|
+
- spec/moodle2cc/canvas_cc/models/outcome_spec.rb
|
455
464
|
- spec/moodle2cc/canvas_cc/models/page_spec.rb
|
456
465
|
- spec/moodle2cc/canvas_cc/models/question_spec.rb
|
466
|
+
- spec/moodle2cc/canvas_cc/models/rating_spec.rb
|
457
467
|
- spec/moodle2cc/canvas_cc/models/resource_spec.rb
|
458
468
|
- spec/moodle2cc/canvas_cc/models/web_content_spec.rb
|
459
469
|
- spec/moodle2cc/canvas_cc/models/web_link_spec.rb
|
@@ -463,9 +473,11 @@ test_files:
|
|
463
473
|
- spec/moodle2cc/canvas_cc/multiple_choice_question_writer_spec.rb
|
464
474
|
- spec/moodle2cc/canvas_cc/multiple_dropdowns_question_writer_spec.rb
|
465
475
|
- spec/moodle2cc/canvas_cc/numerical_question_writer_spec.rb
|
476
|
+
- spec/moodle2cc/canvas_cc/outcome_writer_spec.rb
|
466
477
|
- spec/moodle2cc/canvas_cc/page_writer_spec.rb
|
467
478
|
- spec/moodle2cc/canvas_cc/question_bank_writer_spec.rb
|
468
479
|
- spec/moodle2cc/canvas_cc/question_writer_spec.rb
|
480
|
+
- spec/moodle2cc/canvas_cc/rating_writer_spec.rb
|
469
481
|
- spec/moodle2cc/canvas_cc/short_answer_question_writer_spec.rb
|
470
482
|
- spec/moodle2cc/canvas_cc/text_only_question_writer_spec.rb
|
471
483
|
- spec/moodle2cc/canvas_cc/true_false_question_writer_spec.rb
|