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 =
[: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
-
#initialize ⇒ Question
constructor
A new instance of Question.
Constructor Details
#initialize ⇒ Question
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 |