examLPP 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -0
- data/Guardfile +70 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/coverage/.last_run.json +5 -0
- data/coverage/.resultset.json +714 -0
- data/doc/Exam.html +112 -0
- data/doc/Examen.html +319 -0
- data/doc/Gemfile.html +101 -0
- data/doc/Gemfile_lock.html +186 -0
- data/doc/Guardfile.html +169 -0
- data/doc/LICENSE_txt.html +116 -0
- data/doc/Lista.html +472 -0
- data/doc/Nodo.html +264 -0
- data/doc/Object.html +119 -0
- data/doc/Pregunta.html +346 -0
- data/doc/PreguntaS.html +338 -0
- data/doc/PreguntaVF.html +210 -0
- data/doc/README_md.html +120 -0
- data/doc/Rakefile.html +99 -0
- data/doc/created.rid +18 -0
- data/doc/exam_gemspec.html +127 -0
- data/doc/fonts.css +167 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +118 -0
- data/doc/js/darkfish.js +140 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +109 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +580 -0
- data/doc/table_of_contents.html +222 -0
- data/exam.gemspec +32 -0
- data/lib/exam.rb +12 -0
- data/lib/exam/examen.rb +69 -0
- data/lib/exam/lista.rb +109 -0
- data/lib/exam/nodo.rb +14 -0
- data/lib/exam/pregunta.rb +38 -0
- data/lib/exam/preguntaMadre.rb +47 -0
- data/lib/exam/preguntaVF.rb +19 -0
- data/lib/exam/quiz.rb +44 -0
- data/lib/exam/version.rb +3 -0
- data/pkg/exam-0.0.1.gem +0 -0
- data/spec/exam_spec.rb +353 -0
- data/spec/spec_helper.rb +22 -0
- metadata +226 -0
data/lib/exam/nodo.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#Pregunta de respuesta múltiple
|
3
|
+
class PreguntaS < Pregunta
|
4
|
+
|
5
|
+
attr_reader :re
|
6
|
+
|
7
|
+
#Constructor
|
8
|
+
def initialize (pregunta, dificultad = 5)
|
9
|
+
super
|
10
|
+
@re = Array.new(0)
|
11
|
+
#inicializamos un array con 0 elementos para las respuestas
|
12
|
+
end
|
13
|
+
|
14
|
+
#Método que devuelve la pregunta como String
|
15
|
+
def preg
|
16
|
+
"Pregunta: #{@pr}"
|
17
|
+
end
|
18
|
+
|
19
|
+
#Agrega una respuesta adicional a la pregunta
|
20
|
+
def addr (respuesta)
|
21
|
+
@re.push(respuesta)
|
22
|
+
end
|
23
|
+
|
24
|
+
#Devuelve las respuestas como String
|
25
|
+
def resp
|
26
|
+
respuestas = ""
|
27
|
+
for i in (0..(@re.length - 1))
|
28
|
+
respuestas += "#{i+1}) #{@re[i]}\n"
|
29
|
+
end
|
30
|
+
respuestas
|
31
|
+
end
|
32
|
+
|
33
|
+
#Muestra la pregunta y sus posibles respuestas como una String
|
34
|
+
def to_s
|
35
|
+
preg + "\n\n" + resp
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
#Clase base de las preguntas. No contiene respuestas.
|
4
|
+
class Pregunta
|
5
|
+
attr_reader :pr, :df
|
6
|
+
attr_accessor :correcta
|
7
|
+
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
#Método constructor
|
11
|
+
def initialize(pregunta, dificultad)
|
12
|
+
@pr = pregunta
|
13
|
+
@df = dificultad
|
14
|
+
@correcta = nil #debe modificarse; int que refiere a pos en Array de pr.
|
15
|
+
end
|
16
|
+
|
17
|
+
#Método de comparación (se fija en la dificultad)
|
18
|
+
def <=> (other)
|
19
|
+
@df <=> other.df
|
20
|
+
end
|
21
|
+
|
22
|
+
#Evitamos que se consideren iguales dos preguntas cualquiera
|
23
|
+
#sólo porque tengan la misma dificultad.
|
24
|
+
#Esto es una sobrecarga del método de comparación.
|
25
|
+
def == (other)
|
26
|
+
@pr == other.pr && @df == other.df
|
27
|
+
end
|
28
|
+
|
29
|
+
#Método que contrasta la respuesta entregada (por parámetro)
|
30
|
+
#con el atributo que señala la respuesta correcta.
|
31
|
+
def resp_correcta?(resp)
|
32
|
+
if resp.to_i != 0
|
33
|
+
#sera numero, lo pasamos a int.
|
34
|
+
resp = resp.to_i
|
35
|
+
else
|
36
|
+
#sera String, admitimos mayus y minus.
|
37
|
+
resp.upcase!
|
38
|
+
end
|
39
|
+
|
40
|
+
if resp == @correcta
|
41
|
+
true
|
42
|
+
else
|
43
|
+
false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
#Pregunta de verdadero o falso
|
4
|
+
class PreguntaVF < Pregunta
|
5
|
+
#Método de inicialización
|
6
|
+
def initialize(pregunta, dificultad = 5, correcta = "v")
|
7
|
+
super(pregunta, dificultad)
|
8
|
+
@correcta = correcta
|
9
|
+
end
|
10
|
+
|
11
|
+
#Método para mostrar la pregunta con sus respuestas
|
12
|
+
#en formato String
|
13
|
+
def to_s
|
14
|
+
string = ''
|
15
|
+
string += @pr
|
16
|
+
string += "\nVerdadero"
|
17
|
+
string += "\nFalso"
|
18
|
+
end
|
19
|
+
end
|
data/lib/exam/quiz.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class Quiz
|
2
|
+
|
3
|
+
def initialize (&block)
|
4
|
+
@lista = Lista.new()
|
5
|
+
|
6
|
+
if block_given?
|
7
|
+
if block.arity == 1
|
8
|
+
yield self
|
9
|
+
else
|
10
|
+
instance_eval &block
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
@examen = Examen.new(@lista)
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
@examen.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def questionS (pregunta, respuesta = {})
|
22
|
+
preg = PreguntaS.new(pregunta)
|
23
|
+
count = 1
|
24
|
+
respuesta.each do |key, val|
|
25
|
+
preg.addr(val)
|
26
|
+
if key
|
27
|
+
count += 1
|
28
|
+
else
|
29
|
+
preg.correcta = count
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
@lista.addn(preg)
|
34
|
+
end
|
35
|
+
|
36
|
+
def questionVF (pregunta, respuesta)
|
37
|
+
preg = PreguntaVF.new(pregunta)
|
38
|
+
|
39
|
+
preg.correcta = respuesta
|
40
|
+
|
41
|
+
@lista.addn(preg)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/exam/version.rb
ADDED
data/pkg/exam-0.0.1.gem
ADDED
Binary file
|
data/spec/exam_spec.rb
ADDED
@@ -0,0 +1,353 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "exam"
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Exam do
|
6
|
+
before :all do
|
7
|
+
@p1 = PreguntaS.new("¿Pregunta?", 5)
|
8
|
+
@p1.addr("Si.")
|
9
|
+
@p1.addr("No.")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'Seleccion simple' do
|
13
|
+
it 'Debe existir una pregunta.' do
|
14
|
+
expect(@p1.pr).to eq("¿Pregunta?")
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'Debe existir un metodo para obtener la pregunta.' do
|
18
|
+
expect(@p1.preg).to eq("Pregunta: ¿Pregunta?")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'Deben existir opciones de respuesta(introducir respuesta).' do
|
22
|
+
|
23
|
+
expect(@p1.re).not_to be_empty
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'Se debe invocar a un metodo para obtener las opciones de respuesta.' do
|
27
|
+
|
28
|
+
expect(@p1.resp).to eq("1) Si.\n2) No.\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'Se debe mostrar por consola la pregunta y las opciones de respuesta.' do
|
32
|
+
expect(@p1.to_s).to eq("Pregunta: ¿Pregunta?\n\n1) Si.\n2) No.\n")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
it 'Prueba relacion de preguntas' do
|
38
|
+
|
39
|
+
@p1 = PreguntaS.new("Cual es la salida del siguiente codigo Ruby?", 5)
|
40
|
+
@p1.addr("<#Xyz:0xa000208>")
|
41
|
+
@p1.addr("nil")
|
42
|
+
@p1.addr("0")
|
43
|
+
@p1.addr("Ninguna de las anteriores")
|
44
|
+
|
45
|
+
@p2 = PreguntaS.new("La siguiente definicion de un hash en ruby es valida:\nhash_raro = {\n[1,2,3] => Object.new(),\nHash.new => :toto", 5)
|
46
|
+
@p2.addr("Cierto")
|
47
|
+
@p2.addr("Falso")
|
48
|
+
|
49
|
+
@p3 = PreguntaS.new("Cual es la salida del siguiente codigo Ruby?", 5)
|
50
|
+
@p3.addr("1")
|
51
|
+
@p3.addr("bob")
|
52
|
+
@p3.addr("HEY")
|
53
|
+
@p3.addr("Ninguna de las anteriores")
|
54
|
+
|
55
|
+
@p4 = PreguntaS.new("Cual es el tipo de objeto en el siguiente codigo Ruby?\nclass Objeto\nend", 5)
|
56
|
+
@p4.addr("Una instancia de la clase Class")
|
57
|
+
@p4.addr("Una constante")
|
58
|
+
@p4.addr("Un objeto")
|
59
|
+
@p4.addr("Ninguna de las anteriores")
|
60
|
+
|
61
|
+
@p5 = PreguntaS.new("Es apropiado que una clase Tablero herede de una clase Juego", 5)
|
62
|
+
@p5.addr("Verdadero")
|
63
|
+
@p5.addr("Falso")
|
64
|
+
|
65
|
+
@n1 = Nodo.new(@p1)
|
66
|
+
@n2 = Nodo.new(@p2)
|
67
|
+
@n3 = Nodo.new(@p3)
|
68
|
+
@n4 = Nodo.new(@p4)
|
69
|
+
@n5 = Nodo.new(@p5)
|
70
|
+
|
71
|
+
@lista = Lista.new()
|
72
|
+
@lista.addn(@n1)
|
73
|
+
@lista.addn(@n2)
|
74
|
+
@lista.addn(@n3)
|
75
|
+
@lista.addn(@n4)
|
76
|
+
@lista.addn(@n5)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
describe Exam do
|
82
|
+
describe 'Lista' do
|
83
|
+
|
84
|
+
before :each do
|
85
|
+
@lista = Lista.new()
|
86
|
+
@n1 = Nodo.new("Nodo 1")
|
87
|
+
@n2 = Nodo.new("Nodo 2")
|
88
|
+
@n3 = Nodo.new("Nodo 3")
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'Debe ser posible insertar nodos en la lista.' do
|
92
|
+
@lista.addn(@n1)
|
93
|
+
expect(@lista.head).to eq(@n1)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'Se pueden insertar varios elementos.' do
|
97
|
+
@lista.addn(@n1)
|
98
|
+
@lista.addn(@n2)
|
99
|
+
expect(@lista.head).to eq(@n2)
|
100
|
+
@lista.deln
|
101
|
+
expect(@lista.head).to eq(@n1)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'Se extrae el primer elemento de la lista.' do
|
105
|
+
@lista.addn(@n1)
|
106
|
+
@lista.addn(@n2)
|
107
|
+
@lista.deln
|
108
|
+
expect(@lista.head).to eq(@n1)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'Cada nodo apunta a su siguiente y su anterior' do
|
112
|
+
@lista.addn(@n1)
|
113
|
+
@lista.addn(@n2)
|
114
|
+
@lista.addn(@n3)
|
115
|
+
expect(@lista.head).to eq(@n3)
|
116
|
+
expect(@lista.head.next).to eq(@n2)
|
117
|
+
extra = Nodo.new("EXTRA")
|
118
|
+
@lista.addn(extra)
|
119
|
+
expect(@lista.head).to eq(extra)
|
120
|
+
expect(@lista.tail).to eq(@n1)
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'Cada nodo apunta a su siguiente, desde head' do
|
125
|
+
@lista.addn(@n1)
|
126
|
+
@lista.addn(@n2)
|
127
|
+
@lista.addn(@n3)
|
128
|
+
extra = Nodo.new("EXTRA")
|
129
|
+
@lista.addn(extra)
|
130
|
+
expect(@lista.head).to eq(extra)
|
131
|
+
expect(@lista.head.next).to eq(@n3)
|
132
|
+
expect(@lista.head.next.next).to eq(@n2)
|
133
|
+
expect(@lista.head.next.next.next).to eq(@n1)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'Cada nodo apunta a su anterior, desde tail' do
|
137
|
+
@lista.addn(@n1)
|
138
|
+
@lista.addn(@n2)
|
139
|
+
@lista.addn(@n3)
|
140
|
+
extra = Nodo.new("EXTRA")
|
141
|
+
@lista.addn(extra)
|
142
|
+
expect(@lista.tail.previus.previus.previus).to eq(extra)
|
143
|
+
expect(@lista.tail.previus.previus).to eq(@n3)
|
144
|
+
expect(@lista.tail.previus).to eq(@n2)
|
145
|
+
expect(@lista.tail).to eq(@n1)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'Prueba de pregunta VF' do
|
149
|
+
@pregunta = PreguntaVF.new("Esto es una pregunta?", 5, "Verdadero")
|
150
|
+
expect(@pregunta.to_s).to eq("Esto es una pregunta?\nVerdadero\nFalso")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe 'Exam practica 8: ' do
|
155
|
+
before :each do
|
156
|
+
@D5 = PreguntaS.new("Dificultad5", 5)
|
157
|
+
@D5_2 = PreguntaS.new("Dificultad5", 5)
|
158
|
+
|
159
|
+
@D2 = PreguntaS.new("Dificultad2", 2)
|
160
|
+
end
|
161
|
+
|
162
|
+
describe 'Comparable: ' do
|
163
|
+
it "Pregunta D5 debe ser mayor que pregunta D2" do
|
164
|
+
expect(@D5 > @D2).to eq(true)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "Pregunta D2 debe ser menor que pregunta D5" do
|
168
|
+
expect(@D2 < @D5).to eq(true)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "Pregunta D5 debe ser igual que pregunta D5_2" do
|
172
|
+
expect(@D5 == @D5_2).to eq(true)
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
describe 'Enumerable: ' do
|
177
|
+
|
178
|
+
before :all do
|
179
|
+
|
180
|
+
@p1 = PreguntaS.new("Cual es la salida del siguiente codigo Ruby?", 3)
|
181
|
+
@p1.addr("<#Xyz:0xa000208>")
|
182
|
+
@p1.addr("nil")
|
183
|
+
@p1.addr("0")
|
184
|
+
@p1.addr("Ninguna de las anteriores")
|
185
|
+
|
186
|
+
@p2 = PreguntaS.new("ZLa siguiente definicion de un hash en ruby es valida:\nhash_raro = {\n[1,2,3] => Object.new(),\nHash.new => :toto", 2)
|
187
|
+
@p2.addr("Cierto")
|
188
|
+
@p2.addr("Falso")
|
189
|
+
|
190
|
+
@p3 = PreguntaS.new("Cual es la salida del siguiente codigo Ruby?", 4)
|
191
|
+
@p3.addr("1")
|
192
|
+
@p3.addr("bob")
|
193
|
+
@p3.addr("HEY")
|
194
|
+
@p3.addr("Ninguna de las anteriores")
|
195
|
+
|
196
|
+
@p4 = PreguntaS.new("Cual es el tipo de objeto en el siguiente codigo Ruby?\nclass Objeto\nend", 9)
|
197
|
+
@p4.addr("Una instancia de la clase Class")
|
198
|
+
@p4.addr("Una constante")
|
199
|
+
@p4.addr("Un objeto")
|
200
|
+
@p4.addr("Ninguna de las anteriores")
|
201
|
+
|
202
|
+
@p5 = PreguntaVF.new("Es apropiado que una clase Tablero herede de una clase Juego", 5)
|
203
|
+
|
204
|
+
@n1 = Nodo.new(@p1)
|
205
|
+
@n2 = Nodo.new(@p2)
|
206
|
+
@n3 = Nodo.new(@p3)
|
207
|
+
@n4 = Nodo.new(@p4)
|
208
|
+
@n5 = Nodo.new(@p5)
|
209
|
+
|
210
|
+
@lista = Lista.new()
|
211
|
+
@lista.addn(@n1)
|
212
|
+
@lista.addn(@n2)
|
213
|
+
@lista.addn(@n3)
|
214
|
+
@lista.addn(@n4)
|
215
|
+
@lista.addn(@n5)
|
216
|
+
end
|
217
|
+
|
218
|
+
it "La lista es enumerable" do
|
219
|
+
string = ""
|
220
|
+
@lista.each do |l|
|
221
|
+
string << "test"
|
222
|
+
string << "\n"
|
223
|
+
end
|
224
|
+
expect(string).to eq("test\n"*5)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "Cuenta los elementos de la lista" do
|
228
|
+
expect(@lista.count).to eq(5)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "Drop" do
|
232
|
+
expect(@lista.drop(5)).to eq([])
|
233
|
+
end
|
234
|
+
|
235
|
+
it "Find index" do
|
236
|
+
expect(@lista.find_index {|i| i.value == @n3.value}).to eq(2)
|
237
|
+
end
|
238
|
+
|
239
|
+
it "Maximo" do
|
240
|
+
expect(@lista.max).to eq(@n4)
|
241
|
+
end
|
242
|
+
|
243
|
+
it "Minimo" do
|
244
|
+
expect(@lista.min).to eq(@n2)
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe 'Exam Practica9' do
|
251
|
+
before :all do
|
252
|
+
@p1 = PreguntaS.new("Cuanto es 7*3?", 3)
|
253
|
+
@p1.addr("16")
|
254
|
+
@p1.addr("21")
|
255
|
+
@p1.addr("33")
|
256
|
+
@p1.addr("15")
|
257
|
+
@p1.correcta = 2
|
258
|
+
|
259
|
+
@p2 = PreguntaVF.new("¿La siguiente definicion de un hash en ruby es valida?:\nhash_raro = {\n[1,2,3] => Object.new(),\nHash.new => :toto", 2)
|
260
|
+
@p2.correcta = 'F'
|
261
|
+
|
262
|
+
@p3 = PreguntaS.new("Cual es la salida del siguiente codigo Ruby? puts 'bob'", 4)
|
263
|
+
@p3.addr("1")
|
264
|
+
@p3.addr("bob")
|
265
|
+
@p3.addr("HEY")
|
266
|
+
@p3.addr("Ninguna de las anteriores")
|
267
|
+
@p3.correcta = 1
|
268
|
+
|
269
|
+
@p4 = PreguntaS.new("Cual es el tipo de objeto en el siguiente codigo Ruby?\nclass Objeto\nend", 9)
|
270
|
+
@p4.addr("Una instancia de la clase Class")
|
271
|
+
@p4.addr("Una constante")
|
272
|
+
@p4.addr("Un objeto")
|
273
|
+
@p4.addr("Ninguna de las anteriores")
|
274
|
+
@p4.correcta = 3
|
275
|
+
|
276
|
+
@p5 = PreguntaVF.new("Es apropiado que una clase Tablero herede de una clase Juego", 1)
|
277
|
+
@p5.correcta = 'V'
|
278
|
+
|
279
|
+
@n1 = Nodo.new(@p1)
|
280
|
+
@n2 = Nodo.new(@p2)
|
281
|
+
@n3 = Nodo.new(@p3)
|
282
|
+
@n4 = Nodo.new(@p4)
|
283
|
+
@n5 = Nodo.new(@p5)
|
284
|
+
@lista = Lista.new()
|
285
|
+
@lista.addn(@n1)
|
286
|
+
@lista.addn(@n2)
|
287
|
+
@lista.addn(@n3)
|
288
|
+
@lista.addn(@n4)
|
289
|
+
@lista.addn(@n5)
|
290
|
+
end
|
291
|
+
|
292
|
+
it "¿Se puede ordenar una lista?" do
|
293
|
+
@lista.ordenar
|
294
|
+
expect(@lista.head).to eq(@n5)
|
295
|
+
expect(@lista.head.next).to eq(@n2)
|
296
|
+
expect(@lista.head.next.next).to eq(@n1)
|
297
|
+
expect(@lista.head.next.next.next).to eq(@n3)
|
298
|
+
expect(@lista.tail).to eq(@n4)
|
299
|
+
end
|
300
|
+
|
301
|
+
it "Clase examen, muestra las preguntas en orden" do
|
302
|
+
exam = Examen.new(@lista)
|
303
|
+
expect(exam.to_s).to eq(@p5.to_s+"\n"+@p2.to_s+"\n"+@p1.to_s+"\n"+@p3.to_s+"\n"+@p4.to_s+"\n")
|
304
|
+
|
305
|
+
end
|
306
|
+
|
307
|
+
it "Existe y se puede modificar la respuesta correcta" do
|
308
|
+
expect(@p1.resp_correcta?("2")).to eq(true)
|
309
|
+
expect(@p1.resp_correcta?("3")).to eq(false)
|
310
|
+
@p1.correcta = 3
|
311
|
+
expect(@p1.resp_correcta?("2")).to eq(false)
|
312
|
+
expect(@p1.resp_correcta?("3")).to eq(true)
|
313
|
+
@p1.correcta = 2 #le devolvemos su valor para que no de error la prueba hacer_examen
|
314
|
+
end
|
315
|
+
|
316
|
+
it "Probando hacer_examen" do
|
317
|
+
examen = Examen.new(@lista)
|
318
|
+
resps = ['v','f','2','1','3']
|
319
|
+
expect(examen.hacer_examen(resps)).to eq(5)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "Practica 10: invertir orden" do
|
323
|
+
examen = Examen.new(@lista)
|
324
|
+
expect(examen.inverso).to eq(@p4.to_s+"\n"+@p3.to_s+"\n"+@p1.to_s+"\n"+@p2.to_s+"\n"+@p5.to_s+"\n")
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
it "Practica 11: DSL" do
|
329
|
+
listilla = Lista.new()
|
330
|
+
preg1 = PreguntaS.new("5+4")
|
331
|
+
preg2 = PreguntaVF.new("1+1=2?")
|
332
|
+
preg1.addr("7")
|
333
|
+
preg1.addr("5")
|
334
|
+
preg1.addr("9")
|
335
|
+
preg1.correcta = 3
|
336
|
+
preg2.correcta = "V"
|
337
|
+
listilla.addn(preg1)
|
338
|
+
listilla.addn(preg2)
|
339
|
+
examen = Examen.new(listilla)
|
340
|
+
|
341
|
+
quiz = Quiz.new do
|
342
|
+
questionS "5+4",
|
343
|
+
:wrong => "7",
|
344
|
+
:wrong => "5",
|
345
|
+
:right => "9"
|
346
|
+
questionVF "1+1=2?",
|
347
|
+
"V"
|
348
|
+
end
|
349
|
+
|
350
|
+
expect(examen.to_s).to eq(quiz.to_s)
|
351
|
+
end
|
352
|
+
|
353
|
+
end
|