Class: Moodle2CC::CanvasCC::Models::Question

Inherits:
Object
  • Object
show all
Defined in:
lib/moodle2cc/canvas_cc/models/question.rb

Constant Summary collapse

QTI_META_ATTRIBUTES =
[:question_type, :points_possible, :assessment_question_identifierref]
STANDARD_QUESTION_TYPES =
['essay_question', 'fill_in_multiple_blanks_question',
'multiple_choice_question', 'multiple_answers_question',
'short_answer_question', 'text_only_question', 'true_false_question']
@@subclasses =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQuestion

Returns a new instance of Question.



28
29
30
# File 'lib/moodle2cc/canvas_cc/models/question.rb', line 28

def initialize
  @answers = []
end

Class Method Details

.create(type) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/moodle2cc/canvas_cc/models/question.rb', line 12

def self.create(type)
  q = if STANDARD_QUESTION_TYPES.include?(type)
    self.new
  elsif c = @@subclasses[type]
    c.new
  else
    raise "Unknown question type: #{type}"
  end
  q.question_type = type
  q
end

.register_question_type(name) ⇒ Object



24
25
26
# File 'lib/moodle2cc/canvas_cc/models/question.rb', line 24

def self.register_question_type(name)
  @@subclasses[name] = self
end