class Moodle2CC::Moodle2Converter::QuestionConverters::QuestionConverter
Constants
- STANDARD_CONVERSIONS
Attributes
canvas_question_type[RW]
Public Class Methods
register_converter_type(name)
click to toggle source
# File lib/moodle2cc/moodle2converter/question_converters/question_converter.rb, line 11 def self.register_converter_type(name) @@subclasses[name] = self end
Public Instance Methods
convert(moodle_question)
click to toggle source
# File lib/moodle2cc/moodle2converter/question_converters/question_converter.rb, line 21 def convert(moodle_question) type = moodle_question.type if type && c = @@subclasses[type] c.new.convert_question(moodle_question) elsif type && question_type = STANDARD_CONVERSIONS[type] self.convert_question(moodle_question, question_type) else raise "Unknown converter type: #{type}" end end
convert_question(moodle_question, question_type = nil)
click to toggle source
# File lib/moodle2cc/moodle2converter/question_converters/question_converter.rb, line 32 def convert_question(moodle_question, question_type = nil) canvas_question = create_canvas_question(question_type, moodle_question) canvas_question.identifier = generate_unique_identifier_for(moodle_question.id, '_quiz_question') canvas_question.original_identifier = moodle_question.id canvas_question.title = truncate_text(moodle_question.name) canvas_question.points_possible = moodle_question.max_mark canvas_question.general_feedback = moodle_question.general_feedback canvas_question.answers = moodle_question.answers.map do |moodle_answer| Moodle2CC::CanvasCC::Models::Answer.new(moodle_answer) end canvas_question.material = convert_question_text(moodle_question) canvas_question end
convert_question_text(moodle_question)
click to toggle source
# File lib/moodle2cc/moodle2converter/question_converters/question_converter.rb, line 46 def convert_question_text(moodle_question) material = moodle_question.question_text || '' material = RDiscount.new(material).to_html if moodle_question.question_text_format.to_i == 4 # markdown material end
create_canvas_question(question_type = nil, question = nil)
click to toggle source
# File lib/moodle2cc/moodle2converter/question_converters/question_converter.rb, line 52 def create_canvas_question(question_type = nil, question = nil) question_type ||= self.class.canvas_question_type raise 'set canvas_question_type in question converter subclasses' unless question_type Moodle2CC::CanvasCC::Models::Question.create(question_type) end