Class: Moodle2CC::Moodle2::Parsers::QuestionParsers::TrueFalseParser

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

Constant Summary

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

Methods inherited from QuestionParser

parse, register_parser_type

Instance Method Details

#parse_question(node) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/moodle2cc/moodle2/parsers/question_parsers/true_false_parser.rb', line 6

def parse_question(node)
  question = super
  q_node = node.at_xpath('plugin_qtype_truefalse_question')
  question.true_false_id = q_node.at_xpath('truefalse/@id').value
  question.true_answer = parse_text(q_node, 'truefalse/trueanswer')
  question.false_answer = parse_text(q_node, 'truefalse/falseanswer')

  answer_parser = Parsers::AnswerParser.new
  question.answers += node.search('answers/answer').map { |n| answer_parser.parse(n) }

  question
end