simpleselect 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad46eb28d9d8820a8ef71d530271be9e3151c591
4
+ data.tar.gz: f00c8840d05ef7564ef7b9ed926fb9e70d454979
5
+ SHA512:
6
+ metadata.gz: d2246d523292b7d6bf3cdaac086c69262a21329d4856eed1e53cb5a55d72abdbe7a292f3f2067a225023fe6e05b45d761b91253baf368e8c00a232767bf565dd
7
+ data.tar.gz: 7b596f3fb7cf3bb47b4ed34bcd1b5c6cd987df9489e2909e65c50a652d52c9001dbdea149fc2160222e95ba6a2e71b154c7db04a92a465529653d53cd899cdd7
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-18mode # JRuby in 1.8 mode
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ - 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simpleselect.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,39 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :bundler do
5
+ watch('Gemfile')
6
+ # Uncomment next line if your Gemfile contains the `gemspec' command.
7
+ # watch(/^.+\.gemspec/)
8
+ end
9
+
10
+ # Note: The cmd option is now required due to the increasing number of ways
11
+ # rspec may be run, below are examples of the most common uses.
12
+ # * bundler: 'bundle exec rspec'
13
+ # * bundler binstubs: 'bin/rspec'
14
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
15
+ # installed the spring binstubs per the docs)
16
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
17
+ # * 'just' rspec: 'rspec'
18
+ guard :rspec, cmd: 'bundle exec rspec' do
19
+ watch(%r{^spec/.+_spec\.rb$})
20
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
21
+ watch('spec/spec_helper.rb') { "spec" }
22
+
23
+ # Rails example
24
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
25
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
26
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
27
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
28
+ watch('config/routes.rb') { "spec/routing" }
29
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
30
+ watch('spec/rails_helper.rb') { "spec" }
31
+
32
+ # Capybara features specs
33
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
34
+
35
+ # Turnip features and steps
36
+ watch(%r{^spec/acceptance/(.+)\.feature$})
37
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
38
+ end
39
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 alu0100764666
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Simpleselect
2
+ * Coordinador:Javier Martín Hernández
3
+ * Colaborador: Sabato Ceruso
4
+ *
5
+ Clase para representar pregunta de seleccion simple de examen
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'simpleselect'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install simpleselect
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/simpleselect/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
34
+
35
+ [![Coverage Status](https://img.shields.io/coveralls/alu0100777758/prct9.svg)](https://coveralls.io/r/alu0100777758/prct9)
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :spec
4
+ desc "Ejecutar las espectativas de la clase simpleselect"
5
+ task :spec do
6
+ sh "rspec -I. spec/simpleSelect_spec.rb"
7
+ sh "rspec -I. spec/listNode_spec.rb"
8
+ sh "rspec -I. spec/examen_spec.rb"
9
+ sh "rspec -I. spec/interface_spec.rb"
10
+ sh "rspec -I. spec/quiz_spect.rb"
11
+ end
12
+ task :examen do
13
+ sh "ruby -I. spec/examen_interfaz.rb"
14
+ end
15
+ task :prct11 do
16
+ sh "rspec -I. spec/quiz_spect.rb"
17
+ end
@@ -0,0 +1,12 @@
1
+ require "simpleselect/version"
2
+ require "simpleselect/pregunta"
3
+ require "simpleselect/simpleSelect"
4
+ require "simpleselect/listNode"
5
+ require "simpleselect/list"
6
+ require "simpleselect/tof"
7
+ require "simpleselect/examen"
8
+ require "simpleselect/interface"
9
+ require "simpleselect/quiz"
10
+ module Simpleselect
11
+ # Your code goes here...
12
+ end
@@ -0,0 +1,20 @@
1
+ require "simpleselect/list.rb"
2
+ require "simpleselect/tof.rb"
3
+ require "simpleselect/simpleSelect.rb"
4
+
5
+ class Examen
6
+ attr_reader :preguntas, :respuestas, :n
7
+
8
+ def initialize(pregs, resp, n)
9
+ @preguntas, @respuestas, @n = pregs, resp, n
10
+ end
11
+
12
+ def compara_resp (indx, resp)
13
+ a = false
14
+ if @respuestas[indx].to_s == resp
15
+ a = true
16
+ end
17
+ a
18
+ end
19
+
20
+ end
@@ -0,0 +1,42 @@
1
+ require "simpleselect/examen.rb"
2
+
3
+ class Interface<Examen
4
+ def comenzar
5
+ @pos=0
6
+ @puntuacion=0
7
+ for cuestion in @preguntas.headToTail do
8
+ puts cuestion
9
+ print "\e[96m Su respuesta: "
10
+ loop do
11
+ @eleccion = gets.chomp.downcase[0]
12
+ if (@eleccion == nil)then
13
+ puts "Por favor introduzca una opcion valida"
14
+ else break
15
+ end
16
+ end
17
+ puts "\e[39m"
18
+ if ( compara_resp(@pos,@eleccion) == true ) then
19
+ puts "\e[92m |-> Respuesta correcta! <-|\e[39m\n "
20
+ @puntuacion += 1
21
+ else
22
+ puts "\e[91m |-> Respuesta incorrecta! <-|\e[39m\n "
23
+ end
24
+ loop do
25
+ puts "\e[90mpulse enter para continuar (o i para mas informacion)\e[39m"
26
+ cuestion=gets.chomp.downcase[0]
27
+ if (cuestion == "i") then
28
+ puts "Actual:#{@pos}\nTotal:#{@n}\nAcertadas:#{@puntuacion}\nFallidas:#{@pos+1-@puntuacion}"
29
+ else break
30
+ end
31
+ end
32
+ @pos += 1
33
+ end
34
+ print "ha obtenido usted una puntuacion de "
35
+ if (@puntuacion < (@pos/2) ) then
36
+ print "\e[91m #{@puntuacion}"
37
+ else
38
+ print "\e[92m #{@puntuacion}"
39
+ end
40
+ print"\e[39m Sobre "+@pos.to_s+"\n"
41
+ end
42
+ end
@@ -0,0 +1,87 @@
1
+ require "simpleselect/listNode.rb"
2
+ # Clase que define una lista doblemente enlazada formada por elementos {ListNode}
3
+ #
4
+ # @attr_reader head [ListNode] "puntero" al inicio de la lista
5
+ # @attr_reader tail [ListNode] "puntero" al final de la lista
6
+ class List
7
+ include Enumerable
8
+ attr_reader :head,:tail
9
+
10
+ def initialize(nodo)
11
+ raise unless nodo.is_a? (ListNode)
12
+ @head = nodo
13
+ @tail = nodo
14
+ end
15
+ # Inserta elementos al final de la lista
16
+ #
17
+ # @param nodo [ListNode] "puntero" al inicio de la lista
18
+ def push (nodo)
19
+ raise unless nodo.is_a? (ListNode)
20
+ nodo.prev=@tail
21
+ @tail.next=nodo
22
+ @tail=nodo
23
+
24
+ end
25
+
26
+ # Inserta multiples elementos al final de la lista
27
+ #
28
+ # @param nodos [Array(ListNode)] "puntero" al inicio de la lista
29
+ def multiple_push (nodos)
30
+ nodos.each { |i|
31
+ raise unless i.is_a? (ListNode)
32
+ push(i)
33
+ }
34
+ end
35
+ # Extrae un elemento del final de la lista
36
+ #
37
+ # @return [Object] valor contenido en el ultimo {ListNode} de la lista
38
+ def pop
39
+ aux = @head.value
40
+ @head = @head.next
41
+ @head.prev = nil
42
+ aux
43
+ end
44
+ # Comprueba si la lista se encuentra vacia
45
+ #
46
+ # @return [Boolean] devuelve true en caso de que esté vacia y false en el contrario
47
+ def vacia?
48
+ a = false
49
+ if (@head == nil)
50
+ a = true
51
+ end
52
+ a
53
+ end
54
+ # Realiza un recorrido desde {List::head} hasta {List::tail}
55
+ #
56
+ # @return [Array(ListNode)] Array que contiene todos los {ListNode} de la cadena desde el inicio al final
57
+ def headToTail()
58
+ val=[@head]
59
+ nodo=@head
60
+ while (nodo.next!=nil)do
61
+ nodo=nodo.next
62
+ val.push(nodo)
63
+ end
64
+ val
65
+ end
66
+ def tailToHead()
67
+ val=[@tail]
68
+ nodo=@tail
69
+ while (nodo.prev != nil)do
70
+ nodo=nodo.prev
71
+ val.push(nodo)
72
+ end
73
+ val
74
+ end
75
+ def each
76
+ headToTail.each{|i| yield i}
77
+ end
78
+ def [] (i)
79
+ headToTail[i]
80
+ end
81
+ def invertir
82
+ val = []
83
+ self.each {|i| val.unshift(i)}
84
+ val
85
+ end
86
+
87
+ end
@@ -0,0 +1,21 @@
1
+ # tipo nodo que actua como eslabón en la clase {List}
2
+ #
3
+ # @attr value [object] contenido util que encapsulará
4
+ # @attr next [ListNode] "puntero" al siguiente nodo de la lista
5
+ # @attr prev [ListNode] "puntero" al nodo anterior en la lista
6
+ class ListNode
7
+ include Comparable
8
+ def <=> (other)
9
+ @value <=> other.value
10
+ end
11
+ attr_accessor :value,:next,:prev
12
+ def initialize(value)
13
+ @value=value
14
+ @next = nil
15
+ @prev = nil
16
+ end
17
+ def to_s
18
+ @value.to_s
19
+ end
20
+ end
21
+
@@ -0,0 +1,20 @@
1
+ # Clase que define una pregunta
2
+ #
3
+ # @attr_reader preg [string] almacena la pregunta
4
+ # @attr_reader dif [Fixnum] valoracion de la dificultad de la pregunta
5
+ class Pregunta
6
+ attr_reader :preg, :dif
7
+ include Comparable
8
+
9
+ def initialize (preg, dif)
10
+ @preg = preg
11
+ @dif = dif
12
+ end
13
+ def to_s
14
+ aux = @preg + "\n"
15
+ aux
16
+ end
17
+ def <=> (other)
18
+ @dif <=> other.dif
19
+ end
20
+ end
@@ -0,0 +1,53 @@
1
+ class Quiz
2
+ attr_accessor :questions, :answers, :titulo
3
+ def initialize(titulo, &block)
4
+ @titulo=titulo
5
+ self.questions=[]
6
+ self.answers=[]
7
+
8
+ if block_given?
9
+ if block.arity == 1
10
+ yield self
11
+ else
12
+ instance_eval &block
13
+ end
14
+ end
15
+ end
16
+
17
+ def to_s
18
+ output = @titulo
19
+ output << "\n#{'=' * titulo.size}\n"
20
+
21
+ questions.each_with_index do |q, ind|
22
+ output << "\n"
23
+ output << q
24
+ output <<"\n"
25
+
26
+ answers[ind].each do |an|
27
+ output << an
28
+ output << "\n"
29
+ end
30
+ end
31
+ output
32
+ end
33
+
34
+ def question(name, options = {})
35
+ q = name
36
+ aux = []
37
+ if options[:right] == nil
38
+ puts "No hay una respuesta correcta"
39
+ return
40
+ end
41
+ if options[:wrong] == nil
42
+ puts "No hay ninguna respuesta incorrecta"
43
+ return
44
+ end
45
+
46
+ aux << " *) #{options[:right]}"
47
+ options[:wrong].each do |w|
48
+ aux << " *) #{w}"
49
+ end
50
+ questions << q
51
+ answers << aux
52
+ end
53
+ end
@@ -0,0 +1,24 @@
1
+ require "simpleselect/pregunta.rb"
2
+
3
+ class SimpleSelect < Pregunta
4
+ attr_reader :resp
5
+ def initialize (pregunta, resp, dif)
6
+ super(pregunta, dif)
7
+ @resp = resp
8
+ end
9
+ def imprimir
10
+ puts @preg
11
+ for i in @resp
12
+ puts i
13
+ end
14
+ end
15
+
16
+ def to_s
17
+ aux = super.to_s
18
+
19
+ for i in @resp
20
+ aux = aux + i + "\n"
21
+ end
22
+ aux
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ require "simpleselect/pregunta.rb"
2
+
3
+ class TorFalse < Pregunta
4
+ attr_reader :resp
5
+ def initialize (preg, dif)
6
+ super(preg, dif)
7
+ @resp = ["a) Verdadero", "b)falso"]
8
+ end
9
+ def to_s
10
+ aux = super.to_s + "a) Verdadero\nb)falso\n"
11
+ aux
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Simpleselect
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simpleselect/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simpleselect"
8
+ spec.version = Simpleselect::VERSION
9
+ spec.authors = ["alu0100764666"]
10
+ spec.email = ["alu0100764666@ull.edu.es"]
11
+ spec.summary = %q{"generador de examenes"}
12
+ spec.description = %q{"facilita la creacion de diferentes tipos de tests"}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec', '~>2.11'
24
+ spec.add_development_dependency "guard"
25
+ spec.add_development_dependency "guard-rspec"
26
+ spec.add_development_dependency "guard-bundler"
27
+ spec.add_development_dependency "coveralls"
28
+ spec.add_development_dependency "yard", "~> 1.0"
29
+ end
@@ -0,0 +1,21 @@
1
+ require "simpleselect.rb"
2
+ #require "spec_helper"
3
+ @var6 = TorFalse.new("6.-) Es apropiado que una clase tablero herede de una clase juego?", 1)
4
+ @var5 = SimpleSelect.new("5.-) Es apropiado que una clase Tablero herede de una clase Juego.", ["a) Cierto", "b) Falso"], 1)
5
+ @var4 = SimpleSelect.new("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n", ["a) Una instancia de la clase Class", "b) Una constante","c) Un objeto","d) Ninguna de las anteriores"], 4)
6
+ @var3 = SimpleSelect.new("3.-) Cual es la salida del siguiente codigo Ruby?\nclass Array\ndef say_hi\n\"Hey!\"\nend\nend\np[1, \"bob\"].say_hi\n", ["a) 1", "b) bob","c) Hey","d) Ninguna de las anteriores"], 2)
7
+ @var2 = SimpleSelect.new("2.-) La siguiente definicion de un hash en Ruby es valida:\nhash_raro= {\n[1, 2, 3]=>Object.new(),\nHash.new => :toto\n}\n", ["a) Cierto", "b) Falso"], 2)
8
+ @var1 = SimpleSelect.new("1.-) Cual es la salida del siguiente codigo Ruby?\nclass Xyz\ndef pots\n@nice\nend\nend\nxyz = Xyz.new\np xyz.pots\n", ["a) #<Xyz:0xa000208>", "b) nil","c) 0","d) Ninguna de las anteriores"], 1)
9
+
10
+ @nodovar6=ListNode.new(@var6)
11
+ @nodovar5=ListNode.new(@var5)
12
+ @nodovar4=ListNode.new(@var4)
13
+ @nodovar3=ListNode.new(@var3)
14
+ @nodovar2=ListNode.new(@var2)
15
+ @nodoVar1= ListNode.new(@var1)
16
+
17
+ @lista=List.new(@nodoVar1)
18
+ @lista.multiple_push([@nodovar2, @nodovar3, @nodovar4, @nodovar5, @nodovar6])
19
+
20
+ interfaz = Interface.new(@lista, ["a", "b", "c", "d", "c", "a"], 6)
21
+ interfaz.comenzar
@@ -0,0 +1,65 @@
1
+ require "simpleselect.rb"
2
+ #require "spec_helper"
3
+ describe Examen do
4
+ before :each do
5
+ @v6 = TorFalse.new("6.-) Es apropiado que una clase tablero herede de una clase juego?", 1)
6
+ @v5 = SimpleSelect.new("5.-) Es apropiado que una clase Tablero herede de una clase Juego.", ["a) Cierto", "b) Falso"], 1)
7
+ @v4 = SimpleSelect.new("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n", ["a) Una instancia de la clase Class", "b) Una constante","c) Un objeto","d) Ninguna de las anteriores"], 4)
8
+ @v3 = SimpleSelect.new("3.-) Cual es la salida del siguiente codigo Ruby?\nclass Array\ndef say_hi\n\"Hey!\"\nend\nend\np[1, \"bob\"].say_hi\n", ["a) 1", "b) bob","c) Hey","d) Ninguna de las anteriores"], 2)
9
+ @v2 = SimpleSelect.new("2.-) La siguiente definicion de un hash en Ruby es valida:\nhash_raro= {\n[1, 2, 3]=>Object.new(),\nHash.new => :toto\n}\n", ["a) Cierto", "b) Falso"], 2)
10
+ @v1 = SimpleSelect.new("1.-) Cual es la salida del siguiente codigo Ruby?\nclass Xyz\ndef pots\n@nice\nend\nend\nxyz = Xyz.new\np xyz.pots\n", ["a) #<Xyz:0xa000208>", "b) nil","c) 0","d) Ninguna de las anteriores"], 1)
11
+
12
+ @nvar6=ListNode.new(@v6)
13
+ @nvar5=ListNode.new(@v5)
14
+ @nvar4=ListNode.new(@v4)
15
+ @nvar3=ListNode.new(@v3)
16
+ @nvar2=ListNode.new(@v2)
17
+ @nVar1= ListNode.new(@v1)
18
+
19
+ @r1=ListNode.new("a")
20
+ @r2=ListNode.new("b")
21
+ @r3=ListNode.new("c")
22
+ @r4=ListNode.new("d")
23
+ @r5=ListNode.new("c")
24
+ @r6=ListNode.new("a")
25
+
26
+ @lista=List.new(@nVar1)
27
+ @listar=List.new(@r1)
28
+
29
+ @lista.multiple_push([@nvar2, @nvar3, @nvar4, @nvar5, @nvar6])
30
+ @listar.multiple_push([@r2, @r3, @r4, @r5, @r6])
31
+
32
+ @examen = Examen.new(@lista, @listar, 6)
33
+
34
+ end
35
+
36
+ describe "Specs de un examen" do
37
+ it "Existe" do
38
+ end
39
+ it "Tiene preguntas" do
40
+
41
+ @examen.preguntas.should eq(@lista)
42
+ end
43
+ it "Las preguntas son una lista" do
44
+ @examen.preguntas.is_a?(List).should eq(true)
45
+ end
46
+ it "Tiene respuestas" do
47
+ @examen.respuestas.should eq(@listar)
48
+ end
49
+ it "Estan ordenadas" do
50
+ @examen.preguntas[0].should eq(@nVar1)
51
+ @examen.preguntas[1].should eq(@nvar2)
52
+ @examen.preguntas[3].to_s.should eq("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n\na) Una instancia de la clase Class\nb) Una constante\nc) Un objeto\nd) Ninguna de las anteriores\n")
53
+
54
+
55
+ end
56
+ it "Compara respuestas" do
57
+ @examen.compara_resp(0, "a").should eq(true)
58
+ end
59
+ it "Invierte el examen" do
60
+ @examen.preguntas.invertir[0].should eq (@examen.preguntas[(@examen.n) -1])
61
+ end
62
+ end
63
+
64
+
65
+ end
@@ -0,0 +1,33 @@
1
+ require "simpleselect.rb"
2
+ #require "spec_helper"
3
+ describe Interface do
4
+ before :all do
5
+ @var6 = TorFalse.new("6.-) Es apropiado que una clase tablero herede de una clase juego?", 1)
6
+ @var5 = SimpleSelect.new("5.-) Es apropiado que una clase Tablero herede de una clase Juego.", ["a) Cierto", "b) Falso"], 1)
7
+ @var4 = SimpleSelect.new("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n", ["a) Una instancia de la clase Class", "b) Una constante","c) Un objeto","d) Ninguna de las anteriores"], 4)
8
+ @var3 = SimpleSelect.new("3.-) Cual es la salida del siguiente codigo Ruby?\nclass Array\ndef say_hi\n\"Hey!\"\nend\nend\np[1, \"bob\"].say_hi\n", ["a) 1", "b) bob","c) Hey","d) Ninguna de las anteriores"], 2)
9
+ @var2 = SimpleSelect.new("2.-) La siguiente definicion de un hash en Ruby es valida:\nhash_raro= {\n[1, 2, 3]=>Object.new(),\nHash.new => :toto\n}\n", ["a) Cierto", "b) Falso"], 2)
10
+ @var1 = SimpleSelect.new("1.-) Cual es la salida del siguiente codigo Ruby?\nclass Xyz\ndef pots\n@nice\nend\nend\nxyz = Xyz.new\np xyz.pots\n", ["a) #<Xyz:0xa000208>", "b) nil","c) 0","d) Ninguna de las anteriores"], 1)
11
+
12
+ @nodovar6=ListNode.new(@var6)
13
+ @nodovar5=ListNode.new(@var5)
14
+ @nodovar4=ListNode.new(@var4)
15
+ @nodovar3=ListNode.new(@var3)
16
+ @nodovar2=ListNode.new(@var2)
17
+ @nodoVar1= ListNode.new(@var1)
18
+
19
+ @lista=List.new(@nodoVar1)
20
+ @lista.multiple_push([@nodovar2, @nodovar3, @nodovar4, @nodovar5, @nodovar6])
21
+
22
+ @interfaz = Interface.new(@lista, ["a", "b", "c", "d", "c", "a"], 6)
23
+
24
+ end
25
+
26
+ describe "Specs de la interfaz de un examen" do
27
+ it "Existe" do
28
+ end
29
+ # it "Imprime las preguntas" do
30
+ # @interfaz.comenzar
31
+ #end
32
+ end
33
+ end
@@ -0,0 +1,115 @@
1
+ require "simpleselect.rb"
2
+ #require "spec_helper"
3
+ describe ListNode do
4
+ before :all do
5
+ @var6 = TorFalse.new("6.-) Es apropiado que una clase tablero herede de una clase juego?", 1)
6
+ @var5 = SimpleSelect.new("5.-) Es apropiado que una clase Tablero herede de una clase Juego.", ["a) Cierto", "b) Falso"], 1)
7
+ @var4 = SimpleSelect.new("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n", ["a) Una instancia de la clase Class", "b) Una constante","c) Un objeto","d) Ninguna de las anteriores"], 4)
8
+ @var3 = SimpleSelect.new("3.-) Cual es la salida del siguiente codigo Ruby?\nclass Array\ndef say_hi\n\"Hey!\"\nend\nend\np[1, \"bob\"].say_hi\n", ["a) 1", "b) bob","c) Hey","d) Ninguna de las anteriores"], 2)
9
+ @var2 = SimpleSelect.new("2.-) La siguiente definicion de un hash en Ruby es valida:\nhash_raro= {\n[1, 2, 3]=>Object.new(),\nHash.new => :toto\n}\n", ["a) Cierto", "b) Falso"], 2)
10
+ @var1 = SimpleSelect.new("1.-) Cual es la salida del siguiente codigo Ruby?\nclass Xyz\ndef pots\n@nice\nend\nend\nxyz = Xyz.new\np xyz.pots\n", ["a) #<Xyz:0xa000208>", "b) nil","c) 0","d) Ninguna de las anteriores"], 1)
11
+
12
+ @nodovar5=ListNode.new(@var5)
13
+ @nodovar4=ListNode.new(@var4)
14
+ @nodovar3=ListNode.new(@var3)
15
+ @nodovar2=ListNode.new(@var2)
16
+ @nodoVar1= ListNode.new(@var1)
17
+
18
+ @lista=List.new(@nodoVar1)
19
+
20
+ end
21
+ describe "Existe nodo" do
22
+ it "Existe un nodo" do
23
+ end
24
+ end
25
+ describe "Se puede acceder al valor del nodo" do
26
+ it "para Ver preguntas" do
27
+ @nodoVar1.value.preg.should eq("1.-) Cual es la salida del siguiente codigo Ruby?\nclass Xyz\ndef pots\n@nice\nend\nend\nxyz = Xyz.new\np xyz.pots\n")
28
+ end
29
+ it "para ver respuestas" do
30
+ @nodoVar1.value.resp.should eq (["a) #<Xyz:0xa000208>", "b) nil","c) 0","d) Ninguna de las anteriores"])
31
+ end
32
+
33
+ it"comprobar to_s" do
34
+ @nodoVar1.value.to_s.should eq("1.-) Cual es la salida del siguiente codigo Ruby?\nclass Xyz\ndef pots\n@nice\nend\nend\nxyz = Xyz.new\np xyz.pots\n\na) #<Xyz:0xa000208>\nb) nil\nc) 0\nd) Ninguna de las anteriores\n")
35
+ end
36
+ end
37
+ describe "Tiene que existir la lista, debe tener un metodo para saber si es vacia" do
38
+ it "Existe lista" do
39
+ end
40
+ it "Metodo para saber si es vacia" do
41
+ @lista.vacia?
42
+ end
43
+ end
44
+ describe "Metodos de insercion y eliminacion de elementos de lista" do
45
+ it "Se puede insertar un nodo" do
46
+ @lista.push(@nodovar2)
47
+ end
48
+ it "Se puede insertar varios elementos" do
49
+ @lista.multiple_push([@nodovar3, @nodovar4])
50
+ end
51
+ it "Para extraer el primer elemento" do
52
+ @lista.pop.to_s.should eq("1.-) Cual es la salida del siguiente codigo Ruby?\nclass Xyz\ndef pots\n@nice\nend\nend\nxyz = Xyz.new\np xyz.pots\n\na) #<Xyz:0xa000208>\nb) nil\nc) 0\nd) Ninguna de las anteriores\n")
53
+ end
54
+ it" El orden es el correcto"do
55
+ @lista.pop.to_s.should eq("2.-) La siguiente definicion de un hash en Ruby es valida:\nhash_raro= {\n[1, 2, 3]=>Object.new(),\nHash.new => :toto\n}\n\na) Cierto\nb) Falso\n")
56
+ end
57
+ it "para recorrer de la cabeza a la cola" do
58
+ @lista.headToTail[0].to_s.should eq("3.-) Cual es la salida del siguiente codigo Ruby?\nclass Array\ndef say_hi\n\"Hey!\"\nend\nend\np[1, \"bob\"].say_hi\n\na) 1\nb) bob\nc) Hey\nd) Ninguna de las anteriores\n")
59
+ end
60
+ it "para recorrer de la cabeza a la cola" do
61
+ @lista.tailToHead[0].to_s.should eq("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n\na) Una instancia de la clase Class\nb) Una constante\nc) Un objeto\nd) Ninguna de las anteriores\n")
62
+ end
63
+ end
64
+ describe "Existe una pregunta Verdadero o falso" do
65
+ it "Existe pregunta y respuestas son verdadero o falso" do
66
+ @var6.resp.should eq(["a) Verdadero", "b)falso"])
67
+ end
68
+ end
69
+ describe "Verificacion de jerarquia de clases" do
70
+ it "Se verifica que simpleselect es familia de pregunta" do
71
+ @var1.is_a?(Pregunta).should eq(true)
72
+ end
73
+ it "Se verifica que torfalse es familia de pregunta" do
74
+ @var6.is_a?(Pregunta).should eq(true)
75
+ end
76
+ end
77
+ describe "Se pueden comparar las preguntas" do
78
+ it "Se compara la dificultad usando <" do
79
+ (@var1 < @var2).should eq(true)
80
+ end
81
+ it "Se compara la dificultad usando >" do
82
+ (@var1 > @var2).should eq(false)
83
+ end
84
+ it "Se compara la dificultad usando ==" do
85
+ (@var2 == @var3).should eq(true)
86
+ end
87
+ it "Se compara la dificultad de una true or false y una simpleselect" do
88
+ (@var6 < @var2).should eq(true)
89
+ end
90
+ end
91
+ describe"se comprueba que es enumerable" do
92
+ it "Se puede hacer un each" do
93
+ @lista.each{|i| i}
94
+ end
95
+ it "podemos obtener una cadena de la que extraer los datos" do
96
+ cadena=""
97
+ @lista.each{|i| cadena += i.to_s}
98
+ cadena.to_s.should eq("3.-) Cual es la salida del siguiente codigo Ruby?\nclass Array\ndef say_hi\n\"Hey!\"\nend\nend\np[1, \"bob\"].say_hi\n\na) 1\nb) bob\nc) Hey\nd) Ninguna de las anteriores\n4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n\na) Una instancia de la clase Class\nb) Una constante\nc) Un objeto\nd) Ninguna de las anteriores\n")
99
+ end
100
+ it "Calcular maximo" do
101
+ @lista.max.to_s.should eq("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n\na) Una instancia de la clase Class\nb) Una constante\nc) Un objeto\nd) Ninguna de las anteriores\n")
102
+ end
103
+ end
104
+ describe "se funciona el acceso con []" do
105
+ it "se puede ejecutar []" do
106
+ @lista[0]
107
+ end
108
+ it "estan ordenadas" do
109
+ @lista[0].to_s.should eq("3.-) Cual es la salida del siguiente codigo Ruby?\nclass Array\ndef say_hi\n\"Hey!\"\nend\nend\np[1, \"bob\"].say_hi\n\na) 1\nb) bob\nc) Hey\nd) Ninguna de las anteriores\n")
110
+ # @lista.headToTail()[3].to_s.should eq("4.-) Cual es el tipo del objeto en el siguiente codigo Ruby?\nclass Objeto\nend\n\na) Una instancia de la clase Class\nb) Una constante\nc) Un objeto\nd) Ninguna de las anteriores\n")
111
+
112
+ end
113
+ end
114
+ end
115
+
@@ -0,0 +1,33 @@
1
+ require "simpleselect.rb"
2
+
3
+ describe Quiz do
4
+
5
+ describe "Existe el objeto quiz" do
6
+ it " y recibe un bloque en el initialize"do
7
+ @quiz=Quiz.new("Cuestionario de LPP 05/12/2014") do |a|
8
+
9
+ end
10
+ end
11
+ it "recibe un bloque y guarda una pregunta: " do
12
+ @quiz=Quiz.new("Cuestionario de LPP 05/12/2014") do |a|
13
+ a.question "Ruby es un lenguaje orientado a objetos?", :right => "V", :wrong => ["F"]
14
+ end
15
+ end
16
+ it "Se puede imprimir la pregunta" do
17
+ @quiz.to_s
18
+ end
19
+ it "Se puede crear con preguntas multirespuesta" do
20
+ quiz=Quiz.new("Cuestionario de LPP 05/12/2014") do |a|
21
+ a.question "Ruby es un lenguaje orientado a objetos?", :right => "SI", :wrong => ["F"]
22
+ a.question "Indique cual de los siguientes es un metodo de array", :right => "each", :wrong => ["algo", "otro"]
23
+ end
24
+ end
25
+ it "Se puede crear sin necesidad de utilizar parametros" do
26
+ quiz=Quiz.new("Cuestionario de LPP 05/12/2014") do
27
+ question "Ruby es un lenguaje orientado a objetos?", :right => "SI", :wrong => ["F"]
28
+ question "Indique cual de los siguientes es un metodo de array", :right => "each", :wrong => ["algo", "otro"]
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ require "simpleselect.rb"
2
+ #require "spec_helper"
3
+ describe SimpleSelect do
4
+
5
+ before :all do
6
+ @var = SimpleSelect.new("Pregunta", ["respuesta1", "respuesta2","respuesta3","respuesta4"], 4)
7
+
8
+ end
9
+ describe "Ver existen preguntas y respuestas" do
10
+ it "Existe pregunta y respuesta" do
11
+ end
12
+
13
+
14
+ end
15
+ describe "Ver preguntas y respuestas" do
16
+ it "Ver preguntas" do
17
+ @var.preg.should eq("Pregunta")
18
+ end
19
+ it "ver respuestas" do
20
+ @var.resp.should eq (["respuesta1", "respuesta2","respuesta3", "respuesta4"])
21
+ end
22
+ end
23
+ describe "ver por pantalla" do
24
+ it "Ver preguntas y respuestas" do
25
+ @var.imprimir
26
+ end
27
+ it"comprobar to_s" do
28
+ @var.to_s.should eq("Pregunta\nrespuesta1\nrespuesta2\nrespuesta3\nrespuesta4\n")
29
+
30
+ end
31
+ end
32
+
33
+
34
+
35
+ end
@@ -0,0 +1,21 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # Require this file using `require "spec_helper"` to ensure that it is only
6
+ # loaded once.
7
+ #
8
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+
20
+ end
21
+
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simpleselect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - alu0100764666
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ description: '"facilita la creacion de diferentes tipos de tests"'
126
+ email:
127
+ - alu0100764666@ull.edu.es
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".coveralls.yml"
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - Guardfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - lib/simpleselect.rb
142
+ - lib/simpleselect/examen.rb
143
+ - lib/simpleselect/interface.rb
144
+ - lib/simpleselect/list.rb
145
+ - lib/simpleselect/listNode.rb
146
+ - lib/simpleselect/pregunta.rb
147
+ - lib/simpleselect/quiz.rb
148
+ - lib/simpleselect/simpleSelect.rb
149
+ - lib/simpleselect/tof.rb
150
+ - lib/simpleselect/version.rb
151
+ - simpleselect.gemspec
152
+ - spec/examen_interfaz.rb
153
+ - spec/examen_spec.rb
154
+ - spec/interface_spec.rb
155
+ - spec/listNode_spec.rb
156
+ - spec/quiz_spect.rb
157
+ - spec/simpleSelect_spec.rb
158
+ - spec/spec_helper.rb
159
+ homepage: ''
160
+ licenses:
161
+ - MIT
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.2.2
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: '"generador de examenes"'
183
+ test_files:
184
+ - spec/examen_interfaz.rb
185
+ - spec/examen_spec.rb
186
+ - spec/interface_spec.rb
187
+ - spec/listNode_spec.rb
188
+ - spec/quiz_spect.rb
189
+ - spec/simpleSelect_spec.rb
190
+ - spec/spec_helper.rb
191
+ has_rdoc: