Class: Moodle2CC::CanvasCC::CourseSettingWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/moodle2cc/canvas_cc/course_setting_writer.rb

Constant Summary collapse

SETTINGS_POSTFIX =
'_settings'
COURSE_SETTINGS_FILE =
'course_settings.xml'

Instance Method Summary collapse

Constructor Details

#initialize(work_dir, course) ⇒ CourseSettingWriter

Returns a new instance of CourseSettingWriter.



7
8
9
10
# File 'lib/moodle2cc/canvas_cc/course_setting_writer.rb', line 7

def initialize(work_dir, course)
  @work_dir = work_dir
  @course = course
end

Instance Method Details

#writeObject



12
13
14
15
16
17
18
19
# File 'lib/moodle2cc/canvas_cc/course_setting_writer.rb', line 12

def write
  xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
    course(xml) do |xml|
      @course.settings.each { |k, v| xml.send(k, v) }
    end
  end.to_xml
  File.open(File.join(@work_dir, Moodle2CC::CanvasCC::CartridgeCreator::COURSE_SETTINGS_DIR, COURSE_SETTINGS_FILE), 'w') { |f| f.write(xml) }
end