Class: Moodle2CC::CanvasCC::Models::QuestionBank
- Inherits:
-
Object
- Object
- Moodle2CC::CanvasCC::Models::QuestionBank
- Defined in:
- lib/moodle2cc/canvas_cc/models/question_bank.rb
Constant Summary collapse
- LAR_TYPE =
'associatedcontent/imscc_xmlv1p1/learning-application-resource'
- ASSESSMENT_NON_CC_FOLDER =
'non_cc_assessments'
Instance Attribute Summary collapse
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#original_id ⇒ Object
Returns the value of attribute original_id.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#question_groups ⇒ Object
Returns the value of attribute question_groups.
-
#questions ⇒ Object
Returns the value of attribute questions.
-
#random_question_references ⇒ Object
Returns the value of attribute random_question_references.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#find_children_banks(all_banks, visited_banks = []) ⇒ Object
recursively find all banks that belong to this one.
-
#initialize ⇒ QuestionBank
constructor
A new instance of QuestionBank.
- #question_bank_resource ⇒ Object
- #resources ⇒ Object
Constructor Details
#initialize ⇒ QuestionBank
Returns a new instance of QuestionBank.
6 7 8 9 10 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 6 def initialize @questions = [] @question_groups = [] @random_question_references = [] end |
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 4 def identifier @identifier end |
#original_id ⇒ Object
Returns the value of attribute original_id.
4 5 6 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 4 def original_id @original_id end |
#parent_id ⇒ Object
Returns the value of attribute parent_id.
4 5 6 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 4 def parent_id @parent_id end |
#question_groups ⇒ Object
Returns the value of attribute question_groups.
4 5 6 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 4 def question_groups @question_groups end |
#questions ⇒ Object
Returns the value of attribute questions.
4 5 6 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 4 def questions @questions end |
#random_question_references ⇒ Object
Returns the value of attribute random_question_references.
4 5 6 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 4 def random_question_references @random_question_references end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 4 def title @title end |
Instance Method Details
#find_children_banks(all_banks, visited_banks = []) ⇒ Object
recursively find all banks that belong to this one
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 29 def find_children_banks(all_banks, visited_banks=[]) visited_banks << self children = [] sub_children = [] all_banks.each do |bank| children << bank if bank.parent_id && bank.parent_id == self.original_id && !visited_banks.include?(bank) end children.each do |child| sub_children += child.find_children_banks(all_banks, visited_banks) end return children + sub_children end |
#question_bank_resource ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 19 def question_bank_resource resource = Moodle2CC::CanvasCC::Models::Resource.new resource.identifier = @identifier resource.href = "#{ASSESSMENT_NON_CC_FOLDER}/#{resource.identifier}.xml.qti" resource.type = LAR_TYPE resource.files = [resource.href] resource end |
#resources ⇒ Object
15 16 17 |
# File 'lib/moodle2cc/canvas_cc/models/question_bank.rb', line 15 def resources [question_bank_resource] end |