Module: DataMoodleExporter
- Defined in:
- lib/asker/exporter/data_moodle_exporter.rb
Class Method Summary collapse
- .add_header(file, project) ⇒ Object
- .call(data, project) ⇒ Object
- .close(file) ⇒ Object
- .export_codes(codes:, file:) ⇒ Object
- .export_concepts(concepts:, file:) ⇒ Object
- .export_problems(problems:, file:) ⇒ Object
Class Method Details
.add_header(file, project) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/asker/exporter/data_moodle_exporter.rb', line 17 def self.add_header(file, project) file.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") file.write("<quiz>\n") file.write("<!--\n#{"=" * 50}\n") file.write(" #{Asker::NAME} : version #{Asker::VERSION}\n") file.write(" Filename : #{project.get(:moodlename)}\n") file.write(" Datetime : #{Time.new}\n") file.write("#{"=" * 50}\n-->\n\n") file end |
.call(data, project) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/asker/exporter/data_moodle_exporter.rb', line 6 def self.call(data, project) file = File.open(project.get(:moodlepath), "w") add_header(file, project) export_concepts(concepts: data[:concepts_ai], file: file) export_codes(codes: data[:codes_ai], file: file) export_problems(problems: data[:problems], file: file) close(file) end |
.close(file) ⇒ Object
28 29 30 31 |
# File 'lib/asker/exporter/data_moodle_exporter.rb', line 28 def self.close(file) file.write("</quiz>\n") file.close end |
.export_codes(codes:, file:) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/asker/exporter/data_moodle_exporter.rb', line 45 def self.export_codes(codes:, file:) codes.each do |code| next unless code.process? code.questions.each do |question| file.write QuestionMoodleFormatter.to_s(question) end end end |
.export_concepts(concepts:, file:) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/asker/exporter/data_moodle_exporter.rb', line 33 def self.export_concepts(concepts:, file:) concepts.each do |concept_ai| next unless concept_ai.concept.process? Application.instance.config["questions"]["stages"].each do |stage| concept_ai.questions[stage].each do |question| file.write(QuestionMoodleFormatter.to_s(question)) end end end end |
.export_problems(problems:, file:) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/asker/exporter/data_moodle_exporter.rb', line 54 def self.export_problems(problems:, file:) problems.each do |problem| next unless problem.process? problem.questions.each do |question| file.write QuestionMoodleFormatter.to_s(question) end end end |