ExamSimple 1.0.0
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 +15 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Exam.gemspec +28 -0
- data/Gemfile +8 -0
- data/Guardfile +41 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/README.rdoc +0 -0
- data/Rakefile +24 -0
- data/doc/prct10.pdf +0 -0
- data/doc/prct11.pdf +0 -0
- data/doc/prct5.pdf +0 -0
- data/doc/prct6.pdf +0 -0
- data/doc/prct7.pdf +0 -0
- data/doc/prct8.pdf +0 -0
- data/doc/prct9.pdf +0 -0
- data/doc/test/index.html +467 -0
- data/html/Exam.html +316 -0
- data/html/Examui.html +230 -0
- data/html/List.html +469 -0
- data/html/Object.html +119 -0
- data/html/Question.html +357 -0
- data/html/README_rdoc.html +82 -0
- data/html/TrueOrFalse.html +169 -0
- data/html/created.rid +10 -0
- data/html/fonts.css +167 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +102 -0
- data/html/js/darkfish.js +140 -0
- data/html/js/jquery.js +18 -0
- data/html/js/navigation.js +142 -0
- data/html/js/search.js +109 -0
- data/html/js/search_index.js +1 -0
- data/html/js/searcher.js +228 -0
- data/html/rdoc.css +580 -0
- data/html/table_of_contents.html +159 -0
- data/lib/Exam.rb +2 -0
- data/lib/Exam/base.rb +5 -0
- data/lib/Exam/examen.rb +37 -0
- data/lib/Exam/examui.rb +27 -0
- data/lib/Exam/list.rb +106 -0
- data/lib/Exam/question.rb +44 -0
- data/lib/Exam/quiz.rb +52 -0
- data/lib/Exam/trueorfalse.rb +15 -0
- data/lib/Exam/version.rb +5 -0
- data/spec/Exam_spec.rb +392 -0
- data/spec/spec_helper.rb +98 -0
- metadata +226 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>Table of Contents - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link href="./fonts.css" rel="stylesheet">
|
10
|
+
<link href="./rdoc.css" rel="stylesheet">
|
11
|
+
|
12
|
+
<script type="text/javascript">
|
13
|
+
var rdoc_rel_prefix = "./";
|
14
|
+
</script>
|
15
|
+
|
16
|
+
<script src="./js/jquery.js"></script>
|
17
|
+
<script src="./js/navigation.js"></script>
|
18
|
+
<script src="./js/search_index.js"></script>
|
19
|
+
<script src="./js/search.js"></script>
|
20
|
+
<script src="./js/searcher.js"></script>
|
21
|
+
<script src="./js/darkfish.js"></script>
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" class="table-of-contents">
|
25
|
+
<main role="main">
|
26
|
+
<h1 class="class">Table of Contents - RDoc Documentation</h1>
|
27
|
+
|
28
|
+
<h2 id="pages">Pages</h2>
|
29
|
+
<ul>
|
30
|
+
<li class="file">
|
31
|
+
<a href="README_rdoc.html">README</a>
|
32
|
+
</li>
|
33
|
+
|
34
|
+
</ul>
|
35
|
+
|
36
|
+
<h2 id="classes">Classes and Modules</h2>
|
37
|
+
<ul>
|
38
|
+
<li class="class">
|
39
|
+
<a href="Exam.html">Exam</a>
|
40
|
+
</li>
|
41
|
+
<li class="class">
|
42
|
+
<a href="Examui.html">Examui</a>
|
43
|
+
</li>
|
44
|
+
<li class="class">
|
45
|
+
<a href="List.html">List</a>
|
46
|
+
</li>
|
47
|
+
<li class="class">
|
48
|
+
<a href="Object.html">Object</a>
|
49
|
+
</li>
|
50
|
+
<li class="class">
|
51
|
+
<a href="Question.html">Question</a>
|
52
|
+
</li>
|
53
|
+
<li class="class">
|
54
|
+
<a href="TrueOrFalse.html">TrueOrFalse</a>
|
55
|
+
</li>
|
56
|
+
</ul>
|
57
|
+
|
58
|
+
<h2 id="methods">Methods</h2>
|
59
|
+
<ul>
|
60
|
+
|
61
|
+
<li class="method">
|
62
|
+
<a href="Exam.html#method-c-new">::new</a>
|
63
|
+
—
|
64
|
+
<span class="container">Exam</span>
|
65
|
+
|
66
|
+
<li class="method">
|
67
|
+
<a href="Question.html#method-c-new">::new</a>
|
68
|
+
—
|
69
|
+
<span class="container">Question</span>
|
70
|
+
|
71
|
+
<li class="method">
|
72
|
+
<a href="Examui.html#method-c-new">::new</a>
|
73
|
+
—
|
74
|
+
<span class="container">Examui</span>
|
75
|
+
|
76
|
+
<li class="method">
|
77
|
+
<a href="List.html#method-c-new">::new</a>
|
78
|
+
—
|
79
|
+
<span class="container">List</span>
|
80
|
+
|
81
|
+
<li class="method">
|
82
|
+
<a href="TrueOrFalse.html#method-c-new">::new</a>
|
83
|
+
—
|
84
|
+
<span class="container">TrueOrFalse</span>
|
85
|
+
|
86
|
+
<li class="method">
|
87
|
+
<a href="Question.html#method-i-3C-3D-3E">#<=></a>
|
88
|
+
—
|
89
|
+
<span class="container">Question</span>
|
90
|
+
|
91
|
+
<li class="method">
|
92
|
+
<a href="Question.html#method-i-3D-3D">#==</a>
|
93
|
+
—
|
94
|
+
<span class="container">Question</span>
|
95
|
+
|
96
|
+
<li class="method">
|
97
|
+
<a href="Examui.html#method-i-compare">#compare</a>
|
98
|
+
—
|
99
|
+
<span class="container">Examui</span>
|
100
|
+
|
101
|
+
<li class="method">
|
102
|
+
<a href="List.html#method-i-each">#each</a>
|
103
|
+
—
|
104
|
+
<span class="container">List</span>
|
105
|
+
|
106
|
+
<li class="method">
|
107
|
+
<a href="List.html#method-i-invert">#invert</a>
|
108
|
+
—
|
109
|
+
<span class="container">List</span>
|
110
|
+
|
111
|
+
<li class="method">
|
112
|
+
<a href="List.html#method-i-inverter">#inverter</a>
|
113
|
+
—
|
114
|
+
<span class="container">List</span>
|
115
|
+
|
116
|
+
<li class="method">
|
117
|
+
<a href="List.html#method-i-pop">#pop</a>
|
118
|
+
—
|
119
|
+
<span class="container">List</span>
|
120
|
+
|
121
|
+
<li class="method">
|
122
|
+
<a href="List.html#method-i-push">#push</a>
|
123
|
+
—
|
124
|
+
<span class="container">List</span>
|
125
|
+
|
126
|
+
<li class="method">
|
127
|
+
<a href="Exam.html#method-i-push">#push</a>
|
128
|
+
—
|
129
|
+
<span class="container">Exam</span>
|
130
|
+
|
131
|
+
<li class="method">
|
132
|
+
<a href="Exam.html#method-i-right">#right</a>
|
133
|
+
—
|
134
|
+
<span class="container">Exam</span>
|
135
|
+
|
136
|
+
<li class="method">
|
137
|
+
<a href="Exam.html#method-i-to_s">#to_s</a>
|
138
|
+
—
|
139
|
+
<span class="container">Exam</span>
|
140
|
+
|
141
|
+
<li class="method">
|
142
|
+
<a href="Question.html#method-i-to_s">#to_s</a>
|
143
|
+
—
|
144
|
+
<span class="container">Question</span>
|
145
|
+
|
146
|
+
<li class="method">
|
147
|
+
<a href="List.html#method-i-to_s">#to_s</a>
|
148
|
+
—
|
149
|
+
<span class="container">List</span>
|
150
|
+
</ul>
|
151
|
+
</main>
|
152
|
+
|
153
|
+
|
154
|
+
<footer id="validator-badges" role="contentinfo">
|
155
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
156
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
|
157
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
158
|
+
</footer>
|
159
|
+
|
data/lib/Exam.rb
ADDED
data/lib/Exam/base.rb
ADDED
data/lib/Exam/examen.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'list'
|
3
|
+
|
4
|
+
|
5
|
+
#Clase para la gestión de examens con preguntas.
|
6
|
+
class Exam
|
7
|
+
attr_accessor :exam
|
8
|
+
|
9
|
+
#Creacion de una isntancia a partir de una pregunta.
|
10
|
+
def initialize(o)
|
11
|
+
@exam = List.new(o)
|
12
|
+
end
|
13
|
+
|
14
|
+
#Metodo to_s.
|
15
|
+
def to_s
|
16
|
+
"#{@exam}"
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
#Metodo para la inserción de preguntas sucesivamente.
|
21
|
+
def push(*input)
|
22
|
+
input.each { |o| @exam.push(o)}
|
23
|
+
input
|
24
|
+
end
|
25
|
+
|
26
|
+
#Metodo para obtener el conjunto de respuestas correctas asociadas a las respuestas.
|
27
|
+
def right
|
28
|
+
result = Array.new()
|
29
|
+
i=0
|
30
|
+
@exam.each do |q|
|
31
|
+
result[i] = q.r1
|
32
|
+
i += 1
|
33
|
+
end
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/Exam/examui.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'examen'
|
3
|
+
|
4
|
+
|
5
|
+
#Clase para la muestra de examenes con interfaz grafica.
|
6
|
+
class Examui
|
7
|
+
attr_accessor :examui
|
8
|
+
|
9
|
+
#inicialización de la instancia a partir de una pregunta.
|
10
|
+
def initialize(o)
|
11
|
+
@examui = Exam.new(o)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
#Comparacion de respuestas que se evaluan con la indicacion de cuales son correctas y cuales no.
|
16
|
+
def compare(useranswers)
|
17
|
+
right = @examui.right
|
18
|
+
comp = Array.new(right.count, false)
|
19
|
+
i = 0
|
20
|
+
while i < right.count do
|
21
|
+
comp[i] = (right[i].eql?useranswers[i])? true : false
|
22
|
+
i += 1
|
23
|
+
end
|
24
|
+
comp
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/Exam/list.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'question'
|
3
|
+
require 'trueorfalse'
|
4
|
+
|
5
|
+
#nodos
|
6
|
+
Node = Struct.new :value, :next, :prev
|
7
|
+
|
8
|
+
|
9
|
+
#Clase para las listas doblemente enlazadas
|
10
|
+
class List
|
11
|
+
|
12
|
+
attr_accessor :head, :tail
|
13
|
+
|
14
|
+
include Enumerable
|
15
|
+
|
16
|
+
#Inicializacion de una instancia de la clase Lista a partir de una Question pregunta).
|
17
|
+
def initialize (o)
|
18
|
+
raise TypeError, "Se esperaba que se pasara una pregunta como parámetro" unless o.instance_of? (Question)
|
19
|
+
@head = Node.new(o, nil,nil)
|
20
|
+
@tail = @head
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
#Metodo para extraer "por la cabeza" de la lista acutalmente.
|
25
|
+
def pop
|
26
|
+
raise IndexError, "La lista se encuentra vacía" unless @head.is_a? (Node)
|
27
|
+
aux = @head
|
28
|
+
|
29
|
+
if (@head == @tail)
|
30
|
+
@head = @tail = nil
|
31
|
+
aux.next = aux.prev = nil
|
32
|
+
else
|
33
|
+
@head = @head.next
|
34
|
+
@head.prev = nil
|
35
|
+
aux.next = aux.prev = nil
|
36
|
+
end
|
37
|
+
aux.value
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
#Metodo para instertar varias preguntas sucesivamente
|
42
|
+
def push (*input)
|
43
|
+
input.each do |x|
|
44
|
+
if @head == nil
|
45
|
+
@head = @tail = Node.new(x, nil, nil)
|
46
|
+
else
|
47
|
+
aux = Node.new(x, nil, nil)
|
48
|
+
@tail.next = aux
|
49
|
+
aux.prev = @tail
|
50
|
+
@tail = @tail.next
|
51
|
+
@tail.value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
input
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
#Metodo to_s
|
59
|
+
def to_s
|
60
|
+
aux = @head
|
61
|
+
s = ' '
|
62
|
+
i = 1
|
63
|
+
while (aux != nil) do
|
64
|
+
s += "#{i}) #{aux.value}\n"
|
65
|
+
aux = aux.next
|
66
|
+
i += 1
|
67
|
+
end
|
68
|
+
s
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
#Metodo para le manejo de metodos del modulo Enumerable
|
74
|
+
def each
|
75
|
+
aux =@head
|
76
|
+
while (aux != nil) do
|
77
|
+
yield aux.value
|
78
|
+
aux = aux.next
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
#Metodo que devuelve la lista actual invertida.
|
85
|
+
def inverter (&block)
|
86
|
+
block = ->(x) {true} if !block_given?
|
87
|
+
list = invert(@head, &block)
|
88
|
+
list.pop
|
89
|
+
return nil if list.count == 0
|
90
|
+
list
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
#Metodo auxiliar que se utiliza para invertir la lista (recursividad).
|
95
|
+
def invert(actual, &block)
|
96
|
+
return List.new(Question.new(:qt => "dummy", :r1 => "dummy", :wrong => ["dummy"])) if (actual == nil)
|
97
|
+
list = invert(actual.next, &block)
|
98
|
+
list.push(actual.value) if block[actual.value]
|
99
|
+
list
|
100
|
+
end
|
101
|
+
|
102
|
+
private :invert
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
#Clase para la gestion de preguntas de multiples opciones.
|
4
|
+
class Question
|
5
|
+
attr_accessor :qt, :r1, :wrong, :difficulty
|
6
|
+
|
7
|
+
#Se incluye el método Comparable
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
def <=>(other)
|
11
|
+
@difficulty <=> other.difficulty
|
12
|
+
end
|
13
|
+
|
14
|
+
def ==(other)
|
15
|
+
@qt.eql?other.qt
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
#Inicializacion de una nueva instancia de una nueva pregunta a partir de un texto.
|
20
|
+
def initialize (args)
|
21
|
+
@qt = args[:qt]
|
22
|
+
raise ArgumentError, "Se esperaba una pregunta" unless args.key?(:qt)
|
23
|
+
@r1 = args[:r1]
|
24
|
+
raise ArgumentError, "Se esperaba la respuesta correcta" unless args.key?(:r1)
|
25
|
+
@wrong = args[:wrong]
|
26
|
+
raise ArgumentError, "Se esperaba un array con las respuestas incorrectas" unless args.key?(:wrong)
|
27
|
+
args.has_key?(:difficulty)? (@difficulty = args[:difficulty]) : (@difficulty = 1)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
#Metodo to_s.
|
32
|
+
def to_s
|
33
|
+
s = "#{@qt}\n"
|
34
|
+
opt = [@r1] + @wrong
|
35
|
+
opt = opt.shuffle
|
36
|
+
i = 1
|
37
|
+
opt.each do |o|
|
38
|
+
s += "#{i}- #{o}\n"
|
39
|
+
i += 1
|
40
|
+
end
|
41
|
+
s
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/Exam/quiz.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
require 'examen'
|
3
|
+
class Quiz
|
4
|
+
|
5
|
+
attr_accessor :name, :counter, :exam
|
6
|
+
|
7
|
+
def initialize(name, &block)
|
8
|
+
@name = name
|
9
|
+
@exam = Exam.new(Question.new(:qt => "-", :r1 => "-", :wrong => ["-"]))
|
10
|
+
@exam.exam.pop
|
11
|
+
@counter = 0
|
12
|
+
instance_eval &block
|
13
|
+
end
|
14
|
+
|
15
|
+
def right
|
16
|
+
:right
|
17
|
+
end
|
18
|
+
|
19
|
+
def wrong
|
20
|
+
@counter += 1
|
21
|
+
[:wrong, @counter]
|
22
|
+
end
|
23
|
+
|
24
|
+
def question(*args)
|
25
|
+
wrong = Array.new
|
26
|
+
args[1].keys.each { |x| wrong << args[1][x] if x.instance_of?(Array)}
|
27
|
+
@exam.push(Question.new(:qt => args[0], :r1 => args[1][:right], :wrong => wrong))
|
28
|
+
@exam
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
"\t#{@name}\n\n#{@exam}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def run
|
36
|
+
puts "#{@name}\n\n"
|
37
|
+
punt = 0
|
38
|
+
right = @exam.right
|
39
|
+
userans = Array.new(right.count, false)
|
40
|
+
@exam.exam.each_with_index do |x, i|
|
41
|
+
puts x
|
42
|
+
print "Su respuesta es: "
|
43
|
+
STDOUT.flush
|
44
|
+
if right[i].to_s.eql?gets.chomp
|
45
|
+
punt += 1
|
46
|
+
end
|
47
|
+
puts "\n"
|
48
|
+
end
|
49
|
+
puts "Ha acertado #{punt} de #{right.count}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'question'
|
2
|
+
|
3
|
+
|
4
|
+
#Clase de gestion de preguntar True or False.
|
5
|
+
class TrueOrFalse < Question
|
6
|
+
|
7
|
+
#Inicializacion de la isntancia de la clase TrueOrFalse al cual se le pasa un texto para la pregunta y un booleano para la respuesta.
|
8
|
+
def initialize (args)
|
9
|
+
raise ArgumentError,"Se esperaba una pregunta" unless args.key?(:qt)
|
10
|
+
raise ArgumentError,"Se esperaba la pregunta correcta" unless args.key?(:r1)
|
11
|
+
args[:r1] = (args[:r1] ? "Cierto" : "Falso")
|
12
|
+
args[:wrong] = [(args[:r1] ? "Falso" : "Cierto")]
|
13
|
+
super(args)
|
14
|
+
end
|
15
|
+
end
|