class Kitchen::InjectedQuestionElement
An element for an example
Public Class Methods
new(node:, document: nil)
click to toggle source
Creates a new InjectedQuestionElement
@param node [Nokogiri::XML::Node] the node this element wraps @param document [Document] this element's document
Calls superclass method
Kitchen::ElementBase::new
# File lib/kitchen/injected_question_element.rb, line 13 def initialize(node:, document: nil) super(node: node, document: document, enumerator_class: InjectedQuestionElementEnumerator) end
short_type()
click to toggle source
Returns the short type @return [Symbol]
# File lib/kitchen/injected_question_element.rb, line 22 def self.short_type :injected_question end
Public Instance Methods
answers()
click to toggle source
Returns the list of answers as an element.
@return [Element]
# File lib/kitchen/injected_question_element.rb, line 46 def answers first("ol[data-type='question-answers']") end
correct_answer_letters(alphabet)
click to toggle source
Returns the answer correctness given an alphabet
@return [Array]
# File lib/kitchen/injected_question_element.rb, line 62 def correct_answer_letters(alphabet) answers.search('li[data-type="question-answer"]').each_with_index.map \ do |answer, index| answer[:'data-correctness'] == '1.0' ? alphabet[index] : nil end.compact end
id()
click to toggle source
Returns or creates the question's id
@return [String]
# File lib/kitchen/injected_question_element.rb, line 73 def id self[:id] ||= "auto_#{ancestor(:page).id.gsub(/page_/, '')}_#{self[:'data-id']}" end
solution()
click to toggle source
Returns the solution element.
@return [Element]
# File lib/kitchen/injected_question_element.rb, line 54 def solution first("div[data-type='question-solution']") end
stem()
click to toggle source
Returns the question stem as an element.
@return [Element]
# File lib/kitchen/injected_question_element.rb, line 38 def stem first('div[data-type="question-stem"]') end
stimulus()
click to toggle source
Returns the question stimulus as an element.
@return [Element]
# File lib/kitchen/injected_question_element.rb, line 30 def stimulus first('div[data-type="question-stimulus"]') end