mumuki-gobstones-runner 2.10.1 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/feedback_hook.rb +210 -0
- data/lib/gobstones_runner.rb +3 -2
- data/lib/locales/en.yml +12 -0
- data/lib/locales/es.yml +12 -0
- data/lib/locales/pt.yml +12 -0
- data/lib/version_hook.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1636b8a5a322c4a74f84a725e8df8fa0118e38362b3732a70e76deba7b87e620
|
4
|
+
data.tar.gz: 41d818b4cb24ce921ed45f0c539437ac0395ddc4152e2f5a4ebf3e2a19168b07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb2ac8c37f98b4239de66fdc9f4b73982a013769add4d71172561e7d399774038647690468193a2dee19d2c8cf886582538f4bfc13479057a3837918affec4d0
|
7
|
+
data.tar.gz: aba3b7d54384b3c44587219236ccfb4d3720560d63f5d7ac8193bc95604e4ec1ddd3de32544c8fcbaf0d3f396d19c62b3c9b6576b036e27f17d7d207d155b827
|
@@ -0,0 +1,210 @@
|
|
1
|
+
class GobstonesFeedbackHook < Mumukit::Hook
|
2
|
+
def run!(request, results)
|
3
|
+
content = request.content
|
4
|
+
test_results = results.test_results[0]
|
5
|
+
|
6
|
+
GobstonesExplainer.new.explain(content, test_results) if test_results.is_a? String
|
7
|
+
end
|
8
|
+
|
9
|
+
class GobstonesExplainer < Mumukit::Explainer
|
10
|
+
def explain_program_has_a_name(submission, result)
|
11
|
+
if identifier_instead_of_brace? result
|
12
|
+
(submission.match malformed_program_header_with_name).try do |it|
|
13
|
+
{ name: it[1] }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def explain_program_has_no_opening_curly_brace(submission, result)
|
19
|
+
if identifier_instead_of_brace? result
|
20
|
+
/#{malformed_program_header_with_no_curly_braces}/ =~ submission
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def explain_program_before_closing_structure_when_program(submission, result)
|
25
|
+
if program_instead_of_command?(result) && missing_brace_end?(submission) && function_or_procedure?(submission)
|
26
|
+
(submission.match program).try do |it|
|
27
|
+
{ keyword: last_function_or_procedure(submission) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def explain_program_before_closing_structure_when_no_program(submission, result)
|
33
|
+
if program_instead_of_command?(result) && missing_brace_end?(submission) && function_or_procedure?(submission)
|
34
|
+
if /#{program}/ =~ submission
|
35
|
+
nil
|
36
|
+
else
|
37
|
+
{ keyword: last_function_or_procedure(submission) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def explain_surplus_closing_brace(_, result)
|
43
|
+
if unbalanced_closing_braces? result
|
44
|
+
(error_line(result)).try do |it|
|
45
|
+
{ line: it[1] }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def explain_upper_function_typo(submission, result)
|
51
|
+
if upper_identifier_instead_of_definition? result
|
52
|
+
/#{uppercase_function}/ =~ submission
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def explain_upper_procedure_typo(submission, result)
|
57
|
+
if upper_identifier_instead_of_definition? result
|
58
|
+
/#{uppercase_procedure}/ =~ submission
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def explain_upper_program_typo(submission, result)
|
63
|
+
if upper_identifier_instead_of_definition? result
|
64
|
+
/#{uppercase_program}/ =~ submission
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def explain_missing_closing_brace_after_procedure(submission, result)
|
69
|
+
if procedure_instead_of_command?(result) && missing_brace_end?(submission)
|
70
|
+
(error_line(result)).try do |it|
|
71
|
+
{ line: it[1] }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def explain_lower_builtin_procedure_typo(submission, result)
|
77
|
+
if open_paren_instead_of_assign?(result)
|
78
|
+
(submission.match lower_builtin_procedure).try do |it|
|
79
|
+
{ lower: it[1][0...5], upper: it[1][0...5].capitalize }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def explain_upper_builtin_function_typo(submission, result)
|
85
|
+
if procedure_invocation_instead_of_expression?(result)
|
86
|
+
(submission.match upper_builtin_function).try do |it|
|
87
|
+
{ upper: it[1], lower: it[1].camelize(:lower) }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def explain_color_typo(_, result)
|
93
|
+
if roja_not_defined?(result) || negra_not_defined?(result)
|
94
|
+
(result.match color_not_defined).try do |it|
|
95
|
+
{ color: it[1], rectified_color: rectified_color(it[1]) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def malformed_program_header_with_name
|
103
|
+
'.*program +([A-Za-z]\w*)'
|
104
|
+
end
|
105
|
+
|
106
|
+
def upper_identifier_instead_of_brace?(result)
|
107
|
+
identifier_instead_of_brace?(result, 'may')
|
108
|
+
end
|
109
|
+
|
110
|
+
def lower_identifier_instead_of_brace?(result)
|
111
|
+
identifier_instead_of_brace?(result, 'min')
|
112
|
+
end
|
113
|
+
|
114
|
+
def identifier_instead_of_brace?(result, capital='...')
|
115
|
+
result.match? /<pre>\[\d+:\d+\]: Se esperaba una llave izquierda \("{"\).\nSe encontró: un identificador con #{capital}úsculas.<\/pre>/
|
116
|
+
end
|
117
|
+
|
118
|
+
def malformed_program_header_with_no_curly_braces
|
119
|
+
'.*program *[\r\n]\s*[^{]\w+'
|
120
|
+
end
|
121
|
+
|
122
|
+
def program_instead_of_command?(result)
|
123
|
+
result.match? /<pre>\[\d+:\d+\]: Se esperaba un comando.\nSe encontró: la palabra clave "program".<\/pre>/
|
124
|
+
end
|
125
|
+
|
126
|
+
def missing_brace_end?(submission)
|
127
|
+
submission.count('{') > submission.count('}')
|
128
|
+
end
|
129
|
+
|
130
|
+
def function_or_procedure?(submission)
|
131
|
+
submission.match? function_or_procedure
|
132
|
+
end
|
133
|
+
|
134
|
+
def function_or_procedure
|
135
|
+
'(function)\s*\w+\s*\([\w\d\s,]*\)\s*{|(procedure)\s*\w+\s*\([\w\d\s,]*\)\s*{'
|
136
|
+
end
|
137
|
+
|
138
|
+
def last_function_or_procedure(submission)
|
139
|
+
submission.scan(/#{function_or_procedure}/).last.compact.first
|
140
|
+
end
|
141
|
+
|
142
|
+
def program
|
143
|
+
'program\s*{'
|
144
|
+
end
|
145
|
+
|
146
|
+
def unbalanced_closing_braces?(result)
|
147
|
+
result.match? /<pre>\[\d+:\d+\]: Se encontró un "}" pero no había una llave abierta "{".<\/pre>/
|
148
|
+
end
|
149
|
+
|
150
|
+
def error_line(result)
|
151
|
+
result.match /<pre>\[(\d+):\d+\]:/
|
152
|
+
end
|
153
|
+
|
154
|
+
def upper_identifier_instead_of_definition?(result)
|
155
|
+
result.match? /<pre>\[\d+:\d+\]: Se esperaba una definición \(de programa, función, procedimiento, o tipo\).\nSe encontró: un identificador con mayúsculas.<\/pre>/
|
156
|
+
end
|
157
|
+
|
158
|
+
def uppercase_function
|
159
|
+
'Function\s'
|
160
|
+
end
|
161
|
+
|
162
|
+
def uppercase_procedure
|
163
|
+
'Procedure\s'
|
164
|
+
end
|
165
|
+
|
166
|
+
def uppercase_program
|
167
|
+
'Program[\s{]*'
|
168
|
+
end
|
169
|
+
|
170
|
+
def procedure_instead_of_command?(result)
|
171
|
+
result.match? /<pre>\[\d+:\d+\]: Se esperaba un comando.\nSe encontró: la palabra clave "procedure".<\/pre>/
|
172
|
+
end
|
173
|
+
|
174
|
+
def open_paren_instead_of_assign?(result)
|
175
|
+
result.match? /<pre>\[\d+:\d+\]: Se esperaba un operador de asignación \(":="\).\nSe encontró: un paréntesis izquierdo \("\("\).<\/pre>/
|
176
|
+
end
|
177
|
+
|
178
|
+
def lower_builtin_procedure
|
179
|
+
'(mover[\s(]|poner[\s(]|sacar[\s(])'
|
180
|
+
end
|
181
|
+
|
182
|
+
def procedure_invocation_instead_of_expression?(result)
|
183
|
+
result.match? /<pre>\[\d+:\d+\]: Se esperaba una expresión.\nSe encontró: una invocación a un procedimiento.<\/pre>/
|
184
|
+
end
|
185
|
+
|
186
|
+
def upper_builtin_function
|
187
|
+
'(PuedeMover|NroBolitas|HayBolitas)'
|
188
|
+
end
|
189
|
+
|
190
|
+
def roja_not_defined?(result)
|
191
|
+
color_not_defined? result, 'Roja'
|
192
|
+
end
|
193
|
+
|
194
|
+
def negra_not_defined?(result)
|
195
|
+
color_not_defined? result, 'Negra'
|
196
|
+
end
|
197
|
+
|
198
|
+
def color_not_defined?(result, color)
|
199
|
+
result.match?(color_not_defined(color))
|
200
|
+
end
|
201
|
+
|
202
|
+
def color_not_defined(color='\w+')
|
203
|
+
/<pre>\[\d+:\d+\]: El constructor "(#{color})" no está definido.<\/pre>/
|
204
|
+
end
|
205
|
+
|
206
|
+
def rectified_color(color)
|
207
|
+
color.chop + "o"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
data/lib/gobstones_runner.rb
CHANGED
@@ -21,9 +21,10 @@ require_relative './render/html_renderer'
|
|
21
21
|
|
22
22
|
require_relative './multiple_executions_runner'
|
23
23
|
|
24
|
+
require_relative './checker'
|
25
|
+
require_relative './expectations_hook'
|
26
|
+
require_relative './feedback_hook'
|
24
27
|
require_relative './metadata_hook'
|
25
28
|
require_relative './precompile_hook'
|
26
29
|
require_relative './test_hook'
|
27
30
|
require_relative './version_hook'
|
28
|
-
require_relative './expectations_hook'
|
29
|
-
require_relative './checker'
|
data/lib/locales/en.yml
CHANGED
@@ -12,7 +12,19 @@ en:
|
|
12
12
|
code_wrong_argument_type: 'wrong arguments type'
|
13
13
|
code_unassigned_variable: 'unassigned variable'
|
14
14
|
code_wrong_arguments_quantity: 'wrong arguments quantity'
|
15
|
+
color_typo: 'It seems you wrote %{color}. Maybe you meant %{rectified_color}?'
|
15
16
|
expected_board: 'Expected final board'
|
16
17
|
final_board: 'Final board'
|
17
18
|
initial_board: 'Initial board'
|
19
|
+
lower_builtin_procedure_typo: 'Looks lie you wrote <code>%{lower}</code> in lowercase. Remember procedures such as <code>%{upper}()</code> should start in uppercase!'
|
20
|
+
missing_closing_brace_after_procedure: "Looks like you're missing a <code>}</code> to close a <code>procedure</code>. Maybe it's on line <strong>%{line}</strong> or near it?"
|
18
21
|
no_program_found: 'No program definition was found'
|
22
|
+
program_before_closing_structure_when_no_program: "Looks like you're missing a <code>}</code> to close the last <code>%{keyword}</code>."
|
23
|
+
program_before_closing_structure_when_program: "Looks like you're missing a <code>}</code> to close the last <code>%{keyword}</code> before <code>program</code>."
|
24
|
+
program_has_a_name: "Looks like you named your <code>program</code> <code>%{name}</code>, but <code>program</code>s shouldn't be named."
|
25
|
+
program_has_no_opening_curly_brace: "Looks like a <code>{</code> is missing on <code>program</code>. Remember the content in <code>program</code> should be between curly braces."
|
26
|
+
surplus_closing_brace: "The amount of <code>{</code> and <code>}</code> doesn't match. Maybe there's an extra <code>}</code> on line <strong>%{line}</strong> or near it?"
|
27
|
+
upper_builtin_function_typo: 'Looks like you wrote <code>%{upper}</code> starting in uppercase. Remember functions such as <code>%{lower}</code> should start in lowercase!'
|
28
|
+
upper_function_typo: 'Looks like you wrote <code>Function</code> instead of <code>function</code>. Remember it should start in lowercase!'
|
29
|
+
upper_procedure_typo: 'Looks like you wrote <code>Procedure</code> instead of <code>procedure</code>. Remember it should start in lowercase!'
|
30
|
+
upper_program_typo: 'Looks like you wrote <code>Program</code> instead of <code>program</code>. Remember it should start in lowercase!'
|
data/lib/locales/es.yml
CHANGED
@@ -12,7 +12,19 @@ es:
|
|
12
12
|
code_wrong_argument_type: 'problema de tipos en los argumentos'
|
13
13
|
code_unassigned_variable: 'variable no asignada'
|
14
14
|
code_wrong_arguments_quantity: 'cantidad errónea de argumentos'
|
15
|
+
color_typo: 'Parece que escribiste %{color}. ¿Quisiste referirte al color %{rectified_color}?'
|
15
16
|
expected_board: 'Tablero final esperado'
|
16
17
|
final_board: 'Tablero final'
|
17
18
|
initial_board: 'Tablero inicial'
|
19
|
+
lower_builtin_procedure_typo: 'Parece que escribiste <code>%{lower}</code> en minúsculas. ¡Recordá que los procedimientos como <code>%{upper}()</code> deben comenzar en mayúsculas!'
|
20
|
+
missing_closing_brace_after_procedure: 'Parece que te falta una <code>}</code> que cierre un <code>procedure</code>. ¿Puede que sea en la línea <strong>%{line}</strong> o cerca de ella?'
|
18
21
|
no_program_found: 'No se encontró ninguna definición de programa'
|
22
|
+
program_before_closing_structure_when_no_program: 'Parece que te falta una <code>}</code> que cierre el último <code>%{keyword}</code>.'
|
23
|
+
program_before_closing_structure_when_program: 'Parece que te falta una <code>}</code> que cierre el <code>%{keyword}</code> antes de <code>program</code>.'
|
24
|
+
program_has_a_name: 'Parece que llamaste <code>%{name}</code> a <code>program</code>, pero los <code>program</code> no llevan nombre.'
|
25
|
+
program_has_no_opening_curly_brace: 'Parece que a <code>program</code> le falta <code>{</code>. Recordá que el contenido de <code>program</code> va entre llaves.'
|
26
|
+
surplus_closing_brace: 'La cantidad de <code>{</code> y <code>}</code> no coincide. ¿Puede que sobre una <code>}</code> en la línea <strong>%{line}</strong> o cerca de ella?'
|
27
|
+
upper_builtin_function_typo: 'Parece que escribiste <code>%{upper}</code> comenzando en mayúsculas. ¡Recordá que las funciones como <code>%{lower}</code> deben comenzar en minúsculas!'
|
28
|
+
upper_function_typo: 'Parece que escribiste <code>Function</code> en lugar de <code>function</code>. ¡Recordá que debe comenzar en minúsculas!'
|
29
|
+
upper_procedure_typo: 'Parece que escribiste <code>Procedure</code> en lugar de <code>procedure</code>. ¡Recordá que debe comenzar en minúsculas!'
|
30
|
+
upper_program_typo: 'Parece que escribiste <code>Program</code> en lugar de <code>program</code>. ¡Recordá que debe comenzar en minúsculas!'
|
data/lib/locales/pt.yml
CHANGED
@@ -12,7 +12,19 @@ pt:
|
|
12
12
|
code_wrong_argument_type: 'problema de tipos nos argumentos'
|
13
13
|
code_unassigned_variable: 'variável não atribuída'
|
14
14
|
code_wrong_arguments_quantity: 'quantidade errada de argumentos'
|
15
|
+
color_typo: 'Parece que você escreveu %{color}. Você quis se referir à cor %{rectified_color}?'
|
15
16
|
expected_board: 'Tabuleiro final esperado'
|
16
17
|
final_board: 'Tabuleiro final'
|
17
18
|
initial_board: 'Tabuleiro inicial'
|
19
|
+
lower_builtin_procedure_typo: 'Parece que você escreveu <code>%{lower}</code> em letras minúsculas. Lembre-se de que procedimentos como <code>%{upper}()</code> devem começar em maiúsculas!'
|
20
|
+
missing_closing_brace_after_procedure: 'Parece que está faltando um <code>}</code> que fecha um <code>procedure</code>. Pode ser na linha <strong>%{line}</strong> ou perto dela?'
|
18
21
|
no_program_found: 'Nenhuma definição de programa foi encontrada'
|
22
|
+
program_before_closing_structure_when_no_program: 'Parece que está faltando um <code>}</code> que fecha a última <code>%{keyword}</code>.'
|
23
|
+
program_before_closing_structure_when_program: 'Parece que está faltando um <code>}</code> que fecha o <code>%{keyword}</code> antes do <code>program</code>.'
|
24
|
+
program_has_a_name: 'Parece que você chamou <code>%{name}</code> para <code>program</code>, mas <code>program</code>as não têm nomes.'
|
25
|
+
program_has_no_opening_curly_brace: 'Parece que a <code>program</code> está faltando <code>{</code>. Lembre-se de que o conteúdo do <code>program</code> está entre colchetes.'
|
26
|
+
surplus_closing_brace: 'A quantidade de <code>{</code> e <code>}</code> não corresponde. Pode ser sobre um <code>}</code> na linha <strong>%{line}</strong> ou próximo a ela?'
|
27
|
+
upper_builtin_function_typo: 'Parece que você digitou <code>%{upper}</code> começando com letras maiúsculas. Lembre-se de que funções como <code>%{lower}</code> devem começar em minúsculas!'
|
28
|
+
upper_function_typo: 'Parece que você escreveu <code>Function</code> em vez de <code>function</code>. Lembre-se de começar em letras minúsculas!'
|
29
|
+
upper_procedure_typo: 'Parece que você escreveu <code>Procedure</code> em vez de <code>procedure</code>. Lembre-se de começar em letras minúsculas!'
|
30
|
+
upper_program_typo: 'Parece que você escreveu <code>Program</code> em vez de <code>program</code>. Lembre-se de começar em letras minúsculas!'
|
data/lib/version_hook.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-gobstones-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Alfonso
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-11-
|
12
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gobstones-board
|
@@ -59,14 +59,14 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '2.
|
62
|
+
version: '2.37'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '2.
|
69
|
+
version: '2.37'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: nokogiri
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- lib/checker.rb
|
184
184
|
- lib/expectations_hook.rb
|
185
185
|
- lib/extensions/string.rb
|
186
|
+
- lib/feedback_hook.rb
|
186
187
|
- lib/game_framework/default.gbs.erb
|
187
188
|
- lib/game_framework/default.xml.erb
|
188
189
|
- lib/game_framework/extra.gbs.erb
|