mumuki-gobstones-runner 2.9.0 → 2.12.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 +2 -0
- 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/render/editor/editor.css +6 -1
- data/lib/render/editor/editor.html.erb +86 -24
- data/lib/render/layout/layout.html +1 -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: d85da0b0c9fecd26e9b7d19346e44235e47a3e6efe5ee76c2504d40eb47a2dcd
|
4
|
+
data.tar.gz: 3cff2267ef410ea1cce2d63d4524d0453bc7b976e292050edc7c1441d78b65f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecda66dd1d44e538330f68ea19087eda4eb5c9e5b44bf7d04f60d49f477e75669f78781da58bc3c27bd8375e4a2f80b803190d750f8da970b4dd6ab34612f7e1
|
7
|
+
data.tar.gz: 6cdd4d96eaa8f55ad1f977adbf7b3cfe8ceab835240672a469c78bca907abb4f23735f1eab64e6fa5c776ac609dae00c4d4f9785e51a7ae481df795a5af869a9
|
data/lib/assets_server.rb
CHANGED
@@ -54,6 +54,8 @@ class Mumukit::Server::App < Sinatra::Base
|
|
54
54
|
|
55
55
|
get '/assets/editor/editor.html' do
|
56
56
|
cross_origin
|
57
|
+
content_type 'text/html'
|
58
|
+
|
57
59
|
@game_framework_extra = Gobstones::CompilationMode::GameFramework.extra_code
|
58
60
|
@game_framework_program = Gobstones::CompilationMode::GameFramework.program_code
|
59
61
|
@game_framework_default = Gobstones::CompilationMode::GameFramework.default_code
|
@@ -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
|
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!'
|
@@ -116,7 +116,6 @@
|
|
116
116
|
}
|
117
117
|
}
|
118
118
|
|
119
|
-
|
120
119
|
.mu-kids-exercise.mu-kindergarten .gbs_boom {
|
121
120
|
display: none;
|
122
121
|
}
|
@@ -128,3 +127,9 @@
|
|
128
127
|
.mu-kids-exercise.mu-kindergarten .gbs_gh {
|
129
128
|
outline: 0 !important;
|
130
129
|
}
|
130
|
+
|
131
|
+
.mu-kids-exercise.mu-kindergarten .mu-kids-state .mu-kids-state-image gs-board>table {
|
132
|
+
background-color: #6D6E70!important;
|
133
|
+
border: 1px solid #6D6E70 !important;
|
134
|
+
border-radius: 4px;
|
135
|
+
}
|
@@ -9,6 +9,11 @@
|
|
9
9
|
Blockly.FieldImage.prototype.setValue = function(a) {
|
10
10
|
if (a && a.startsWith("undefined")) {
|
11
11
|
console.debug(`Ignoring unavailable image ${a}`);
|
12
|
+
} else if (a) {
|
13
|
+
const absoluteUrl = a
|
14
|
+
.replace("../media/", "../local-media/")
|
15
|
+
.replace("../local-media/", "<%= @assets_url %>/local-media/");
|
16
|
+
this.__setValue__(absoluteUrl);
|
12
17
|
} else {
|
13
18
|
this.__setValue__(a);
|
14
19
|
}
|
@@ -211,10 +216,7 @@
|
|
211
216
|
this._setBlocklyDisplayMode();
|
212
217
|
this._setBlocklySounds();
|
213
218
|
this._setBlocklyColors();
|
214
|
-
|
215
|
-
if (!this.readOnly) {
|
216
|
-
this._relocateTrashOnResize();
|
217
|
-
}
|
219
|
+
this._relocateTrashOnResize();
|
218
220
|
|
219
221
|
// Removing "/" from the block id character set to avoid syntax errors
|
220
222
|
Blockly.utils.genUid.soup_ = Blockly.utils.genUid.soup_.replace("/", "");
|
@@ -228,6 +230,11 @@
|
|
228
230
|
},
|
229
231
|
|
230
232
|
_relocateTrashOnResize() {
|
233
|
+
if (this.readOnly) {
|
234
|
+
console.debug("No trash relocate on resize required");
|
235
|
+
return;
|
236
|
+
}
|
237
|
+
|
231
238
|
$('.mu-kids-context, .mu-kids-results').on('hidden.bs.modal shown.bs.modal', () => {
|
232
239
|
this._relocateTrash();
|
233
240
|
});
|
@@ -241,6 +248,8 @@
|
|
241
248
|
*
|
242
249
|
* Blockly's workspace is destroyed when toolbox changes, so initialization
|
243
250
|
* is performed here
|
251
|
+
|
252
|
+
* @see _initializeBlocklyWorkspace
|
244
253
|
*/
|
245
254
|
_initializeCustomToolboxBlocklyWorkspace(toolboxXml) {
|
246
255
|
this._getBlockly().toolbox = { defaultToolbox: toolboxXml };
|
@@ -253,6 +262,8 @@
|
|
253
262
|
* Blockly's workspace is destroyed when toolbox changes,
|
254
263
|
* so this method will initialize it only if a there is a custom toolbox
|
255
264
|
* that will be called later.
|
265
|
+
*
|
266
|
+
* @see _initializeBlocklyWorkspace
|
256
267
|
*/
|
257
268
|
_initializeNonCustomToolboxBlocklyWorkspace() {
|
258
269
|
if (!this.hasCustomToolbox()) {
|
@@ -260,11 +271,20 @@
|
|
260
271
|
}
|
261
272
|
},
|
262
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
|
+
*/
|
263
282
|
_initializeBlocklyWorkspace() {
|
264
283
|
console.debug('Initializing Blockly Workspace');
|
265
284
|
|
266
285
|
this._setInitialXml();
|
267
286
|
this._initializeWorkspace();
|
287
|
+
this._relocateTrash();
|
268
288
|
this._subscribeToWorkspace(() => this._updateSolution());
|
269
289
|
|
270
290
|
if (this.hasInteractiveProgram()) {
|
@@ -275,19 +295,31 @@
|
|
275
295
|
},
|
276
296
|
|
277
297
|
_relocateTrash() {
|
298
|
+
if (this.readOnly) {
|
299
|
+
console.debug("No trash relocate required");
|
300
|
+
return;
|
301
|
+
}
|
302
|
+
|
303
|
+
const $blocklyTrash = $('.blocklyTrash');
|
278
304
|
const width = $('#blocklyDiv').width() - 68;
|
279
305
|
const height = $('#blocklyDiv').height() - 210;
|
280
|
-
$
|
281
|
-
$
|
306
|
+
$blocklyTrash.css("transform", `translate(${width}px, ${height}px)`);
|
307
|
+
$blocklyTrash.css("display", "unset");
|
282
308
|
},
|
283
309
|
|
284
310
|
_updateSolution() {
|
311
|
+
console.debug("Updating solution");
|
285
312
|
const blockly = this._getBlockly();
|
286
|
-
|
313
|
+
let changed;
|
287
314
|
if (this.teacherMode) {
|
288
|
-
this._setExtraCode(blockly.workspaceXml);
|
315
|
+
changed = this._setExtraCode(blockly.workspaceXml);
|
289
316
|
} else {
|
290
|
-
this._setStudentSolution(blockly.workspaceXml);
|
317
|
+
changed = this._setStudentSolution(blockly.workspaceXml);
|
318
|
+
}
|
319
|
+
|
320
|
+
if (!changed) {
|
321
|
+
console.debug("No solution update required")
|
322
|
+
return;
|
291
323
|
}
|
292
324
|
|
293
325
|
// TODO: this hack enables Angular two-way binding for Bibliotheca. Should be replaced with Mumuki events system
|
@@ -380,22 +412,44 @@
|
|
380
412
|
return;
|
381
413
|
}
|
382
414
|
|
383
|
-
|
415
|
+
console.debug("Set teacher actions");
|
384
416
|
const actions = new Parser().getActionsFromSource(teacherCode);
|
385
|
-
|
386
|
-
|
417
|
+
|
418
|
+
this._setPrimitiveProcedures(this._withDefaultIcons(actions, 'procedureDeclarations'));
|
419
|
+
this._setPrimitiveFunctions(this._withDefaultIcons(actions, 'functionDeclarations'));
|
387
420
|
},
|
388
421
|
|
389
422
|
_setGameActions() {
|
423
|
+
if (!this._isGame()) {
|
424
|
+
return;
|
425
|
+
}
|
426
|
+
|
427
|
+
console.debug("Set game actions");
|
390
428
|
const blockly = this._getBlockly();
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
429
|
+
|
430
|
+
this._setPrimitiveProcedures((blockly.primitiveProcedures || []).concat([
|
431
|
+
this._gamePrimitive('ShiftUp'),
|
432
|
+
this._gamePrimitive('ShiftDown'),
|
433
|
+
this._gamePrimitive('ShiftLeft'),
|
434
|
+
this._gamePrimitive('ShiftRight')
|
435
|
+
]));
|
436
|
+
},
|
437
|
+
|
438
|
+
_setPrimitiveProcedures(procedures) {
|
439
|
+
this._setBlocklyActions("primitiveProcedures", procedures);
|
440
|
+
},
|
441
|
+
|
442
|
+
_setPrimitiveFunctions(functions) {
|
443
|
+
this._setBlocklyActions("primitiveFunctions", functions);
|
444
|
+
},
|
445
|
+
|
446
|
+
_setBlocklyActions(key, actions) {
|
447
|
+
try {
|
448
|
+
this._getBlockly()[key] = actions
|
449
|
+
} catch (e) {
|
450
|
+
if (this._getBlockly()[key] !== actions) {
|
451
|
+
throw e;
|
452
|
+
}
|
399
453
|
}
|
400
454
|
},
|
401
455
|
|
@@ -416,8 +470,12 @@
|
|
416
470
|
* to user content in laboratory, and default content in bibliotheca
|
417
471
|
*/
|
418
472
|
_setStudentSolution(code) {
|
419
|
-
|
420
|
-
|
473
|
+
if (this._getStudentEditor().value !== code) {
|
474
|
+
console.debug(`Setting student ${code}`)
|
475
|
+
this._getStudentEditor().value = code;
|
476
|
+
return true;
|
477
|
+
}
|
478
|
+
return false;
|
421
479
|
},
|
422
480
|
|
423
481
|
_getDefaultCode() {
|
@@ -429,8 +487,12 @@
|
|
429
487
|
},
|
430
488
|
|
431
489
|
_setExtraCode(code) {
|
432
|
-
|
433
|
-
|
490
|
+
if (this._getEditorExtra().value !== code) {
|
491
|
+
console.debug(`Setting extra ${code}`)
|
492
|
+
this._getEditorExtra().value = code;
|
493
|
+
return true;
|
494
|
+
}
|
495
|
+
return false;
|
434
496
|
},
|
435
497
|
|
436
498
|
_getEditorExtra: function() {
|
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.12.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-
|
12
|
+
date: 2020-11-16 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
|