class Exam::Test

create a Test

Attributes

correcta[RW]
nivel[RW]
pregunta[RW]
respuestas[RW]

Public Class Methods

new(pregunta, correcta, respuestas, nivel=nil) click to toggle source
# File lib/exam/test.rb, line 17
def initialize(pregunta, correcta, respuestas, nivel=nil)
  @pregunta = pregunta
  @correcta = correcta
  @respuestas = respuestas.shuffle
  @nivel = nivel
end

Public Instance Methods

<=>(a) click to toggle source
# File lib/exam/test.rb, line 9
def <=> (a)
  @nivel <=> a.nivel
end
==(a) click to toggle source
# File lib/exam/test.rb, line 13
def == (a)
  @pregunta==a.pregunta && @correcta==a.correcta && @respuestas.should =~ a.respuestas
end
check_ans(c) click to toggle source
# File lib/exam/test.rb, line 24
def check_ans(c)
  return (c == @correcta)
end
to_s() click to toggle source
# File lib/exam/test.rb, line 28
def to_s
  texto = "Pregunta: #{@pregunta} \n"
  for i in 0..@respuestas.size-1
    texto = texto + "\t #{i+1}) #{@respuestas[i]} \n"
  end
  return texto
end