Module: DataGiftExporter

Defined in:
lib/asker/exporter/data_gift_exporter.rb

Class Method Summary collapse

Class Method Details

.export_all(data, project) ⇒ Object

Export an array of Data (ConceptAIs, Codes and Problems objects) into GIFT file

Parameters:

  • data (Hash)
  • project (Project)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/asker/exporter/data_gift_exporter.rb', line 14

def self.export_all(data, project)
  file = File.open(project.get(:outputpath), "w")
  file.write("// " + ("=" * 50) + "\n")
  file.write("// #{Asker::NAME}    : version #{Asker::VERSION}\n")
  file.write("// Filename : #{project.get(:outputname)}\n")
  file.write("// Datetime : #{Time.new}\n")
  file.write("// " + ("=" * 50) + "\n\n")
  category = Application.instance.config["questions"]["category"]
  file.write("$CATEGORY: $course$/#{category}\n") unless category.nil?

  ConceptAIGiftExporter.export_all(data[:concepts_ai], file)
  CodeGiftExporter.export_all(data[:codes_ai], file)
  ProblemGiftExporter.new.call(data[:problems], file)
  file.close
end