Class: Senkyoshi::QuestionBank
- Inherits:
-
QTI
- Object
- Resource
- FileResource
- QTI
- Senkyoshi::QuestionBank
- Defined in:
- lib/senkyoshi/models/question_bank.rb
Constant Summary collapse
- TAGS =
{ "<p><span size=\"2\" style=\"font-size: small;\">.</span></p>" => "", "<p>.</p>" => "", }.freeze
- TAGS_RE =
Regexp.union(TAGS.keys)
Instance Attribute Summary
Attributes inherited from QTI
Attributes inherited from FileResource
Instance Method Summary collapse
- #canvas_conversion(course, resources) ⇒ Object
-
#clean_up_material(material) ⇒ 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, from, get_pre_data, #get_question_group, #get_questions, #get_quiz_pool_items, #initialize, #iterate_xml, #set_assessment_details, #setup_assessment
Methods inherited from FileResource
#create_module, from, #initialize, #iterate_xml
Methods inherited from Resource
#_find_directories, #_fix_path, #_matches_directory_xid?, #_search_and_replace, #cleanup, #fix_html, get_pre_data, #matches_xid?, #strip_xid
Constructor Details
This class inherits a constructor from Senkyoshi::QTI
Instance Method Details
#canvas_conversion(course, resources) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/senkyoshi/models/question_bank.rb', line 26 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(material) ⇒ Object
This is to remove the random extra <p>.</p> included in the description that is just randomly there
56 57 58 59 60 61 62 |
# File 'lib/senkyoshi/models/question_bank.rb', line 56 def clean_up_material(material) if material material = material.gsub(TAGS_RE, TAGS) material = material.strip end material end |
#create_items(question_bank, resources) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/senkyoshi/models/question_bank.rb', line 40 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.material) question_bank.questions << question end question_bank end |
#setup_question_bank(question_bank, resources) ⇒ Object
35 36 37 38 |
# File 'lib/senkyoshi/models/question_bank.rb', line 35 def setup_question_bank(question_bank, resources) question_bank = create_items(question_bank, resources) question_bank end |