mumuki-laboratory 7.12.0 → 8.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/mumuki_laboratory/application/characters.js +3 -1
- data/app/assets/javascripts/mumuki_laboratory/application/gamification.js +89 -11
- data/app/assets/javascripts/mumuki_laboratory/application/kids.js +171 -333
- data/app/assets/javascripts/mumuki_laboratory/application/kindergarten.js +144 -130
- data/app/assets/javascripts/mumuki_laboratory/application/mu-modal-carrousel.js +63 -0
- data/app/assets/javascripts/mumuki_laboratory/application/number-counter.js +18 -0
- data/app/assets/javascripts/mumuki_laboratory/application/primary.js +258 -0
- data/app/assets/javascripts/mumuki_laboratory/application/submission.js +1 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids_results.scss +117 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kindergarten.scss +47 -113
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_terms.scss +9 -12
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_profile.scss +31 -3
- data/app/controllers/api/courses_controller.rb +1 -2
- data/app/controllers/api/organizations_controller.rb +2 -3
- data/app/controllers/api/users_controller.rb +2 -4
- data/app/controllers/application_controller.rb +41 -8
- data/app/controllers/assets_controller.rb +1 -0
- data/app/controllers/book_discussions_controller.rb +1 -1
- data/app/controllers/chapters_controller.rb +1 -0
- data/app/controllers/discussions_controller.rb +4 -0
- data/app/controllers/exercises_controller.rb +1 -0
- data/app/controllers/guides_controller.rb +2 -0
- data/app/controllers/invitations_controller.rb +2 -2
- data/app/controllers/lessons_controller.rb +1 -0
- data/app/controllers/login_controller.rb +1 -0
- data/app/controllers/users_controller.rb +9 -1
- data/app/helpers/assistance_box_helper.rb +7 -5
- data/app/helpers/contextualization_result_helper.rb +9 -1
- data/app/helpers/gamification_helper.rb +5 -0
- data/app/helpers/links_helper.rb +1 -1
- data/app/views/exercise_solutions/_assistant_rules_box.html.erb +13 -0
- data/app/views/exercise_solutions/_contextualization_results_container.html.erb +9 -0
- data/app/views/exercise_solutions/_kids_level_up.html.erb +11 -0
- data/app/views/exercise_solutions/_kids_results.html.erb +1 -1
- data/app/views/exercise_solutions/_results.html.erb +19 -19
- data/app/views/exercise_solutions/_results_title.html.erb +5 -0
- data/app/views/exercises/show.html.erb +4 -1
- data/app/views/layouts/_kindergarten.html.erb +4 -4
- data/app/views/layouts/_organizations_listing.html.erb +8 -12
- data/app/views/layouts/application.html.erb +8 -2
- data/app/views/layouts/modals/_guide_corollary.html.erb +1 -1
- data/app/views/layouts/modals/_kids_context.html.erb +1 -1
- data/app/views/layouts/modals/_kids_results.html.erb +16 -6
- data/app/views/layouts/modals/_kindergarten_context.html.erb +15 -15
- data/app/views/layouts/modals/_kindergarten_results.html.erb +20 -7
- data/app/views/layouts/modals/_kindergarten_results_aborted.html.erb +10 -7
- data/app/views/layouts/modals/_level_up.html.erb +27 -0
- data/app/views/users/_edit_user_form.html.erb +1 -1
- data/app/views/users/_user_form.html.erb +12 -2
- data/app/views/users/terms.html.erb +12 -0
- data/config/routes.rb +8 -8
- data/lib/mumuki/laboratory.rb +18 -5
- data/lib/mumuki/laboratory/controllers.rb +2 -0
- data/lib/mumuki/laboratory/controllers/action_redirector.rb +21 -0
- data/lib/mumuki/laboratory/controllers/immersive_navigation.rb +7 -0
- data/lib/mumuki/laboratory/controllers/results_rendering.rb +1 -0
- data/lib/mumuki/laboratory/events/events.rb +0 -33
- data/lib/mumuki/laboratory/locales/en.yml +11 -0
- data/lib/mumuki/laboratory/locales/es-CL.yml +5 -0
- data/lib/mumuki/laboratory/locales/es.yml +12 -1
- data/lib/mumuki/laboratory/locales/pt.yml +11 -0
- data/lib/mumuki/laboratory/version.rb +1 -1
- data/spec/capybara_helper.rb +5 -1
- data/spec/controllers/exercise_solutions_controller_spec.rb +1 -1
- data/spec/features/immersive_redirection_spec.rb +181 -0
- data/spec/features/profile_flow_spec.rb +35 -3
- data/spec/features/terms_flow_spec.rb +155 -0
- metadata +108 -98
- data/app/helpers/organization_list_helper.rb +0 -5
- data/spec/features/choose_organization_spec.rb +0 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5feda4ed95a66abdfc68c218f1d2b5752fe6fdd8d8da0a18cc7c968d90550bbd
|
4
|
+
data.tar.gz: '080a983c6f384a8568ba2c8e7f092fcab9afe2a82b728bdfcc1e66fb8256377f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f95a1a2057a7946e2f26589a50076ec7e3c0e3d538a3feeb75da6a7cd1e030598a048dbb2e8918f1dcf39aa6565bc22fec237c66c88ee6842503c4d0bf94947c
|
7
|
+
data.tar.gz: 006504d33b8cb9ea871cff01be16fbc9f4b9f89e8cab63f11e1bfcc41cb4384cf1aff2e6e501e053d9279a1dd3a2009ae0b6a5c242012ab311b0a1e1ed9702a5
|
@@ -9,8 +9,10 @@ mumuki.load(() => {
|
|
9
9
|
});
|
10
10
|
|
11
11
|
function placeKidsAnimations() {
|
12
|
+
placeAnimation('.mu-kids-character-result-aborted', 'failure');
|
12
13
|
placeAnimation('.mu-kids-character-animation', 'blink');
|
13
14
|
placeAnimation('.mu-kids-character-context', 'context');
|
15
|
+
placeAnimation('.mu-kids-character-result', 'blink');
|
14
16
|
}
|
15
17
|
|
16
18
|
function placeAnimation(selector, clip) {
|
@@ -20,7 +22,7 @@ mumuki.load(() => {
|
|
20
22
|
|
21
23
|
function atRandom(array) {
|
22
24
|
return array[Math.floor(Math.random() * array.length)];
|
23
|
-
}
|
25
|
+
}
|
24
26
|
|
25
27
|
mumuki.characters = characters;
|
26
28
|
});
|
@@ -5,9 +5,22 @@ mumuki.gamification = (() => {
|
|
5
5
|
static get CONSTANT_TERM() { return -125; }
|
6
6
|
}
|
7
7
|
|
8
|
+
class DummyLevelProgression {
|
9
|
+
setExpMessage() {}
|
10
|
+
|
11
|
+
registerLevelUpAction() {}
|
12
|
+
|
13
|
+
registerGainedExperienceAction() {}
|
14
|
+
|
15
|
+
updateLevel() {}
|
16
|
+
}
|
17
|
+
|
8
18
|
class LevelProgression {
|
9
19
|
constructor(currentExp) {
|
10
20
|
this.currentExp = currentExp;
|
21
|
+
this.lastEarnedExp = 0;
|
22
|
+
this._levelUpAction = this.defaultLevelUpAction;
|
23
|
+
this._gainedExperienceAction = this.defaultGainedExperienceAction;
|
11
24
|
}
|
12
25
|
|
13
26
|
expToLevelUp() {
|
@@ -38,8 +51,8 @@ mumuki.gamification = (() => {
|
|
38
51
|
return Math.floor((-b + Math.sqrt(Math.pow(b, 2) - 4 * a * (c - exp))) / (2 * a));
|
39
52
|
}
|
40
53
|
|
41
|
-
triggersLevelChange(
|
42
|
-
return this.levelFor(
|
54
|
+
triggersLevelChange(newExp) {
|
55
|
+
return this.levelFor(this.currentExp + newExp) !== this.currentLevel();
|
43
56
|
}
|
44
57
|
|
45
58
|
currentLevelProgress() {
|
@@ -50,23 +63,87 @@ mumuki.gamification = (() => {
|
|
50
63
|
return this.expFor(this.currentLevel());
|
51
64
|
}
|
52
65
|
|
53
|
-
|
54
|
-
|
66
|
+
exercisesToNextLevel() {
|
67
|
+
return Math.ceil(this.expToLevelUp() / 100);
|
68
|
+
}
|
69
|
+
|
70
|
+
setExpMessage(data) {
|
71
|
+
const exp = data.current_exp;
|
72
|
+
this.lastEarnedExp = exp - this.currentExp;
|
73
|
+
|
74
|
+
if (this.lastEarnedExp > 0) {
|
75
|
+
this.levelUpActionIfLevelUp(data.level_up_html);
|
76
|
+
this._gainedExperienceAction();
|
55
77
|
|
56
|
-
if (expGained > 0) {
|
57
78
|
this.currentExp = exp;
|
58
|
-
|
59
|
-
|
79
|
+
this.updateLevel();
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
defaultGainedExperienceAction() {
|
84
|
+
$('#mu-exp-points').html(this.lastEarnedExp);
|
85
|
+
$('#mu-exp-earned-message').removeClass('hidden');
|
86
|
+
}
|
87
|
+
|
88
|
+
defaultLevelUpAction(_levelUpHtml) {
|
89
|
+
$('#mu-level-up').modal();
|
90
|
+
}
|
91
|
+
|
92
|
+
registerLevelUpAction(action) {
|
93
|
+
this._levelUpAction = action;
|
94
|
+
}
|
95
|
+
|
96
|
+
registerGainedExperienceAction(action) {
|
97
|
+
this._gainedExperienceAction = action;
|
98
|
+
}
|
99
|
+
|
100
|
+
levelUpActionIfLevelUp(levelUpHtml) {
|
101
|
+
if (this.triggersLevelChange(this.lastEarnedExp)) {
|
102
|
+
this._levelUpAction(levelUpHtml);
|
60
103
|
}
|
61
104
|
}
|
105
|
+
|
106
|
+
animateExperienceCounter(selector) {
|
107
|
+
mumuki.animateNumberCounter(selector, this.lastEarnedExp);
|
108
|
+
}
|
109
|
+
|
110
|
+
updateLevel() {
|
111
|
+
const $muLevelProgress = $('#mu-level-progress');
|
112
|
+
|
113
|
+
$('#mu-solve-more-exercises span').text(this.exercisesToNextLevel());
|
114
|
+
$('.mu-level-number').html(this.currentLevel());
|
115
|
+
$('.mu-level-tooltip').attr("title", (_, value) => `${value} ${this.currentLevel()}`);
|
116
|
+
|
117
|
+
if (this.currentLevelProgress() === 0) {
|
118
|
+
$muLevelProgress.attr("display", "none");
|
119
|
+
}
|
120
|
+
|
121
|
+
$muLevelProgress.animate(
|
122
|
+
{'progress': this.currentLevelProgress() * 250},
|
123
|
+
{
|
124
|
+
step: function(progress) {
|
125
|
+
let pattern = progress + ", 999";
|
126
|
+
$(this).attr("stroke-dasharray", pattern);
|
127
|
+
},
|
128
|
+
duration: 1000
|
129
|
+
});
|
130
|
+
}
|
62
131
|
}
|
63
132
|
|
64
133
|
function _setUpCurrentLevelProgression() {
|
65
|
-
|
134
|
+
if (_gamificationEnabled()) {
|
135
|
+
mumuki.gamification.currentLevelProgression = new LevelProgression(currentExp());
|
136
|
+
} else {
|
137
|
+
mumuki.gamification.currentLevelProgression = new DummyLevelProgression();
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
function _gamificationEnabled() {
|
142
|
+
return $('#mu-current-exp').length;
|
66
143
|
}
|
67
144
|
|
68
145
|
function currentExp() {
|
69
|
-
return $('#mu-current-exp').val();
|
146
|
+
return parseInt($('#mu-current-exp').val());
|
70
147
|
}
|
71
148
|
|
72
149
|
return {
|
@@ -75,11 +152,12 @@ mumuki.gamification = (() => {
|
|
75
152
|
|
76
153
|
_setUpCurrentLevelProgression,
|
77
154
|
|
78
|
-
/** @type {LevelProgression} */
|
79
|
-
|
155
|
+
/** @type {LevelProgression|DummyLevelProgression} */
|
156
|
+
currentLevelProgression: null
|
80
157
|
};
|
81
158
|
})();
|
82
159
|
|
83
160
|
mumuki.load(() => {
|
84
161
|
mumuki.gamification._setUpCurrentLevelProgression();
|
162
|
+
mumuki.gamification.currentLevelProgression.updateLevel();
|
85
163
|
});
|
@@ -1,379 +1,217 @@
|
|
1
|
-
mumuki.
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let paragraphCount = 1;
|
8
|
-
let paragraphsLines = 2;
|
9
|
-
let $prevSpeech = $('.mu-kids-character-speech-bubble-normal > .mu-kids-prev-speech').hide();
|
10
|
-
let $nextSpeech = $('.mu-kids-character-speech-bubble-normal > .mu-kids-next-speech');
|
11
|
-
let $speechTabs = $('.mu-kids-character-speech-bubble-tabs > li:not(.separator)');
|
12
|
-
let $defaultSpeechTabName = 'description';
|
13
|
-
let $texts = $bubble.children(availableTabs.join(", "));
|
14
|
-
let $hint = $('.mu-kids-hint');
|
15
|
-
let $description = $('.mu-kids-description');
|
16
|
-
let discussionsLinkHtml = $('#mu-kids-discussion-link-html').html();
|
17
|
-
let $kidsContext = $('#mu-kids-context');
|
18
|
-
let contextModalButton = new mumuki.Button($('.mu-kids-context .modal-footer button'));
|
19
|
-
|
20
|
-
// It is important that context is shown as early as possible
|
21
|
-
// in order to display the loading animation
|
22
|
-
function showContext() {
|
23
|
-
$kidsContext.modal({
|
24
|
-
backdrop: 'static',
|
25
|
-
keyboard: false
|
26
|
-
});
|
1
|
+
mumuki.Kids = class {
|
2
|
+
|
3
|
+
constructor() {
|
4
|
+
this.initialize();
|
5
|
+
this.showContext();
|
6
|
+
$(document).ready(this.onReady.bind(this));
|
27
7
|
}
|
28
8
|
|
29
|
-
|
30
|
-
|
31
|
-
|
9
|
+
// ================
|
10
|
+
// == Public API ==
|
11
|
+
// ================
|
12
|
+
|
13
|
+
initialize() {
|
14
|
+
this.submitButton = new mumuki.submission.SubmitButton($('#kids-btn-retry'), $('.submission_control'));
|
15
|
+
this.resultActions = {};
|
16
|
+
this.$states = $('.mu-kids-states');
|
17
|
+
this.$state = $('.mu-kids-state');
|
18
|
+
this.$blocks = $('.mu-kids-blocks');
|
19
|
+
this.$exercise = $('.mu-kids-exercise');
|
20
|
+
this.$exerciseDescription = $('.mu-kids-exercise-description');
|
21
|
+
this.$stateImage = $('.mu-kids-state-image');
|
22
|
+
this.$contextModal = $('#mu-kids-context');
|
23
|
+
this.$resultsModal = $('#kids-results');
|
24
|
+
this.resultsCarrousel = new mumuki.ModalCarrousel('.mu-kids-results-carrousel');
|
25
|
+
this.$resultsAbortedModal = $('#kids-results-aborted');
|
26
|
+
this.$bubbleCharacterAnimation = $('.mu-kids-character-animation');
|
27
|
+
this.$submissionResult = $('.submission-results');
|
28
|
+
mumuki.gamification.currentLevelProgression.registerLevelUpAction(this.levelUpAction);
|
29
|
+
mumuki.gamification.currentLevelProgression.registerGainedExperienceAction(this.gainedExperienceAction);
|
30
|
+
}
|
32
31
|
|
33
|
-
|
32
|
+
gainedExperienceAction() {
|
33
|
+
mumuki.gamification.currentLevelProgression.animateExperienceCounter('.mu-kids-results .mu-experience');
|
34
|
+
}
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
levelUpAction(levelUpHtml) {
|
37
|
+
$('.mu-kids-results-carrousel').append(levelUpHtml);
|
37
38
|
}
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
var newParagraphIndex = Math.floor((paragraphCount / previousParagraphCount) * currentParagraphIndex);
|
45
|
-
showParagraph(paragraphIndex || newParagraphIndex);
|
40
|
+
showContext() {
|
41
|
+
this.$contextModal.modal({
|
42
|
+
backdrop: 'static',
|
43
|
+
keyboard: false
|
44
|
+
});
|
46
45
|
}
|
47
46
|
|
48
|
-
|
49
|
-
|
47
|
+
showNonAbortedPopup(data, animation_name, open_modal_delay_ms = 0) {
|
48
|
+
this.$submissionResult.html(data.html);
|
49
|
+
mumuki.presenterCharacter.playAnimation(animation_name, $('.mu-kids-character-result'));
|
50
|
+
setTimeout(() => this._openSubmissionResultModal(data), open_modal_delay_ms);
|
51
|
+
this.onNonAbortedPopupCall(data);
|
50
52
|
}
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
showAbortedPopup(_data) {
|
55
|
+
this.submitButton.disable();
|
56
|
+
this.$resultsAbortedModal.modal();
|
55
57
|
}
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
+
// ==================
|
60
|
+
// == Hook Methods ==
|
61
|
+
// ==================
|
62
|
+
|
63
|
+
_showSuccessPopup() {
|
64
|
+
this._mustImplementThisMethod()
|
59
65
|
}
|
60
66
|
|
61
|
-
|
62
|
-
|
63
|
-
currentParagraphIndex = index;
|
64
|
-
checkArrowsSpeechVisibility();
|
67
|
+
_showFailurePopup() {
|
68
|
+
this._mustImplementThisMethod()
|
65
69
|
}
|
66
70
|
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
// ====================
|
72
|
+
// == Event Callback ==
|
73
|
+
// ====================
|
74
|
+
|
75
|
+
onReady() {
|
76
|
+
// SubClasses may override this method
|
70
77
|
}
|
71
78
|
|
72
|
-
|
73
|
-
|
79
|
+
onResize() {
|
80
|
+
// SubClasses may override this method
|
74
81
|
}
|
75
82
|
|
76
|
-
|
77
|
-
|
78
|
-
* depending on the presence and type of available states
|
79
|
-
*
|
80
|
-
* @param {*} $muKidsStateImage
|
81
|
-
* @param {*} $muKidsStatesContainer
|
82
|
-
* @param {*} $muKidsBlocks
|
83
|
-
* @param {number} fullMargin
|
84
|
-
*/
|
85
|
-
function distributeAreas($muKidsStateImage, $muKidsStatesContainer, $muKidsBlocks, fullMargin) {
|
86
|
-
if ($muKidsStateImage.children().length) {
|
87
|
-
var ratio = $muKidsStatesContainer.hasClass('mu-kids-single-state') ? 1 : 2;
|
88
|
-
$muKidsStatesContainer.width($muKidsStatesContainer.height() / ratio * 1.25 - fullMargin);
|
89
|
-
} else {
|
90
|
-
$muKidsStatesContainer.width(0);
|
91
|
-
$muKidsBlocks.width('100%');
|
92
|
-
}
|
83
|
+
onNonAbortedPopupCall(_data) {
|
84
|
+
// SubClasses may override this method
|
93
85
|
}
|
94
86
|
|
95
|
-
|
96
|
-
|
97
|
-
// ==========
|
98
|
-
// Public API
|
99
|
-
// ==========
|
100
|
-
|
101
|
-
// Sets a function that will be called each
|
102
|
-
// time the states need to be resized. The function takes:
|
103
|
-
//
|
104
|
-
// * $state: a single state area
|
105
|
-
// * fullMargin
|
106
|
-
// * preferredWidth
|
107
|
-
// * preferredHeight
|
108
|
-
//
|
109
|
-
// Runners must call this method on within the runner's editor.js extension
|
110
|
-
registerStateScaler: function (scaler) {
|
111
|
-
this._stateScaler = scaler;
|
112
|
-
},
|
113
|
-
|
114
|
-
// Sets a function that will be called each
|
115
|
-
// time the blocks area needs to be resized. The function takes:
|
116
|
-
//
|
117
|
-
// * $blocks: the blocks area
|
118
|
-
//
|
119
|
-
// Runners must call this method on within the runner's editor.js extension
|
120
|
-
registerBlocksAreaScaler: function (scaler) {
|
121
|
-
this._blocksAreaScaler = scaler;
|
122
|
-
},
|
123
|
-
|
124
|
-
// Scales a single state.
|
125
|
-
//
|
126
|
-
// This method is called by the kids code, but the runner's editor.js extension may need
|
127
|
-
// to perform additional calls to it.
|
128
|
-
scaleState: function ($state, fullMargin) {
|
129
|
-
const preferredWidth = $state.width() - fullMargin * 2;
|
130
|
-
const preferredHeight = $state.height() - fullMargin * 2;
|
131
|
-
this._stateScaler($state, fullMargin, preferredWidth, preferredHeight);
|
132
|
-
},
|
133
|
-
|
134
|
-
// Scales the blocks area.
|
135
|
-
//
|
136
|
-
// This method is called by the kids code, but the runner's editor.js extension may need
|
137
|
-
// to perform additional calls to it.
|
138
|
-
scaleBlocksArea: function ($blocks) {
|
139
|
-
this._blocksAreaScaler($blocks);
|
140
|
-
},
|
141
|
-
|
142
|
-
// Displays the kids results, updating the progress bar
|
143
|
-
// firing the modal and running appropriate animations.
|
144
|
-
//
|
145
|
-
// This method needs to be called by the runner's editor.html extension
|
146
|
-
// in order to finish an exercise
|
147
|
-
showResult: function (data) {
|
148
|
-
mumuki.updateProgressBarAndShowModal(data);
|
149
|
-
if (data.guide_finished_by_solution) return;
|
150
|
-
mumuki.kids.resultAction[data.status](data);
|
151
|
-
},
|
152
|
-
|
153
|
-
// Restarts the kids exercise.
|
154
|
-
//
|
155
|
-
// This method may need to be called by the runner's editor.html extension
|
156
|
-
// in order to recover from a failed submission
|
157
|
-
restart: function () {
|
158
|
-
mumuki.kids._hideMessageOnCharacterBubble();
|
159
|
-
var $bubble = mumuki.kids._getCharacterBubble();
|
160
|
-
Object.keys(mumuki.kids.resultAction).forEach($bubble.removeClass.bind($bubble));
|
161
|
-
mumuki.presenterCharacter.playAnimation('talk', mumuki.kids._getCharacterImage());
|
162
|
-
},
|
163
|
-
|
164
|
-
disableContextModalButton: function () {
|
165
|
-
contextModalButton.setWaiting();
|
166
|
-
},
|
167
|
-
|
168
|
-
enableContextModalButton: function () {
|
169
|
-
contextModalButton.enable();
|
170
|
-
},
|
171
|
-
|
172
|
-
showContext,
|
173
|
-
|
174
|
-
// ===========
|
175
|
-
// Private API
|
176
|
-
// ===========
|
177
|
-
|
178
|
-
_updateSubmissionResult: function (html) {
|
179
|
-
return $('.submission-results').html(html);
|
180
|
-
},
|
181
|
-
|
182
|
-
_getResultsModal: function () {
|
183
|
-
return $('#kids-results');
|
184
|
-
},
|
185
|
-
|
186
|
-
_getResultsAbortedModal: function () {
|
187
|
-
return $('#kids-results-aborted');
|
188
|
-
},
|
189
|
-
|
190
|
-
_getCharacterImage: function () {
|
191
|
-
return $('.mu-kids-character > img');
|
192
|
-
},
|
193
|
-
|
194
|
-
_getCharacterBubble: function () {
|
195
|
-
return $('.mu-kids-character-speech-bubble');
|
196
|
-
},
|
197
|
-
|
198
|
-
_getOverlay: function () {
|
199
|
-
return $('.mu-kids-overlay');
|
200
|
-
},
|
201
|
-
|
202
|
-
_hideMessageOnCharacterBubble: function () {
|
203
|
-
var $bubble = mumuki.kids._getCharacterBubble();
|
204
|
-
$bubble.find('.mu-kids-character-speech-bubble-tabs').show();
|
205
|
-
$bubble.find('.mu-kids-character-speech-bubble-normal').show();
|
206
|
-
$bubble.find('.mu-kids-character-speech-bubble-failed').hide();
|
207
|
-
$bubble.find('.mu-kids-discussion-link').remove();
|
208
|
-
Object.keys(mumuki.kids.resultAction).forEach($bubble.removeClass.bind($bubble));
|
209
|
-
mumuki.kids._getOverlay().hide()
|
210
|
-
},
|
211
|
-
|
212
|
-
_showMessageOnCharacterBubble: function (data) {
|
213
|
-
const renderer = new mumuki.renderers.SpeechBubbleRenderer(mumuki.kids._getCharacterBubble());
|
214
|
-
renderer.setDiscussionsLinkHtml(discussionsLinkHtml);
|
215
|
-
renderer.setResponseData(data);
|
216
|
-
renderer.render();
|
217
|
-
mumuki.kids._getOverlay().show();
|
218
|
-
},
|
219
|
-
|
220
|
-
_showOnSuccessPopup: function (data) {
|
221
|
-
mumuki.kids._updateSubmissionResult(data.html);
|
222
|
-
mumuki.presenterCharacter.playAnimation('success_l', mumuki.kids._getCharacterImage());
|
223
|
-
mumuki.kids._showMessageOnCharacterBubble(data);
|
224
|
-
mumuki.presenterCharacter.playAnimation('success2_l', $('.mu-kids-character-success'));
|
225
|
-
setTimeout(function () {
|
226
|
-
var $resultsKidsModal = mumuki.kids._getResultsModal();
|
227
|
-
if ($resultsKidsModal) {
|
228
|
-
$resultsKidsModal.modal({
|
229
|
-
backdrop: 'static',
|
230
|
-
keyboard: false
|
231
|
-
});
|
232
|
-
$resultsKidsModal.find('.modal-header').first().html(data.title_html);
|
233
|
-
$resultsKidsModal.find('.modal-footer').first().html(data.button_html);
|
234
|
-
mumuki.kids._showCorollaryCharacter();
|
235
|
-
$('.mu-close-modal').click(() => mumuki.kids._getResultsModal().modal('hide'));
|
236
|
-
}
|
237
|
-
}, 1000 * 4);
|
238
|
-
},
|
239
|
-
|
240
|
-
_showOnFailurePopup: function () {
|
241
|
-
mumuki.kids.submitButton.disable();
|
242
|
-
mumuki.kids._getResultsAbortedModal().modal();
|
243
|
-
mumuki.submission.animateTimeoutError(mumuki.kids.submitButton);
|
244
|
-
},
|
245
|
-
|
246
|
-
_showOnCharacterBubble: function (data) {
|
247
|
-
mumuki.presenterCharacter.playAnimation('failure', mumuki.kids._getCharacterImage());
|
248
|
-
mumuki.kids._showMessageOnCharacterBubble(data);
|
249
|
-
},
|
250
|
-
|
251
|
-
_showCorollaryCharacter: function () {
|
252
|
-
mumuki.characters.magnifying_glass.playAnimation('show', $('.mu-kids-corollary-animation'));
|
253
|
-
},
|
254
|
-
|
255
|
-
_stateScaler: function ($state, fullMargin, preferredWidth, preferredHeight) {
|
256
|
-
var $table = $state.find('gs-board > table');
|
257
|
-
if (!$table.length) return setTimeout(() => this.scaleState($state, fullMargin));
|
258
|
-
|
259
|
-
console.warn("You are using the default states scaler, which is gobstones-specific. Please register your own scaler in the future");
|
260
|
-
|
261
|
-
$table.css('transform', 'scale(1)');
|
262
|
-
var scaleX = preferredWidth / $table.width();
|
263
|
-
var scaleY = preferredHeight / $table.height();
|
264
|
-
$table.css('transform', 'scale(' + Math.min(scaleX, scaleY) + ')');
|
265
|
-
},
|
266
|
-
|
267
|
-
_blocksAreaScaler: function ($blocks) {
|
268
|
-
console.warn("You are using the default blocks scaler, which is blockly-specific. Please register your own scaler in the future");
|
269
|
-
|
270
|
-
var $blockArea = $blocks.find('#blocklyDiv');
|
271
|
-
var $blockSvg = $blocks.find('.blocklySvg');
|
272
|
-
|
273
|
-
$blockArea.width($blocks.width());
|
274
|
-
$blockArea.height($blocks.height());
|
275
|
-
|
276
|
-
$blockSvg.width($blocks.width());
|
277
|
-
$blockSvg.height($blocks.height());
|
278
|
-
},
|
279
|
-
|
280
|
-
resultAction: {}
|
281
|
-
|
282
|
-
};
|
283
|
-
|
284
|
-
mumuki.kids.submitButton = new mumuki.submission.SubmitButton($('#kids-btn-retry'), $('.submission_control'));
|
285
|
-
|
286
|
-
function showPrevParagraph() {
|
287
|
-
animateSpeech();
|
288
|
-
showParagraph(currentParagraphIndex - 1);
|
87
|
+
onSubmissionResultModalOpen(_data) {
|
88
|
+
this.resultsCarrousel.show();
|
289
89
|
}
|
290
90
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
91
|
+
// =================
|
92
|
+
// == Private API ==
|
93
|
+
// =================
|
94
|
+
|
95
|
+
_openSubmissionResultModal(data) {
|
96
|
+
this.$resultsModal.modal({ backdrop: 'static', keyboard: false });
|
97
|
+
this.$resultsModal.find('.modal-header').first().html(data.title_html);
|
98
|
+
mumuki.gamification.currentLevelProgression.setExpMessage(data);
|
99
|
+
this.$resultsModal.find('.modal-footer').first().html(data.button_html);
|
100
|
+
$('.mu-close-modal').click(() => this.$resultsModal.modal('hide'));
|
101
|
+
this.onSubmissionResultModalOpen(data);
|
295
102
|
}
|
296
103
|
|
297
|
-
|
298
|
-
|
104
|
+
// ==========================
|
105
|
+
// == Called by the runner ==
|
106
|
+
// ==========================
|
107
|
+
|
108
|
+
// Displays the exercise results, updating the progress bar
|
109
|
+
// firing the modal and running appropriate animations.
|
110
|
+
//
|
111
|
+
// This method needs to be called by the runner's editor.html extension
|
112
|
+
// in order to finish an exercise
|
113
|
+
showResult(data) {
|
114
|
+
mumuki.progress.updateProgressBarAndShowModal(data);
|
115
|
+
if (data.guide_finished_by_solution) return;
|
116
|
+
this.resultActions[data.status](data);
|
299
117
|
}
|
300
118
|
|
301
|
-
|
302
|
-
|
119
|
+
// Restarts the kids exercise.
|
120
|
+
//
|
121
|
+
// This method may need to be called by the runner's editor.html extension
|
122
|
+
// in order to recover from a failed submission
|
123
|
+
restart() {
|
124
|
+
this._mustImplementThisMethod();
|
303
125
|
}
|
304
126
|
|
305
|
-
|
306
|
-
|
127
|
+
// =================================
|
128
|
+
// == Called by the assets loader ==
|
129
|
+
// =================================
|
307
130
|
|
308
|
-
|
131
|
+
disableContextModalButton() {
|
132
|
+
this.$contextModalButton.setWaiting();
|
133
|
+
}
|
309
134
|
|
310
|
-
|
311
|
-
|
312
|
-
|
135
|
+
enableContextModalButton() {
|
136
|
+
this.$contextModalButton.enable();
|
137
|
+
}
|
313
138
|
|
139
|
+
// ============
|
140
|
+
// == Helper ==
|
141
|
+
// ============
|
314
142
|
|
315
|
-
|
316
|
-
|
317
|
-
|
143
|
+
_mustImplementThisMethod() {
|
144
|
+
throw new Error('TODO: implement method')
|
145
|
+
}
|
318
146
|
|
319
|
-
|
320
|
-
|
321
|
-
|
147
|
+
// ============
|
148
|
+
// == Scaler ==
|
149
|
+
// ============
|
150
|
+
|
151
|
+
// Sets a function that will be called each
|
152
|
+
// time the states need to be resized. The function takes:
|
153
|
+
//
|
154
|
+
// * $state: a single state area
|
155
|
+
// * fullMargin
|
156
|
+
// * preferredWidth
|
157
|
+
// * preferredHeight
|
158
|
+
//
|
159
|
+
// Runners must call this method on within the runner's editor.js extension
|
160
|
+
registerStateScaler(scaler) {
|
161
|
+
this._stateScaler = scaler;
|
162
|
+
}
|
322
163
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
$tab.addClass('active');
|
333
|
-
$texts.hide();
|
334
|
-
$bubble.children('.' + $tab.data('target')).show();
|
335
|
-
updateSpeechParagraphs();
|
336
|
-
})
|
337
|
-
}
|
338
|
-
});
|
164
|
+
// Sets a function that will be called each
|
165
|
+
// time the blocks area needs to be resized. The function takes:
|
166
|
+
//
|
167
|
+
// * $blocks: the blocks area
|
168
|
+
//
|
169
|
+
// Runners must call this method on within the runner's editor.js extension
|
170
|
+
registerBlocksAreaScaler(scaler) {
|
171
|
+
this._blocksAreaScaler = scaler;
|
172
|
+
}
|
339
173
|
|
340
|
-
|
341
|
-
|
342
|
-
|
174
|
+
// Scales a single state.
|
175
|
+
//
|
176
|
+
// This method is called by the kids code, but the runner's editor.js extension may need
|
177
|
+
// to perform additional calls to it.
|
178
|
+
scaleState($state, fullMargin) {
|
179
|
+
const preferredWidth = $state.width() - fullMargin * 2;
|
180
|
+
const preferredHeight = $state.height() - fullMargin * 2;
|
181
|
+
this._stateScaler($state, fullMargin, preferredWidth, preferredHeight);
|
182
|
+
}
|
343
183
|
|
344
|
-
|
345
|
-
|
346
|
-
|
184
|
+
// Scales the blocks area.
|
185
|
+
//
|
186
|
+
// This method is called by the kids code, but the runner's editor.js extension may need
|
187
|
+
// to perform additional calls to it.
|
188
|
+
scaleBlocksArea($blocks) {
|
189
|
+
this._blocksAreaScaler($blocks);
|
190
|
+
}
|
347
191
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
});
|
192
|
+
_stateScaler($state, fullMargin, preferredWidth, preferredHeight) {
|
193
|
+
const $table = $state.find('gs-board > table');
|
194
|
+
if (!$table.length) return setTimeout(() => this.scaleState($state, fullMargin));
|
352
195
|
|
353
|
-
|
354
|
-
mumuki.resize(function () {
|
355
|
-
var margin = 15;
|
356
|
-
var fullMargin = margin * 2;
|
196
|
+
console.warn("You are using the default states scaler, which is gobstones-specific. Please register your own scaler in the future");
|
357
197
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
let $muKidsStateImage = $('.mu-kids-state-image');
|
198
|
+
$table.css('transform', 'scale(1)');
|
199
|
+
const scaleX = preferredWidth / $table.width();
|
200
|
+
const scaleY = preferredHeight / $table.height();
|
201
|
+
$table.css('transform', 'scale(' + Math.min(scaleX, scaleY) + ')');
|
202
|
+
}
|
364
203
|
|
365
|
-
|
204
|
+
_blocksAreaScaler($blocks) {
|
205
|
+
console.warn("You are using the default blocks scaler, which is blockly-specific. Please register your own scaler in the future");
|
366
206
|
|
367
|
-
|
368
|
-
|
369
|
-
}
|
207
|
+
const $blockArea = $blocks.find('#blocklyDiv');
|
208
|
+
const $blockSvg = $blocks.find('.blocklySvg');
|
370
209
|
|
371
|
-
|
372
|
-
|
210
|
+
$blockArea.width($blocks.width());
|
211
|
+
$blockArea.height($blocks.height());
|
373
212
|
|
374
|
-
|
213
|
+
$blockSvg.width($blocks.width());
|
214
|
+
$blockSvg.height($blocks.height());
|
215
|
+
}
|
375
216
|
|
376
|
-
|
377
|
-
});
|
378
|
-
})
|
379
|
-
});
|
217
|
+
}
|