Module: QuestionMoodleFormatter
- Defined in:
- lib/asker/formatter/question_moodle_formatter.rb
Overview
Transform Questions into Gift format
Class Method Summary collapse
-
.to_s(question) ⇒ Object
Convert question object into gift formatted string.
Class Method Details
.to_s(question) ⇒ Object
Convert question object into gift formatted string
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/asker/formatter/question_moodle_formatter.rb', line 11 def self.to_s(question) case question.type when :choice penalties = ['', '-50', '-33.33333', '-25', '-20'] 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 :match template = File.read(File.join(File.dirname(__FILE__), 'moodle', 'matching.erb')) when :short template = File.read(File.join(File.dirname(__FILE__), 'moodle', 'shortanswer.erb')) end renderer = ERB.new(template) renderer.result(binding) end |