mumuki-laboratory 5.4.0 → 5.5.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: f2a576c10df838214910df546c5ba3aca918fc08275df1b39be0191c419a1d28
4
- data.tar.gz: e87e69c8d7a253d16b0694413db2618c37bf6de828bc72e9270fc371b4560631
3
+ metadata.gz: a40f596693f402240e506ca625b2562809f3d77ccd5422ec322b1b8dd3a0f48c
4
+ data.tar.gz: 40b3b07e73b77804a1884d8ee6d6ad4d9ca80c636bdabe379411f73d159eb00f
5
5
  SHA512:
6
- metadata.gz: c8a8b571044afdd28d6a59957b0bd51ec6b92197429cd5c36e2221842d65cd65ef44c3e7b8727dafd66c8437fde9e774d3fc39e8e130b31a44ff92910224a472
7
- data.tar.gz: 936bf126f56fcdc664c28ec9a52ea6d7cf426b347e15e1c31d32e9b07809454f9da5692dbb88a4a8dcd7b2b1b632b2c55a0eb19f76ed041227c9dbf186784b44
6
+ metadata.gz: e20ea051587798caeecbb8e774adece970c19d714b39c102505ce52847a2dcd0e5afa5081aebb9c28ad64c4686786ac4e548b4cf3c048af9d2f4e08221cee7f0
7
+ data.tar.gz: 38f858df0af512db29f1febad4f7fa007395cbf328a7272904585985dbf8ce2e0bde0fe674eb7335b7e983862fda7e160f1a5c5588910805385c138d4d8eaf17
data/README.md CHANGED
@@ -26,7 +26,7 @@ sudo apt-get install autoconf curl git build-essential libssl-dev autoconf bison
26
26
  > [rbenv](https://github.com/rbenv/rbenv) is a ruby versions manager, similar to rvm, nvm, and so on.
27
27
 
28
28
  ```bash
29
- curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
29
+ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash
30
30
  echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc # or .bash_profile
31
31
  echo 'eval "$(rbenv init -)"' >> ~/.bashrc # or .bash_profile
32
32
  ```
@@ -43,6 +43,7 @@ mumuki.load(function () {
43
43
  var $prevSpeech = $('.mu-kids-character-speech-bubble-normal > .mu-kids-prev-speech').hide();
44
44
  var $nextSpeech = $('.mu-kids-character-speech-bubble-normal > .mu-kids-next-speech');
45
45
  var $speechTabs = $('.mu-kids-character-speech-bubble-tabs > li:not(.separator)');
46
+ var $defaultSpeechTabName = 'description';
46
47
  var $bubble = $('.mu-kids-character-speech-bubble').children('.mu-kids-character-speech-bubble-normal');
47
48
  var $texts = $bubble.children('.description, .hint');
48
49
 
@@ -75,7 +76,7 @@ mumuki.load(function () {
75
76
  });
76
77
 
77
78
  function getSelectedTabName() {
78
- return $speechTabs.filter(".active").data('target');
79
+ return $speechTabs.filter(".active").data('target') || $defaultSpeechTabName;
79
80
  }
80
81
 
81
82
  function hideCurrentParagraph() {
@@ -102,22 +103,6 @@ mumuki.load(function () {
102
103
  if (isVisible) element.show(); else element.hide();
103
104
  }
104
105
 
105
- function autoScrollBubble(toBottom) {
106
- var SCROLL_TIME = 1000;
107
- var PAUSE_TIME = 2000;
108
-
109
- setTimeout(function () {
110
- $bubble.animate({scrollTop: toBottom ? $bubble.height() : 0}, {
111
- duration: SCROLL_TIME,
112
- complete: function () {
113
- autoScrollBubble(!toBottom);
114
- }
115
- });
116
- }, PAUSE_TIME);
117
- }
118
-
119
- autoScrollBubble();
120
-
121
106
  mumuki.kids = {
122
107
 
123
108
  getResultsModal: function () {
@@ -117,6 +117,12 @@ $kids-speech-tabs-width: 40px;
117
117
  ul {
118
118
  margin: 0;
119
119
  }
120
+ &.no-tabs {
121
+ .mu-kids-prev-speech,
122
+ .mu-kids-next-speech {
123
+ right: 0px;
124
+ }
125
+ }
120
126
  .mu-kids-prev-speech,
121
127
  .mu-kids-next-speech {
122
128
  position: absolute;
@@ -191,6 +197,9 @@ $kids-speech-tabs-width: 40px;
191
197
  display: flex;
192
198
  align-items: center;
193
199
  padding: 15px 50px 15px 15px;
200
+ &.no-tabs {
201
+ padding-right: 25px;
202
+ }
194
203
  color: #333;
195
204
  border-radius: 10px;
196
205
  background: $kids-speech-background-color;
@@ -1,5 +1,6 @@
1
1
  class ExerciseQueryController < AjaxController
2
2
  include Mumuki::Laboratory::Controllers::NestedInExercise
3
+ include Mumuki::Laboratory::Controllers::ExerciseSeed
3
4
 
4
5
  def create
5
6
  results = @exercise.submit_query! current_user, query_params
@@ -1,6 +1,7 @@
1
1
  class ExerciseSolutionsController < AjaxController
2
2
  include Mumuki::Laboratory::Controllers::NestedInExercise
3
3
  include Mumuki::Laboratory::Controllers::ResultsRendering
4
+ include Mumuki::Laboratory::Controllers::ExerciseSeed
4
5
 
5
6
  before_action :set_messages, only: :create
6
7
  before_action :validate_accessible!, only: :create
@@ -1,6 +1,7 @@
1
1
  class ExerciseTriesController < AjaxController
2
2
  include Mumuki::Laboratory::Controllers::NestedInExercise
3
3
  include Mumuki::Laboratory::Controllers::ResultsRendering
4
+ include Mumuki::Laboratory::Controllers::ExerciseSeed
4
5
 
5
6
  def create
6
7
  assignment, results = @exercise.submit_try! current_user, try_params
@@ -1,4 +1,6 @@
1
1
  class ExercisesController < ApplicationController
2
+ include Mumuki::Laboratory::Controllers::ExerciseSeed
3
+
2
4
  before_action :set_guide!, only: :show
3
5
  before_action :set_default_content!, only: :show, if: :current_user?
4
6
  before_action :set_assignment!, only: :show, if: :current_user?
@@ -12,8 +12,8 @@ class Challenge < Exercise
12
12
  self.layout = self.class.default_layout
13
13
  end
14
14
 
15
- def extra
16
- [guide.extra, self[:extra]]
15
+ def extra(*)
16
+ [guide.extra, super]
17
17
  .compact
18
18
  .join("\n")
19
19
  .strip
@@ -5,7 +5,8 @@ class Exercise < ApplicationRecord
5
5
  WithAssignments,
6
6
  FriendlyName,
7
7
  WithLanguage,
8
- Assistable
8
+ Assistable,
9
+ WithRandomizations
9
10
 
10
11
  include Submittable,
11
12
  Questionable
@@ -19,6 +20,8 @@ class Exercise < ApplicationRecord
19
20
  validates_presence_of :submissions_count,
20
21
  :guide
21
22
 
23
+ randomize :description, :hint, :extra, :test, :default_content
24
+
22
25
  def console?
23
26
  queriable?
24
27
  end
@@ -1,5 +1,5 @@
1
1
  <img src="/anim_amarillo.svg" alt="">
2
- <div class="mu-kids-character-speech-bubble">
2
+ <div class="mu-kids-character-speech-bubble <%= 'no-tabs' unless @exercise.hint? %>">
3
3
  <% if @exercise.hint? %>
4
4
  <ul class="mu-kids-character-speech-bubble-tabs">
5
5
  <li class="active" data-target="description" title="<%= t :task %>"><i class="fa fa-fw fa-file-text-o"></i>
@@ -0,0 +1,5 @@
1
+ class AddRandomizationsToExercises < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :exercises, :randomizations, :text
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module Mumuki::Laboratory::Controllers::ExerciseSeed
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :set_seed!
6
+ end
7
+
8
+ def set_seed!
9
+ @exercise.seed_with! current_user&.id if @exercise
10
+ end
11
+ end
@@ -7,3 +7,4 @@ require_relative './controllers/dynamic_errors'
7
7
  require_relative './controllers/messages'
8
8
  require_relative './controllers/nested_in_exercise'
9
9
  require_relative './controllers/results_rendering'
10
+ require_relative './controllers/exercise_seed'
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Laboratory
3
- VERSION = '5.4.0'
3
+ VERSION = '5.5.0'
4
4
  end
5
5
  end
@@ -10,6 +10,7 @@ module Mumuki
10
10
  end
11
11
 
12
12
  require 'mumukit/assistant'
13
+ require 'mumukit/randomizer'
13
14
  require 'mumukit/inspection'
14
15
  require 'mumukit/bridge'
15
16
  require 'mumukit/content_type'
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20180526141344) do
13
+ ActiveRecord::Schema.define(version: 20180611190239) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -138,6 +138,7 @@ ActiveRecord::Schema.define(version: 20180526141344) do
138
138
  t.string "initial_state"
139
139
  t.string "final_state"
140
140
  t.text "assistance_rules"
141
+ t.text "randomizations"
141
142
  t.index ["guide_id"], name: "index_exercises_on_guide_id"
142
143
  t.index ["language_id"], name: "index_exercises_on_language_id"
143
144
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Dynamic Exam', organization_workspace: :test do
4
+ let(:user) { create(:user, id: 1) }
5
+ let(:user2) { create(:user, id: 2) }
6
+
7
+ let!(:problem) { build(:problem, description: 'do f = $someVariable', randomizations: { someVariable: { type: :oneOf, value: %w(some_string some_other_string)} }) }
8
+
9
+ let!(:chapter) {
10
+ create(:chapter, lessons: [
11
+ create(:lesson, description: 'An awesome guide', exercises: [
12
+ problem
13
+ ])
14
+ ]) }
15
+
16
+ before { reindex_current_organization! }
17
+
18
+ context 'not logged user' do
19
+ scenario 'visit exercise by slug' do
20
+ visit "/exercises/#{problem.slug}"
21
+
22
+ expect(page).to have_text('do f = some_string')
23
+ end
24
+ end
25
+
26
+
27
+ context 'logged user' do
28
+ scenario 'visit exercise by slug' do
29
+ set_current_user! user
30
+ visit "/exercises/#{problem.slug}"
31
+
32
+ expect(page).to have_text('do f = some_other_string')
33
+
34
+ set_current_user! user2
35
+ visit "/exercises/#{problem.slug}"
36
+
37
+ expect(page).to have_text('do f = some_string')
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mumukit::Randomizer do
4
+ let(:randomizer) { Mumukit::Randomizer.parse(randomizations) }
5
+
6
+ describe '#with_seed' do
7
+ before { Mumukit::Randomizer::Randomization::Base.any_instance.stub(:modulo) { |_, value, range| value % range.size + range.first } }
8
+ let(:randomizer) { Mumukit::Randomizer.parse(some_string: { type: :oneOf, value: %w(some string) }, some_number: { type: :range, value: [1, 3] } ) }
9
+
10
+ it { expect(randomizer.with_seed 0).to eq([['some_string', 'some'], ['some_number', 2]]) }
11
+ it { expect(randomizer.with_seed 1).to eq([['some_string', 'string'], ['some_number', 3]]) }
12
+ it { expect(randomizer.with_seed 2).to eq([['some_string', 'some'], ['some_number', 1]]) }
13
+ it { expect(randomizer.with_seed 3).to eq([['some_string', 'string'], ['some_number', 2]]) }
14
+ it { expect(randomizer.with_seed 4).to eq([['some_string', 'some'], ['some_number', 3]]) }
15
+ it { expect(randomizer.with_seed 5).to eq([['some_string', 'string'], ['some_number', 1]]) }
16
+ it { expect(randomizer.with_seed 6).to eq([['some_string', 'some'], ['some_number', 2]]) }
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-laboratory
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-03 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.1'
167
+ - !ruby/object:Gem::Dependency
168
+ name: mumukit-randomizer
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.1'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.1'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rack
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -703,6 +717,7 @@ files:
703
717
  - db/migrate/20180326224511_remove_book_ids.rb
704
718
  - db/migrate/20180402015405_remove_course_uid.rb
705
719
  - db/migrate/20180526141344_add_tips_rules_to_exercise.rb
720
+ - db/migrate/20180611190239_add_randomizations_to_exercises.rb
706
721
  - db/seeds/users.rb
707
722
  - lib/events.rb
708
723
  - lib/mumuki/laboratory.rb
@@ -710,6 +725,7 @@ files:
710
725
  - lib/mumuki/laboratory/controllers/authorization.rb
711
726
  - lib/mumuki/laboratory/controllers/current_organization.rb
712
727
  - lib/mumuki/laboratory/controllers/dynamic_errors.rb
728
+ - lib/mumuki/laboratory/controllers/exercise_seed.rb
713
729
  - lib/mumuki/laboratory/controllers/messages.rb
714
730
  - lib/mumuki/laboratory/controllers/nested_in_exercise.rb
715
731
  - lib/mumuki/laboratory/controllers/results_rendering.rb
@@ -841,6 +857,7 @@ files:
841
857
  - spec/features/chapter_spec.rb
842
858
  - spec/features/choose_organization_spec.rb
843
859
  - spec/features/complements_flow_spec.rb
860
+ - spec/features/dynamic_exam_spec.rb
844
861
  - spec/features/exams_flow_spec.rb
845
862
  - spec/features/exercise_flow_spec.rb
846
863
  - spec/features/guide_reset_spec.rb
@@ -886,6 +903,7 @@ files:
886
903
  - spec/models/problem_spec.rb
887
904
  - spec/models/query_spec.rb
888
905
  - spec/models/question_spec.rb
906
+ - spec/models/randomizer_spec.rb
889
907
  - spec/models/reading_spec.rb
890
908
  - spec/models/solution_spec.rb
891
909
  - spec/models/stats_spec.rb
@@ -1022,6 +1040,7 @@ test_files:
1022
1040
  - spec/features/chapter_spec.rb
1023
1041
  - spec/features/choose_organization_spec.rb
1024
1042
  - spec/features/complements_flow_spec.rb
1043
+ - spec/features/dynamic_exam_spec.rb
1025
1044
  - spec/features/exams_flow_spec.rb
1026
1045
  - spec/features/exercise_flow_spec.rb
1027
1046
  - spec/features/guide_reset_spec.rb
@@ -1067,6 +1086,7 @@ test_files:
1067
1086
  - spec/models/problem_spec.rb
1068
1087
  - spec/models/query_spec.rb
1069
1088
  - spec/models/question_spec.rb
1089
+ - spec/models/randomizer_spec.rb
1070
1090
  - spec/models/reading_spec.rb
1071
1091
  - spec/models/solution_spec.rb
1072
1092
  - spec/models/stats_spec.rb