Class: Senkyoshi::QuestionBank
- Defined in:
- lib/senkyoshi/models/question_bank.rb
Instance Method Summary collapse
- #canvas_conversion(course, resources) ⇒ Object
-
#clean_up_material(question) ⇒ Object
This is to remove the random extra <p>.</p> included in the description that is just randomly there.
- #create_items(question_bank, resources) ⇒ Object
- #setup_question_bank(question_bank, resources) ⇒ Object
Methods inherited from QTI
#canvas_module?, #create_assignment, #create_assignment_group, from, #get_pre_data, #get_question_group, #get_questions, #get_quiz_pool_items, #initialize, #iterate_xml, #set_assessment_details, #setup_assessment
Methods inherited from Resource
#_search_and_replace, #cleanup, #fix_html, #matches_xid?
Constructor Details
This class inherits a constructor from Senkyoshi::QTI
Instance Method Details
#canvas_conversion(course, resources) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/senkyoshi/models/question_bank.rb', line 5 def canvas_conversion(course, resources) question_bank = CanvasCc::CanvasCC::Models::QuestionBank.new question_bank.identifier = @id question_bank.title = @title question_bank = setup_question_bank(question_bank, resources) course.question_banks << question_bank course end |
#clean_up_material(question) ⇒ Object
This is to remove the random extra <p>.</p> included in the description that is just randomly there
39 40 41 42 43 44 |
# File 'lib/senkyoshi/models/question_bank.rb', line 39 def clean_up_material(question) tag = "<p><span size=\"2\" style=\"font-size: small;\">.</span></p>" question.material.gsub!(tag, "") question.material.gsub!("<p>.</p>", "") question.material.strip! end |
#create_items(question_bank, resources) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/senkyoshi/models/question_bank.rb', line 23 def create_items(question_bank, resources) @items = @items - ["", nil] questions = @items.map do |item| Question.from(item) end question_bank.questions = [] questions.each do |item| question = item.canvas_conversion(question_bank, resources) question.material = clean_up_material(question) question_bank.questions << question end question_bank end |
#setup_question_bank(question_bank, resources) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/senkyoshi/models/question_bank.rb', line 14 def setup_question_bank(question_bank, resources) if @items.count.zero? question_bank.description += "Empty Quiz -- No questions were contained in the blackboard quiz bank" end question_bank = create_items(question_bank, resources) question_bank end |