Class: CanvasCc::CanvasCC::OutcomeWriter
- Inherits:
-
Object
- Object
- CanvasCc::CanvasCC::OutcomeWriter
- Defined in:
- lib/canvas_cc/canvas_cc/outcome_writer.rb
Constant Summary collapse
- LEARNING_OUTCOMES_FILE =
'learning_outcomes.xml'
Instance Method Summary collapse
-
#initialize(work_dir, *outcomes) ⇒ OutcomeWriter
constructor
A new instance of OutcomeWriter.
- #write ⇒ Object
Constructor Details
#initialize(work_dir, *outcomes) ⇒ OutcomeWriter
Returns a new instance of OutcomeWriter.
5 6 7 8 |
# File 'lib/canvas_cc/canvas_cc/outcome_writer.rb', line 5 def initialize(work_dir, *outcomes) @work_dir = work_dir @outcomes = outcomes end |
Instance Method Details
#write ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/canvas_cc/canvas_cc/outcome_writer.rb', line 10 def write xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| write_outcomes(xml) do |xml| @outcomes.each do |outcome| xml.learningOutcome(identifier: outcome.identifier) do xml.title outcome.title xml.description outcome.description xml.calculation_method outcome.calculation_method if outcome.calculation_method xml.calculation_int(outcome.calculation_int) if outcome.calculation_method == 'decaying_average' xml.points_possible outcome.points_possible xml.mastery_points outcome.mastery_points xml << CanvasCc::CanvasCC::RatingWriter.new(*outcome.).write xml.is_global_outcome outcome.is_global_outcome xml.external_identifier outcome.external_identifier if outcome.external_identifier end end end end.to_xml File.open(File.join(@work_dir, CanvasCc::CanvasCC::CartridgeCreator::COURSE_SETTINGS_DIR, LEARNING_OUTCOMES_FILE), 'w') { |f| f.write(xml) } end |