class Questions::TextArea

Public Class Methods

new(index, question_json) click to toggle source
# File lib/erik-text-area.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-area.rb, line 24
def self.schema
  {
    "properties": {
      "question": {
        "type": "string"
      },
      "type": {
        "type": "string",
        "pattern": "^text-area$"
      },
      "answer": {
        "type": "string"
      }
    },
    "required": [
      "question",
      "type",
      "answer"
    ],
    "additionalProperties": false
  }
end

Public Instance Methods

mark(answer) click to toggle source
# File lib/erik-text-area.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-area.rb, line 11
def name
  @text
end
to_html() click to toggle source
# File lib/erik-text-area.rb, line 20
def to_html
  %(<textarea name="q-#{@index}"></textarea>)
end