mumuki-laboratory 9.0.2 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mumuki_laboratory/application/codemirror.js +10 -2
  3. data/app/assets/javascripts/mumuki_laboratory/application/discussions.js +49 -8
  4. data/app/assets/javascripts/mumuki_laboratory/application/faqs.js +14 -4
  5. data/app/assets/javascripts/mumuki_laboratory/application/gamification.js +3 -3
  6. data/app/assets/javascripts/mumuki_laboratory/application/kids.js +11 -7
  7. data/app/assets/javascripts/mumuki_laboratory/application/kindergarten.js +3 -3
  8. data/app/assets/javascripts/mumuki_laboratory/application/messages.js +3 -3
  9. data/app/assets/javascripts/mumuki_laboratory/application/mu-modal-carrousel.js +4 -4
  10. data/app/assets/javascripts/mumuki_laboratory/application/multiple-files.js +18 -5
  11. data/app/assets/javascripts/mumuki_laboratory/application/multiple-scenarios.js +1 -1
  12. data/app/assets/javascripts/mumuki_laboratory/application/organization.js +32 -0
  13. data/app/assets/javascripts/mumuki_laboratory/application/primary.js +4 -4
  14. data/app/assets/javascripts/mumuki_laboratory/application/profile.js +0 -6
  15. data/app/assets/javascripts/mumuki_laboratory/application/progress.js +1 -1
  16. data/app/assets/javascripts/mumuki_laboratory/application/speech-bubble-renderer.js +1 -1
  17. data/app/assets/javascripts/mumuki_laboratory/application/submission.js +4 -3
  18. data/app/assets/javascripts/mumuki_laboratory/application/submissions-store.js +1 -1
  19. data/app/assets/javascripts/mumuki_laboratory/application/toast.js +3 -0
  20. data/app/assets/javascripts/mumuki_laboratory/application/tooltip.js +1 -1
  21. data/app/assets/javascripts/mumuki_laboratory/application/upload.js +2 -2
  22. data/app/assets/javascripts/mumuki_laboratory/application/user.js +49 -5
  23. data/app/assets/stylesheets/mumuki_laboratory/application.scss +0 -1
  24. data/app/assets/stylesheets/mumuki_laboratory/application/_errors.scss +1 -1
  25. data/app/assets/stylesheets/mumuki_laboratory/application/_layout.scss +1 -27
  26. data/app/assets/stylesheets/mumuki_laboratory/application/_modules.scss +1 -2
  27. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_activity.scss +14 -0
  28. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_avatar.scss +5 -0
  29. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_breadcrumb.scss +2 -2
  30. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_datepicker.scss +0 -4
  31. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_discussion.scss +49 -59
  32. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_editor.scss +16 -18
  33. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_exercise_assignment.scss +2 -11
  34. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_exercise_results.scss +1 -7
  35. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_faqs.scss +30 -8
  36. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_flash.scss +7 -46
  37. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids.scss +19 -4
  38. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids_results.scss +18 -23
  39. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kindergarten.scss +1 -9
  40. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_overlap.scss +1 -1
  41. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_progress_bar.scss +5 -5
  42. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_terms.scss +3 -2
  43. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_timer.scss +1 -3
  44. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_menu.scss +38 -3
  45. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_profile.scss +1 -2
  46. data/app/controllers/application_controller.rb +4 -2
  47. data/app/controllers/discussions_messages_controller.rb +9 -3
  48. data/app/controllers/users_controller.rb +13 -0
  49. data/app/helpers/application_helper.rb +5 -5
  50. data/app/helpers/assignment_result_helper.rb +3 -2
  51. data/app/helpers/assistance_box_helper.rb +1 -1
  52. data/app/helpers/concerns/with_student_path_navigation.rb +8 -3
  53. data/app/helpers/concerns/with_student_path_navigation/continue_navigation.rb +1 -1
  54. data/app/helpers/concerns/with_student_path_navigation/finish_navigation.rb +1 -1
  55. data/app/helpers/concerns/with_student_path_navigation/next_parent_navigation.rb +7 -0
  56. data/app/helpers/concerns/with_student_path_navigation/revisit_navigation.rb +1 -1
  57. data/app/helpers/discussions_helper.rb +64 -23
  58. data/app/helpers/editor_tabs_helper.rb +10 -6
  59. data/app/helpers/email_helper.rb +2 -2
  60. data/app/helpers/exercise_input_helper.rb +2 -3
  61. data/app/helpers/links_helper.rb +12 -9
  62. data/app/helpers/menu_bar_helper.rb +1 -1
  63. data/app/helpers/messages_helper.rb +1 -1
  64. data/app/helpers/multiple_file_editor_helper.rb +2 -1
  65. data/app/helpers/overlapped_buttons_helper.rb +22 -12
  66. data/app/helpers/profile_helper.rb +3 -3
  67. data/app/helpers/toast_helper.rb +27 -0
  68. data/app/helpers/user_activity_helper.rb +48 -0
  69. data/app/helpers/user_menu_helper.rb +24 -6
  70. data/app/views/book/show.html.erb +2 -2
  71. data/app/views/certificates/verify.html.erb +1 -1
  72. data/app/views/chapters/show.html.erb +2 -2
  73. data/app/views/discussions/_description_message.html.erb +1 -1
  74. data/app/views/discussions/_message.html.erb +32 -7
  75. data/app/views/discussions/_new_message.html.erb +13 -2
  76. data/app/views/discussions/index.html.erb +8 -10
  77. data/app/views/discussions/new.html.erb +2 -2
  78. data/app/views/discussions/show.html.erb +20 -12
  79. data/app/views/exam_registrations/show.html.erb +10 -11
  80. data/app/views/exercise_solutions/_assistant_rules_box.html.erb +1 -1
  81. data/app/views/exercise_solutions/_contextualization_results_body.html.erb +1 -1
  82. data/app/views/exercise_solutions/_contextualization_results_container.html.erb +1 -1
  83. data/app/views/exercise_solutions/_kids_results_button.html.erb +2 -2
  84. data/app/views/exercise_solutions/_results.html.erb +1 -1
  85. data/app/views/exercises/_exercise_assignment.html.erb +2 -2
  86. data/app/views/exercises/_exercise_skipped.html.erb +1 -1
  87. data/app/views/exercises/_read_only.html.erb +108 -105
  88. data/app/views/exercises/show.html.erb +7 -7
  89. data/app/views/faqs/index.html.erb +5 -1
  90. data/app/views/guides/_guide.html.erb +1 -1
  91. data/app/views/guides/_guide_container.html.erb +4 -4
  92. data/app/views/invitations/_invitation_form.html.erb +5 -4
  93. data/app/views/layouts/_authoring.html.erb +1 -1
  94. data/app/views/layouts/_discussions.html.erb +7 -7
  95. data/app/views/layouts/_kids.html.erb +5 -5
  96. data/app/views/layouts/_kindergarten.html.erb +10 -6
  97. data/app/views/layouts/_main.html.erb +10 -10
  98. data/app/views/layouts/_organizations_listing.html.erb +2 -2
  99. data/app/views/layouts/_progress_bar.html.erb +2 -0
  100. data/app/views/layouts/_submission_result_error.html.erb +1 -1
  101. data/app/views/layouts/_test_results.html.erb +1 -1
  102. data/app/views/layouts/_timer.html.erb +1 -1
  103. data/app/views/layouts/_user_menu.html.erb +13 -20
  104. data/app/views/layouts/application.html.erb +39 -42
  105. data/app/views/layouts/exercise_inputs/editors/_code.html.erb +4 -4
  106. data/app/views/layouts/exercise_inputs/editors/_free_form.html.erb +1 -1
  107. data/app/views/layouts/exercise_inputs/editors/_multiple_choice.html.erb +7 -9
  108. data/app/views/layouts/exercise_inputs/editors/_multiple_files.html.erb +10 -10
  109. data/app/views/layouts/exercise_inputs/editors/_single_choice.html.erb +6 -8
  110. data/app/views/layouts/exercise_inputs/editors/_text.html.erb +2 -3
  111. data/app/views/layouts/exercise_inputs/editors/_upload.html.erb +5 -5
  112. data/app/views/layouts/exercise_inputs/forms/_form.html.erb +1 -1
  113. data/app/views/layouts/exercise_inputs/forms/_interactive_form.html.erb +2 -2
  114. data/app/views/layouts/exercise_inputs/forms/_kids_form.html.erb +1 -1
  115. data/app/views/layouts/exercise_inputs/forms/_playground_form.html.erb +2 -2
  116. data/app/views/layouts/exercise_inputs/forms/_problem_form.html.erb +13 -9
  117. data/app/views/layouts/exercise_inputs/layouts/_input_primary.html.erb +2 -2
  118. data/app/views/layouts/exercise_inputs/layouts/_input_right.html.erb +2 -2
  119. data/app/views/layouts/exercise_inputs/read_only_editors/_code.html.erb +1 -1
  120. data/app/views/layouts/exercise_inputs/read_only_editors/_free_form.html.erb +1 -1
  121. data/app/views/layouts/exercise_inputs/read_only_editors/_multiple_choice.html.erb +4 -4
  122. data/app/views/layouts/exercise_inputs/read_only_editors/_multiple_files.html.erb +2 -2
  123. data/app/views/layouts/exercise_inputs/read_only_editors/_single_choice.html.erb +4 -4
  124. data/app/views/layouts/exercise_inputs/read_only_editors/_text.erb +1 -1
  125. data/app/views/layouts/modals/_avatar_picker.html.erb +2 -5
  126. data/app/views/layouts/modals/_guide_corollary.html.erb +4 -8
  127. data/app/views/layouts/modals/_kids_context.html.erb +7 -5
  128. data/app/views/layouts/modals/_kids_results.html.erb +2 -2
  129. data/app/views/layouts/modals/_kids_results_aborted.html.erb +2 -2
  130. data/app/views/layouts/modals/_kindergarten_context.html.erb +3 -3
  131. data/app/views/layouts/modals/_kindergarten_results.html.erb +3 -3
  132. data/app/views/layouts/modals/_kindergarten_results_aborted.html.erb +2 -2
  133. data/app/views/layouts/modals/_level_up.html.erb +2 -5
  134. data/app/views/layouts/modals/_new_message.html.erb +5 -5
  135. data/app/views/notifications/_dropdown.html.erb +3 -3
  136. data/app/views/users/_activity_indicator.html.erb +17 -0
  137. data/app/views/users/_edit_user_form.html.erb +6 -6
  138. data/app/views/users/_profile_fields.html.erb +6 -6
  139. data/app/views/users/_user_form.html.erb +2 -2
  140. data/app/views/users/activity.html.erb +37 -0
  141. data/app/views/users/certificates.html.erb +26 -24
  142. data/app/views/users/discussions.html.erb +23 -21
  143. data/app/views/users/messages.html.erb +22 -20
  144. data/app/views/users/show.html.erb +5 -3
  145. data/app/views/users/terms.html.erb +4 -2
  146. data/config/initializers/inflections.rb +3 -0
  147. data/config/routes.rb +3 -0
  148. data/lib/mumuki/laboratory.rb +1 -1
  149. data/lib/mumuki/laboratory/extensions.rb +1 -0
  150. data/lib/mumuki/laboratory/extensions/date_and_time.rb +11 -0
  151. data/lib/mumuki/laboratory/locales/en.yml +28 -2
  152. data/lib/mumuki/laboratory/locales/es-CL.yml +33 -4
  153. data/lib/mumuki/laboratory/locales/es.yml +33 -4
  154. data/lib/mumuki/laboratory/locales/pt.yml +34 -3
  155. data/lib/mumuki/laboratory/version.rb +1 -1
  156. data/spec/capybara_helper.rb +1 -0
  157. data/spec/controllers/discussions_messages_controller_spec.rb +84 -3
  158. data/spec/dummy/db/schema.rb +23 -3
  159. data/spec/features/discussion_flow_spec.rb +22 -2
  160. data/spec/features/exercise_flow_spec.rb +1 -1
  161. data/spec/features/guide_reset_spec.rb +1 -1
  162. data/spec/features/terms_flow_spec.rb +1 -2
  163. data/spec/features/user_activity_flow_spec.rb +65 -0
  164. data/spec/helpers/breadcrumbs_helper_spec.rb +2 -2
  165. data/spec/helpers/user_activity_helper_spec.rb +32 -0
  166. data/spec/helpers/with_navigation_spec.rb +36 -13
  167. data/spec/javascripts/editors-spec.js +3 -3
  168. data/spec/javascripts/kids-button-spec.js +2 -2
  169. data/spec/javascripts/upload-spec.js +8 -8
  170. metadata +133 -123
  171. data/app/assets/stylesheets/mumuki_laboratory/application/hovers.scss +0 -12
  172. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_checkboxes.scss +0 -34
  173. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_guide_corollary.scss +0 -9
@@ -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: 20210302181654) do
13
+ ActiveRecord::Schema.define(version: 20210330175706) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -79,14 +79,16 @@ ActiveRecord::Schema.define(version: 20210302181654) do
79
79
  t.bigint "organization_id"
80
80
  t.datetime "created_at", null: false
81
81
  t.datetime "updated_at", null: false
82
+ t.datetime "start_date"
83
+ t.datetime "end_date"
82
84
  t.index ["organization_id"], name: "index_certificate_programs_on_organization_id"
83
85
  end
84
86
 
85
87
  create_table "certificates", force: :cascade do |t|
86
88
  t.bigint "user_id"
87
89
  t.bigint "certificate_program_id"
88
- t.datetime "start_date"
89
- t.datetime "end_date"
90
+ t.datetime "started_at"
91
+ t.datetime "ended_at"
90
92
  t.string "code"
91
93
  t.datetime "created_at", null: false
92
94
  t.datetime "updated_at", null: false
@@ -121,6 +123,8 @@ ActiveRecord::Schema.define(version: 20210302181654) do
121
123
  t.integer "organization_id"
122
124
  t.datetime "created_at", null: false
123
125
  t.datetime "updated_at", null: false
126
+ t.datetime "period_start"
127
+ t.datetime "period_end"
124
128
  end
125
129
 
126
130
  create_table "discussions", force: :cascade do |t|
@@ -199,6 +203,13 @@ ActiveRecord::Schema.define(version: 20210302181654) do
199
203
  t.index ["exam_registration_id"], name: "index_exam_registrations_exams_on_exam_registration_id"
200
204
  end
201
205
 
206
+ create_table "exam_registrations_users", id: false, force: :cascade do |t|
207
+ t.bigint "exam_registration_id", null: false
208
+ t.bigint "user_id", null: false
209
+ t.index ["exam_registration_id"], name: "index_exam_registrations_users_on_exam_registration_id"
210
+ t.index ["user_id"], name: "index_exam_registrations_users_on_user_id"
211
+ end
212
+
202
213
  create_table "exams", id: :serial, force: :cascade do |t|
203
214
  t.integer "organization_id"
204
215
  t.integer "guide_id"
@@ -368,6 +379,13 @@ ActiveRecord::Schema.define(version: 20210302181654) do
368
379
  t.integer "discussion_id"
369
380
  t.boolean "approved", default: false
370
381
  t.boolean "not_actually_a_question", default: false
382
+ t.datetime "approved_at"
383
+ t.bigint "approved_by_id"
384
+ t.integer "deletion_motive"
385
+ t.datetime "deleted_at"
386
+ t.bigint "deleted_by_id"
387
+ t.index ["approved_by_id"], name: "index_messages_on_approved_by_id"
388
+ t.index ["deleted_by_id"], name: "index_messages_on_deleted_by_id"
371
389
  end
372
390
 
373
391
  create_table "notifications", force: :cascade do |t|
@@ -507,6 +525,8 @@ ActiveRecord::Schema.define(version: 20210302181654) do
507
525
  t.datetime "forum_terms_accepted_at"
508
526
  t.boolean "banned_from_forum"
509
527
  t.boolean "uppercase_mode"
528
+ t.string "delete_account_token"
529
+ t.datetime "delete_account_token_expiration_date"
510
530
  t.index ["avatar_type", "avatar_id"], name: "index_users_on_avatar_type_and_avatar_id"
511
531
  t.index ["disabled_at"], name: "index_users_on_disabled_at"
512
532
  t.index ["last_organization_id"], name: "index_users_on_last_organization_id"
@@ -162,14 +162,27 @@ feature 'Discussion Flow', organization_workspace: :test do
162
162
  end
163
163
 
164
164
  context 'and forum enabled' do
165
- before { Organization.current.update! forum_enabled: true }
165
+ let!(:problem_2_discussion_message) { create(:message, discussion: problem_2_discussions.first, sender: another_student.uid) }
166
+ let!(:another_problem_2_discussion_message) { create(:message, discussion: problem_2_discussions.first, sender: another_student.uid) }
167
+ before do
168
+ Organization.current.update! forum_enabled: true
169
+ another_problem_2_discussion_message.soft_delete! :inappropriate_content, moderator
170
+ end
166
171
 
167
172
  scenario 'newly created discussion' do
168
173
  visit current_path
169
174
  expect(page).to have_text(problem_2.name)
170
175
  expect(page).to have_text('Open')
171
176
  expect(page).to have_text('Messages')
177
+ expect(page).not_to have_text('Preview')
178
+ expect(page).to have_text(problem_2_discussion_message.content)
179
+ expect(page).not_to have_text(another_problem_2_discussion_message.content)
172
180
  expect(page).not_to have_xpath("//div[@class='discussion-actions']")
181
+ expect(page).to_not have_text('Includes inappropriate content')
182
+ expect(page).to_not have_text('Shares the correct solution')
183
+ expect(page).to_not have_text('Discloses personal information')
184
+ expect(page).to have_text('included inappropriate content')
185
+ expect(page).to_not have_text ("Deleted by #{moderator.name}")
173
186
  end
174
187
 
175
188
  context 'for moderator' do
@@ -180,11 +193,18 @@ feature 'Discussion Flow', organization_workspace: :test do
180
193
  expect(page).to have_text(problem_2.name)
181
194
  expect(page).to have_text('Open')
182
195
  expect(page).to have_text('Messages')
196
+ expect(page).to have_text('Preview')
197
+ expect(page).to have_text(problem_2_discussion_message.content)
198
+ expect(page).to have_text(another_problem_2_discussion_message.content)
183
199
  expect(page).to have_xpath("//div[@class='discussion-actions']")
200
+ expect(page).to have_text('Includes inappropriate content')
201
+ expect(page).to have_text('Shares the correct solution')
202
+ expect(page).to have_text('Discloses personal information')
203
+ expect(page).to have_text('included inappropriate content')
204
+ expect(page).to have_text ("Deleted by #{moderator.name}")
184
205
  end
185
206
  end
186
207
  end
187
208
  end
188
209
  end
189
-
190
210
  end
@@ -190,7 +190,7 @@ feature 'Exercise Flow', organization_workspace: :test do
190
190
  expect(page).to have_text('need a hint?')
191
191
  expect(page).to have_selector('.upload')
192
192
  expect(problem_5.language.extension).to eq('gbs')
193
- expect(page.find("//div[@class = 'form-group']/input")['accept']).to eq(".gbs")
193
+ expect(page.find("//input[@id = 'mu-upload-input']")['accept']).to eq(".gbs")
194
194
 
195
195
  expect(page.find("#mu-exercise-id")['value']).to eq(problem_5.id.to_s)
196
196
  expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
@@ -18,7 +18,7 @@ feature 'Guide Reset Flow', organization_workspace: :test do
18
18
 
19
19
  before { reindex_current_organization! }
20
20
 
21
- let(:restart_xpath) { "//i[@title='#{I18n.t(:restart)}']" }
21
+ let(:restart_xpath) { "//a[@title='#{I18n.t(:restart)}']" }
22
22
 
23
23
  context 'no logged in user' do
24
24
  scenario 'visit guide' do
@@ -92,8 +92,7 @@ feature 'Terms Flow', organization_workspace: :test do
92
92
  end
93
93
  end
94
94
 
95
- context 'with unaccepted role terms' do
96
-
95
+ context 'with unaccepted role terms', :toast_interferes_with_view do
97
96
  context 'visit forum' do
98
97
  let(:terms_path) { '/discussions/terms' }
99
98
  before { test_organization.update! forum_enabled: true }
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'User Activity Flow', organization_workspace: :test do
4
+ let(:user) { create(:user) }
5
+ before { set_current_user!(user) }
6
+
7
+ let(:fake_stats) { double('stats') }
8
+ before do
9
+ allow(UserStats).to receive(:stats_for).and_return(fake_stats)
10
+ allow(fake_stats).to receive(:activity).and_return(
11
+ { exercises: { solved_count: 8, count: 10 },
12
+ messages: { count: 12, approved: 6 } })
13
+ end
14
+
15
+ let(:week_start) { Time.new(2020, 10, 12) }
16
+ before do
17
+ allow(Time).to receive(:now).and_return(week_start)
18
+ end
19
+
20
+ context 'total' do
21
+ before { visit activity_user_path }
22
+
23
+ scenario 'displays exercises done percentage' do
24
+ expect(page).to have_text('80%')
25
+ expect(page).to have_text('done')
26
+ end
27
+
28
+ scenario 'displays exercises solved count' do
29
+ expect(page).to have_text('8')
30
+ expect(page).to have_text('solved')
31
+ end
32
+
33
+ scenario 'displays messages count' do
34
+ expect(page).to have_text('12')
35
+ expect(page).to have_text('messages')
36
+ end
37
+
38
+ scenario 'displays validated messages count' do
39
+ expect(page).to have_text('6')
40
+ expect(page).to have_text('validated')
41
+ end
42
+
43
+ scenario 'displays recent weeks' do
44
+ expect(page).to have_text 'Week of 2020-10-12'
45
+ expect(page).to have_text 'Week of 2020-10-05'
46
+ expect(page).to have_text 'Week of 2020-09-28'
47
+ end
48
+ end
49
+
50
+ context 'selecting a specific week' do
51
+ before do
52
+ visit activity_user_path
53
+ click_on 'Week of 2020-10-12'
54
+ end
55
+
56
+ scenario "redirects to week activity" do
57
+ expect(page).to have_current_path('/user/activity?date_from=2020-10-12&date_to=2020-10-19')
58
+ end
59
+
60
+ scenario "doesn't display exercises done percentage" do
61
+ expect(page).not_to have_text('80%')
62
+ expect(page).not_to have_text('done')
63
+ end
64
+ end
65
+ end
@@ -46,7 +46,7 @@ describe BreadcrumbsHelper, organization_workspace: :test do
46
46
  end
47
47
 
48
48
  context 'in chapter' do
49
- let!(:chapter) { create(:chapter, name: 'my chapter', lessons: [lesson]) }
49
+ let!(:chapter) { create(:chapter, name: 'my chapter', lessons: [lesson], number: 1) }
50
50
  let(:lesson) { create(:lesson, name: 'my lesson', exercises: [exercise]) }
51
51
  let(:exercise) { create(:exercise, name: 'my exercise') }
52
52
 
@@ -64,7 +64,7 @@ describe BreadcrumbsHelper, organization_workspace: :test do
64
64
  it 'mumuki, organization, chapter and lesson have links but exercise does not' do
65
65
  expect(breadcrumb).to include home_breadcrumb_with_link
66
66
  expect(breadcrumb).to include organization_breadcrumb_with_link
67
- expect(breadcrumb).to include "<a href=\"/chapters/#{chapter.id}-my-chapter\">my chapter</a>"
67
+ expect(breadcrumb).to include "<a href=\"/chapters/#{chapter.id}-my-chapter\">1. my chapter</a>"
68
68
  expect(breadcrumb).to include "<a href=\"/lessons/#{lesson.id}-my-chapter-my-lesson\">1. my lesson</a>"
69
69
  expect(breadcrumb).to include "<li class='mu-breadcrumb-list-item last'>1. my exercise</li>"
70
70
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe UserActivityHelper, organization_workspace: :test do
4
+ helper UserActivityHelper
5
+
6
+ let(:organization) { Organization.current }
7
+
8
+ before do
9
+ # Set today date to Wednesday to test week always starts on Monday
10
+ allow(Date).to receive(:today).and_return(Date.new(2021, 2, 10))
11
+ allow_any_instance_of(UserActivityHelper).to receive(:min_week).and_return(8.weeks.ago(Date.today))
12
+ end
13
+
14
+ describe 'activity_selector_week_range_for' do
15
+ let(:range) { activity_selector_week_range_for organization }
16
+ let(:closest_monday) { Date.new(2021, 2, 8) }
17
+
18
+ context 'organization without in preparation until' do
19
+ it { expect(range.length).to eq 9 }
20
+ it { expect(range.first).to eq [closest_monday, 1.week.since(closest_monday).to_date] }
21
+ it { expect(range.last).to eq [8.week.ago(closest_monday).to_date, 7.week.ago(closest_monday).to_date] }
22
+ end
23
+
24
+ context 'organization with in preparation until' do
25
+ before { organization.update! in_preparation_until: 3.week.ago(Date.today) }
26
+
27
+ it { expect(range.length).to eq 4 }
28
+ it { expect(range.first).to eq [closest_monday, 1.week.since(closest_monday).to_date] }
29
+ it { expect(range.last).to eq [3.week.ago(closest_monday).to_date, 2.week.ago(closest_monday).to_date] }
30
+ end
31
+ end
32
+ end
@@ -14,9 +14,9 @@ describe WithStudentPathNavigation, organization_workspace: :test do
14
14
  let!(:exercise_3) { create(:exercise, id: 13, name: 'exercise 3', guide: guide) }
15
15
 
16
16
  context 'when user did not submit any solution' do
17
- it { expect(next_button(exercise_1)).to eq "<a class=\"btn btn-success btn-block\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
18
- it { expect(next_button(exercise_2)).to eq "<a class=\"btn btn-success btn-block\" role=\"button\" href=\"/exercises/#{exercise_3.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 3</span><i class=\"fas fa-chevron-right\"></i></a>" }
19
- it { expect(next_button(exercise_3)).to eq "<a class=\"btn btn-warning btn-block\" role=\"button\" href=\"/exercises/#{exercise_1.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 1</span><i class=\"fas fa-chevron-right\"></i></a>" }
17
+ it { expect(next_button(exercise_1)).to eq "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
18
+ it { expect(next_button(exercise_2)).to eq "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/exercises/#{exercise_3.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 3</span><i class=\"fas fa-chevron-right\"></i></a>" }
19
+ it { expect(next_button(exercise_3)).to eq "<a class=\"btn btn-warning w-100\" role=\"button\" href=\"/exercises/#{exercise_1.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 1</span><i class=\"fas fa-chevron-right\"></i></a>" }
20
20
  end
21
21
 
22
22
  context 'when on last unresolved exercise' do
@@ -25,9 +25,9 @@ describe WithStudentPathNavigation, organization_workspace: :test do
25
25
  exercise_3.submit_solution!(current_user).passed!
26
26
  end
27
27
 
28
- it { expect(next_button(exercise_1)).to eq "<a class=\"btn btn-success btn-block\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
28
+ it { expect(next_button(exercise_1)).to eq "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
29
29
  it { expect(next_button(exercise_2)).to be nil }
30
- it { expect(next_button(exercise_3)).to eq "<a class=\"btn btn-warning btn-block\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
30
+ it { expect(next_button(exercise_3)).to eq "<a class=\"btn btn-warning w-100\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
31
31
  end
32
32
 
33
33
  context 'when user did submit a solution' do
@@ -35,9 +35,9 @@ describe WithStudentPathNavigation, organization_workspace: :test do
35
35
  exercise_1.submit_solution!(current_user).passed!
36
36
  end
37
37
 
38
- it { expect(next_button(exercise_1)).to eq "<a class=\"btn btn-success btn-block\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
39
- it { expect(next_button(exercise_2)).to eq "<a class=\"btn btn-success btn-block\" role=\"button\" href=\"/exercises/#{exercise_3.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 3</span><i class=\"fas fa-chevron-right\"></i></a>" }
40
- it { expect(next_button(exercise_3)).to eq "<a class=\"btn btn-warning btn-block\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
38
+ it { expect(next_button(exercise_1)).to eq "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
39
+ it { expect(next_button(exercise_2)).to eq "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/exercises/#{exercise_3.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 3</span><i class=\"fas fa-chevron-right\"></i></a>" }
40
+ it { expect(next_button(exercise_3)).to eq "<a class=\"btn btn-warning w-100\" role=\"button\" href=\"/exercises/#{exercise_2.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
41
41
  end
42
42
  end
43
43
 
@@ -46,8 +46,8 @@ describe WithStudentPathNavigation, organization_workspace: :test do
46
46
  let!(:exercise) { create(:exercise, id: 12, name: 'exercise 2', guide: guide) }
47
47
 
48
48
  context 'when user did not submit any exercise' do
49
- it { expect(next_button(reading)).to eq "<a class=\"btn-confirmation btn btn-success btn-block\" data-confirmation-url=\"/exercises/#{reading.friendly_name}/confirmations\" role=\"button\" href=\"/exercises/#{exercise.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
50
- it { expect(next_button(exercise)).to eq "<a class=\"btn btn-warning btn-block\" role=\"button\" href=\"/exercises/#{reading.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 1</span><i class=\"fas fa-chevron-right\"></i></a>" }
49
+ it { expect(next_button(reading)).to eq "<a class=\"btn-confirmation btn btn-complementary w-100\" data-confirmation-url=\"/exercises/#{reading.friendly_name}/confirmations\" role=\"button\" href=\"/exercises/#{exercise.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
50
+ it { expect(next_button(exercise)).to eq "<a class=\"btn btn-warning w-100\" role=\"button\" href=\"/exercises/#{reading.friendly_name}\"><span class=\"fa5-text-r\">Next pending: exercise 1</span><i class=\"fas fa-chevron-right\"></i></a>" }
51
51
  end
52
52
 
53
53
  context 'when user finished just reading' do
@@ -55,7 +55,7 @@ describe WithStudentPathNavigation, organization_workspace: :test do
55
55
  reading.submit_confirmation!(current_user)
56
56
  end
57
57
 
58
- it { expect(next_button(reading)).to eq "<a class=\"btn-confirmation btn btn-success btn-block\" data-confirmation-url=\"/exercises/#{reading.friendly_name}/confirmations\" role=\"button\" href=\"/exercises/#{exercise.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
58
+ it { expect(next_button(reading)).to eq "<a class=\"btn-confirmation btn btn-complementary w-100\" data-confirmation-url=\"/exercises/#{reading.friendly_name}/confirmations\" role=\"button\" href=\"/exercises/#{exercise.friendly_name}\"><span class=\"fa5-text-r\">Next: exercise 2</span><i class=\"fas fa-chevron-right\"></i></a>" }
59
59
  it { expect(next_button(exercise)).to eq nil }
60
60
  end
61
61
  end
@@ -83,15 +83,38 @@ describe WithStudentPathNavigation, organization_workspace: :test do
83
83
  let(:lessons) { [lesson_1, lesson_2, lesson_3] }
84
84
 
85
85
  context 'one suggestion' do
86
- it { expect(next_button(lesson_2)).to include "<a class=\"btn btn-success btn-block\" role=\"button\" href=\"/lessons/#{lesson_3.friendly_name}\"><span class=\"fa5-text-r\">Next: #{lesson_3.name}</span><i class=\"fas fa-chevron-right\"></i></a>" }
86
+ it { expect(next_button(lesson_2)).to include "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/lessons/#{lesson_3.friendly_name}\"><span class=\"fa5-text-r\">Next: #{lesson_3.name}</span><i class=\"fas fa-chevron-right\"></i></a>" }
87
87
  it { expect(next_button(lesson_1)).to be_html_safe }
88
88
  end
89
89
 
90
90
  context 'many suggestions' do
91
- it { expect(next_button(lesson_1)).to include "<a class=\"btn btn-success btn-block\" role=\"button\" href=\"/lessons/#{lesson_2.friendly_name}\"><span class=\"fa5-text-r\">Next: #{lesson_2.name}</span><i class=\"fas fa-chevron-right\"></i></a>" }
91
+ it { expect(next_button(lesson_1)).to include "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/lessons/#{lesson_2.friendly_name}\"><span class=\"fa5-text-r\">Next: #{lesson_2.name}</span><i class=\"fas fa-chevron-right\"></i></a>" }
92
92
  it { expect(next_button(lesson_1)).to be_html_safe }
93
93
  end
94
94
  end
95
95
  end
96
+
97
+ context "when there's a next chapter" do
98
+ let(:organization) { create :organization, book: book }
99
+
100
+ let(:book) { create(:book, chapters: [
101
+ chapter_1,
102
+ chapter_2
103
+ ]) }
104
+
105
+ let(:chapter_1) { create(:chapter, lessons: [lesson_1]) }
106
+ let(:chapter_2) { create(:chapter, lessons: [create(:lesson, exercises: [ create(:exercise) ])]) }
107
+
108
+ let(:lesson_1) { create(:lesson, exercises: [ exercise_1 ]) }
109
+ let(:exercise_1) { create(:exercise) }
110
+
111
+ before do
112
+ organization.switch!
113
+ reindex_current_organization!
114
+ exercise_1.submit_solution!(current_user).passed!
115
+ end
116
+
117
+ it { expect(next_button(lesson_1)).to include "<a class=\"btn btn-complementary w-100\" role=\"button\" href=\"/chapters/#{chapter_2.friendly_name}\"><span class=\"fa5-text-r\">Next: #{chapter_2.name}</span><i class=\"fas fa-chevron-right\"></i></a>" }
118
+ end
96
119
  end
97
120
  end
@@ -22,7 +22,7 @@ describe('editors', () => {
22
22
  it('reads the custom sources if present, ignoring the form', () => {
23
23
  $('body').html(`
24
24
  <form role="form" class="new_solution">
25
- <div class="field form-group editor-code">
25
+ <div class="editor-code">
26
26
  <textarea class="form-control editor" name="solution[content]" id="solution_content">the standard solution</textarea>
27
27
  </div>
28
28
  </form>`);
@@ -39,7 +39,7 @@ describe('editors', () => {
39
39
  it('reads the form if no sources', () => {
40
40
  $('body').html(`
41
41
  <form role="form" class="new_solution">
42
- <div class="field form-group editor-code">
42
+ <div class="editor-code">
43
43
  <textarea class="form-control editor" name="solution[content]" id="solution_content">the solution</textarea>
44
44
  </div>
45
45
  </form>`);
@@ -49,7 +49,7 @@ describe('editors', () => {
49
49
  it('reads the form if no sources and exercise is multifile', () => {
50
50
  $('body').html(`
51
51
  <form role="form" class="new_solution">
52
- <div class="field form-group editor-code">
52
+ <div class="editor-code">
53
53
  <textarea
54
54
  class="form-control editor"
55
55
  data-editor-language="html"
@@ -4,7 +4,7 @@ describe('KidsButton', () => {
4
4
  fixture.set(`
5
5
  <div class="mu-kindergarten">
6
6
  <button class="mu-kids-button">Click me<button>
7
- <div class="mu-kids-overlay" style="display: none"></div>
7
+ <div class="mu-kids-overlay d-none"></div>
8
8
  </div>
9
9
  `);
10
10
 
@@ -18,7 +18,7 @@ describe('KidsButton', () => {
18
18
  });
19
19
 
20
20
  it('overlay is hidden by default', () => {
21
- expect(mumuki.kids.$overlay.css('display')).toBe('none');
21
+ expect(mumuki.kids.$overlay.hasClass('d-none'));
22
22
  });
23
23
 
24
24
  it('call showOverlay on wait', () => {
@@ -2,11 +2,11 @@ describe('upload', () => {
2
2
  const fileSizeLimit = 20;
3
3
 
4
4
  fixture.set(`
5
- <textarea id="solution_content" type="text" name="solution[content]" class="hidden"></textarea>
6
- <input id="mu-upload-input" type="file" class="upload submission-control hidden" mu-upload-file-limit=${fileSizeLimit} accept=".txt" />
7
- <label id="mu-upload-label" for="mu-upload-input" class="btn btn-success"></label>
8
- <button class="btn btn-success btn-block btn-submit disabled"></button>
9
- <div id="mu-upload-file-limit-exceeded" class="hidden"></div>
5
+ <textarea id="solution_content" type="text" name="solution[content]" class="d-none"></textarea>
6
+ <input id="mu-upload-input" type="file" class="upload submission-control d-none" mu-upload-file-limit=${fileSizeLimit} accept=".txt" />
7
+ <label id="mu-upload-label" for="mu-upload-input" class="btn btn-complementary"></label>
8
+ <button class="btn btn-complementary w-100 btn-submit disabled"></button>
9
+ <div id="mu-upload-file-limit-exceeded" class="d-none"></div>
10
10
  `);
11
11
 
12
12
  beforeEach(() => {
@@ -38,7 +38,7 @@ describe('upload', () => {
38
38
  });
39
39
 
40
40
  it('does not exceed max file size', function () {
41
- expect($('#mu-upload-file-limit-exceeded').hasClass('hidden')).toBe(true);
41
+ expect($('#mu-upload-file-limit-exceeded').hasClass('d-none')).toBe(true);
42
42
  });
43
43
  });
44
44
 
@@ -56,7 +56,7 @@ describe('upload', () => {
56
56
  });
57
57
 
58
58
  it('does not exceed max file size', function () {
59
- expect($('#mu-upload-file-limit-exceeded').hasClass('hidden')).toBe(true);
59
+ expect($('#mu-upload-file-limit-exceeded').hasClass('d-none')).toBe(true);
60
60
  });
61
61
  });
62
62
 
@@ -74,7 +74,7 @@ describe('upload', () => {
74
74
  });
75
75
 
76
76
  it('exceeds max file size', function () {
77
- expect($('#mu-upload-file-limit-exceeded').hasClass('hidden')).toBe(false);
77
+ expect($('#mu-upload-file-limit-exceeded').hasClass('d-none')).toBe(false);
78
78
  });
79
79
  });
80
80
  });