Class: Moodle2CC::Moodle2::Models::Quizzes::MultianswerQuestion
- Inherits:
-
Question
- Object
- Question
- Moodle2CC::Moodle2::Models::Quizzes::MultianswerQuestion
- Defined in:
- lib/moodle2cc/moodle2/models/quizzes/multianswer_question.rb
Constant Summary
Constants inherited from Question
Instance Attribute Summary collapse
-
#embedded_question_references ⇒ Object
Returns the value of attribute embedded_question_references.
-
#embedded_questions ⇒ Object
Returns the value of attribute embedded_questions.
Attributes inherited from Question
#answers, #bank_entry_id, #default_mark, #general_feedback, #hidden, #id, #length, #max_mark, #name, #parent, #penalty, #qtype, #question_text, #question_text_format, #stamp, #type, #version
Instance Method Summary collapse
-
#initialize ⇒ MultianswerQuestion
constructor
A new instance of MultianswerQuestion.
- #resolve_embedded_question_references(question_categories) ⇒ Object
Methods inherited from Question
create, register_question_type
Constructor Details
#initialize ⇒ MultianswerQuestion
Returns a new instance of MultianswerQuestion.
6 7 8 9 |
# File 'lib/moodle2cc/moodle2/models/quizzes/multianswer_question.rb', line 6 def initialize super @embedded_questions = [] end |
Instance Attribute Details
#embedded_question_references ⇒ Object
Returns the value of attribute embedded_question_references.
4 5 6 |
# File 'lib/moodle2cc/moodle2/models/quizzes/multianswer_question.rb', line 4 def @embedded_question_references end |
#embedded_questions ⇒ Object
Returns the value of attribute embedded_questions.
4 5 6 |
# File 'lib/moodle2cc/moodle2/models/quizzes/multianswer_question.rb', line 4 def @embedded_questions end |
Instance Method Details
#resolve_embedded_question_references(question_categories) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/moodle2cc/moodle2/models/quizzes/multianswer_question.rb', line 11 def (question_categories) return unless @embedded_question_references @embedded_questions ||= [] @embedded_question_references.each do |ref| question = nil question_categories.each do |qc| if question = qc.questions.detect{|q| q.id.to_s == ref && q.parent.to_s == @id} qc.questions.delete(question) break end end @embedded_questions << question if question end end |