mumuki-gobstones-runner 1.12.1 → 2.0.0

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: 723bbfbcc40eeb896fff1a108034ed476bece40a65c756d3142de9d557063c7e
4
- data.tar.gz: 7da68cd760020ce4bd4fdaa49443101a53f72d8c1957444767da42578cfa0c5c
3
+ metadata.gz: ba2ba3ad0ac2a0fe242c7a5ac0be73e6abfe0cd59e605fa763620e6b086cabad
4
+ data.tar.gz: 88044e138b6b6a208c2047479a0f44166fa9de72c0cdcf061ff67e1afd905e64
5
5
  SHA512:
6
- metadata.gz: 8451a0d0d8c65ab5af1e2986aec3126dc46e887a83fca0ddfea0f9bbfa3f7206749d981cd51bced05da712d37af8e7a1368e9bcf9a227f156cffd39e3abbda39
7
- data.tar.gz: c226b89c9ef297094423efd971e29c233c8dff01fada80b4451c217857dd27f2cb047716aa36e5b25e448fbed1792be916bcae88cb2289e582f8b4e4f03298e9
6
+ metadata.gz: f8f1b910a07058d709e8e590193e3c124701d68f2ac3ff24034b1a7aa96546fec0649db037c57894c3f4d85f9ac93b804c8a3aec4a7ac8b2f1587021e26347e8
7
+ data.tar.gz: 73c81f0a3366f144132e243f16cee9fc97dd614f6a26cf08ea8e07e8e88947d9e39e42a76cd56c5dcdc61832d062d9396b49cfae51dc55dfe419a7b3d9807826
data/lib/checker.rb CHANGED
@@ -113,16 +113,12 @@ module Gobstones
113
113
  return "no_stones" if code == 'cannot-remove-stone'
114
114
  return "out_of_board" if code == 'cannot-move-to'
115
115
  return "unassigned_variable" if code == 'undefined-variable'
116
- return "wrong_argument_type" if has_wrong_argument_type? code
116
+ return "wrong_argument_type" if code.include? 'type-mismatch'
117
117
  return "wrong_arguments_quantity" if code.include? 'arity-mismatch'
118
118
 
119
119
  code
120
120
  end
121
121
 
122
- def has_wrong_argument_type?(code)
123
- code.match Regexp.union('type-mismatch', 'expected-value-of-type')
124
- end
125
-
126
122
  def adapt_value(return_value)
127
123
  type = return_value[:type]
128
124
  value = return_value[:value]
@@ -36,9 +36,9 @@
36
36
  <% @result[:boards].each do |it| %>
37
37
  <div class="board">
38
38
  <p class="title"><%=I18n.t it.title %></p>
39
- <p>
39
+ <p class="<%= it.title %>">
40
40
  <% if it.board.boom %>
41
- <img src=<%= "#{Mumukit.runner_url}/assets/boom.png" %> />
41
+ <gs-board boom></gs-board>
42
42
  <% else %>
43
43
  <gs-board <%= it.title == :expected_board && !@options[:check_head_position] ? "without-header" : "" %>>
44
44
  <%= it.board.gbb %>
@@ -62,3 +62,9 @@
62
62
  .gbs_gh {
63
63
  outline: 1px solid #cc0000 !important;
64
64
  }
65
+
66
+ @-moz-document url-prefix() {
67
+ .mu-kids-exercise gs-board table.gbs_board {
68
+ position: absolute;
69
+ }
70
+ }
@@ -412,23 +412,33 @@
412
412
  this._onResetState();
413
413
  })
414
414
  };
415
+ const _getScenarioSelector = function (scenario) {
416
+ return `.mu-state-${scenario} .mu-kids-state-image > *`;
417
+ };
418
+
419
+ const _createMultipleScenarios = () => {
420
+ const scenarios = ['initial', 'final'];
421
+ const scenarioSelectors = scenarios.map(it => _getScenarioSelector(it));
422
+ this.multipleScenarios = new mumuki.MultipleScenarios(scenarioSelectors);
423
+ };
415
424
 
416
425
  const setInitialState = () => {
417
- const initialBoard = this._getTargetBoard();
418
- if (!initialBoard.size) return postpone(setInitialState);
426
+ const initialBoards = this._getInitialBoards();
427
+ if (!initialBoards[0].size) return postpone(setInitialState);
419
428
 
420
- this.initialState = {
421
- size: initialBoard.size,
422
- table: initialBoard.table,
423
- header: initialBoard.header
424
- };
429
+ this.initialState = initialBoards.toArray().map((board) => this._boardToState(board));
425
430
 
426
431
  resetStatusAfterAborted();
427
- }
432
+ };
428
433
 
434
+ _createMultipleScenarios();
429
435
  setInitialState();
430
436
  },
431
437
 
438
+ _boardToState : function ({size, table, header, boom}) {
439
+ return {size, table, header, boom}
440
+ },
441
+
432
442
  _onRunRequest: function (event) {
433
443
  const {detail: controller} = event;
434
444
 
@@ -443,6 +453,7 @@
443
453
  this._cleanState();
444
454
  this._cleanErrors(finalBoard);
445
455
 
456
+ this.targetState = this._boardToState(finalBoard);
446
457
  const promise = new mumuki.bridge.Laboratory()
447
458
  .runTests(solution)
448
459
  .then((results) => {
@@ -456,7 +467,7 @@
456
467
  this.serverPromise = promise;
457
468
 
458
469
  controller.start({
459
- initialState: this.initialState,
470
+ initialState: this.targetState,
460
471
  code: {
461
472
  main: code,
462
473
  library: "",
@@ -500,9 +511,46 @@
500
511
 
501
512
  _onExecutionStop: function (data) {
502
513
  this._cleanState();
514
+ this._setResultsBoards(data.test_results);
503
515
  mumuki.kids.showResult(data);
504
516
  },
505
517
 
518
+ _setResultsBoards: function (testResults) {
519
+ if (!testResults) return;
520
+ const testResultsBoards = this._testResultsBoards(testResults);
521
+ this._updateBoards(testResultsBoards);
522
+ const testResultsStatuses = this._testResultsStatuses(testResults);
523
+ this.multipleScenarios.updateIndicators(testResultsStatuses);
524
+ },
525
+
526
+ _testResultsBoards: function (testResults) {
527
+ return testResults.map(it => $(it.result).find('.actual_board > *, .final_board > *')[0]);
528
+ },
529
+
530
+ _testResultsStatuses: function (testResults) {
531
+ return testResults.map(it => it.status);
532
+ },
533
+
534
+ _updateBoards: function (resultsBoards) {
535
+ const initialBoards = this.multipleScenarios.scenarios[0];
536
+ resultsBoards.forEach((resultScenario, index) => {
537
+ if (this.multipleScenarios.currentScenarioIndex === index) return;
538
+ const currentBoard = initialBoards[index];
539
+ this._updateBoardFromResult(currentBoard.firstChild, resultScenario);
540
+ });
541
+ },
542
+
543
+ _updateBoardFromResult: function (originalBoard, resultBoard) {
544
+ resultBoard = resultBoard.cloneNode(); // To force initialization
545
+ if (resultBoard.textContent) {
546
+ const boardAttrs = gbbReader.fromString(resultBoard.textContent);
547
+ originalBoard.update(boardAttrs.table, boardAttrs.header);
548
+ }
549
+ else {
550
+ originalBoard.boom = resultBoard.boom;
551
+ }
552
+ },
553
+
506
554
  _updateBoard: function (state, finalBoard) {
507
555
  const {error, table, head} = state;
508
556
 
@@ -561,8 +609,12 @@
561
609
  return $("mu-gobstones-custom-editor")[0];
562
610
  },
563
611
 
612
+ _getInitialBoards: function () {
613
+ return $(".mu-kids-gbs-board-initial gs-board");
614
+ },
615
+
564
616
  _getTargetBoard: function () {
565
- return $(".mu-kids-gbs-board-initial gs-board")[0];
617
+ return this._getInitialBoards().parent('.active').children()[0];
566
618
  },
567
619
 
568
620
  _getSubmitCss: function (isWaiting) {
@@ -573,17 +625,20 @@
573
625
  return isWaiting ? "visible" : "hidden";
574
626
  },
575
627
 
576
- _resetBoard: function () {
577
- const initialState = this.initialState;
578
- const initialBoard = this._getTargetBoard();
579
- initialBoard.update(initialState.table, initialState.header);
580
- initialBoard.boom = false;
628
+ _resetBoards: function () {
629
+ const boards = this._getInitialBoards();
630
+ this.initialState.forEach(({table, header, boom}, index) => {
631
+ const board = boards[index];
632
+ board.update(table, header);
633
+ board.boom = boom;
634
+ });
581
635
  },
582
636
 
583
637
  _onResetState: function () {
584
638
  this._getBlockly().workspace.removeBlockErrors();
585
- this._resetBoard();
639
+ this._resetBoards();
586
640
  this._toggleInitialState();
641
+ this.multipleScenarios.resetIndicators();
587
642
  mumuki.kids.restart();
588
643
  },
589
644
 
@@ -649,9 +704,13 @@
649
704
  <dom-module id="gs-attire-toggle-button">
650
705
  <style>
651
706
  .button {
652
- padding: 5px;
707
+ position: absolute;
653
708
  cursor: pointer;
654
- float: right;
709
+ top: -2px;
710
+ right: 0;
711
+ -ms-transform-origin: right center;
712
+ -webkit-transform-origin: right center;
713
+ transform-origin: right center;
655
714
  }
656
715
  </style>
657
716
 
@@ -680,6 +739,7 @@
680
739
 
681
740
  ready: function () {
682
741
  document.addEventListener('board-attire-changed', this._updateVisibility.bind(this));
742
+ this._relocateButton();
683
743
  },
684
744
 
685
745
  _updateVisibility: function () {
@@ -694,7 +754,23 @@
694
754
  if (board.attire) board.set("attire.enabled", this.isEnabled);
695
755
  gbsBoardRemoveBorder(board);
696
756
  });
697
- }
757
+ },
758
+
759
+ _relocateButton: function () {
760
+ const $container = $('.mu-kids-gbs-board-initial');
761
+ if(!$container.length) return;
762
+ const $header = $('.mu-initial-state-header');
763
+ const $attireToggle = $container.find('.button.gs-attire-toggle-button');
764
+ if(!$attireToggle.length) return setTimeout(() => this._relocateButton());
765
+ const margin = 4; // Leave a margin between text and image
766
+ const maxSize = 65.75; // Original width
767
+ mumuki.resize(() => {
768
+ $attireToggle.css('transform', 'scale(1)');
769
+ let buttonSize = (($container.width() - $header.width()) / 2) - margin;
770
+ let scaleX = Math.min(buttonSize, maxSize) / $attireToggle.width();
771
+ $attireToggle.css('transform', `scale(${scaleX})`);
772
+ });
773
+ },
698
774
  });
699
775
  </script>
700
776
  </dom-module>
@@ -1,5 +1,5 @@
1
1
  $(document).ready(function () {
2
2
  $(".mu-kids-submit-button").html("<kids-submit-button></kids-submit-button>");
3
3
  $(".mu-kids-reset-button").html("<kids-reset-button></kids-reset-button>");
4
- $(".mu-kids-states").prepend("<gs-attire-toggle-button></gs-attire-toggle-button>");
4
+ $(".mu-initial-state-header").append("<gs-attire-toggle-button></gs-attire-toggle-button>");
5
5
  });
data/lib/version_hook.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GobstonesVersionHook
2
- VERSION = '1.12.1'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-gobstones-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-07 00:00:00.000000000 Z
11
+ date: 2019-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.0.3
211
+ rubygems_version: 3.0.2
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Gobstones Runner for Mumuki