Class: Moodle2CC::Moodle2::Parsers::QuestionCategoryParser

Inherits:
Object
  • Object
show all
Includes:
ParserHelper
Defined in:
lib/moodle2cc/moodle2/parsers/question_category_parser.rb

Constant Summary collapse

QUESTIONS_XML =
"questions.xml"

Constants included from ParserHelper

ParserHelper::FILES_XML, ParserHelper::IMS_FILEBASE_TOKEN, ParserHelper::MODULE_XML, ParserHelper::MOODLE_FILEBASE_TOKEN, ParserHelper::SLASH_TOKEN, ParserHelper::XML_NULL_VALUE

Instance Method Summary collapse

Methods included from ParserHelper

#activity_directories, #parse_boolean, #parse_module, #parse_text

Constructor Details

#initialize(backup_dir) ⇒ QuestionCategoryParser

Returns a new instance of QuestionCategoryParser.



9
10
11
# File 'lib/moodle2cc/moodle2/parsers/question_category_parser.rb', line 9

def initialize(backup_dir)
  @backup_dir = backup_dir
end

Instance Method Details

#parseObject



13
14
15
16
17
18
# File 'lib/moodle2cc/moodle2/parsers/question_category_parser.rb', line 13

def parse
  File.open(File.join(@backup_dir, QUESTIONS_XML)) do |f|
    root_xml = Nokogiri::XML(f)
    root_xml.search("/question_categories/question_category").map { |node| question_category_parser(node) }
  end
end