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 =
['description', 'essay', 'random', 'shortanswer']
- @@subclasses =
{}
Instance Attribute Summary collapse
-
#answers ⇒ Object
Returns the value of attribute answers.
-
#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.
29 30 31 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 29 def initialize @answers = [] end |
Instance Attribute Details
#answers ⇒ Object
Returns the value of attribute answers.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def answers @answers end |
#default_mark ⇒ Object
Returns the value of attribute default_mark.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def default_mark @default_mark end |
#general_feedback ⇒ Object
Returns the value of attribute general_feedback.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def general_feedback @general_feedback end |
#hidden ⇒ Object
Returns the value of attribute hidden.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def hidden @hidden end |
#id ⇒ Object
Returns the value of attribute id.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def id @id end |
#length ⇒ Object
Returns the value of attribute length.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def length @length end |
#max_mark ⇒ Object
Returns the value of attribute max_mark.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def max_mark @max_mark end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def parent @parent end |
#penalty ⇒ Object
Returns the value of attribute penalty.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def penalty @penalty end |
#qtype ⇒ Object
Returns the value of attribute qtype.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def qtype @qtype end |
#question_text ⇒ Object
Returns the value of attribute question_text.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def question_text @question_text end |
#question_text_format ⇒ Object
Returns the value of attribute question_text_format.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def question_text_format @question_text_format end |
#stamp ⇒ Object
Returns the value of attribute stamp.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def stamp @stamp end |
#type ⇒ Object
Returns the value of attribute type.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
26 27 28 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 26 def version @version end |
Class Method Details
.create(type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 8 def self.create(type) if c = @@subclasses[type] q = c.new q.type = type q elsif STANDARD_TYPES.include?(type) q = self.new q.type = type q else raise "Unknown question type: #{type}" end end |
.register_question_type(name) ⇒ Object
22 23 24 |
# File 'lib/moodle2cc/moodle2/models/quizzes/question.rb', line 22 def self.register_question_type(name) @@subclasses[name] = self end |