Class: CanvasCc::Canvas::QuestionBank
- Inherits:
-
Object
- Object
- CanvasCc::Canvas::QuestionBank
- Includes:
- CanvasCc::CC::CCHelper
- Defined in:
- lib/canvas_cc/canvas/question_bank.rb
Constant Summary
Constants included from CanvasCc::CC::CCHelper
CanvasCc::CC::CCHelper::ASSESSMENT_CC_QTI, CanvasCc::CC::CCHelper::ASSESSMENT_META, CanvasCc::CC::CCHelper::ASSESSMENT_NON_CC_FOLDER, CanvasCc::CC::CCHelper::ASSESSMENT_TYPE, CanvasCc::CC::CCHelper::ASSIGNMENT_GROUPS, CanvasCc::CC::CCHelper::ASSIGNMENT_SETTINGS, CanvasCc::CC::CCHelper::BASIC_LTI, CanvasCc::CC::CCHelper::BLTI_NAMESPACE, CanvasCc::CC::CCHelper::CANVAS_NAMESPACE, CanvasCc::CC::CCHelper::CANVAS_PLATFORM, CanvasCc::CC::CCHelper::CC_ASSIGNMENT_FOLDER, CanvasCc::CC::CCHelper::CC_EXTENSION, CanvasCc::CC::CCHelper::CC_WIKI_FOLDER, CanvasCc::CC::CCHelper::COURSE_SETTINGS, CanvasCc::CC::CCHelper::COURSE_SETTINGS_DIR, CanvasCc::CC::CCHelper::COURSE_TOKEN, CanvasCc::CC::CCHelper::DISCUSSION_TOPIC, CanvasCc::CC::CCHelper::EVENTS, CanvasCc::CC::CCHelper::EXTERNAL_FEEDS, CanvasCc::CC::CCHelper::EXTERNAL_TOOLS, CanvasCc::CC::CCHelper::FILES_META, CanvasCc::CC::CCHelper::GRADING_STANDARDS, CanvasCc::CC::CCHelper::IMS_DATE, CanvasCc::CC::CCHelper::IMS_DATETIME, CanvasCc::CC::CCHelper::LEARNING_OUTCOMES, CanvasCc::CC::CCHelper::LOR, CanvasCc::CC::CCHelper::MANIFEST, CanvasCc::CC::CCHelper::MEDIA_OBJECTS_FOLDER, CanvasCc::CC::CCHelper::MODULE_META, CanvasCc::CC::CCHelper::MOODLE_FILEBASE_TOKEN, CanvasCc::CC::CCHelper::MOODLE_SLASH_TOKEN, CanvasCc::CC::CCHelper::OBJECT_TOKEN, CanvasCc::CC::CCHelper::QTI_ASSESSMENT_TYPE, CanvasCc::CC::CCHelper::QTI_EXTENSION, CanvasCc::CC::CCHelper::QUESTION_BANK, CanvasCc::CC::CCHelper::RUBRICS, CanvasCc::CC::CCHelper::SYLLABUS, CanvasCc::CC::CCHelper::WEBCONTENT, CanvasCc::CC::CCHelper::WEB_CONTENT_TOKEN, CanvasCc::CC::CCHelper::WEB_LINK, CanvasCc::CC::CCHelper::WEB_RESOURCES_FOLDER, CanvasCc::CC::CCHelper::WIKI_FOLDER, CanvasCc::CC::CCHelper::WIKI_TOKEN, CanvasCc::CC::CCHelper::XSD_URI
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#questions ⇒ Object
Returns the value of attribute questions.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #create_files(export_dir) ⇒ Object
- #create_qti_xml(export_dir) ⇒ Object
- #create_resource_node(resources_node) ⇒ Object
-
#initialize(question_category) ⇒ QuestionBank
constructor
A new instance of QuestionBank.
Methods included from CanvasCc::CC::CCHelper
#convert_file_path_tokens, convert_file_path_tokens, #create_key, create_key, create_mod_key, #create_mod_key, #create_resource_key, create_resource_key, file_query_string, #file_slug, file_slug, #get_html_title_and_body, #get_html_title_and_body_and_id, #get_html_title_and_body_and_meta_fields, ims_date, #ims_date, ims_datetime, #ims_datetime, media_object_info
Constructor Details
#initialize(question_category) ⇒ QuestionBank
Returns a new instance of QuestionBank.
6 7 8 9 10 11 12 13 14 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 6 def initialize(question_category) @id = question_category.id @title = question_category.name @identifier = create_key(@id, 'objectbank_') @question_category = question_category @questions = @question_category.questions.reject { |q| q.type == 'random' }.map do |question| Question.new question end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 4 def id @id end |
#identifier ⇒ Object
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 4 def identifier @identifier end |
#questions ⇒ Object
Returns the value of attribute questions.
4 5 6 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 4 def questions @questions end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 4 def title @title end |
Instance Method Details
#create_files(export_dir) ⇒ Object
27 28 29 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 27 def create_files(export_dir) create_qti_xml(export_dir) end |
#create_qti_xml(export_dir) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 31 def create_qti_xml(export_dir) path = File.join(export_dir, ASSESSMENT_NON_CC_FOLDER, "#{identifier}.xml.qti") FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w') do |file| node = Builder::XmlMarkup.new(:target => file, :indent => 2) node.instruct! node.questestinterop( 'xsi:schemaLocation' => "http://www.imsglobal.org/xsd/ims_qtiasiv1p2 http://www.imsglobal.org/xsd/ims_qtiasiv1p2p1.xsd", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns' => "http://www.imsglobal.org/xsd/ims_qtiasiv1p2" ) do |root_node| root_node.objectbank(:ident => identifier) do |objectbank_node| objectbank_node. do || . do || .fieldlabel "bank_title" .fieldentry @title end end @questions.each do |question| question.create_item_xml(objectbank_node) if question end end end end end |
#create_resource_node(resources_node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/canvas_cc/canvas/question_bank.rb', line 16 def create_resource_node(resources_node) href = File.join(ASSESSMENT_NON_CC_FOLDER, "#{identifier}.xml.qti") resources_node.resource( :href => href, :type => LOR, :identifier => identifier ) do |resource_node| resource_node.file(:href => href) end end |