class Questions::TextBox
Public Class Methods
new(index, question_json)
click to toggle source
# File lib/erik-text-box.rb, line 5 def initialize(index, question_json) @index = index @text = question_json['question'] @answer = question_json['answer'] end
schema()
click to toggle source
# File lib/erik-text-box.rb, line 24 def self.schema { "properties": { "question": { "type": "string" }, "type": { "type": "string", "pattern": "^text-box$" }, "answer": { "type": "string" } }, "required": [ "question", "type", "answer" ], "additionalProperties": false } end
Public Instance Methods
mark(answer)
click to toggle source
# File lib/erik-text-box.rb, line 15 def mark(answer) correct = answer && (answer.strip == @answer.strip) QuestionFeedback.new(correct, correct ? nil : %(The correct answer was "#{@answer}".)) end
name()
click to toggle source
# File lib/erik-text-box.rb, line 11 def name @text end
to_html()
click to toggle source
# File lib/erik-text-box.rb, line 20 def to_html %(<input type="text" name="q-#{@index}" />) end