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
@@ -1,20 +1,24 @@
1
1
  module EditorTabsHelper
2
2
  def extra_code_tab
3
- "<li role='presentation'> <a data-target='#visible-extra' aria-controls='visible-extra' role='tab' data-toggle='tab' class='editor-tab'>#{fa_icon 'code'} #{t 'activerecord.attributes.exercise.extra'}</a> </li>".html_safe
3
+ "<li role='presentation'>
4
+ <a class='editor-tab nav-link' data-bs-target='#visible-extra' aria-controls='visible-extra' role='tab' data-bs-toggle='tab'>
5
+ #{fa_icon 'code', text: (t 'activerecord.attributes.exercise.extra')}
6
+ </a>
7
+ </li>".html_safe
4
8
  end
5
9
 
6
10
  def console_tab(active: false)
7
- "<li role='presentation' class='#{'active' if active}'>
8
- <a data-target='#console' aria-controls='console' tabindex='0' role='tab' data-toggle='tab' class='editor-tab'>
9
- #{fa_icon 'terminal'}#{t :console }
11
+ "<li role='presentation'>
12
+ <a class='editor-tab nav-link #{'active' if active}' data-bs-target='#console' aria-controls='console' tabindex='0' role='tab' data-bs-toggle='tab' >
13
+ #{fa_icon 'terminal', text: (t :console)}
10
14
  </a>
11
15
  </li>".html_safe
12
16
  end
13
17
 
14
18
  def messages_tab(exercise, organization = Organization.current)
15
19
  "<li id='messages-tab' role='presentation'>
16
- <a data-target='#messages' tabindex='0' aria-controls='console' role='tab' data-toggle='tab' class='editor-tab'>
17
- #{fa_icon 'comments', type: :regular} #{t :messages }
20
+ <a class='editor-tab nav-link' data-bs-target='#messages' tabindex='0' aria-controls='console' role='tab' data-bs-toggle='tab'>
21
+ #{fa_icon 'comments', type: :regular, text: (t :messages)}
18
22
  </a>
19
23
  </li>".html_safe if organization.raise_hand_enabled? && exercise.has_messages_for?(current_user)
20
24
  end
@@ -12,9 +12,9 @@ See #{transparent_exercise_url(assignment.exercise.transparent_params)}
12
12
  EOM
13
13
  end
14
14
 
15
- def permissions_help_email_body(user)
15
+ def permissions_help_email_body(user, organization)
16
16
  <<EOM
17
- #{t :want_permissions}: #{user.try(:uid)} - #{user.try(:email)}
17
+ #{t :want_permissions} #{organization.name}: #{user.try(:uid)} - #{user.try(:email)}
18
18
  EOM
19
19
  end
20
20
  end
@@ -53,10 +53,9 @@ 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
- <button class="btn btn-success btn-block btn-submit #{options.classes}"
56
+ <button class="btn btn-complementary w-100 btn-submit #{options.classes}"
57
57
  data-waiting="#{waiting_text}">
58
- #{fa_icon 'play'}
59
- #{text} #{remaining_attempts_text(assignment)}
58
+ #{fa_icon 'play', text: ([text, remaining_attempts_text(assignment)].join('')).html_safe}
60
59
  </button>
61
60
  </div>
62
61
  }.html_safe
@@ -25,13 +25,16 @@ module LinksHelper
25
25
  def teacher_info_button(item)
26
26
  if current_user&.teacher_here? && item.teacher_info.present?
27
27
  %Q{
28
- <a
29
- class="mu-popover"
30
- data-toggle="popover"
31
- data-html="true"
32
- title="#{t :teacher_info}"
33
- data-placement="bottom"
34
- data-content="#{html_rescape item.teacher_info_html}">#{fixed_fa_icon('info-circle')}</a>
28
+ <div data-bs-toggle="tooltip" title="#{t :teacher_info}">
29
+ <a
30
+ class="mu-popover"
31
+ data-bs-toggle="popover"
32
+ data-bs-html="true"
33
+ title="#{t :teacher_info}"
34
+ data-bs-placement="bottom"
35
+ data-bs-content="#{html_rescape item.teacher_info_html}">#{fixed_fa_icon('info-circle')}
36
+ </a>
37
+ </div>
35
38
  }.html_safe
36
39
  end
37
40
  end
@@ -48,7 +51,7 @@ module LinksHelper
48
51
  mail_to Organization.current.contact_email,
49
52
  Organization.current.contact_email,
50
53
  subject: I18n.t(:permissions),
51
- body: permissions_help_email_body(current_user)
54
+ body: permissions_help_email_body(current_user, Organization.current)
52
55
  end
53
56
 
54
57
  def link_to_profile_terms
@@ -88,7 +91,7 @@ module LinksHelper
88
91
  return unless current_user&.writer?
89
92
 
90
93
  url = yield
91
- link_to fixed_fa_icon('pencil-alt'), url, target: "_blank", title: t(:edit)
94
+ link_to fixed_fa_icon('pencil-alt'), url, target: "_blank", 'data-bs-toggle': 'tooltip', title: t(:edit)
92
95
  end
93
96
 
94
97
  def url_for_bibliotheca_guide(guide)
@@ -40,7 +40,7 @@ module MenuBarHelper
40
40
  end
41
41
 
42
42
  def menu_item(icon, name, url, translation_params = {})
43
- link_to fixed_fa_icon(icon, text: t(name, translation_params)), url, role: 'menuitem', tabindex: '-1'
43
+ link_to fixed_fa_icon(icon, text: t(name, translation_params)), url, role: 'menuitem', tabindex: '-1', class: 'dropdown-item'
44
44
  end
45
45
 
46
46
  def any_menu_bar_links?
@@ -4,7 +4,7 @@ module MessagesHelper
4
4
  end
5
5
 
6
6
  def hidden_pending(assignment)
7
- assignment.pending_messages? ? '' : 'hidden'
7
+ assignment.pending_messages? ? '' : 'd-none'
8
8
  end
9
9
 
10
10
  def disabled_submit_class(assignment)
@@ -9,6 +9,7 @@ module MultipleFileEditorHelper
9
9
 
10
10
  def multifile_hidden_inputs
11
11
  hidden_field_tag('highlight-modes', highlight_modes.to_json) +
12
- hidden_field_tag('multifile-locales', multifile_locales.to_json)
12
+ hidden_field_tag('multifile-locales', multifile_locales.to_json) +
13
+ hidden_field_tag('multifile-default-content', @files.to_json)
13
14
  end
14
15
  end
@@ -1,25 +1,35 @@
1
1
  module OverlappedButtonsHelper
2
2
  def expand_icon
3
- overlapped_button_icon :fullscreen, :expand
3
+ overlapped_link :fullscreen, :expand, class: 'editor-resize'
4
4
  end
5
5
 
6
- def restart_icon(data_placement='left')
7
- overlapped_button_icon :restart, :undo, data_placement
6
+ def format_icon
7
+ overlapped_link :format, :indent, class: 'editor-format'
8
8
  end
9
9
 
10
- def format_icon
11
- overlapped_button_icon :format, :indent
10
+ def restart_icon(source='console', **options)
11
+ overlapped_link :restart, :undo, class: "#{source}-reset submission-reset", **options
12
12
  end
13
13
 
14
14
  def restart_guide_link(guide)
15
- link_to restart_icon('top'),
16
- guide_progress_path(guide),
17
- class: 'mu-content-toolbar-item mu-restart-guide',
18
- data: {confirm: t(:confirm_restart)},
19
- method: :delete
15
+ all_options = tooltip_options(:restart).merge!(
16
+ {class: 'mu-content-toolbar-item mu-restart-guide',
17
+ data: {confirm: t(:confirm_restart)}, method: :delete, 'data-bs-placement': 'top'})
18
+
19
+ link_to overlapped_button_icon(:undo), guide_progress_path(guide), all_options
20
+ end
21
+
22
+ private
23
+
24
+ def overlapped_link(key, icon, **options)
25
+ content_tag :a, overlapped_button_icon(icon), tooltip_options(key).merge!(options)
26
+ end
27
+
28
+ def overlapped_button_icon(icon)
29
+ fa_icon icon, class: 'fa-fw', role: 'button'
20
30
  end
21
31
 
22
- def overlapped_button_icon(key, icon, data_placement='left')
23
- fa_icon(icon, title: t(key), class: 'fa-fw', role: 'button', 'aria-label': t(key), 'data-placement': data_placement)
32
+ def tooltip_options(key)
33
+ {title: t(key), 'aria-label': t(key), 'data-bs-toggle': 'tooltip', 'data-bs-placement': 'left'}
24
34
  end
25
35
  end
@@ -1,13 +1,13 @@
1
1
  module ProfileHelper
2
2
  def edit_profile_button
3
- link_to t(:edit_profile), :edit_user, class: 'btn btn-success'
3
+ link_to t(:edit_profile), :edit_user, class: 'btn btn-complementary'
4
4
  end
5
5
 
6
6
  def cancel_edit_profile_button
7
- link_to t(:cancel), :user, class: 'btn btn-default' if current_user.profile_completed?
7
+ link_to t(:cancel), :user, class: 'btn btn-secondary' if current_user.profile_completed?
8
8
  end
9
9
 
10
10
  def save_edit_profile_button(form)
11
- form.submit t(:save), disabled: true, class: 'btn btn-success mu-edit-profile-btn'
11
+ form.submit t(:save), disabled: true, class: 'btn btn-complementary mu-edit-profile-btn'
12
12
  end
13
13
  end
@@ -0,0 +1,27 @@
1
+ module ToastHelper
2
+ def toast_notice(text)
3
+ toast_for('success', 'check-circle', text)
4
+ end
5
+
6
+ def toast_alert(text)
7
+ toast_for('error', 'times-circle', text)
8
+ end
9
+
10
+ def toast_info(text)
11
+ toast_for('info', 'info-circle', text)
12
+ end
13
+
14
+ private
15
+
16
+ def toast_for(type, icon, text)
17
+ "<div class='toast mu-toast-#{type}' role='alert'>
18
+ <div class='toast-body'>
19
+ <div class='d-flex align-items-center'>
20
+ #{fa_icon icon, class: 'fa-lg me-3'}
21
+ <span class='flex-grow-1 text-break'>#{text}</span>
22
+ <button type='button' class='btn-close btn-close-white mx-2 flex-shrink-0' data-bs-dismiss='toast' aria-label='Close'></button>
23
+ </div>
24
+ </div>
25
+ </div>".html_safe
26
+ end
27
+ end
@@ -0,0 +1,48 @@
1
+ module UserActivityHelper
2
+ def activity_selector_week_range_for(organization = Organization.current)
3
+ start = organization.activity_start_date min_week
4
+ (start.prev_occurring(:monday) + 1..Date.today)
5
+ .step(7)
6
+ .to_a
7
+ .reverse
8
+ .map { |it| [it, it + 7.days] }
9
+ end
10
+
11
+ def mark_period_if_active(period_start)
12
+ active_period?(period_start) ? 'nav-link active' : 'nav-link'
13
+ end
14
+
15
+ def solved_exercises_percentage
16
+ percentage = @activity[:exercises][:solved_count].to_f / @activity[:exercises][:count] * 100
17
+ "#{percentage.ceil}%"
18
+ end
19
+
20
+ def exercises_activity_stats
21
+ solved_count = {
22
+ name: t(:solved_exercises_count, count: @activity[:exercises][:solved_count]),
23
+ value: @activity[:exercises][:solved_count] }
24
+ solved_percentage = {
25
+ name: t(:solved_exercises_percentage),
26
+ value: solved_exercises_percentage }
27
+
28
+ @date_from ? [solved_count] : [solved_count, solved_percentage]
29
+ end
30
+
31
+ def messages_activity_stats
32
+ count = @activity[:messages][:count]
33
+ approved = @activity[:messages][:approved]
34
+
35
+ [{name: t(:messages_pluralized, count: count), value: count},
36
+ {name: t(:approved_messages, count: approved), value: approved}]
37
+ end
38
+
39
+ private
40
+
41
+ def active_period?(period_start)
42
+ period_start ? @date_from == period_start : !@date_from
43
+ end
44
+
45
+ def min_week
46
+ 8.week.ago.to_date
47
+ end
48
+ end
@@ -1,22 +1,40 @@
1
1
  module UserMenuHelper
2
+ def user_menu_header
3
+ content_tag :div, user_menu_header_icon, class: 'mu-user-menu-header'
4
+ end
5
+
6
+ def user_menu_divider
7
+ content_tag :div, '', class: 'mu-user-menu-divider horizontal'
8
+ end
9
+
2
10
  def profile_user_menu_link
3
- user_menu_link t(:my_profile), user_path, 'show'
11
+ user_menu_item t(:my_profile), user_path, 'show'
4
12
  end
5
13
 
6
14
  def messages_user_menu_link
7
- user_menu_link t(:messages), messages_user_path, 'messages'
15
+ user_menu_item t(:messages), messages_user_path, 'messages'
8
16
  end
9
17
 
10
18
  def discussions_user_menu_link
11
- user_menu_link t(:discussions), discussions_user_path, 'discussions'
19
+ user_menu_item t(:discussions), discussions_user_path, 'discussions' if current_user&.can_discuss_here?
20
+ end
21
+
22
+ def activity_user_menu_link
23
+ user_menu_item t(:activity), activity_user_path, 'activity'
12
24
  end
13
25
 
14
26
  def certificates_user_menu_link
15
- user_menu_link t(:certificates), certificates_user_path, 'certificates'
27
+ user_menu_item t(:certificates), certificates_user_path, 'certificates'
16
28
  end
17
29
 
18
- def user_menu_link(label, path, active_on)
30
+ private
31
+
32
+ def user_menu_item(label, path, active_on)
19
33
  link_klass = 'active' if action_name == active_on
20
- link_to label, path, { class: link_klass }.compact
34
+ content_tag :div, link_to(label, path, { class: link_klass }.compact), class: 'mu-user-menu-item'
35
+ end
36
+
37
+ def user_menu_header_icon
38
+ fa_icon('chevron-down', text: t(:my_account), id: 'mu-user-menu-header-icon', right: true)
21
39
  end
22
40
  end
@@ -2,12 +2,12 @@
2
2
  <%= header_breadcrumbs(link_for_organization: false) %>
3
3
  <% end %>
4
4
 
5
- <div class="col-md-offset-2 col-md-8">
5
+ <div class="col-lg-8 offset-lg-2">
6
6
  <%= render partial: 'book/header' %>
7
7
 
8
8
  <% @book.next_lesson_for(current_user).try do |lesson| %>
9
9
  <div class="actions">
10
- <a href="<%= lesson_path(lesson) %>" class="btn btn-success">
10
+ <a href="<%= lesson_path(lesson) %>" class="btn btn-complementary">
11
11
  <%= t book_practice_key_for(current_user) %>
12
12
  </a>
13
13
  </div>
@@ -22,7 +22,7 @@
22
22
  <a href="<%= linkedin_post_url @certificate %>" target="_blank">
23
23
  <img src="https://download.linkedin.com/desktop/add2profile/buttons/<%= t :linkedin_profile_button_locale %>.png" alt="LinkedIn Add to Profile button">
24
24
  </a>
25
- <a class="btn btn-success mu-certificate-download-btn pull-right" href="<%= download_certificate_path @certificate.code %>" target="_blank">
25
+ <a class="btn btn-complementary mu-certificate-download-btn pull-right" href="<%= download_certificate_path @certificate.code %>" target="_blank">
26
26
  <i class="fas fa-fw fa-lg fa-download mu-certificate-download-btn-icon"></i>
27
27
  <span class="mu-certificate-download-btn-text"><%= t :certificate %></span>
28
28
  </a>
@@ -4,8 +4,8 @@
4
4
 
5
5
  <div class="row">
6
6
  <div class="mu-inline-block-left">
7
- <h1 class="hidden-xs"><%= full_title_for @chapter %></h1>
8
- <h1 class="visible-xs"><%= short_title_for @chapter %></h1>
7
+ <h1 class="d-none d-sm-block"><%= full_title_for @chapter %></h1>
8
+ <h1 class="d-block d-sm-none"><%= short_title_for @chapter %></h1>
9
9
 
10
10
  <% if @chapter.monolesson? %>
11
11
  <%= render partial: 'guides/guide_title_icons' %>
@@ -2,7 +2,7 @@
2
2
  <div class="discussion-message-bubble">
3
3
  <div class="discussion-message-bubble-header">
4
4
  <div class="discussion-message-bubble-title">
5
- <%= discussion.initiator.name %>
5
+ <%= discussion_user_name(discussion.initiator) %>
6
6
  <span class="message-date">
7
7
  <%= t(:time_since, time: time_ago_in_words(discussion.created_at)) %>
8
8
  </span>
@@ -2,7 +2,7 @@
2
2
  <div class="discussion-message-bubble">
3
3
  <div class="discussion-message-bubble-header">
4
4
  <div class="discussion-message-bubble-title">
5
- <%= user.name %>
5
+ <%= discussion_user_name user %>
6
6
  <% if user.moderator_here? %>
7
7
  <span class="moderator-badge"><%= t(:moderation) %></span>
8
8
  <% end %>
@@ -10,22 +10,28 @@
10
10
  <%= t(:time_since, time: time_ago_in_words(message.created_at)) %>
11
11
  </span>
12
12
  <span class="actions">
13
- <% if message.authorized? current_user %>
13
+ <% if message.authorized?(current_user) && !message.deleted? %>
14
14
  <% if current_user&.moderator_here? %>
15
- <a class="discussion-message-approved <%= 'selected' if message.approved? %>" onclick="mumuki.Forum.discussionMessageToggleApprove('<%= approve_discussion_message_url(@discussion, message) %>', $(this))">
15
+ <a class="discussion-message-approved <%= 'selected' if message.approved? %>"
16
+ onclick="mumuki.Forum.discussionMessageToggleApprove('<%= approve_discussion_message_url(@discussion, message) %>', $(this))">
16
17
  <%= fa_icon(:check, class: 'fa-lg') %>
17
18
  </a>
18
19
  <% if message.from_initiator? %>
19
- <a class="discussion-message-not-actually-a-question <%= 'selected' if message.not_actually_a_question? %>" onclick="mumuki.Forum.discussionMessageToggleNotActuallyAQuestion('<%= question_discussion_message_url(@discussion, message) %>', $(this))">
20
+ <a class="discussion-message-not-actually-a-question <%= 'selected' if message.not_actually_a_question? %>"
21
+ onclick="mumuki.Forum.discussionMessageToggleNotActuallyAQuestion('<%= question_discussion_message_url(@discussion, message) %>', $(this))">
20
22
  <%= fa_icon('question-circle', type: 'regular', class: 'fa-lg') %>
21
23
  </a>
22
24
  <% end %>
23
25
  <% end %>
24
- <%= link_to fa_icon('trash-alt', type: :regular, class: 'fa-lg'), discussion_message_path(@discussion, message), method: :delete, data: { confirm: t(:are_you_sure, action: t(:destroy_message)) }, class: 'discussion-delete-message' %>
26
+ <% if message.from_user? current_user %>
27
+ <%= discussion_delete_message_link @discussion, message %>
28
+ <% else %>
29
+ <%= discussion_delete_message_dropdown @discussion, message %>
30
+ <% end %>
25
31
  <% end %>
26
32
  <% if should_show_approved_for?(current_user, message) %>
27
33
  <span class="discussion-message-approved selected">
28
- <%= fa_icon(:check, class: 'fa-lg', 'data-toggle': 'tooltip', title: (t :approved_message)) %>
34
+ <%= fa_icon(:check, class: 'fa-lg', 'data-bs-toggle': 'tooltip', title: (t :approved_message)) %>
29
35
  </span>
30
36
  <% end %>
31
37
  </span>
@@ -33,7 +39,26 @@
33
39
  </div>
34
40
  <div class="discussion-message-bubble-content">
35
41
  <div class="discussion-message-content">
36
- <%= message.content_html %>
42
+ <% if message.deleted? %>
43
+ <em><%= message_deleted_text message %></em>
44
+ <% if message.from_user? current_user %>
45
+ <p><%= t :deleted_message_warning %></p>
46
+ <% end %>
47
+ <% if current_user&.moderator_here? %>
48
+ <hr>
49
+ <%= t :deleted_by, deleter: message.deleted_by.name %>
50
+ <%= t(:time_since, time: time_ago_in_words(message.deleted_at)) %>.
51
+ <a href='<%= "#deletedMessage#{message.id}" %>' data-bs-toggle="collapse">
52
+ <%= t :show_message %>
53
+ </a>
54
+ <div id='<%= "deletedMessage#{message.id}" %>' class="collapse">
55
+ <hr>
56
+ <%= message.content_html %>
57
+ </div>
58
+ <% end %>
59
+ <% else %>
60
+ <%= message.content_html %>
61
+ <% end %>
37
62
  </div>
38
63
  </div>
39
64
  </div>
@@ -10,12 +10,23 @@
10
10
  <div class="container-fluid">
11
11
  <div class="row">
12
12
  <div class="discussion-new-message-content">
13
- <%= f.editor :content, '', { id: 'new-discussion-message', class: 'form-control', placeholder: t(:message) } %>
13
+ <%= f.editor :content, '', { id: 'discussion-new-message', class: 'form-control', placeholder: t(:message) } %>
14
14
  </div>
15
+ <div class="discussion-message-content d-none" id="discussion-new-message-preview"></div>
15
16
  </div>
16
17
  </div>
17
18
  </div>
18
19
  </div>
19
- <button class="btn btn-success btn-block discussion-new-message-button"> <%= t :comment %> </button>
20
+ <div class="discussion-new-message-buttons">
21
+ <% if user.moderator_here? %>
22
+ <button class="btn btn-secondary discussion-new-message-preview-button preview" type="button" error-text="<%= t :preview_error %>"
23
+ onclick="mumuki.Forum.discussionMessagePreview('<%= preview_discussion_message_url %>')"> <%= fa_icon('eye', text: t(:preview)) %> </button>
24
+ <button class="btn btn-secondary discussion-new-message-preview-button edit d-none" type="button"
25
+ onclick="mumuki.Forum.hidePreviewAndShowEditor()"> <%= fa_icon('pencil-alt', text: t(:edit_message)) %> </button>
26
+ <% end %>
27
+ <%= button_tag type: 'submit', class: 'btn btn-complementary discussion-new-message-button', data: { disable: true } do %>
28
+ <%= fa_icon('comment', text: t(:comment)) %>
29
+ <% end %>
30
+ </div>
20
31
  <% end %>
21
32
  <% end %>