Skip to content

Commit

Permalink
generate base imsmanifest
Browse files Browse the repository at this point in the history
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch moodle2
# Changes to be committed:
#	modified:   Rakefile
#	new file:   lib/moodle2cc/common_cartridge/course.rb
#	modified:   test/acceptance/migrator_test.rb
#	renamed:    lib/test/test_helper.rb -> test/test_helper.rb
#	renamed:    lib/test/test_question_helper.rb -> test/test_question_helper.rb
#	renamed:    lib/test/test_wiki_helper.rb -> test/test_wiki_helper.rb
#	modified:   test/unit/canvas/assessment_test.rb
#	modified:   test/unit/canvas/assignment_test.rb
#	modified:   test/unit/canvas/converter_test.rb
#	modified:   test/unit/canvas/course_test.rb
#	modified:   test/unit/canvas/discussion_topic_test.rb
#	modified:   test/unit/canvas/label_test.rb
#	modified:   test/unit/canvas/question_bank_test.rb
#	modified:   test/unit/canvas/question_group_test.rb
#	modified:   test/unit/canvas/question_test.rb
#	modified:   test/unit/canvas/web_content_test.rb
#	modified:   test/unit/canvas/web_link_test.rb
#	modified:   test/unit/canvas/wiki_test.rb
#	modified:   test/unit/cc/assessment_test.rb
#	modified:   test/unit/cc/assignment_test.rb
#	modified:   test/unit/cc/cc_helper_test.rb
#	modified:   test/unit/cc/converter_test.rb
#	modified:   test/unit/cc/course_test.rb
#	modified:   test/unit/cc/discussion_topic_test.rb
#	modified:   test/unit/cc/label_test.rb
#	modified:   test/unit/cc/question_test.rb
#	modified:   test/unit/cc/web_content_test.rb
#	modified:   test/unit/cc/web_link_test.rb
#	modified:   test/unit/cc/wiki_test.rb
#	modified:   test/unit/migrator_test.rb
#	modified:   test/unit/moodle/backup_test.rb
#	modified:   test/unit/moodle/course_test.rb
#	modified:   test/unit/moodle/grade_item_test.rb
#	modified:   test/unit/moodle/info_test.rb
#	modified:   test/unit/moodle/mod_test.rb
#	modified:   test/unit/moodle/question_category_test.rb
#	modified:   test/unit/moodle/question_test.rb
#	modified:   test/unit/moodle/section_test.rb
#	modified:   test/unit/resource_factory_test.rb
#
# Changes not staged for commit:
#	modified:   Gemfile
#	modified:   Guardfile
#	modified:   lib/moodle2cc.rb
#	modified:   lib/moodle2cc/common_cartridge/course.rb
#	modified:   test/acceptance/migrator_test.rb
#
# Untracked files:
#	test/unit/common_cartridge/
#
  • Loading branch information
rivernate committed Mar 28, 2014
1 parent 43c4dee commit f3e0e01
Show file tree
Hide file tree
Showing 25 changed files with 2,756 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
nguage: ruby
language: ruby
branches:
only:
- moodle2
rvm:
- "1.9.3"
- "2.0.0"
Expand Down
11 changes: 11 additions & 0 deletions lib/moodle2cc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,15 @@ module Moodle
autoload :QuestionCategory, 'moodle2cc/moodle/question_category'
autoload :Section, 'moodle2cc/moodle/section'
end
module CommonCartridge
autoload :ImsManifestGenerator, 'moodle2cc/common_cartridge/ims_manifest_generator'
module Resources
autoload :Course, 'moodle2cc/common_cartridge/resources/course'
autoload :Assignment, 'moodle2cc/common_cartridge/resources/assignment'
autoload :DiscussionTopic, 'moodle2cc/common_cartridge/resources/discussion_topic'
autoload :Question, 'moodle2cc/common_cartridge/resources/question'
autoload :WebContent, 'moodle2cc/common_cartridge/resources/web_content'
autoload :WebLink, 'moodle2cc/common_cartridge/resources/web_link'
end
end
end
2 changes: 0 additions & 2 deletions lib/moodle2cc/common_cartridge/course.rb

This file was deleted.

77 changes: 77 additions & 0 deletions lib/moodle2cc/common_cartridge/ims_manifest_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
class Moodle2CC::CommonCartridge::ImsManifestGenerator

MANIFEST_FILE_NAME = 'imsmanifest.xml'
SCHEMA = 'IMS Common Cartridge'
SCHEMA_VERSION = '1.1.0'
LOMIMSCC = 'lomimscc'

def initialize(course)
@course = course
end

def generate
Nokogiri::XML::Builder.new do |xml|
manifest(xml) do |xml|
metadata(xml)
organizations(xml)
resources(xml)
end

end.to_xml
end

def manifest(xml)
xml.manifest(
"identifier" => @course.identifier,
"xmlns" => "http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1",
"xmlns:lom" => "http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource",
"xmlns:lomimscc" => "http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" => "http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1 http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imscp_v1p2_v1p0.xsd http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lomresource_v1p0.xsd http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lommanifest_v1p0.xsd"
) {
yield xml
}
end

def metadata(xml)
xml.metadata {
xml.schema SCHEMA
xml.schemaversion SCHEMA_VERSION
ns = LOMIMSCC
xml[ns].lom {
xml[ns].general{
xml[ns].title{
xml[ns].string @course.title
}
}
rights(xml)
}
}
end

def rights(xml)
ns = LOMIMSCC
has_copyright = @course.copyright && !@course.copyright.empty?
xml[ns].rights{
xml[ns].copyrightAndOtherRestrictions{
xml[ns].value has_copyright ? 'yes' : 'no'
}
if has_copyright
xml[ns].description{
xml[ns].string @course.copyright
}
end
}
end


def organizations(xml)
xml.organizations
end

def resources(xml)
xml.resources
end


end
3 changes: 3 additions & 0 deletions lib/moodle2cc/common_cartridge/resources/assignment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Moodle2CC::CommonCartridge::Resources::Assignment
attr_accessor :body, :meta_fields
end
5 changes: 5 additions & 0 deletions lib/moodle2cc/common_cartridge/resources/course.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Moodle2CC::CommonCartridge::Resources::Course

attr_accessor :format, :identifier, :title, :copyright

end
3 changes: 3 additions & 0 deletions lib/moodle2cc/common_cartridge/resources/discussion_topic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Moodle2CC::CommonCartridge::Resources::DiscussionTopic
attr_accessor :text
end
5 changes: 5 additions & 0 deletions lib/moodle2cc/common_cartridge/resources/question.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Moodle2CC::CommonCartridge::Resources::Question

attr_accessor :id, :title, :identifier

end
5 changes: 5 additions & 0 deletions lib/moodle2cc/common_cartridge/resources/web_content.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Moodle2CC::CommonCartridge::Resources::WebContent

attr_accessor :body

end
5 changes: 5 additions & 0 deletions lib/moodle2cc/common_cartridge/resources/web_link.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Moodle2CC::CommonCartridge::Resources::WebLink

attr_accessor :url, :external_link, :href

end
1 change: 1 addition & 0 deletions test/acceptance/migrator_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
puts $LOAD_PATH
require 'minitest/autorun'
require 'test_helper'
require 'moodle2cc'
Expand Down
45 changes: 45 additions & 0 deletions test/fixtures/common_cartridge/ims_manifest_simple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest identifier="icc16454176b28467d5eaeb311a7a107d" xmlns="http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1" xmlns:lom="http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource" xmlns:lomimscc="http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1 http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imscp_v1p2_v1p0.xsd http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lomresource_v1p0.xsd http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lommanifest_v1p0.xsd">
<metadata>
<schema>IMS Common Cartridge</schema>
<schemaversion>1.1.0</schemaversion>
<lomimscc:lom>
<lomimscc:general>
<lomimscc:title>
<lomimscc:string>Sample Course</lomimscc:string>
</lomimscc:title>
</lomimscc:general>
<lomimscc:lifeCycle>
<lomimscc:contribute>
<lomimscc:date>
<lomimscc:dateTime>2014-02-05</lomimscc:dateTime>
</lomimscc:date>
</lomimscc:contribute>
</lomimscc:lifeCycle>
<lomimscc:rights>
<lomimscc:copyrightAndOtherRestrictions>
<lomimscc:value>yes</lomimscc:value>
</lomimscc:copyrightAndOtherRestrictions>
<lomimscc:description>
<lomimscc:string>Private (Copyrighted) - http://en.wikipedia.org/wiki/Copyright</lomimscc:string>
</lomimscc:description>
</lomimscc:rights>
</lomimscc:lom>
</metadata>
<organizations>
<organization identifier="org_1" structure="rooted-hierarchy">
<item identifier="LearningModules">
</item>
</organization>
</organizations>
<resources>
<resource identifier="i1df71e5dc5307ca91998f80fc71275e7_syllabus" type="associatedcontent/imscc_xmlv1p1/learning-application-resource" href="course_settings/syllabus.html" intendeduse="syllabus">
<file href="course_settings/syllabus.html"/>
</resource>
<resource identifier="i1df71e5dc5307ca91998f80fc71275e7" type="associatedcontent/imscc_xmlv1p1/learning-application-resource" href="course_settings/canvas_export.txt">
<file href="course_settings/course_settings.xml"/>
<file href="course_settings/files_meta.xml"/>
<file href="course_settings/canvas_export.txt"/>
</resource>
</resources>
</manifest>
Loading

0 comments on commit f3e0e01

Please sign in to comment.