Class: Question2MoodleXML
- Inherits:
-
Object
- Object
- Question2MoodleXML
- Defined in:
- lib/asker/formatter/question2moodle_xml.rb
Overview
Transform Questions into Gift format
Instance Method Summary collapse
-
#format(question) ⇒ Object
Convert question object into gift formatted string.
Instance Method Details
#format(question) ⇒ Object
Convert question object into gift formatted string
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/asker/formatter/question2moodle_xml.rb', line 10 def format(question) case question.type when :choice fractions = Application.instance.config["questions"]["fractions"] penalties = fractions # penalties = ['', '-50', '-33.33333', '-25', '-20'] # puts "[DEBUG] fractions : #{fractions}" # puts "[DEBUG] penalties : #{penalties}" penalty = penalties[question.bads.size] template = File.read(File.join(File.dirname(__FILE__), "moodle", "multichoice.erb")) when :boolean template = File.read(File.join(File.dirname(__FILE__), "moodle", "truefalse.erb")) when :ddmatch template = File.read(File.join(File.dirname(__FILE__), "moodle", "ddmatch.erb")) when :match template = File.read(File.join(File.dirname(__FILE__), "moodle", "matching.erb")) when :ordering template = File.read(File.join(File.dirname(__FILE__), "moodle", "ordering.erb")) when :short template = File.read(File.join(File.dirname(__FILE__), "moodle", "shortanswer.erb")) else warn "[ERROR] Question2MoodleXML: Unknown type (#{question.type})" exit 1 end renderer = ERB.new(template) renderer.result(binding) end |