Class: Moodle2CC::Moodle2::Models::Quizzes::Question
- Inherits:
-
Object
- Object
- Moodle2CC::Moodle2::Models::Quizzes::Question
- Defined in:
- lib/moodle2cc/moodle2/models/quizzes/question.rb
Direct Known Subclasses
CalculatedQuestion, MatchQuestion, MultianswerQuestion, MultichoiceQuestion, NumericalQuestion, RandomSAQuestion, TrueFalseQuestion
Constant Summary collapse
- STANDARD_TYPES =
%w[description essay random shortanswer].freeze
- @@subclasses =
{}
Instance Attribute Summary collapse
-
#answers ⇒ Object
Returns the value of attribute answers.
-
#bank_entry_id ⇒ Object
Returns the value of attribute bank_entry_id.
-
#default_mark ⇒ Object
Returns the value of attribute default_mark.
-
#general_feedback ⇒ Object
Returns the value of attribute general_feedback.
-
#hidden ⇒ Object
Returns the value of attribute hidden.
-
#id ⇒ Object
Returns the value of attribute id.
-
#length ⇒ Object
Returns the value of attribute length.
-
#max_mark ⇒ Object
Returns the value of attribute max_mark.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#penalty ⇒ Object
Returns the value of attribute penalty.
-
#qtype ⇒ Object
Returns the value of attribute qtype.
-
#question_text ⇒ Object
Returns the value of attribute question_text.
-
#question_text_format ⇒ Object
Returns the value of attribute question_text_format.
-
#stamp ⇒ Object
Returns the value of attribute stamp.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
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.
45 46 47 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 45 def initialize @answers = [] end |
Instance Attribute Details
#answers ⇒ Object
Returns the value of attribute answers.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def answers @answers end |
#bank_entry_id ⇒ Object
Returns the value of attribute bank_entry_id.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def bank_entry_id @bank_entry_id end |
#default_mark ⇒ Object
Returns the value of attribute default_mark.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def default_mark @default_mark end |
#general_feedback ⇒ Object
Returns the value of attribute general_feedback.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def general_feedback @general_feedback end |
#hidden ⇒ Object
Returns the value of attribute hidden.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def hidden @hidden end |
#id ⇒ Object
Returns the value of attribute id.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def id @id end |
#length ⇒ Object
Returns the value of attribute length.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def length @length end |
#max_mark ⇒ Object
Returns the value of attribute max_mark.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def max_mark @max_mark end |
#name ⇒ Object
Returns the value of attribute name.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def parent @parent end |
#penalty ⇒ Object
Returns the value of attribute penalty.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def penalty @penalty end |
#qtype ⇒ Object
Returns the value of attribute qtype.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def qtype @qtype end |
#question_text ⇒ Object
Returns the value of attribute question_text.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def question_text @question_text end |
#question_text_format ⇒ Object
Returns the value of attribute question_text_format.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def question_text_format @question_text_format end |
#stamp ⇒ Object
Returns the value of attribute stamp.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def stamp @stamp end |
#type ⇒ Object
Returns the value of attribute type.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
27 28 29 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 27 def version @version end |
Class Method Details
.create(type) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 9 def self.create(type) if (c = @@subclasses[type]) q = c.new q.type = type q elsif STANDARD_TYPES.include?(type) q = new q.type = type q else raise "Unknown question type: #{type}" end end |
.register_question_type(name) ⇒ Object
23 24 25 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 23 def self.register_question_type(name) @@subclasses[name] = self end |