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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abbf0ec6c1d486eadb06f71d4d479a520700c79376ab9d1e785a8fc658485624
4
- data.tar.gz: 60dc12c4d5e60614a94987ae2c725892cb6e06065aefd673952cf0f73880ce06
3
+ metadata.gz: 2438326f59bc9d3a85086e5bf5c11edc44cb2907d64fda30c23a9dcd8f952f16
4
+ data.tar.gz: 16ea0ef08aed78f7f24b67d21088b7ab3f0b6bee8fd4d42798010ef5915000b5
5
5
  SHA512:
6
- metadata.gz: f253ffce6bfffc3aa0af02995cd3739df9a1ccb2122c6c7fbdb70883b3cb7da9ef6078372a1aa141fe62561491c929450fe2e9ba30fe7d8dad5561abc57f6c55
7
- data.tar.gz: d7227916c7b0e94173319e8753364ceec1818a07aa10f70e155735549872c6541cf7065235be16f0d43aece40df847c3a5ee1842e20c33fa205161fafa0b23d0
6
+ metadata.gz: f762dc032fd7d2f32cadf4d88fb4d2c14659e270af017bc498bb2dfcd65e91f38c1314fb23c44d05f87ef1e2c3bbc681f45c08de444769d2e60d009ecff62e0c
7
+ data.tar.gz: 5fa4241b9d422bba3ac77803fefe331958830d0c110fa80cec8b2dd80cf544b31447cc4b73e1188b2a46dfca3585aebc13f3719a415406b101d65bed00766751
@@ -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
- const blockly = this._getBlockly();
394
+ console.debug("Set teacher actions");
384
395
  const actions = new Parser().getActionsFromSource(teacherCode);
385
- blockly.primitiveProcedures = this._withDefaultIcons(actions, 'procedureDeclarations');
386
- blockly.primitiveFunctions = this._withDefaultIcons(actions, 'functionDeclarations');
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
- if (this._isGame()) {
392
- blockly.primitiveProcedures = blockly.primitiveProcedures || [];
393
- blockly.primitiveProcedures = blockly.primitiveProcedures.concat([
394
- this._gamePrimitive('ShiftUp'),
395
- this._gamePrimitive('ShiftDown'),
396
- this._gamePrimitive('ShiftLeft'),
397
- this._gamePrimitive('ShiftRight')
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
- console.debug(`Setting student ${code}`)
420
- this._getStudentEditor().value = code;
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
- console.debug(`Setting extra ${code}`)
433
- this._getEditorExtra().value = code;
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() {
@@ -1,3 +1,3 @@
1
1
  module GobstonesVersionHook
2
- VERSION = '2.10.0'
2
+ VERSION = '2.10.1'
3
3
  end
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.10.0
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso