question-simpleChoice 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.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/#question-simpleChoice.gemspec# +27 -0
  3. data/.coveralls.yml +1 -0
  4. data/.gitignore +15 -0
  5. data/.rspec +2 -0
  6. data/.travis.yml +3 -0
  7. data/.yardoc/checksums +13 -0
  8. data/.yardoc/object_types +0 -0
  9. data/.yardoc/objects/root.dat +0 -0
  10. data/.yardoc/proxy_types +0 -0
  11. data/Gemfile +7 -0
  12. data/Guardfile +7 -0
  13. data/LICENSE.txt +22 -0
  14. data/README.md +32 -0
  15. data/Rakefile +15 -0
  16. data/doc/Examen.html +766 -0
  17. data/doc/Interfaz.html +440 -0
  18. data/doc/Lista.html +929 -0
  19. data/doc/Lista/Node.html +397 -0
  20. data/doc/Node.html +516 -0
  21. data/doc/Question.html +117 -0
  22. data/doc/Question/SimpleChoice.html +132 -0
  23. data/doc/Question/TrueOrFalse.html +134 -0
  24. data/doc/QuestionFather.html +565 -0
  25. data/doc/SimpleChoice.html +505 -0
  26. data/doc/TrueOrFalse.html +279 -0
  27. data/doc/_index.html +207 -0
  28. data/doc/class_list.html +58 -0
  29. data/doc/css/common.css +1 -0
  30. data/doc/css/full_list.css +57 -0
  31. data/doc/css/style.css +339 -0
  32. data/doc/file.README.html +110 -0
  33. data/doc/file_list.html +60 -0
  34. data/doc/frames.html +26 -0
  35. data/doc/index.html +110 -0
  36. data/doc/js/app.js +219 -0
  37. data/doc/js/full_list.js +181 -0
  38. data/doc/js/jquery.js +4 -0
  39. data/doc/method_list.html +309 -0
  40. data/doc/top-level-namespace.html +114 -0
  41. data/lib/exam/examen.rb +85 -0
  42. data/lib/interfaz/interfaz.rb +49 -0
  43. data/lib/interfaz/interfazV2.rb +38 -0
  44. data/lib/node/node.rb +9 -0
  45. data/lib/nodelist/list.rb +119 -0
  46. data/lib/question/questionFather.rb +2 -0
  47. data/lib/question/questionFather/base.rb +16 -0
  48. data/lib/question/questionFather/version.rb +5 -0
  49. data/lib/question/simpleChoice.rb +2 -0
  50. data/lib/question/simpleChoice/base.rb +17 -0
  51. data/lib/question/simpleChoice/version.rb +5 -0
  52. data/lib/question/trueOrFalse.rb +2 -0
  53. data/lib/question/trueOrFalse/base.rb +10 -0
  54. data/lib/question/trueOrFalse/version.rb +5 -0
  55. data/lib/quiz/quiz.rb +58 -0
  56. data/prueba.html +1 -0
  57. data/prueba.rb +48 -0
  58. data/question-simpleChoice.gemspec +27 -0
  59. data/spec/list_spec.rb +51 -0
  60. data/spec/quiz_spec.rb +31 -0
  61. data/spec/simpleChoice_spec.rb +106 -0
  62. data/spec/spec_examen.rb +21 -0
  63. data/spec/spec_helper.rb +93 -0
  64. data/test.html +310 -0
  65. metadata +183 -0
@@ -0,0 +1,114 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!top-level-namespace.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index</a> &raquo;
35
+
36
+
37
+ <span class="title">Top Level Namespace</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Top Level Namespace
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ </dl>
82
+ <div class="clear"></div>
83
+
84
+ <h2>Defined Under Namespace</h2>
85
+ <p class="children">
86
+
87
+
88
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Question.html" title="Question (module)">Question</a></span>
89
+
90
+
91
+
92
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Examen.html" title="Examen (class)">Examen</a></span>, <span class='object_link'><a href="Interfaz.html" title="Interfaz (class)">Interfaz</a></span>, <span class='object_link'><a href="Lista.html" title="Lista (class)">Lista</a></span>, <span class='object_link'><a href="Node.html" title="Node (class)">Node</a></span>, <span class='object_link'><a href="QuestionFather.html" title="QuestionFather (class)">QuestionFather</a></span>, <span class='object_link'><a href="SimpleChoice.html" title="SimpleChoice (class)">SimpleChoice</a></span>, <span class='object_link'><a href="TrueOrFalse.html" title="TrueOrFalse (class)">TrueOrFalse</a></span>
93
+
94
+
95
+ </p>
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ </div>
106
+
107
+ <div id="footer">
108
+ Generated on Thu Nov 27 14:39:06 2014 by
109
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
110
+ 0.8.7.6 (ruby-2.0.0).
111
+ </div>
112
+
113
+ </body>
114
+ </html>
@@ -0,0 +1,85 @@
1
+ if __FILE__ == $0 then
2
+ $: << "."
3
+ end
4
+
5
+ require './lib/nodelist/list'
6
+ require './lib/question/simpleChoice/base'
7
+ require './lib/question/trueOrFalse/base'
8
+ require './lib/question/questionFather/base'
9
+
10
+ class Examen
11
+ attr_accessor :list , :node_i , :acierto , :fallo
12
+ def initialize(list)
13
+ @acierto = 0
14
+ @fallo = 0
15
+ @list = list
16
+ end
17
+
18
+ def next_question()
19
+ if @node_i != nil then
20
+ if @node_i.next != nil then
21
+ @node_i = @node_i.next
22
+ else
23
+ return nil
24
+ end
25
+ else
26
+ @node_i = @list.head
27
+ end
28
+
29
+ puts @node_i.value.to_s
30
+ return @node_i.value.to_s
31
+ end
32
+ def reverse_question
33
+ @list.reverse
34
+ end
35
+ def response_question(value)
36
+ print "Respuesta: "
37
+ if value == @node_i.value.right then
38
+ puts "\n"
39
+ puts "La pregunta es correcta"
40
+ puts "\n"
41
+ @acierto += 1
42
+ else
43
+ puts "\n"
44
+ puts "La pregunta es incorrecta"
45
+ puts "\n"
46
+ @fallo += 1
47
+ end
48
+ end
49
+ def show_stats
50
+ puts "\n"
51
+ puts "|---------------------------|"
52
+ puts "|--- Estadisticas ---|"
53
+ puts "|---------------------------|"
54
+ puts "|- Aciertos: #{@acierto} | Fallos: #{@fallo} -|"
55
+ puts "|---------------------------|"
56
+ puts "\n"
57
+ end
58
+ end
59
+ if $0 == __FILE__ then
60
+
61
+ p1 = SimpleChoice.new(:text => '1)2 + 2 = ',:right => '1',:distractor => [5,3,2], :dif =>1)
62
+ p2 = SimpleChoice.new(:text => '2)5 + 2 = ',:right => '2',:distractor => [5,3,2], :dif =>1)
63
+ p3 = SimpleChoice.new(:text => '3)2 * 2 = ',:right => '3',:distractor => [5,3,2], :dif =>1)
64
+
65
+ list = Lista.new()
66
+ list.add(p1,p2,p3)
67
+ list.reverse
68
+ examen = Examen.new(list)
69
+
70
+ examen.next_question
71
+ STDOUT.flush
72
+ value = gets.chomp
73
+ examen.response_question(value)
74
+ examen.next_question
75
+ STDOUT.flush
76
+ value = gets.chomp
77
+ examen.response_question(value)
78
+ examen.next_question
79
+ STDOUT.flush
80
+ value = gets.chomp
81
+ examen.response_question(value)
82
+
83
+ examen.show_stats
84
+
85
+ end
@@ -0,0 +1,49 @@
1
+ if __FILE__ == $0 then
2
+ $: << "."
3
+ end
4
+ require './lib/nodelist/list'
5
+ require './lib/exam/examen'
6
+ require './lib/question/simpleChoice/base'
7
+ require './lib/question/trueOrFalse/base'
8
+ require './lib/question/questionFather/base'
9
+
10
+ class Interfaz
11
+ attr_accessor :list
12
+ def initialize(list)
13
+ if list != nil then
14
+ @list = list
15
+ else
16
+ @list = Lista.new()
17
+ end
18
+ end
19
+ def generate_q
20
+ q1 = SimpleChoice.new(:text => '2 + 2 = ',:right => '4',:distractor => [5,3,2], :dif =>1)
21
+ q2 = SimpleChoice.new(:text => '2 * 2 = ',:right => '4',:distractor => [5,3,2], :dif =>2)
22
+ q3 = SimpleChoice.new(:text => '3 + 2 = ',:right => '5',:distractor => [6,3,2], :dif =>3)
23
+ q4 = SimpleChoice.new(:text => '2 - 1 = ',:right => '1',:distractor => [0,3,2], :dif =>4)
24
+ q5 = SimpleChoice.new(:text => '2 - 2 = ',:right => '0',:distractor => [4,3,2], :dif =>5)
25
+ q6 = TrueOrFalse.new(:text => '2 + 2 = 4',:right => 'true', :dif =>6)
26
+ q7 = TrueOrFalse.new(:text => '2 * 2 = 4',:right => 'true', :dif =>7)
27
+ q8 = TrueOrFalse.new(:text => '3 + 2 = 6',:right => 'false', :dif =>8)
28
+ q9 = TrueOrFalse.new(:text => '2 - 2 = 1',:right => 'false', :dif =>9)
29
+ q10 = TrueOrFalse.new(:text => '2 - 1 = 1',:right => 'true', :dif =>10)
30
+ @list.add(q1,q2,q3,q4,q5,q6,q7,q8,q9,q10)
31
+ @list.reverse
32
+ end
33
+ def run
34
+ if @list.head == nil then
35
+ generate_q
36
+ end
37
+ examen = Examen.new(@list)
38
+ while examen.next_question != nil do
39
+ STDOUT.flush
40
+ value = gets.chomp
41
+ examen.response_question(value)
42
+ end
43
+ examen.show_stats
44
+ end
45
+ end
46
+ if __FILE__ == $0 then
47
+ interfaz = Interfaz.new(nil)
48
+ interfaz.run
49
+ end
@@ -0,0 +1,38 @@
1
+ if __FILE__ == $0 then
2
+ $: << "."
3
+ end
4
+ require './lib/nodelist/list'
5
+ require './lib/exam/examen'
6
+ require './lib/question/simpleChoice/base'
7
+ require './lib/question/trueOrFalse/base'
8
+ require './lib/question/questionFather/base'
9
+ require './lib/quiz/quiz.rb'
10
+
11
+ class Interfaz
12
+ def initialize
13
+ @quiz = Quiz.new("Cuestionario de LPP 05/12/2014") {
14
+ question '¿Cuantos argumentos de tipo bloque puede recibir un m´etodo?',
15
+ right =>'1',
16
+ wrong =>'2',
17
+ wrong =>'muchos',
18
+ wrong =>'los que defina el usuario'
19
+ question "En Ruby los bloque son objetos que continen codigo",
20
+ wrong =>'Cierto',
21
+ right =>'Falso'
22
+ }
23
+ end
24
+
25
+ def run
26
+ examen = @quiz.to_exam
27
+ while examen.next_question != nil do
28
+ STDOUT.flush
29
+ value = gets.chomp
30
+ examen.response_question(value)
31
+ end
32
+ examen.show_stats
33
+ end
34
+ end
35
+ if $0 == __FILE__ then
36
+ interfaz = Interfaz.new()
37
+ interfaz.run
38
+ end
@@ -0,0 +1,9 @@
1
+ Node = Struct.new(:value, :next, :father )
2
+ class Node
3
+ def reverse(&block)
4
+ if self.next != nil
5
+ self.next.reverse(&block)
6
+ end
7
+ yield self
8
+ end
9
+ end
@@ -0,0 +1,119 @@
1
+ # encoding: UTF-8
2
+ require "./lib/node/node.rb"
3
+ class Lista
4
+ include Enumerable
5
+ attr_accessor :head, :lastnext, :puntero
6
+ def initialize()
7
+ @head = nil
8
+ @lastnext = nil
9
+ end
10
+ def each
11
+ aux = @head
12
+ while aux != nil
13
+ yield aux.value
14
+ aux = aux.next
15
+ end
16
+ end
17
+ def reverse_each
18
+ @head.each {yield @lastnext.value; @lastnext=@lastnext.father} if @lastnext != nil
19
+ end
20
+
21
+ def reverse
22
+ list = Array.new
23
+ @head.reverse{|x| list.push(x.value)}
24
+ @head = nil
25
+ @lastnext = nil
26
+ list.each{|x| self.add(x)}
27
+ end
28
+ def add_s(value)
29
+ if @head == nil then
30
+ @head = Node.new(value, nil, nil)
31
+ @lastnext = @head
32
+ else
33
+ last = Node.new(value, nil, @lastnext)
34
+ last.father = @lastnext
35
+ @lastnext.next = last
36
+ @lastnext = last
37
+ end
38
+ end
39
+ def add(*args)
40
+ args.each do |value|
41
+ if @head == nil then
42
+ @head = Node.new(value, nil, nil)
43
+ @lastnext = @head
44
+ else
45
+ last = Node.new(value, nil, @lastnext)
46
+ last.father = @lastnext
47
+ @lastnext.next = last
48
+ @lastnext = last
49
+ end
50
+ end
51
+ end
52
+ def first
53
+ if @head != nil then
54
+ aux = @head.value
55
+ @head = @head.next
56
+ return aux
57
+ else
58
+ return -1
59
+ end
60
+ end
61
+ def to_s
62
+ "#{@head}"
63
+ end
64
+ def to_a
65
+ a_value = Array.new
66
+ pointer = @head
67
+ while pointer.next != nil do
68
+ a_value.push(pointer.value)
69
+ pointer = pointer.next
70
+ end
71
+ a_value.push(pointer.value)
72
+ a_value.to_s
73
+ end
74
+ end
75
+ if __FILE__ == $0 then
76
+ $: << "."
77
+ re = File.new("question/simpleChoice.rb")
78
+ require re
79
+
80
+ lista1 = Lista.new()
81
+ lista1.add(1,2,3)
82
+ lista1.add(4)
83
+ puts "Uso de la función first:"
84
+ puts lista1.first
85
+ puts "-- Estructura de la lista enlazada --"
86
+ puts lista1
87
+ puts "-- -- --"
88
+ puts lista1.to_a
89
+
90
+ listQuestion = Lista.new()
91
+
92
+ #Preguntas para el test de la practica 06
93
+ p1 = SimpleChoice.new(:text =>"¿Cual es la salida del siguiente código Ruby ? \n class Xyz \n def pots \n @nice\n end\n end\n", :right => 'nil' ,:distractor => ['#<Xyz: 0xa000208>','0','Nunguna de las anteriores'] )
94
+ p2 = SimpleChoice.new(:text => "La siguiente definici´on de un hash en Ruby es v´alida:hash_raro = {[1, 2, 3] => Object.new(),Hash.new => :toto}", :right => 'falso', :distractor => 'Cierto')
95
+ p3 = SimpleChoice.new(:text =>"¿Cu´al es la salida del siguiente c´odigo Ruby?class Arraydef say_hi\"HEY!\"endendp [1, \"bob\"].say_hi", :right =>'"HEY!"', :distractor => ['1','bob','Nunguna de las anteriores'] )
96
+ p4 = SimpleChoice.new(:text => "¿Cu´al es el tipo del objeto en el siguiente c´odigo Ruby?class Objetoend", :right =>'Un objeto', :distractor => ['Una instancia de una clase', 'Una constante', 'Ninguna de las anteriores'] )
97
+ p5 = SimpleChoice.new(:text => "Es apropiado que una clase Tablero herede de una clase Juego.", :right => 'Cierto', :distractor => 'Falso')
98
+
99
+ listQuestion.add(p1,p2,p3,p4,p5)
100
+ =begin
101
+ puts listQuestion.to_s
102
+ puts "**********"
103
+ puts listQuestion.first.right
104
+ puts "**********"
105
+ puts listQuestion.lastnext
106
+ puts " "
107
+ puts "******EACH****"
108
+ puts listQuestion.each { |o| p o }
109
+ puts listQuestion.is_a? Enumerable
110
+ =end
111
+ puts "------------------Normal--------------------"
112
+ listQuestion.each { |o| p o }
113
+ puts "------------------END NORMAL----------------"
114
+ puts "------------------REVERSE--------------------"
115
+ listQuestion.reverse
116
+ listQuestion.each{|x| p x}
117
+ puts "------------------END_REVERSE--------------------"
118
+ end
119
+
@@ -0,0 +1,2 @@
1
+ require "question/questionFather/version"
2
+ require "question/questionFather/base"
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+ class QuestionFather
3
+ include Comparable
4
+ attr_accessor :text, :right, :distractor,:dif
5
+
6
+ def initialize(args)
7
+ @text = args[:text]
8
+ @right = args[:right]
9
+ @distractor = args[:distractor]
10
+ @dif = args[:dif]
11
+ end
12
+ def <=>(other)
13
+ self.dif <=> other.dif
14
+ end
15
+ end
16
+
@@ -0,0 +1,5 @@
1
+ module Question
2
+ class TrueOrFalse
3
+ VERSION = "0.0.1"
4
+ end
5
+ end