mumuki-gobstones-runner 2.6.0 → 2.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assets_server.rb +20 -1
  3. data/lib/checker.rb +2 -2
  4. data/lib/game_framework/default.gbs.erb +3 -0
  5. data/lib/game_framework/default.xml.erb +3 -0
  6. data/lib/game_framework/extra.gbs.erb +84 -0
  7. data/lib/game_framework/program.gbs.erb +5 -0
  8. data/lib/game_framework/program.xml.erb +17 -0
  9. data/lib/gobstones.rb +1 -0
  10. data/lib/gobstones/batch.rb +4 -2
  11. data/lib/gobstones/batch_parser.rb +5 -1
  12. data/lib/gobstones/compilation_mode.rb +60 -0
  13. data/lib/gobstones_runner.rb +3 -1
  14. data/lib/public/full-kindergarten-toolbox.xml +5 -0
  15. data/lib/public/local-media/bool-false.svg +24 -0
  16. data/lib/public/local-media/bool-true.svg +17 -0
  17. data/lib/public/local-media/clean.png +0 -0
  18. data/lib/public/local-media/color-azul.svg +44 -0
  19. data/lib/public/local-media/color-negro.svg +44 -0
  20. data/lib/public/local-media/color-rojo.svg +44 -0
  21. data/lib/public/local-media/color-verde.svg +44 -0
  22. data/lib/public/local-media/direccion-este.svg +38 -0
  23. data/lib/public/local-media/direccion-norte.svg +38 -0
  24. data/lib/public/local-media/direccion-oeste.svg +38 -0
  25. data/lib/public/local-media/direccion-sur.svg +38 -0
  26. data/lib/public/local-media/hand.png +0 -0
  27. data/lib/public/local-media/main-procedure.png +0 -0
  28. data/lib/public/local-media/minus.png +0 -0
  29. data/lib/public/local-media/plus.png +0 -0
  30. data/lib/public/local-media/program.png +0 -0
  31. data/lib/public/local-media/repeticion-simple.png +0 -0
  32. data/lib/public/media/1x1.gif +0 -0
  33. data/lib/public/media/ShiftDown.png +0 -0
  34. data/lib/public/media/ShiftLeft.png +0 -0
  35. data/lib/public/media/ShiftRight.png +0 -0
  36. data/lib/public/media/ShiftUp.png +0 -0
  37. data/lib/public/media/click.mp3 +0 -0
  38. data/lib/public/media/click.ogg +0 -0
  39. data/lib/public/media/click.wav +0 -0
  40. data/lib/public/media/delete.mp3 +0 -0
  41. data/lib/public/media/delete.ogg +0 -0
  42. data/lib/public/media/delete.wav +0 -0
  43. data/lib/public/media/disconnect.mp3 +0 -0
  44. data/lib/public/media/disconnect.ogg +0 -0
  45. data/lib/public/media/disconnect.wav +0 -0
  46. data/lib/public/media/quote0.png +0 -0
  47. data/lib/public/media/quote1.png +0 -0
  48. data/lib/public/media/sprites.png +0 -0
  49. data/lib/public/media/sprites.svg +74 -0
  50. data/lib/public/minimal-kindergarten-toolbox.xml +2 -0
  51. data/lib/render/boards.html.erb +4 -6
  52. data/lib/render/editor/editor.css +9 -0
  53. data/lib/render/editor/{editor.html → editor.html.erb} +143 -18
  54. data/lib/render/html_renderer.rb +2 -2
  55. data/lib/render/with_renderer.rb +6 -3
  56. data/lib/version_hook.rb +1 -1
  57. metadata +92 -36
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="14.173px" height="14.173px" viewBox="0 0 14.173 14.173" enable-background="new 0 0 14.173 14.173" xml:space="preserve">
6
+ <g id="Layer_2" display="none">
7
+ <g display="inline">
8
+ <rect x="-5.132" y="-3.933" fill="#5CBEFF" width="67.306" height="25.396"/>
9
+ </g>
10
+ </g>
11
+ <g id="Layer_3" display="none">
12
+ </g>
13
+ <g id="Layer_7">
14
+ </g>
15
+ <g id="Layer_1">
16
+
17
+ <circle fill="#E25242" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="7.087" cy="7.086" r="3.688"/>
18
+ </g>
19
+ <g id="Layer_6" display="none">
20
+ <g display="inline">
21
+ <g>
22
+
23
+ <path fill="#231F20" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
24
+ M7.082,3.701c0.021,1.21-0.007,5.512,0,6.771L0.889,7.086L7.082,3.701z"/>
25
+ </g>
26
+ <g>
27
+
28
+ <path fill="none" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
29
+ M7.09,3.701c-0.021,1.21,0.008,5.512,0,6.771l6.194-3.386L7.09,3.701z"/>
30
+ </g>
31
+ </g>
32
+ </g>
33
+ <g id="Layer_5" display="none">
34
+
35
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="3.836" y1="3.836" x2="10.336" y2="10.336"/>
36
+
37
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="10.336" y1="3.836" x2="3.836" y2="10.336"/>
38
+ </g>
39
+ <g id="Layer_4" display="none">
40
+
41
+ <polyline display="inline" fill="none" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
42
+ 10.958,4.801 6.388,9.372 3.215,6.094 "/>
43
+ </g>
44
+ </svg>
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="14.173px" height="14.173px" viewBox="0 0 14.173 14.173" enable-background="new 0 0 14.173 14.173" xml:space="preserve">
6
+ <g id="Layer_2" display="none">
7
+ <g display="inline">
8
+ <rect x="-5.132" y="-3.933" fill="#5CBEFF" width="67.306" height="25.396"/>
9
+ </g>
10
+ </g>
11
+ <g id="Layer_3" display="none">
12
+ </g>
13
+ <g id="Layer_7">
14
+ </g>
15
+ <g id="Layer_1">
16
+
17
+ <circle fill="#13B47B" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" cx="7.087" cy="7.086" r="3.688"/>
18
+ </g>
19
+ <g id="Layer_6" display="none">
20
+ <g display="inline">
21
+ <g>
22
+
23
+ <path fill="#231F20" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
24
+ M7.082,3.701c0.021,1.21-0.007,5.512,0,6.771L0.889,7.086L7.082,3.701z"/>
25
+ </g>
26
+ <g>
27
+
28
+ <path fill="none" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
29
+ M7.09,3.701c-0.021,1.21,0.008,5.512,0,6.771l6.194-3.386L7.09,3.701z"/>
30
+ </g>
31
+ </g>
32
+ </g>
33
+ <g id="Layer_5" display="none">
34
+
35
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="3.836" y1="3.836" x2="10.336" y2="10.336"/>
36
+
37
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="10.336" y1="3.836" x2="3.836" y2="10.336"/>
38
+ </g>
39
+ <g id="Layer_4" display="none">
40
+
41
+ <polyline display="inline" fill="none" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
42
+ 10.958,4.801 6.388,9.372 3.215,6.094 "/>
43
+ </g>
44
+ </svg>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="14.173px" height="14.173px" viewBox="0 0 14.173 14.173" enable-background="new 0 0 14.173 14.173" xml:space="preserve">
6
+ <g id="Layer_2" display="none">
7
+ <g display="inline">
8
+ <rect x="-5.132" y="-3.933" fill="#5CBEFF" width="67.306" height="25.396"/>
9
+ </g>
10
+ </g>
11
+ <g id="Layer_3" display="none">
12
+ </g>
13
+ <g id="Layer_1">
14
+ <g>
15
+ <g>
16
+
17
+ <path fill="#231F20" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
18
+ M7.091,3.701c-0.021,1.21,0.007,5.512,0,6.771l6.193-3.386L7.091,3.701z"/>
19
+ </g>
20
+ <g>
21
+
22
+ <path fill="none" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
23
+ M7.083,3.701c0.021,1.21-0.008,5.512,0,6.771L0.889,7.086L7.083,3.701z"/>
24
+ </g>
25
+ </g>
26
+ </g>
27
+ <g id="Layer_5" display="none">
28
+
29
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="3.836" y1="3.836" x2="10.336" y2="10.336"/>
30
+
31
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="10.336" y1="3.836" x2="3.836" y2="10.336"/>
32
+ </g>
33
+ <g id="Layer_4" display="none">
34
+
35
+ <polyline display="inline" fill="none" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
36
+ 10.958,4.801 6.388,9.372 3.215,6.094 "/>
37
+ </g>
38
+ </svg>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="14.173px" height="14.173px" viewBox="0 0 14.173 14.173" enable-background="new 0 0 14.173 14.173" xml:space="preserve">
6
+ <g id="Layer_2" display="none">
7
+ <g display="inline">
8
+ <rect x="-5.132" y="-3.933" fill="#5CBEFF" width="67.306" height="25.396"/>
9
+ </g>
10
+ </g>
11
+ <g id="Layer_3" display="none">
12
+ </g>
13
+ <g id="Layer_1">
14
+ <g>
15
+ <g>
16
+
17
+ <path fill="#231F20" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
18
+ M10.472,7.083c-1.21,0.021-5.512-0.007-6.771,0l3.386-6.193L10.472,7.083z"/>
19
+ </g>
20
+ <g>
21
+
22
+ <path fill="none" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
23
+ M10.472,7.09c-1.21-0.021-5.512,0.008-6.771,0l3.386,6.194L10.472,7.09z"/>
24
+ </g>
25
+ </g>
26
+ </g>
27
+ <g id="Layer_5" display="none">
28
+
29
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="3.836" y1="3.836" x2="10.336" y2="10.336"/>
30
+
31
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="10.336" y1="3.836" x2="3.836" y2="10.336"/>
32
+ </g>
33
+ <g id="Layer_4" display="none">
34
+
35
+ <polyline display="inline" fill="none" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
36
+ 10.958,4.801 6.388,9.372 3.215,6.094 "/>
37
+ </g>
38
+ </svg>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="14.173px" height="14.173px" viewBox="0 0 14.173 14.173" enable-background="new 0 0 14.173 14.173" xml:space="preserve">
6
+ <g id="Layer_2" display="none">
7
+ <g display="inline">
8
+ <rect x="-5.132" y="-3.933" fill="#5CBEFF" width="67.306" height="25.396"/>
9
+ </g>
10
+ </g>
11
+ <g id="Layer_3" display="none">
12
+ </g>
13
+ <g id="Layer_1">
14
+ <g>
15
+ <g>
16
+
17
+ <path fill="#231F20" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
18
+ M7.082,3.701c0.021,1.21-0.007,5.512,0,6.771L0.889,7.086L7.082,3.701z"/>
19
+ </g>
20
+ <g>
21
+
22
+ <path fill="none" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
23
+ M7.09,3.701c-0.021,1.21,0.008,5.512,0,6.771l6.194-3.386L7.09,3.701z"/>
24
+ </g>
25
+ </g>
26
+ </g>
27
+ <g id="Layer_5" display="none">
28
+
29
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="3.836" y1="3.836" x2="10.336" y2="10.336"/>
30
+
31
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="10.336" y1="3.836" x2="3.836" y2="10.336"/>
32
+ </g>
33
+ <g id="Layer_4" display="none">
34
+
35
+ <polyline display="inline" fill="none" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
36
+ 10.958,4.801 6.388,9.372 3.215,6.094 "/>
37
+ </g>
38
+ </svg>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="14.173px" height="14.173px" viewBox="0 0 14.173 14.173" enable-background="new 0 0 14.173 14.173" xml:space="preserve">
6
+ <g id="Layer_2" display="none">
7
+ <g display="inline">
8
+ <rect x="-5.132" y="-3.933" fill="#5CBEFF" width="67.306" height="25.396"/>
9
+ </g>
10
+ </g>
11
+ <g id="Layer_3" display="none">
12
+ </g>
13
+ <g id="Layer_1">
14
+ <g>
15
+ <g>
16
+
17
+ <path fill="#231F20" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
18
+ M10.472,7.091c-1.21-0.021-5.512,0.007-6.771,0l3.386,6.193L10.472,7.091z"/>
19
+ </g>
20
+ <g>
21
+
22
+ <path fill="none" stroke="#231F20" stroke-width="0.9761" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
23
+ M10.472,7.083c-1.21,0.021-5.512-0.008-6.771,0l3.386-6.194L10.472,7.083z"/>
24
+ </g>
25
+ </g>
26
+ </g>
27
+ <g id="Layer_5" display="none">
28
+
29
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="3.836" y1="3.836" x2="10.336" y2="10.336"/>
30
+
31
+ <line display="inline" fill="#FFFFFF" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="10.336" y1="3.836" x2="3.836" y2="10.336"/>
32
+ </g>
33
+ <g id="Layer_4" display="none">
34
+
35
+ <polyline display="inline" fill="none" stroke="#231F20" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
36
+ 10.958,4.801 6.388,9.372 3.215,6.094 "/>
37
+ </g>
38
+ </svg>
Binary file
@@ -0,0 +1,74 @@
1
+ <?xml version="1.0" encoding="utf-8" standalone="no"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="96px" height="124px">
3
+ <style type="text/css">
4
+ #background {
5
+ fill: none;
6
+ }
7
+ .arrows {
8
+ fill: #000;
9
+ stroke: none;
10
+ }
11
+ .selected>.arrows {
12
+ fill: #fff;
13
+ }
14
+ .checkmark {
15
+ fill: #000;
16
+ font-family: sans-serif;
17
+ font-size: 10pt;
18
+ text-anchor: middle;
19
+ }
20
+ .trash {
21
+ fill: #888;
22
+ }
23
+ .zoom {
24
+ fill: none;
25
+ stroke: #888;
26
+ stroke-width: 2;
27
+ stroke-linecap: round;
28
+ }
29
+ .zoom>.center {
30
+ fill: #888;
31
+ stroke-width: 0;
32
+ }
33
+ </style>
34
+ <rect id="background" width="96" height="124" x="0" y="0" />
35
+
36
+ <g>
37
+ <path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z" />
38
+ <path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z" />
39
+ <path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z" />
40
+ </g>
41
+ <g class="selected" transform="translate(0, 16)">
42
+ <path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z" />
43
+ <path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z" />
44
+ <path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z" />
45
+ </g>
46
+
47
+ <text class="checkmark" x="55.5" y="28">&#10003;</text>
48
+
49
+ <g class="trash">
50
+ <path d="M 2,41 v 6 h 42 v -6 h -10.5 l -3,-3 h -15 l -3,3 z" />
51
+ <rect width="36" height="20" x="5" y="50" />
52
+ <rect width="36" height="42" x="5" y="50" rx="4" ry="4" />
53
+ </g>
54
+
55
+ <g class="zoom">
56
+ <circle r="11.5" cx="16" cy="108" />
57
+ <circle r="4.3" cx="16" cy="108" class="center" />
58
+ <path d="m 28,108 h3" />
59
+ <path d="m 1,108 h3" />
60
+ <path d="m 16,120 v3" />
61
+ <path d="m 16,93 v3" />
62
+ </g>
63
+
64
+ <g class="zoom">
65
+ <circle r="15" cx="48" cy="108" />
66
+ <path d="m 48,101.6 v12.8" />
67
+ <path d="m 41.6,108 h12.8" />
68
+ </g>
69
+
70
+ <g class="zoom">
71
+ <circle r="15" cx="80" cy="108" />
72
+ <path d="m 73.6,108 h12.8" />
73
+ </g>
74
+ </svg>
@@ -0,0 +1,2 @@
1
+ <category name="Procedimientos primitivos"></category>
2
+ <category name="Funciones primitivas"></category>
@@ -4,6 +4,10 @@
4
4
  display: inline-flex;
5
5
  }
6
6
 
7
+ .results-list .boards-container {
8
+ margin: 20px 10px 30px;
9
+ }
10
+
7
11
  .error-text {
8
12
  color: #d9534f;
9
13
  }
@@ -25,12 +29,6 @@
25
29
 
26
30
  </style>
27
31
 
28
- <% if @result[:error] %>
29
- <p class="error-text">
30
- <%=I18n.t @result[:error], @result %>
31
- </p>
32
- <% end %>
33
-
34
32
  <div class="boards-container">
35
33
 
36
34
  <% @result[:boards].each do |it| %>
@@ -115,3 +115,12 @@
115
115
  position: absolute;
116
116
  }
117
117
  }
118
+
119
+
120
+ .mu-kids-exercise.mu-kindergarten .gbs_boom {
121
+ display: none;
122
+ }
123
+
124
+ .mu-kids-exercise.mu-kindergarten .mu-scenario.active table.gbs_board {
125
+ display: block !important;
126
+ }
@@ -29,16 +29,49 @@
29
29
  board.updateStyles();
30
30
  }
31
31
 
32
+ const compilationModes = {
33
+ gameFramework: {
34
+ compile: ({ main, teacher, ...args }) => {
35
+ const extra = `<%= @game_framework_extra %>`;
36
+ const program = `<%= @game_framework_program %>`;
37
+
38
+ const append = (code, anotherCode) => `${code}\n\n${anotherCode}`
39
+
40
+ return {
41
+ main: append(main, program),
42
+ teacher: append(teacher, extra),
43
+ ...args
44
+ };
45
+ },
46
+
47
+ scrollToMainBlock: (blockly) => {
48
+ const mainBlock = blockly.getBlocksOfType('procedures_defnoreturnnoparams')[0];
49
+ blockly.scrollToBlock(mainBlock.id);
50
+ },
51
+
52
+ defaultCode: `<%= @game_framework_default %>`
53
+ },
54
+ classic: {
55
+ compile: (code) => code,
56
+
57
+ scrollToMainBlock: (blockly) => {
58
+ blockly.scrollToBlock();
59
+ },
60
+
61
+ defaultCode: ''
62
+ }
63
+ };
64
+
32
65
  Polymer({
33
66
  is: 'mu-gobstones-custom-editor',
34
67
  properties: {
35
68
  mediaUrl: {
36
69
  type: String,
37
- value: "https://github.com/Program-AR/blockly-package/raw/v0.0.15/media/"
70
+ value: "<%= @assets_url %>/media/"
38
71
  },
39
72
  localMediaUrl: {
40
73
  type: String,
41
- value: "https://github.com/Program-AR/gs-element-blockly/raw/0.19.1/media/"
74
+ value: "<%= @assets_url %>/local-media/"
42
75
  },
43
76
  readOnly: {
44
77
  type: Boolean,
@@ -47,6 +80,13 @@
47
80
  teacherMode: {
48
81
  type: Boolean,
49
82
  default: false
83
+ },
84
+ defaultIcons: {
85
+ type: Object,
86
+ value: {
87
+ procedureDeclarations: { /** for future use */ },
88
+ functionDeclarations: { /** for future use */ }
89
+ }
50
90
  }
51
91
  },
52
92
 
@@ -70,7 +110,8 @@
70
110
  Blockly.MUMUKI_COLORS = {
71
111
  pink: "#FF5C82",
72
112
  blue: "#5CBEFF",
73
- yellow: "#FFC95C"
113
+ yellow: "#FFC95C",
114
+ green: "#5CED71"
74
115
  };
75
116
 
76
117
  // reserved
@@ -81,8 +122,10 @@
81
122
  Blockly.CUSTOM_COLORS.function = Blockly.MUMUKI_COLORS.pink;
82
123
  Blockly.CUSTOM_COLORS.complete = Blockly.MUMUKI_COLORS.pink;
83
124
 
125
+ // control structures
126
+ Blockly.CUSTOM_COLORS.controlStructure = this._isKindergarten() ? Blockly.MUMUKI_COLORS.green : Blockly.MUMUKI_COLORS.yellow;
127
+
84
128
  // commands
85
- Blockly.CUSTOM_COLORS.controlStructure = Blockly.MUMUKI_COLORS.yellow;
86
129
  Blockly.CUSTOM_COLORS.primitiveCommand = Blockly.MUMUKI_COLORS.yellow;
87
130
  Blockly.CUSTOM_COLORS.primitiveProcedure = Blockly.MUMUKI_COLORS.yellow;
88
131
  Blockly.CUSTOM_COLORS.procedure_call = Blockly.MUMUKI_COLORS.yellow;
@@ -105,6 +148,12 @@
105
148
 
106
149
  const setBlocklyCustomSettings = () => {
107
150
  if (typeof Blockly === 'undefined' || !Blockly.CUSTOM_COLORS) return postpone(setBlocklyCustomSettings);
151
+
152
+ // The display mode configuration could be monkey-patched here, like this:
153
+ Blockly.displayModes.iconic.iconSize = 64;
154
+ Blockly.displayModes.iconic.procedureDefIcon = `${this.localMediaUrl}main-procedure.png`;
155
+
156
+ Blockly.displayMode = this._isKindergarten() ? 'iconic' : 'text';
108
157
  setBlocklySounds();
109
158
  setBlocklyColors();
110
159
 
@@ -173,6 +222,8 @@
173
222
 
174
223
  if (!blockly || !blockly.workspace) return initialize();
175
224
 
225
+ blockly.showCategories = !this._isKindergarten();
226
+
176
227
  if (!this.readOnly) {
177
228
  relocateTrash(blockly);
178
229
  }
@@ -190,6 +241,8 @@
190
241
 
191
242
  const hasCustomToolbox = $('gs-toolbox').length;
192
243
  if(!hasCustomToolbox) this.enableContextButton();
244
+
245
+ this._registerLayoutChangedEvent();
193
246
  });
194
247
  };
195
248
 
@@ -208,6 +261,12 @@
208
261
  document.dispatchEvent(event);
209
262
  },
210
263
 
264
+ reset(code) {
265
+ const blockly = this.getBlockly();
266
+ blockly.workspaceXml = code || blockly.initialXml;
267
+ this._scrollToMainBlock();
268
+ },
269
+
211
270
  setInteractiveLayout() {
212
271
  this.$exerciseContainer.addClass('mu-kids-interactive');
213
272
  $('.mu-final-state').html('<gs-keyboard/>');
@@ -223,14 +282,31 @@
223
282
  if (teacherCode) {
224
283
  setTimeout(() => {
225
284
  const actions = new Parser().getActionsFromSource(teacherCode);
226
- blockly.primitiveProcedures = actions.procedureDeclarations;
227
- blockly.primitiveFunctions = actions.functionDeclarations;
285
+
286
+ blockly.primitiveProcedures = this._withDefaultIcons(actions, 'procedureDeclarations');
287
+ blockly.primitiveFunctions = this._withDefaultIcons(actions, 'functionDeclarations');
228
288
  });
229
289
  }
230
290
  },
231
291
 
292
+ setGameActions(blockly) {
293
+ if (this._isGame()) {
294
+ blockly.primitiveProcedures = blockly.primitiveProcedures || [];
295
+ blockly.primitiveProcedures = blockly.primitiveProcedures.concat([
296
+ this.gamePrimitive('ShiftUp'),
297
+ this.gamePrimitive('ShiftDown'),
298
+ this.gamePrimitive('ShiftLeft'),
299
+ this.gamePrimitive('ShiftRight')
300
+ ]);
301
+ }
302
+ },
303
+
304
+ gamePrimitive(name) {
305
+ return { alias: 'procedureDeclaration', name: name, attributes: {block_icon: `<%= @assets_url %>/media/${name}.png`} };
306
+ },
307
+
232
308
  enableContextButton() {
233
- if(typeof mumuki !== "undefined" && mumuki.kids && mumuki.assetsLoadedFor) {
309
+ if(mumuki.kids && mumuki.assetsLoadedFor) {
234
310
  return mumuki.assetsLoadedFor('editor');
235
311
  } else {
236
312
  return postpone(this.enableContextButton.bind(this));
@@ -275,6 +351,55 @@
275
351
  return $("#mu-custom-editor-test")[0];
276
352
  },
277
353
 
354
+ compile(code) {
355
+ return this._compilationMode().compile(code);
356
+ },
357
+
358
+ _registerLayoutChangedEvent() {
359
+ if (!this.teacherMode) {
360
+ return;
361
+ }
362
+
363
+ mumuki.events.on('layoutChanged', () => {
364
+ this.getEditorDefaultValue().value = this._compilationMode().defaultCode;
365
+ });
366
+ },
367
+
368
+ _scrollToMainBlock() {
369
+ this._compilationMode().scrollToMainBlock(this.getBlockly());
370
+ },
371
+
372
+ _withDefaultIcons(actions, type) {
373
+ const addIcon = (declaration, block_icon) =>
374
+ ({ ...declaration, attributes: { ...declaration.attributes, block_icon } });
375
+
376
+ return actions[type].map((declaration) => {
377
+ const defaultIcon = this.defaultIcons[type][declaration.name];
378
+ if (defaultIcon) {
379
+ return addIcon(declaration, defaultIcon);
380
+ } else {
381
+ return declaration;
382
+ }
383
+ });
384
+ },
385
+
386
+ _isKindergarten() {
387
+ return mumuki.exercise.layout === 'input_kindergarten';
388
+ },
389
+
390
+ _isGame() {
391
+ if (mumuki.exercise.settings) {
392
+ return mumuki.exercise.settings.game_framework;
393
+ } else {
394
+ // for backwards compatibility
395
+ return this._isKindergarten();
396
+ }
397
+ },
398
+
399
+ _compilationMode() {
400
+ return this._isGame() ? compilationModes.gameFramework : compilationModes.classic;
401
+ },
402
+
278
403
  _setInitialXml: function (blockly) {
279
404
  const editorDefaultContent = this.getEditorDefaultValue();
280
405
  if (editorDefaultContent && editorDefaultContent.value) {
@@ -293,7 +418,7 @@
293
418
  ? "<xml></xml>"
294
419
  : blockly.initialXml
295
420
  );
296
- blockly.scrollToBlock();
421
+ this._scrollToMainBlock();
297
422
 
298
423
  callback();
299
424
  });
@@ -433,13 +558,7 @@
433
558
  is: 'kids-reset-button',
434
559
 
435
560
  _onButtonClick: function () {
436
- const blockly = this._getBlockly();
437
- blockly.workspaceXml = blockly.initialXml;
438
- blockly.scrollToBlock();
439
- },
440
-
441
- _getBlockly: function () {
442
- return this._getEditor().getBlockly();
561
+ this._getEditor().reset();
443
562
  },
444
563
 
445
564
  _getEditor: function () {
@@ -559,11 +678,11 @@
559
678
 
560
679
  controller.start({
561
680
  initialState: this.targetState,
562
- code: {
681
+ code: editor.compile({
563
682
  main: code,
564
683
  library: "",
565
684
  teacher: teacherCode
566
- }
685
+ })
567
686
  }, {
568
687
  onResult: (state, fullState) => {
569
688
  const region = this._getLastRegion(fullState);
@@ -785,9 +904,16 @@
785
904
  const editor = $("mu-gobstones-custom-editor")[0];
786
905
  const blockly = editor.getBlockly();
787
906
  if(blockly.readOnly) return;
907
+ const previousCode = editor.getEditorValue().value;
788
908
  $.get(this.toolboxUrl, function (toolboxXml) {
789
909
  blockly.toolbox = { defaultToolbox: toolboxXml };
790
910
  editor.setTeacherActions(blockly);
911
+ editor.setGameActions(blockly);
912
+ // @faloi - I couldn't figure out why the workspace gets replaced with a generic code,
913
+ // so here I force a reset with the code previously saved. Sorry not sorry.
914
+ postpone(() => {
915
+ editor.reset(previousCode);
916
+ });
791
917
  }).always(function () {
792
918
  editor.enableContextButton();
793
919
  });
@@ -1065,4 +1191,3 @@
1065
1191
  });
1066
1192
  </script>
1067
1193
  </dom-module>
1068
-