common_cartridge 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/common_cartridge.rb +40 -0
- data/lib/common_cartridge/elements/lom.rb +60 -0
- data/lib/common_cartridge/elements/manifest.rb +24 -0
- data/lib/common_cartridge/elements/metadata.rb +12 -0
- data/lib/common_cartridge/elements/organizations.rb +42 -0
- data/lib/common_cartridge/elements/outcomes.rb +10 -0
- data/lib/common_cartridge/elements/outcomes/outcome.rb +15 -0
- data/lib/common_cartridge/elements/outcomes/outcome_group.rb +12 -0
- data/lib/common_cartridge/elements/outcomes/outcome_root.rb +11 -0
- data/lib/common_cartridge/elements/resources.rb +117 -0
- data/lib/common_cartridge/elements/resources/assessment.rb +21 -0
- data/lib/common_cartridge/elements/resources/assignment.rb +59 -0
- data/lib/common_cartridge/elements/resources/attachments.rb +20 -0
- data/lib/common_cartridge/elements/resources/page.rb +22 -0
- data/lib/common_cartridge/elements/resources/topic.rb +28 -0
- data/lib/common_cartridge/elements/resources/web_link.rb +25 -0
- data/lib/common_cartridge/package.rb +87 -0
- data/lib/common_cartridge/parsers/dependencies.rb +23 -0
- data/lib/common_cartridge/parsers/files.rb +34 -0
- data/lib/common_cartridge/parsers/items.rb +58 -0
- data/lib/common_cartridge/parsers/outcomes.rb +17 -0
- data/lib/common_cartridge/parsers/parser.rb +78 -0
- data/lib/common_cartridge/parsers/questions.rb +34 -0
- data/lib/sax_machine/sax_handler.rb +13 -0
- data/spec/elements/lom_spec.rb +66 -0
- data/spec/elements/manifest_spec.rb +27 -0
- data/spec/elements/metadata_spec.rb +40 -0
- data/spec/elements/organizations_spec.rb +51 -0
- data/spec/elements/outcomes/outcome_group_spec.rb +29 -0
- data/spec/elements/outcomes/outcome_spec.rb +37 -0
- data/spec/elements/resources/assignment_spec.rb +53 -0
- data/spec/elements/resources/attachments_spec.rb +24 -0
- data/spec/elements/resources/resources_spec.rb +73 -0
- data/spec/elements/resources/topic_spec.rb +39 -0
- data/spec/elements/resources/web_link_spec.rb +31 -0
- data/spec/files/canvas_large_1.3.imscc +0 -0
- data/spec/files/canvas_small_1.1.corrupt.imscc +0 -0
- data/spec/files/canvas_small_1.1.imscc +0 -0
- data/spec/package_spec.rb +110 -0
- data/spec/parser_spec.rb +13 -0
- data/spec/spec_helper.rb +13 -0
- metadata +179 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
module Lom
|
6
|
+
describe General do
|
7
|
+
before(:all) do
|
8
|
+
manifest = CommonCartridge.parse_from_zip('canvas_small_1.1.imscc').manifest
|
9
|
+
@lom = manifest.metadata.lom
|
10
|
+
end
|
11
|
+
|
12
|
+
subject(:general) { @lom.general }
|
13
|
+
|
14
|
+
it "parses correctly" do
|
15
|
+
expect(general).to be_kind_of(CommonCartridge::Elements::Lom::General)
|
16
|
+
end
|
17
|
+
|
18
|
+
context "title element" do
|
19
|
+
it "parses correctly" do
|
20
|
+
expect(general.title).to be_kind_of(CommonCartridge::Elements::Lom::Title)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has a value attribute" do
|
24
|
+
expect(general.title.value).to eq("Common Cartridge Test Data Set - Validation Cartridge 1")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a language attribute" do
|
28
|
+
expect(general.title.language).to eq("en-US")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "description element" do
|
33
|
+
it "parses correctly" do
|
34
|
+
expect(general.description).to be_kind_of(CommonCartridge::Elements::Lom::Description)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "has a value attribute" do
|
38
|
+
expect(general.description.value).to eq("Sample materials to test a variety of Common Cartridge content types")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has a language attribute" do
|
42
|
+
expect(general.description.language).to eq("en-US")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "keywords elements" do
|
47
|
+
it "is a collection" do
|
48
|
+
expect(general.keywords).to be_kind_of(Array)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "parses correctly" do
|
52
|
+
expect(general.keywords.first).to be_kind_of(CommonCartridge::Elements::Lom::Keyword)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has a value attribute" do
|
56
|
+
expect(general.keywords.first.value).to eq("Sample")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has a language attribute" do
|
60
|
+
expect(general.keywords.first.language).to eq("en-US")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
describe Manifest do
|
6
|
+
before(:all) do
|
7
|
+
@manifest = CommonCartridge.parse_from_zip("canvas_large_1.3.imscc").manifest
|
8
|
+
end
|
9
|
+
|
10
|
+
it "recognizes the manifest file and parses it correctly" do
|
11
|
+
expect(@manifest).to be_kind_of(CommonCartridge::Elements::Manifest)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has metadata" do
|
15
|
+
expect(@manifest.metadata).to be_kind_of(CommonCartridge::Elements::Metadata)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has organizations" do
|
19
|
+
expect(@manifest.root_organization).to be_kind_of(CommonCartridge::Elements::Organizations::RootOrganization)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has resources" do
|
23
|
+
expect(@manifest.root_resource).to be_kind_of(CommonCartridge::Elements::Resources::RootResource)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
describe Metadata do
|
6
|
+
context "Common Cartridge 1.1" do
|
7
|
+
before(:all) { @metadata = CommonCartridge.parse_from_zip("canvas_small_1.1.imscc").manifest.metadata }
|
8
|
+
|
9
|
+
it "has a schema" do
|
10
|
+
expect(@metadata.schema).to eq("IMS Common Cartridge")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has a schemaversion" do
|
14
|
+
expect(@metadata.schemaversion).to eq("1.1.0")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has a lom" do
|
18
|
+
expect(@metadata.lom).to be_kind_of(CommonCartridge::Elements::Lom::Lom)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "Common Cartridge 1.3" do
|
23
|
+
before(:all) { @metadata = CommonCartridge.parse_from_zip("canvas_large_1.3.imscc").manifest.metadata }
|
24
|
+
|
25
|
+
it "has a schema" do
|
26
|
+
expect(@metadata.schema).to eq("IMS Common Cartridge")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "has a schemaversion" do
|
30
|
+
expect(@metadata.schemaversion).to eq("1.3.0")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has a lom" do
|
34
|
+
expect(@metadata.lom).to be_kind_of(CommonCartridge::Elements::Lom::Lom)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
describe Organizations do
|
6
|
+
before(:all) do
|
7
|
+
@manifest = CommonCartridge.parse_from_zip("canvas_large_1.3.imscc").manifest
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:organizations) { @manifest.organizations }
|
11
|
+
|
12
|
+
it "has a root organization" do
|
13
|
+
expect(@manifest.root_organization).to be_kind_of(CommonCartridge::Elements::Organizations::RootOrganization)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a root item" do
|
17
|
+
expect(organizations.first.root_item).to be_kind_of(CommonCartridge::Elements::Organizations::RootItem)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Organizations::RootItem do
|
21
|
+
let(:root_item) { organizations.first.root_item }
|
22
|
+
|
23
|
+
it "has an identifier" do
|
24
|
+
expect(root_item.identifier).to eq("LearningModules")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a collection of items" do
|
28
|
+
expect(root_item.items).to be_kind_of(Array)
|
29
|
+
|
30
|
+
root_item.items.each do |item|
|
31
|
+
expect(item).to be_kind_of(CommonCartridge::Elements::Organizations::Item)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe Organizations::Item do
|
37
|
+
# todo: use find_by method here when implemented
|
38
|
+
let(:item) { organizations.first.root_item.items.first }
|
39
|
+
|
40
|
+
it "has an identifier" do
|
41
|
+
expect(item.identifier).to eq("i224aa0e52b019dbf9aeece014df883c7")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "has a title" do
|
45
|
+
expect(item.title).to eq("Example Course Module")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
module Outcomes
|
6
|
+
describe OutcomeGroup do
|
7
|
+
before(:all) do
|
8
|
+
@package = CommonCartridge.parse_from_zip('canvas_small_1.1.imscc')
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:outcome_groups) { @package.outcomes.outcome_groups }
|
12
|
+
let(:outcome_group) { outcome_groups.first }
|
13
|
+
|
14
|
+
it "is parsed correctly" do
|
15
|
+
expect(outcome_groups.size).to eq(1)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has an identifier attribute" do
|
19
|
+
expect(outcome_group.identifier).to eq("i5c10922a7fdce7cb710733108d3a26dc")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has a collection of outcomes" do
|
23
|
+
expect(outcome_group.outcomes.size).to eq(9)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
module Outcomes
|
6
|
+
describe Outcome do
|
7
|
+
before(:all) do
|
8
|
+
@package = CommonCartridge.parse_from_zip('canvas_small_1.1.imscc')
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:outcomes) { @package.all_outcomes }
|
12
|
+
let(:outcome) { @package.all_outcomes.first }
|
13
|
+
|
14
|
+
it "is parsed correctly" do
|
15
|
+
expect(outcomes.size).to eq(9)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has an identifier attribute" do
|
19
|
+
expect(outcome.identifier).to eq "i63a00efe444e7edfc75e3051a4f8edac"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has a title element" do
|
23
|
+
expect(outcome.title).to match(/You can speak the 'HigherEd-K12-Education' speak/)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has a points_possible element" do
|
27
|
+
expect(outcome.points_possible).to eq "5"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has a mastery_points element" do
|
31
|
+
expect(outcome.mastery_points).to eq "3"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
module Resources
|
6
|
+
describe Assignment do
|
7
|
+
before(:all) do
|
8
|
+
package = CommonCartridge.parse_from_zip('canvas_large_1.3.imscc')
|
9
|
+
@assignment = package.assignments.first
|
10
|
+
end
|
11
|
+
|
12
|
+
it "parses correctly" do
|
13
|
+
expect(@assignment).to be_kind_of(CommonCartridge::Elements::Resources::Assignment)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a title" do
|
17
|
+
expect(@assignment.title).to eq("Online Submission Assignment")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has a 'gradable' element" do
|
21
|
+
expect(@assignment.gradable).to eq("true")
|
22
|
+
end
|
23
|
+
|
24
|
+
context "text element" do
|
25
|
+
let(:text) { @assignment.text }
|
26
|
+
|
27
|
+
it "parses correctly" do
|
28
|
+
expect(text).to be_kind_of(CommonCartridge::Elements::Resources::Text)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has a value" do
|
32
|
+
expect(text.value).to match(/Lorem ipsum dolor sit amet, consectetur adipiscing elit/)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "submission_formats" do
|
37
|
+
let(:submission_formats) { @assignment.submission_formats }
|
38
|
+
|
39
|
+
it "parses correctly" do
|
40
|
+
expect(submission_formats).to be_kind_of(CommonCartridge::Elements::Resources::SubmissionFormats)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has formats" do
|
44
|
+
expect(submission_formats.formats).to be_kind_of(Array)
|
45
|
+
expect(submission_formats.formats).not_to be_empty
|
46
|
+
expect(submission_formats.formats.first.type).to eq("html")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
module Resources
|
6
|
+
describe Attachments do
|
7
|
+
before(:all) do
|
8
|
+
manifest = CommonCartridge.parse_from_zip('canvas_small_1.1.imscc').manifest
|
9
|
+
resource = manifest.resources.detect { |r| r.identifier =~ /I_00006_R/ }
|
10
|
+
@attachment = resource.files.first.content.attachments.first
|
11
|
+
end
|
12
|
+
|
13
|
+
it "is parsed correctly" do
|
14
|
+
expect(@attachment).to be_kind_of(CommonCartridge::Elements::Resources::Attachments::Attachment)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has a href" do
|
18
|
+
expect(@attachment.href).to match(/angry_person\.jpg/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
module Resources
|
6
|
+
describe Resources do
|
7
|
+
before(:all) do
|
8
|
+
@package = CommonCartridge.parse_from_zip("canvas_small_1.1.imscc")
|
9
|
+
@resources = @package.manifest.resources
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has a root resource" do
|
13
|
+
expect(@package.manifest.root_resource).to be_kind_of(CommonCartridge::Elements::Resources::RootResource)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a collection of resources" do
|
17
|
+
expect(@resources).to be_kind_of(Array)
|
18
|
+
|
19
|
+
@resources.each do |resource|
|
20
|
+
expect(resource).to be_kind_of(CommonCartridge::Elements::Resources::Resource)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
describe Resources::Resource do
|
26
|
+
# todo: implement 'find_by' method to use here
|
27
|
+
let(:resource) { @resources.first }
|
28
|
+
|
29
|
+
it "has an identifier" do
|
30
|
+
expect(resource.identifier).to eq('I_00001_R')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has a type" do
|
34
|
+
expect(resource.type).to eq('webcontent')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "has a href" do
|
38
|
+
expect(resource.href).to eq('I_00001_R/Learning_Objectives.html')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has files" do
|
42
|
+
resource.files.each do |f|
|
43
|
+
expect(f).to be_kind_of(CommonCartridge::Elements::Resources::File)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when a quiz" do
|
48
|
+
let(:quiz) { @package.quizzes.first }
|
49
|
+
it "has question count" do
|
50
|
+
expect(quiz.question_count).to eq(11)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe Resources::File do
|
56
|
+
let(:file) { @resources.first.files.first }
|
57
|
+
|
58
|
+
it "has a href" do
|
59
|
+
expect(file.href).to eq("I_00001_R/Learning_Objectives.html")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe Resources::Dependency do
|
64
|
+
let(:dependency) { @resources[1].dependencies.first }
|
65
|
+
|
66
|
+
it "has an identifierref" do
|
67
|
+
expect(dependency.identifierref).to eq("I_00003_R_IMAGERESOURCE")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CommonCartridge
|
4
|
+
module Elements
|
5
|
+
module Resources
|
6
|
+
describe Topic do
|
7
|
+
before(:all) do
|
8
|
+
manifest = CommonCartridge.parse_from_zip('canvas_small_1.1.imscc').manifest
|
9
|
+
@resource = manifest.resources.detect { |r| r.identifier =~ /I_00006_R/ }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is parsed correctly" do
|
13
|
+
expect(@resource.files.first.content).to be_kind_of(CommonCartridge::Elements::Resources::Topic)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a title" do
|
17
|
+
expect(@resource.files.first.content.title).to eq("The Psychology of Faces")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has text" do
|
21
|
+
expect(@resource.files.first.content.text).to match(/Your face is ugly\./)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has a text_type" do
|
25
|
+
expect(@resource.files.first.content.text_type).to eq("text/html")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "has attachments" do
|
29
|
+
expect(@resource.files.first.content.attachments).not_to be_empty
|
30
|
+
|
31
|
+
@resource.files.first.content.attachments.each do |a|
|
32
|
+
expect(a.href).not_to be_empty
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|