mumuki-gobstones-runner 2.10.0 → 2.10.1
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/render/editor/editor.html.erb +59 -18
- data/lib/version_hook.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2438326f59bc9d3a85086e5bf5c11edc44cb2907d64fda30c23a9dcd8f952f16
|
4
|
+
data.tar.gz: 16ea0ef08aed78f7f24b67d21088b7ab3f0b6bee8fd4d42798010ef5915000b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f762dc032fd7d2f32cadf4d88fb4d2c14659e270af017bc498bb2dfcd65e91f38c1314fb23c44d05f87ef1e2c3bbc681f45c08de444769d2e60d009ecff62e0c
|
7
|
+
data.tar.gz: 5fa4241b9d422bba3ac77803fefe331958830d0c110fa80cec8b2dd80cf544b31447cc4b73e1188b2a46dfca3585aebc13f3719a415406b101d65bed00766751
|
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
|
@@ -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
|
}
|
@@ -282,12 +287,18 @@
|
|
282
287
|
},
|
283
288
|
|
284
289
|
_updateSolution() {
|
290
|
+
console.debug("Updating solution");
|
285
291
|
const blockly = this._getBlockly();
|
286
|
-
|
292
|
+
let changed;
|
287
293
|
if (this.teacherMode) {
|
288
|
-
this._setExtraCode(blockly.workspaceXml);
|
294
|
+
changed = this._setExtraCode(blockly.workspaceXml);
|
289
295
|
} else {
|
290
|
-
this._setStudentSolution(blockly.workspaceXml);
|
296
|
+
changed = this._setStudentSolution(blockly.workspaceXml);
|
297
|
+
}
|
298
|
+
|
299
|
+
if (!changed) {
|
300
|
+
console.debug("No solution update required")
|
301
|
+
return;
|
291
302
|
}
|
292
303
|
|
293
304
|
// TODO: this hack enables Angular two-way binding for Bibliotheca. Should be replaced with Mumuki events system
|
@@ -380,22 +391,44 @@
|
|
380
391
|
return;
|
381
392
|
}
|
382
393
|
|
383
|
-
|
394
|
+
console.debug("Set teacher actions");
|
384
395
|
const actions = new Parser().getActionsFromSource(teacherCode);
|
385
|
-
|
386
|
-
|
396
|
+
|
397
|
+
this._setPrimitiveProcedures(this._withDefaultIcons(actions, 'procedureDeclarations'));
|
398
|
+
this._setPrimitiveFunctions(this._withDefaultIcons(actions, 'functionDeclarations'));
|
387
399
|
},
|
388
400
|
|
389
401
|
_setGameActions() {
|
402
|
+
if (!this._isGame()) {
|
403
|
+
return;
|
404
|
+
}
|
405
|
+
|
406
|
+
console.debug("Set game actions");
|
390
407
|
const blockly = this._getBlockly();
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
408
|
+
|
409
|
+
this._setPrimitiveProcedures((blockly.primitiveProcedures || []).concat([
|
410
|
+
this._gamePrimitive('ShiftUp'),
|
411
|
+
this._gamePrimitive('ShiftDown'),
|
412
|
+
this._gamePrimitive('ShiftLeft'),
|
413
|
+
this._gamePrimitive('ShiftRight')
|
414
|
+
]));
|
415
|
+
},
|
416
|
+
|
417
|
+
_setPrimitiveProcedures(procedures) {
|
418
|
+
this._setBlocklyActions("primitiveProcedures", procedures);
|
419
|
+
},
|
420
|
+
|
421
|
+
_setPrimitiveFunctions(functions) {
|
422
|
+
this._setBlocklyActions("primitiveFunctions", functions);
|
423
|
+
},
|
424
|
+
|
425
|
+
_setBlocklyActions(key, actions) {
|
426
|
+
try {
|
427
|
+
this._getBlockly()[key] = actions
|
428
|
+
} catch (e) {
|
429
|
+
if (this._getBlockly()[key] !== actions) {
|
430
|
+
throw e;
|
431
|
+
}
|
399
432
|
}
|
400
433
|
},
|
401
434
|
|
@@ -416,8 +449,12 @@
|
|
416
449
|
* to user content in laboratory, and default content in bibliotheca
|
417
450
|
*/
|
418
451
|
_setStudentSolution(code) {
|
419
|
-
|
420
|
-
|
452
|
+
if (this._getStudentEditor().value !== code) {
|
453
|
+
console.debug(`Setting student ${code}`)
|
454
|
+
this._getStudentEditor().value = code;
|
455
|
+
return true;
|
456
|
+
}
|
457
|
+
return false;
|
421
458
|
},
|
422
459
|
|
423
460
|
_getDefaultCode() {
|
@@ -429,8 +466,12 @@
|
|
429
466
|
},
|
430
467
|
|
431
468
|
_setExtraCode(code) {
|
432
|
-
|
433
|
-
|
469
|
+
if (this._getEditorExtra().value !== code) {
|
470
|
+
console.debug(`Setting extra ${code}`)
|
471
|
+
this._getEditorExtra().value = code;
|
472
|
+
return true;
|
473
|
+
}
|
474
|
+
return false;
|
434
475
|
},
|
435
476
|
|
436
477
|
_getEditorExtra: function() {
|
data/lib/version_hook.rb
CHANGED