mumuki-laboratory 8.2.1 → 8.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -8
  3. data/app/assets/javascripts/mumuki_laboratory/application/bridge.js +2 -1
  4. data/app/assets/javascripts/mumuki_laboratory/application/button.js +0 -2
  5. data/app/assets/javascripts/mumuki_laboratory/application/codemirror.js +1 -1
  6. data/app/assets/javascripts/mumuki_laboratory/application/i18n.js +73 -0
  7. data/app/assets/javascripts/mumuki_laboratory/application/kids.js +22 -1
  8. data/app/assets/javascripts/mumuki_laboratory/application/kindergarten.js +6 -1
  9. data/app/assets/javascripts/mumuki_laboratory/application/primary.js +5 -3
  10. data/app/assets/javascripts/mumuki_laboratory/application/results-renderer.js +28 -1
  11. data/app/assets/javascripts/mumuki_laboratory/application/submission.js +72 -48
  12. data/app/assets/javascripts/mumuki_laboratory/application/upload.js +69 -14
  13. data/app/assets/stylesheets/mumuki_laboratory/application.scss +1 -0
  14. data/app/assets/stylesheets/mumuki_laboratory/application/_codemirror-themes.scss +1 -0
  15. data/app/assets/stylesheets/mumuki_laboratory/application/codemirror-themes/_mu-light.scss +3 -0
  16. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_content_show.scss +1 -1
  17. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_discussion.scss +31 -8
  18. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids.scss +4 -0
  19. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids_results.scss +1 -0
  20. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_terms.scss +4 -0
  21. data/app/controllers/application_controller.rb +1 -1
  22. data/app/controllers/chapters_controller.rb +9 -5
  23. data/app/controllers/exam_authorization_requests_controller.rb +26 -0
  24. data/app/controllers/exam_registrations_controller.rb +6 -0
  25. data/app/controllers/guide_container_controller.rb +2 -7
  26. data/app/helpers/application_helper.rb +4 -0
  27. data/app/helpers/contextualization_result_helper.rb +0 -8
  28. data/app/helpers/discussions_helper.rb +8 -0
  29. data/app/helpers/exercise_input_helper.rb +8 -17
  30. data/app/helpers/icons_helper.rb +3 -11
  31. data/app/helpers/menu_bar_helper.rb +6 -2
  32. data/app/helpers/overlapped_buttons_helper.rb +10 -6
  33. data/app/helpers/progress_bar_helper.rb +2 -2
  34. data/app/views/book_discussions/index.html.erb +3 -1
  35. data/app/views/chapters/show.html.erb +21 -9
  36. data/app/views/complements/show.html.erb +1 -1
  37. data/app/views/discussions/_message.html.erb +7 -7
  38. data/app/views/discussions/index.html.erb +11 -4
  39. data/app/views/exam_authorization_requests/show.html.erb +17 -0
  40. data/app/views/exam_registrations/show.html.erb +37 -0
  41. data/app/views/exams/show.html.erb +1 -1
  42. data/app/views/exercises/show.html.erb +2 -2
  43. data/app/views/layouts/_discussions.html.erb +0 -4
  44. data/app/views/layouts/_guide.html.erb +4 -33
  45. data/app/views/layouts/_guide_container.html.erb +28 -0
  46. data/app/views/layouts/_guide_title_icons.html.erb +9 -0
  47. data/app/views/layouts/_progress_bar.html.erb +9 -7
  48. data/app/views/layouts/_progress_listing.html.erb +5 -5
  49. data/app/views/layouts/_social_media.html.erb +2 -2
  50. data/app/views/layouts/application.html.erb +4 -7
  51. data/app/views/layouts/exercise_inputs/editors/_upload.html.erb +11 -2
  52. data/app/views/layouts/exercise_inputs/layouts/_input_kindergarten.html.erb +1 -1
  53. data/app/views/layouts/modals/_kindergarten_results_aborted.html.erb +1 -1
  54. data/app/views/lessons/show.html.erb +1 -1
  55. data/app/views/notifications/_discussion.html.erb +1 -0
  56. data/app/views/notifications/_dropdown.html.erb +13 -0
  57. data/app/views/notifications/_exam_authorization_request.html.erb +1 -0
  58. data/app/views/notifications/_exam_registration.html.erb +1 -0
  59. data/app/views/notifications/_message.html.erb +1 -0
  60. data/app/views/users/_term.html.erb +1 -1
  61. data/app/views/users/terms.html.erb +1 -1
  62. data/config/routes.rb +3 -0
  63. data/lib/mumuki/laboratory/controllers/notifications.rb +3 -22
  64. data/lib/mumuki/laboratory/controllers/results_rendering.rb +2 -1
  65. data/lib/mumuki/laboratory/locales/en.yml +34 -24
  66. data/lib/mumuki/laboratory/locales/es-CL.yml +25 -10
  67. data/lib/mumuki/laboratory/locales/es.yml +32 -23
  68. data/lib/mumuki/laboratory/locales/pt.yml +27 -17
  69. data/lib/mumuki/laboratory/version.rb +1 -1
  70. data/spec/controllers/exam_authorization_requests_controller_spec.rb +40 -0
  71. data/spec/controllers/exam_registrations_controller_spec.rb +19 -0
  72. data/spec/controllers/exercise_solutions_controller_spec.rb +3 -2
  73. data/spec/dummy/db/schema.rb +50 -1
  74. data/spec/dummy/public/character/animations.json +1 -0
  75. data/{public → spec/dummy/public}/character/kibi/context.svg +0 -0
  76. data/{public → spec/dummy/public}/character/kibi/failure.svg +0 -0
  77. data/{public → spec/dummy/public}/character/kibi/jump.svg +0 -0
  78. data/spec/dummy/public/character/kibi/passed_with_warnings.svg +4 -0
  79. data/{public → spec/dummy/public}/character/kibi/success2_l.svg +0 -0
  80. data/{public → spec/dummy/public}/character/kibi/success_l.svg +0 -0
  81. data/{public → spec/dummy/public}/character/magnifying_glass/apparition.svg +0 -0
  82. data/{public → spec/dummy/public}/character/magnifying_glass/loop.svg +0 -0
  83. data/spec/features/chapters_flow_spec.rb +112 -0
  84. data/spec/features/login_flow_spec.rb +1 -1
  85. data/spec/features/notifications_flow_spec.rb +46 -0
  86. data/spec/features/profile_flow_spec.rb +1 -2
  87. data/spec/features/terms_flow_spec.rb +30 -0
  88. data/spec/features/topic_flow_spec.rb +0 -1
  89. data/spec/javascripts/bridge-spec.js +2 -2
  90. data/spec/javascripts/csrf-token-spec.js +2 -2
  91. data/spec/javascripts/editors-spec.js +7 -9
  92. data/spec/javascripts/elipsis-spec.js +4 -4
  93. data/spec/javascripts/events-spec.js +7 -7
  94. data/spec/javascripts/exercise-spec.js +7 -8
  95. data/spec/javascripts/global-spec.js +3 -3
  96. data/spec/javascripts/i18n-spec.js +82 -0
  97. data/spec/javascripts/kids-button-spec.js +34 -0
  98. data/spec/javascripts/results-renderers-spec.js +5 -5
  99. data/spec/javascripts/speech-bubble-renderer-spec.js +2 -3
  100. data/spec/javascripts/submissions-store-spec.js +14 -14
  101. data/spec/javascripts/sync-mode-spec.js +3 -3
  102. data/spec/javascripts/timeout-spec.js +2 -2
  103. data/spec/javascripts/timer-spec.js +2 -2
  104. data/spec/javascripts/upload-spec.js +80 -0
  105. metadata +131 -96
  106. data/spec/features/chapter_spec.rb +0 -70
@@ -1,17 +1,72 @@
1
+ mumuki.upload = (() => {
2
+ class FileUploader {
3
+ constructor(file) {
4
+ this.file = file;
5
+ }
6
+
7
+ uploadFileIfValid() {
8
+ if (!this.file) return;
9
+
10
+ let maxFileSize = $('#mu-upload-input').attr("mu-upload-file-limit");
11
+ if (this.file.size > maxFileSize) {
12
+ return mumuki.upload.ui.showFileExceedsMaxSize();
13
+ }
14
+
15
+ mumuki.upload.ui.allowSubmissionFor(this.file.name);
16
+
17
+ const reader = new FileReader();
18
+ reader.onload = function (e) {
19
+ const contents = e.target.result;
20
+ $('#solution_content').html(contents);
21
+ };
22
+ reader.readAsText(this.file);
23
+
24
+ return reader;
25
+ }
26
+ }
27
+
28
+ class UI {
29
+ constructor() {
30
+ this.$uploadFileLimitExceeded = $('#mu-upload-file-limit-exceeded');
31
+ this.$uploadLabel = $('#mu-upload-label span');
32
+ this.$uploadLabelText = this.$uploadLabel.text();
33
+ this.$uploadIcon = $('#mu-upload-icon');
34
+ this.$btnSubmit = $('.btn-submit');
35
+ }
36
+
37
+ showFileExceedsMaxSize() {
38
+ this.$uploadFileLimitExceeded.removeClass('hidden');
39
+ this.$uploadLabel.text(this.$uploadLabelText);
40
+ this.$uploadIcon.addClass('fa-upload').removeClass('fa-file-alt');
41
+ this.$btnSubmit.addClass('disabled');
42
+ }
43
+
44
+ allowSubmissionFor(filename) {
45
+ this.$uploadFileLimitExceeded.addClass('hidden');
46
+ this.$uploadLabel.text(filename);
47
+ this.$uploadIcon.removeClass('fa-upload').addClass('fa-file-alt');
48
+ this.$btnSubmit.removeClass('disabled');
49
+ }
50
+ }
51
+
52
+ function _setUI() {
53
+ mumuki.upload.ui = new UI();
54
+ }
55
+
56
+ return {
57
+ FileUploader,
58
+ UI,
59
+
60
+ _setUI,
61
+
62
+ /** @type {UI} */
63
+ ui: null
64
+ };
65
+ })();
66
+
1
67
  mumuki.load(() => {
2
- $('#upload-input').change(function (evt) {
3
- var file = evt.target.files[0];
4
- if (!file) return;
5
-
6
- var reader = new FileReader();
7
- reader.onload = function (e) {
8
- var contents = e.target.result;
9
- $('#solution_content').html(contents);
10
- $(evt.target).val("");
11
- $('form.new_solution').submit();
12
- };
13
- reader.readAsText(file);
14
- return false;
68
+ $('#mu-upload-input').change(function (evt) {
69
+ if (!mumuki.upload.ui) mumuki.upload._setUI();
70
+ return new mumuki.upload.FileUploader(evt.target.files[0]).uploadFileIfValid();
15
71
  });
16
72
  });
17
-
@@ -15,3 +15,4 @@ $da-font-path: asset-path('assets');
15
15
  @import "application/modules";
16
16
  @import "application/errors";
17
17
  @import "application/alerts";
18
+ @import "application/codemirror-themes";
@@ -0,0 +1 @@
1
+ @import "codemirror-themes/mu-light";
@@ -0,0 +1,3 @@
1
+ .cm-s-mu-light .CodeMirror-code {
2
+ padding-right: 25px;
3
+ }
@@ -1,3 +1,3 @@
1
- .chapter-description p {
1
+ .chapter-description {
2
2
  display: inline-block;
3
3
  }
@@ -5,7 +5,7 @@ $discussion-toolbar-color: #f6f6fa;
5
5
  $message-divider-color: #ecf0f1;
6
6
  $discussion-button-color: #fafafa;
7
7
  $toolbar-filter-color: #808080;
8
- $moderator-star-color: #dd9900;
8
+ $moderator-badge-color: #dd9900;
9
9
 
10
10
  .discussions-list {
11
11
  margin: 30px 0;
@@ -177,8 +177,17 @@ $moderator-star-color: #dd9900;
177
177
  width: 100%;
178
178
  }
179
179
 
180
- .moderator-star {
181
- color: $moderator-star-color;
180
+ .moderator-badge {
181
+ position: relative;
182
+ top: -2px;
183
+ margin: 2px;
184
+ font-size: 12px;
185
+ text-transform: uppercase;
186
+ color: white;
187
+ background-color: $moderator-badge-color;
188
+ border: solid $moderator-badge-color 1px;
189
+ border-radius: 5px;
190
+ padding-inline: 5px;
182
191
  }
183
192
 
184
193
  .discussion-user-menu {
@@ -326,12 +335,15 @@ summary.discussion-summary {
326
335
  .actions {
327
336
  float: right;
328
337
  a {
329
- margin-left: 5px;
338
+ margin-left: 20px;
330
339
  cursor: pointer;
331
340
  }
332
341
  .discussion-message-approved {
333
342
  text-decoration: none;
334
- &.selected {
343
+ i {
344
+ transition: color 0.3s;
345
+ }
346
+ &:hover, &.selected {
335
347
  i {
336
348
  color: $brand-success;
337
349
  }
@@ -341,17 +353,20 @@ summary.discussion-summary {
341
353
  text-decoration: none;
342
354
  i {
343
355
  position: relative;
356
+ transition: color 0.3s;
344
357
  &:after {
345
358
  position: absolute;
346
- left: 6px;
359
+ left: 10px;
360
+ top: -6px;
347
361
  content: ' ';
348
- height: 19px;
362
+ height: 30px;
349
363
  width: 2px;
350
364
  transform: rotate(-45deg);
351
365
  background-color: #aaaaaa;
366
+ transition: background-color 0.3s;
352
367
  }
353
368
  }
354
- &.selected {
369
+ &:hover, &.selected {
355
370
  i {
356
371
  color: $brand-primary;
357
372
  &:after {
@@ -360,6 +375,14 @@ summary.discussion-summary {
360
375
  }
361
376
  }
362
377
  }
378
+ .discussion-delete-message {
379
+ i {
380
+ transition: color 0.3s;
381
+ &:hover {
382
+ color: black;
383
+ }
384
+ }
385
+ }
363
386
  i {
364
387
  color: #aaaaaa
365
388
  }
@@ -10,6 +10,10 @@ $kids-speech-border: 1px solid $kids-speech-border-color;
10
10
 
11
11
  $kids-speech-tabs-width: 40px;
12
12
 
13
+ .mu-kids-exercise-workspace.mu-submitless-exercise .mu-kids-submit-button {
14
+ display: none;
15
+ }
16
+
13
17
  .mu-kids-exercise {
14
18
  height: $kids-height;
15
19
  min-height: $kids-height;
@@ -131,6 +131,7 @@ $capital-animation-width: 135px;
131
131
  'success': $mu-color-success,
132
132
  'warning': $mu-color-warning,
133
133
  'passed': $mu-color-success,
134
+ 'passed_with_warnings': $mu-color-warning,
134
135
  'passed-with-warnings': $mu-color-warning,
135
136
  'failed': $mu-color-danger,
136
137
  'errored': $mu-color-broken,
@@ -15,11 +15,15 @@
15
15
  }
16
16
  .terms-card-header {
17
17
  cursor: pointer;
18
+ outline: 0;
18
19
  font-weight: bold;
19
20
  padding: .75rem 1.25rem;
20
21
  margin-bottom: 0;
21
22
  background-color: rgba(0,0,0,.03);
22
23
  border-bottom: 1px solid rgba(0,0,0,.125);
24
+ &::-webkit-details-marker {
25
+ display:none;
26
+ }
23
27
  }
24
28
  &:first-child .terms-card-header{
25
29
  border-radius: calc(.25rem - 1px) calc(.25rem - 1px) 0 0;
@@ -34,8 +34,8 @@ class ApplicationController < ActionController::Base
34
34
  helper_method :current_workspace,
35
35
  :login_button,
36
36
  :notifications_count,
37
- :user_notifications_path,
38
37
  :has_notifications?,
38
+ :notifications,
39
39
  :subject,
40
40
  :should_choose_organization?,
41
41
  :current_immersive_organizations,
@@ -1,13 +1,17 @@
1
1
  require 'addressable/uri'
2
2
 
3
- class ChaptersController < ApplicationController
4
- include Mumuki::Laboratory::Controllers::Content
3
+ # It acts as a guide container in monolesson contexts
4
+ class ChaptersController < GuideContainerController
5
5
  include Mumuki::Laboratory::Controllers::ImmersiveNavigation
6
6
 
7
- def show
8
- end
9
-
10
7
  def subject
11
8
  @chapter ||= Chapter.find_by(id: params[:id])
12
9
  end
10
+
11
+ private
12
+
13
+ def set_guide
14
+ @monolesson = subject.monolesson
15
+ @guide = @monolesson&.guide
16
+ end
13
17
  end
@@ -0,0 +1,26 @@
1
+ class ExamAuthorizationRequestsController < ApplicationController
2
+ def show
3
+ @authorization_request = ExamAuthorizationRequest.find(params[:id])
4
+ current_user.read_notification! @authorization_request
5
+ end
6
+
7
+ def create
8
+ authorization_request = ExamAuthorizationRequest.create! authorization_request_params
9
+ current_user.read_notification! authorization_request.exam_registration
10
+ flash.notice = I18n.t :exam_authorization_request_created
11
+ end
12
+
13
+ def update
14
+ ExamAuthorizationRequest.update params[:id], authorization_request_params
15
+ flash.notice = I18n.t :exam_authorization_request_saved
16
+ redirect_to root_path
17
+ end
18
+
19
+ private
20
+
21
+ def authorization_request_params
22
+ params
23
+ .require(:exam_authorization_request).permit(:exam_id, :exam_registration_id)
24
+ .merge(user: current_user, organization: Organization.current)
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ class ExamRegistrationsController < ApplicationController
2
+ def show
3
+ @registration = ExamRegistration.find(params[:id])
4
+ @authorization_request = @registration.authorization_request_for(current_user)
5
+ end
6
+ end
@@ -4,18 +4,13 @@ class GuideContainerController < ApplicationController
4
4
  before_action :set_guide
5
5
 
6
6
  def show
7
- if current_user?
8
- @stats = subject.stats_for(current_user)
9
- @next_exercise = subject.next_exercise(current_user)
10
- else
11
- @next_exercise = subject.first_exercise
12
- end
7
+ @stats = subject.stats_for(current_user)
8
+ @next_exercise = subject.next_exercise(current_user)
13
9
  end
14
10
 
15
11
  private
16
12
 
17
13
  def set_guide
18
- raise Mumuki::Domain::NotFoundError if subject.nil?
19
14
  @guide = subject.guide
20
15
  end
21
16
  end
@@ -44,4 +44,8 @@ module ApplicationHelper
44
44
  <span class="#{'hidden' unless active} #{options[:class]}">#{active_text}</span>
45
45
  }.html_safe
46
46
  end
47
+
48
+ def notification_preview_for(target)
49
+ render "notifications/#{target.class.name.underscore}", { target: target }
50
+ end
47
51
  end
@@ -16,14 +16,6 @@ module ContextualizationResultHelper
16
16
  :hidden_done
17
17
  elsif contextualization.exercise.choice?
18
18
  contextualization.solved? ? :correct_answer : :wrong_answer
19
- else
20
- contextualization_status_translation_key contextualization
21
- end
22
- end
23
-
24
- def contextualization_status_translation_key(contextualization)
25
- if contextualization.exercise.input_kindergarten?
26
- "kindergarten_#{contextualization.submission_status}"
27
19
  else
28
20
  contextualization.submission_status
29
21
  end
@@ -52,6 +52,14 @@ module DiscussionsHelper
52
52
  profile_picture_for(user, class: image_class)
53
53
  end
54
54
 
55
+ def forum_terms_link
56
+ %Q{
57
+ <span>
58
+ #{ t(:forum_terms_link, terms_link: link_to_forum_terms).html_safe }
59
+ </span>
60
+ }.html_safe
61
+ end
62
+
55
63
  def discussions_link_with_teaser(item)
56
64
  %Q{
57
65
  <div>
@@ -53,12 +53,11 @@ module ExerciseInputHelper
53
53
  waiting_text = t(options.waiting_t) if options.waiting_t.present?
54
54
  %Q{
55
55
  <div class="btn-submit-container">
56
- <#{options.tag} for="#{options.for}"
57
- class="btn btn-success btn-block btn-submit #{options.classes}"
56
+ <button class="btn btn-success btn-block btn-submit #{options.classes}"
58
57
  data-waiting="#{waiting_text}">
59
- #{fa_icon options.fa_icon}
58
+ #{fa_icon 'play'}
60
59
  #{text} #{remaining_attempts_text(assignment)}
61
- </#{options.tag}>
60
+ </button>
62
61
  </div>
63
62
  }.html_safe
64
63
  end
@@ -92,26 +91,18 @@ module ExerciseInputHelper
92
91
 
93
92
  def submit_button_options(exercise)
94
93
  if exercise.upload?
95
- struct for: 'upload-input',
96
- tag: :label,
94
+ struct classes: 'disabled',
97
95
  waiting_t: :uploading_solution,
98
- fa_icon: :upload,
99
- t: :upload_solution
96
+ t: :create_submission
100
97
  elsif exercise.hidden?
101
- struct tag: :button,
102
- classes: 'submission_control',
98
+ struct classes: 'submission_control',
103
99
  waiting_t: :working,
104
- fa_icon: :play,
105
100
  t: :continue_exercise
106
101
  elsif exercise.input_kids?
107
- struct tag: :button,
108
- classes: 'submission_control',
109
- fa_icon: :play
102
+ struct classes: 'submission_control'
110
103
  else
111
- struct tag: :button,
112
- classes: 'submission_control',
104
+ struct classes: 'submission_control',
113
105
  waiting_t: :sending_solution,
114
- fa_icon: :play,
115
106
  t: :create_submission
116
107
  end
117
108
  end
@@ -7,9 +7,9 @@ module IconsHelper
7
7
  fa_icon name, options.merge(class: 'fa-fw fixed-icon')
8
8
  end
9
9
 
10
- def exercise_status_icon(exercise)
11
- link_to exercise_status_fa_icon(exercise),
12
- exercise_path(exercise) if current_user?
10
+ def assignment_status_icon(assignment)
11
+ link_to contextualization_fa_icon(assignment),
12
+ exercise_path(assignment.exercise) if current_user?
13
13
  end
14
14
 
15
15
  def language_icon(language)
@@ -22,10 +22,6 @@ module IconsHelper
22
22
  fa_icon(*icon_for(contextualization))
23
23
  end
24
24
 
25
- def exercise_status_fa_icon(exercise)
26
- contextualization_fa_icon(exercise.assignment_for(current_user))
27
- end
28
-
29
25
  def discussion_status_fa_icon(discussion)
30
26
  contextualization_fa_icon(discussion)
31
27
  end
@@ -35,10 +31,6 @@ module IconsHelper
35
31
  [iconized[:type], class: "text-#{iconized[:class]} status-icon"]
36
32
  end
37
33
 
38
- def class_for_exercise(exercise)
39
- icon_class_for(exercise.assignment_for(current_user))
40
- end
41
-
42
34
  def icon_class_for(iconizable)
43
35
  iconizable.iconize[:class].to_s
44
36
  end