Class: Moodle2CC::CanvasCC::Models::Question
- Inherits:
-
Object
- Object
- Moodle2CC::CanvasCC::Models::Question
- Defined in:
- lib/moodle2cc/canvas_cc/models/question.rb
Direct Known Subclasses
CalculatedQuestion, MatchingQuestion, MultipleDropdownsQuestion, NumericalQuestion
Constant Summary collapse
- QTI_META_ATTRIBUTES =
%i[question_type points_possible assessment_question_identifierref].freeze
- STANDARD_QUESTION_TYPES =
%w[essay_question fill_in_multiple_blanks_question multiple_choice_question multiple_answers_question short_answer_question text_only_question true_false_question].freeze
- @@subclasses =
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Question
constructor
A new instance of Question.
Constructor Details
#initialize ⇒ Question
Returns a new instance of Question.
34 35 36 |
# File 'lib/moodle2cc/canvas_cc/models/question.rb', line 34 def initialize @answers = [] end |
Class Method Details
.create(type) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/moodle2cc/canvas_cc/models/question.rb', line 18 def self.create(type) q = if STANDARD_QUESTION_TYPES.include?(type) 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
30 31 32 |
# File 'lib/moodle2cc/canvas_cc/models/question.rb', line 30 def self.register_question_type(name) @@subclasses[name] = self end |