Class: Moodle2CC::Moodle2::Parsers::QuestionParsers::NumericalParser

Inherits:
QuestionParser
  • Object
show all
Includes:
ParserHelper
Defined in:
lib/moodle2cc/moodle2/parsers/question_parsers/numerical_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
18
19
20
21
# File 'lib/moodle2cc/moodle2/parsers/question_parsers/numerical_parser.rb', line 6

def parse_question(node)
  question = super

  q_node = node.at_xpath("plugin_qtype_#{question.qtype}_question")

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

  q_node.search('numerical_records/numerical_record').each do |nr_node|
    answer_id = parse_text(nr_node, 'answer')
    tolerance = parse_text(nr_node, 'tolerance')
    question.tolerances[answer_id] = tolerance
  end

  question
end