mumuki-gobstones-runner 2.10.1 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets_server.rb +6 -2
- data/lib/feedback_hook.rb +210 -0
- data/lib/game_framework/extra.gbs.erb +20 -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/public/media/five.png +0 -0
- data/lib/public/media/four.png +0 -0
- data/lib/public/media/one.png +0 -0
- data/lib/public/media/three.png +0 -0
- data/lib/public/media/two.png +0 -0
- data/lib/public/minimal-kindergarten-toolbox.xml +0 -1
- data/lib/public/toolbox/kindergarten-2-to-3.xml +6 -0
- data/lib/public/toolbox/kindergarten-2-to-4.xml +7 -0
- data/lib/public/toolbox/kindergarten-2-to-5.xml +8 -0
- data/lib/public/toolbox/kindergarten-full.xml +5 -0
- data/lib/public/toolbox/kindergarten-minimal.xml +1 -0
- data/lib/render/editor/editor.css +4 -0
- data/lib/render/editor/editor.html.erb +43 -14
- data/lib/render/layout/layout.html +1 -0
- data/lib/version_hook.rb +1 -1
- metadata +16 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1e37b379d7f5b9d1741c5e284a8fb194bf7cf4e98d8ebe0d5560f8c18f550f3
|
4
|
+
data.tar.gz: f4db093fd3129f3427244acbcc5b5848044471bd917c1313d0c074e0adaf04cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfbe216007c99bc8cd60aac82a806dbdfed12a4b4a9384de32de8d0b3718151d289e77ab9c895d1e1da621419dc9bdf720e766d6289d8f83357af8be1177bdd3
|
7
|
+
data.tar.gz: 149eaa77b7069cf2f0af824afee3af05480d7d7e3a6dd36d1a31f4d90a7ea3fa377c70995b56b40dddcce119c9bc689139f3befe5ccb81a4748708d988440483
|
data/lib/assets_server.rb
CHANGED
@@ -17,10 +17,10 @@ class Mumukit::Server::App < Sinatra::Base
|
|
17
17
|
get_local_asset "#{asset_type}/#{name}.svg", "lib/public/#{name}.svg", 'image/svg+xml'
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.get_media_assets(folder)
|
20
|
+
def self.get_media_assets(folder, content_type = nil)
|
21
21
|
Dir.glob(File.join(__dir__,"../lib/public/#{folder}/*")).each do |path|
|
22
22
|
relative_media_asset_path = "#{folder}/#{File.basename path}"
|
23
|
-
get_local_asset relative_media_asset_path, "lib/public/#{relative_media_asset_path}"
|
23
|
+
get_local_asset relative_media_asset_path, "lib/public/#{relative_media_asset_path}", content_type
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -38,9 +38,13 @@ class Mumukit::Server::App < Sinatra::Base
|
|
38
38
|
get_local_asset 'editor/editor.css', 'lib/render/editor/editor.css', 'text/css'
|
39
39
|
get_local_asset 'editor/hammer.min.js', 'lib/render/editor/hammer.min.js', 'application/javascript'
|
40
40
|
get_local_asset 'boom.png', 'lib/public/boom.png', 'image/png'
|
41
|
+
|
42
|
+
# Depracated, prefer toolbox path
|
41
43
|
get_local_asset 'full-kindergarten-toolbox.xml', 'lib/public/full-kindergarten-toolbox.xml', 'text/plain'
|
42
44
|
get_local_asset 'minimal-kindergarten-toolbox.xml', 'lib/public/minimal-kindergarten-toolbox.xml', 'text/plain'
|
43
45
|
|
46
|
+
get_media_assets 'toolbox', 'text/plain'
|
47
|
+
|
44
48
|
get_media_assets 'media'
|
45
49
|
get_media_assets 'local-media'
|
46
50
|
|
@@ -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_before_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
|
@@ -62,6 +62,26 @@ procedure ShiftDown() {
|
|
62
62
|
ShiftTo(Sur)
|
63
63
|
}
|
64
64
|
|
65
|
+
function one() {
|
66
|
+
return (1);
|
67
|
+
}
|
68
|
+
|
69
|
+
function two() {
|
70
|
+
return (2);
|
71
|
+
}
|
72
|
+
|
73
|
+
function three() {
|
74
|
+
return (3);
|
75
|
+
}
|
76
|
+
|
77
|
+
function four() {
|
78
|
+
return (4);
|
79
|
+
}
|
80
|
+
|
81
|
+
function five() {
|
82
|
+
return (5);
|
83
|
+
}
|
84
|
+
|
65
85
|
procedure ShiftTo(dir) {
|
66
86
|
if (puedeMover(dir)) {
|
67
87
|
Sacar(Rojo)
|
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 <code>%{color}</code>. Did you mean <code>%{rectified_color}</code>?'
|
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_before_procedure: "Looks like you're missing a <code>}</code> before 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 <code>%{color}</code>. ¿Quisiste referirte al color <code>%{rectified_color}</code>?'
|
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_before_procedure: 'Parece que te falta una <code>}</code> antes de 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 <code>%{color}</code>. Você quis se referir à cor <code>%{rectified_color}</code>?'
|
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_before_procedure: 'Parece que está faltando um <code>}</code> antes de 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!'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<category name="Bloques de Gobstones">
|
2
|
+
<block type="RepeticionSimple"></block>
|
3
|
+
<block type="two"></block>
|
4
|
+
<block type="three"></block>
|
5
|
+
<block type="four"></block>
|
6
|
+
<block type="five"></block>
|
7
|
+
</category>
|
8
|
+
<category name="Procedimientos primitivos"></category>
|
@@ -0,0 +1 @@
|
|
1
|
+
<category name="Procedimientos primitivos"></category>
|
@@ -216,10 +216,7 @@
|
|
216
216
|
this._setBlocklyDisplayMode();
|
217
217
|
this._setBlocklySounds();
|
218
218
|
this._setBlocklyColors();
|
219
|
-
|
220
|
-
if (!this.readOnly) {
|
221
|
-
this._relocateTrashOnResize();
|
222
|
-
}
|
219
|
+
this._relocateTrashOnResize();
|
223
220
|
|
224
221
|
// Removing "/" from the block id character set to avoid syntax errors
|
225
222
|
Blockly.utils.genUid.soup_ = Blockly.utils.genUid.soup_.replace("/", "");
|
@@ -233,11 +230,16 @@
|
|
233
230
|
},
|
234
231
|
|
235
232
|
_relocateTrashOnResize() {
|
233
|
+
if (this.readOnly) {
|
234
|
+
console.debug("No trash relocate on resize required");
|
235
|
+
return;
|
236
|
+
}
|
237
|
+
|
236
238
|
$('.mu-kids-context, .mu-kids-results').on('hidden.bs.modal shown.bs.modal', () => {
|
237
239
|
this._relocateTrash();
|
238
240
|
});
|
239
241
|
|
240
|
-
$(window).resize(() => this._relocateTrash
|
242
|
+
$(window).resize(() => setTimeout(this._relocateTrash));
|
241
243
|
},
|
242
244
|
|
243
245
|
|
@@ -246,6 +248,8 @@
|
|
246
248
|
*
|
247
249
|
* Blockly's workspace is destroyed when toolbox changes, so initialization
|
248
250
|
* is performed here
|
251
|
+
|
252
|
+
* @see _initializeBlocklyWorkspace
|
249
253
|
*/
|
250
254
|
_initializeCustomToolboxBlocklyWorkspace(toolboxXml) {
|
251
255
|
this._getBlockly().toolbox = { defaultToolbox: toolboxXml };
|
@@ -258,6 +262,8 @@
|
|
258
262
|
* Blockly's workspace is destroyed when toolbox changes,
|
259
263
|
* so this method will initialize it only if a there is a custom toolbox
|
260
264
|
* that will be called later.
|
265
|
+
*
|
266
|
+
* @see _initializeBlocklyWorkspace
|
261
267
|
*/
|
262
268
|
_initializeNonCustomToolboxBlocklyWorkspace() {
|
263
269
|
if (!this.hasCustomToolbox()) {
|
@@ -265,11 +271,20 @@
|
|
265
271
|
}
|
266
272
|
},
|
267
273
|
|
274
|
+
/**
|
275
|
+
* Performs actual workspace (re)creation,
|
276
|
+
* which sets initial xml, user solution, trash position
|
277
|
+
* and appropriate callbacks.
|
278
|
+
*
|
279
|
+
* This method is the actual culmination of the blockly initialization
|
280
|
+
* process
|
281
|
+
*/
|
268
282
|
_initializeBlocklyWorkspace() {
|
269
283
|
console.debug('Initializing Blockly Workspace');
|
270
284
|
|
271
285
|
this._setInitialXml();
|
272
286
|
this._initializeWorkspace();
|
287
|
+
this._relocateTrash();
|
273
288
|
this._subscribeToWorkspace(() => this._updateSolution());
|
274
289
|
|
275
290
|
if (this.hasInteractiveProgram()) {
|
@@ -280,10 +295,17 @@
|
|
280
295
|
},
|
281
296
|
|
282
297
|
_relocateTrash() {
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
298
|
+
if (this.readOnly) {
|
299
|
+
console.debug("No trash relocate required");
|
300
|
+
return;
|
301
|
+
}
|
302
|
+
|
303
|
+
const $blocklyTrash = $('.blocklyTrash');
|
304
|
+
const $blocklyDiv = $('#blocklyDiv');
|
305
|
+
const width = $blocklyDiv.width() - 68;
|
306
|
+
const height = $blocklyDiv.height() - 210;
|
307
|
+
$blocklyTrash.css("transform", `translate(${width}px, ${height}px)`);
|
308
|
+
$blocklyTrash.css("display", "unset");
|
287
309
|
},
|
288
310
|
|
289
311
|
_updateSolution() {
|
@@ -406,11 +428,14 @@
|
|
406
428
|
console.debug("Set game actions");
|
407
429
|
const blockly = this._getBlockly();
|
408
430
|
|
409
|
-
this._setPrimitiveProcedures(
|
410
|
-
this.
|
411
|
-
|
412
|
-
|
413
|
-
|
431
|
+
this._setPrimitiveProcedures(
|
432
|
+
this._gamePrimitivesFor(blockly.primitiveProcedures, [
|
433
|
+
'ShiftUp', 'ShiftDown', 'ShiftLeft', 'ShiftRight'
|
434
|
+
]));
|
435
|
+
|
436
|
+
this._setPrimitiveFunctions(
|
437
|
+
this._gamePrimitivesFor(blockly.primitiveFunctions, [
|
438
|
+
'one', 'two', 'three', 'four', 'five'
|
414
439
|
]));
|
415
440
|
},
|
416
441
|
|
@@ -436,6 +461,10 @@
|
|
436
461
|
return { alias: 'procedureDeclaration', name, attributes: {block_icon: `<%= @assets_url %>/media/${name}.png`} };
|
437
462
|
},
|
438
463
|
|
464
|
+
_gamePrimitivesFor(base, names) {
|
465
|
+
return (base || []).concat(names.map(it => this._gamePrimitive(it)));
|
466
|
+
},
|
467
|
+
|
439
468
|
_getBlockly() {
|
440
469
|
return this.$.blocklyElement;
|
441
470
|
},
|
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.14.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-12-11 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
|
@@ -239,12 +240,22 @@ files:
|
|
239
240
|
- lib/public/media/disconnect.mp3
|
240
241
|
- lib/public/media/disconnect.ogg
|
241
242
|
- lib/public/media/disconnect.wav
|
243
|
+
- lib/public/media/five.png
|
244
|
+
- lib/public/media/four.png
|
245
|
+
- lib/public/media/one.png
|
242
246
|
- lib/public/media/quote0.png
|
243
247
|
- lib/public/media/quote1.png
|
244
248
|
- lib/public/media/sprites.png
|
245
249
|
- lib/public/media/sprites.svg
|
250
|
+
- lib/public/media/three.png
|
251
|
+
- lib/public/media/two.png
|
246
252
|
- lib/public/minimal-kindergarten-toolbox.xml
|
247
253
|
- lib/public/red.svg
|
254
|
+
- lib/public/toolbox/kindergarten-2-to-3.xml
|
255
|
+
- lib/public/toolbox/kindergarten-2-to-4.xml
|
256
|
+
- lib/public/toolbox/kindergarten-2-to-5.xml
|
257
|
+
- lib/public/toolbox/kindergarten-full.xml
|
258
|
+
- lib/public/toolbox/kindergarten-minimal.xml
|
248
259
|
- lib/render/boards.html.erb
|
249
260
|
- lib/render/editor/editor.css
|
250
261
|
- lib/render/editor/editor.html.erb
|
@@ -275,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
286
|
- !ruby/object:Gem::Version
|
276
287
|
version: '0'
|
277
288
|
requirements: []
|
278
|
-
rubygems_version: 3.0.
|
289
|
+
rubygems_version: 3.0.3
|
279
290
|
signing_key:
|
280
291
|
specification_version: 4
|
281
292
|
summary: Gobstones Runner for Mumuki
|