mumuki-domain 7.7.2 → 7.8.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: f58b3302ee7ffdf0a503a9a4dc816e00a9f11c62d2b6792512834c9289e190a9
4
- data.tar.gz: fd9b0bdcecb5dd0cc3a56234af7718e6b6a4440b3117f620786f5fd5aa981295
3
+ metadata.gz: 14a6d0b035451e69ddc77479e3f32854ecae51ca0a3c6bc3031f8d68a4b7fcdd
4
+ data.tar.gz: a1dbea618e7a152e55417174cecf35a0338a464cd199b02114d524c65c7c23c5
5
5
  SHA512:
6
- metadata.gz: 85ec2a5cc695671fdc09471348b62bf88456ea5ad95c40225c1e66dfd45851dcfaff45d0b5e834e119834ab09dfb83e6579955c68d0fbc6e2fdf7c2b87b7687b
7
- data.tar.gz: e011c6f5cef571718d98980a58b51ecad15d8efcdecd253892889eb64ae7ca1b3521e30068454e67ff519204f77110d96b90d6cdee91fe5beb195bdaace31959
6
+ metadata.gz: d3e2039abf83cd21c0ef3d6b33bcfcef54db1dc7df1eb91fb771ab218076b484b34a4a7c034a1e945d5ab3f84e739fdffbdba05999e2bb1878430af4698e4678
7
+ data.tar.gz: 1cc3cb4565b4999bfac4f351fffb0d937c28db74c93e26a94267332b9c15ca8812f0bce4c19e2298169a957d008546bde95442a2ca7d798f9912b2bd3c9c39e8
@@ -1,11 +1,11 @@
1
1
  module SiblingsNavigation
2
2
 
3
3
  def next_for(user)
4
- pending_siblings_for(user).select { |it| it.number > number }.sort_by(&:number).first
4
+ user.pending_siblings_at(self).select { |it| it.number > number }.sort_by(&:number).first
5
5
  end
6
6
 
7
7
  def restart(user)
8
- pending_siblings_for(user).sort_by(&:number).first
8
+ user.pending_siblings_at(self).sort_by(&:number).first
9
9
  end
10
10
 
11
11
  def siblings
@@ -5,7 +5,7 @@ module Submittable
5
5
 
6
6
  def find_assignment_and_submit!(user, submission)
7
7
  assignment = assignment_for user
8
- results = submission.run! assignment, evaluation_class.new
8
+ results = user.run_submission! submission, assignment, evaluation_class.new
9
9
  [assignment, results]
10
10
  end
11
11
  end
@@ -28,6 +28,6 @@ module WithAssignments
28
28
  end
29
29
 
30
30
  def assignment_for(user, organization=Organization.current)
31
- find_assignment_for(user, organization) || user.assignments.build(exercise: self, organization: organization)
31
+ find_assignment_for(user, organization) || user.build_assignment(self, organization)
32
32
  end
33
33
  end
@@ -1,6 +1,6 @@
1
1
  module WithProgress
2
2
  def progress_for(user, organization)
3
- Indicator.find_or_initialize_by(user: user, organization: organization, content: self)
3
+ user.progress_at(self, organization)
4
4
  end
5
5
 
6
6
  def completion_percentage_for(user, organization=Organization.current)
@@ -42,7 +42,7 @@ class Guide < Content
42
42
  end
43
43
 
44
44
  def next_exercise(user)
45
- pending_exercises(user).order('public.exercises.number asc').first
45
+ user.next_exercise_at(self)
46
46
  end
47
47
 
48
48
  # TODO: Make use of pending_siblings logic
@@ -18,6 +18,7 @@ class Organization < ApplicationRecord
18
18
  has_many :usages
19
19
 
20
20
  validates_presence_of :contact_email, :locale
21
+ validates_presence_of :welcome_email_template, if: :greet_new_users?
21
22
  validates :name, uniqueness: true,
22
23
  presence: true,
23
24
  format: { with: Mumukit::Platform::Organization.anchored_valid_name_regex }
@@ -39,6 +39,8 @@ class User < ApplicationRecord
39
39
  before_validation :set_uid!
40
40
  validates :uid, presence: true
41
41
 
42
+ after_save :welcome_to_new_organizations!, if: :gained_access_to_new_orga?
43
+
42
44
  resource_fields :uid, :social_id, :email, :permissions, :verified_first_name, :verified_last_name, *profile_fields
43
45
 
44
46
  def last_lesson
@@ -189,8 +191,50 @@ class User < ApplicationRecord
189
191
  name.split.map(&:first).map(&:capitalize).join(' ')
190
192
  end
191
193
 
194
+ def progress_at(content, organization)
195
+ Indicator.find_or_initialize_by(user: self, organization: organization, content: content)
196
+ end
197
+
198
+ def build_assignment(exercise, organization)
199
+ assignments.build(exercise: exercise, organization: organization)
200
+ end
201
+
202
+ def pending_siblings_at(content)
203
+ content.pending_siblings_for(self)
204
+ end
205
+
206
+ def next_exercise_at(guide)
207
+ guide.pending_exercises(self).order('public.exercises.number asc').first
208
+ end
209
+
210
+ def run_submission!(submission, assignment, evaluation)
211
+ submission.run! assignment, evaluation
212
+ end
213
+
214
+ def incognito?
215
+ false
216
+ end
217
+
192
218
  private
193
219
 
220
+ def welcome_to_new_organizations!
221
+ new_accessible_organizations.each do |organization|
222
+ UserMailer.welcome_email(self, organization).deliver_later if organization.greet_new_users?
223
+ end
224
+ end
225
+
226
+ def gained_access_to_new_orga?
227
+ new_accessible_organizations.present?
228
+ end
229
+
230
+ def new_accessible_organizations
231
+ return [] unless saved_change_to_permissions?
232
+
233
+ old, new = saved_change_to_permissions
234
+ new_organizations = (new.any_granted_organizations - old.any_granted_organizations).to_a
235
+ Organization.where(name: new_organizations)
236
+ end
237
+
194
238
  def set_uid!
195
239
  self.uid ||= email
196
240
  end
@@ -0,0 +1,5 @@
1
+ class AddIncognitoModeEnabledToOrganization < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :organizations, :incognito_mode_enabled, :boolean
4
+ end
5
+ end
@@ -26,6 +26,7 @@ Mumukit::Platform.configure do |config|
26
26
  end
27
27
 
28
28
  require_relative './domain/area'
29
+ require_relative './domain/incognito'
29
30
  require_relative './domain/evaluation'
30
31
  require_relative './domain/submission'
31
32
  require_relative './domain/status'
@@ -0,0 +1,112 @@
1
+ module Mumuki::Domain
2
+ class IncognitoClass
3
+
4
+ def incognito?
5
+ true
6
+ end
7
+
8
+ # ============
9
+ # Permissions
10
+ # ============
11
+
12
+ def ensure_enabled!
13
+ end
14
+
15
+ def has_student_granted_organizations?
16
+ false
17
+ end
18
+
19
+ def teacher_here?
20
+ false
21
+ end
22
+
23
+ def teacher_of?(*)
24
+ false
25
+ end
26
+
27
+ def profile_completed?
28
+ true
29
+ end
30
+
31
+ def writer?
32
+ false
33
+ end
34
+
35
+ def moderator_here?
36
+ false
37
+ end
38
+
39
+ def can_discuss_here?
40
+ false
41
+ end
42
+
43
+ # ========
44
+ # Visiting
45
+ # ========
46
+
47
+ def visit!(*)
48
+ end
49
+
50
+ # ========
51
+ # Progress
52
+ # ========
53
+
54
+ def next_exercise_at(guide)
55
+ guide.exercises.first
56
+ end
57
+
58
+ # def completed_containers_with_lookahead(*)
59
+ # raise 'Unsupported operation. Userless mode and progressive display modes are incompatible'
60
+ # end
61
+
62
+ def progress_at(content, organization)
63
+ Indicator.new content: content, organization: organization
64
+ end
65
+
66
+ def build_assignment(exercise, organization)
67
+ Assignment.new exercise: exercise, organization: organization, submitter: self
68
+ end
69
+
70
+ def pending_siblings_at(content)
71
+ []
72
+ end
73
+
74
+ # ============
75
+ # ActiveRecord
76
+ # ============
77
+
78
+ def id
79
+ '<incognito>'
80
+ end
81
+
82
+ def is_a?(other)
83
+ other.is_a?(Class) && other.name == 'User' || super
84
+ end
85
+
86
+ def _read_attribute(key)
87
+ return id if key == 'id'
88
+ raise "unknown attribute #{key}"
89
+ end
90
+
91
+ def self.primary_key
92
+ 'id'
93
+ end
94
+
95
+ # ==========
96
+ # Evaluation
97
+ # ==========
98
+
99
+ def interpolations
100
+ []
101
+ end
102
+
103
+ def run_submission!(submission, assignment, evaluation)
104
+ results = submission.dry_run! assignment, evaluation
105
+ assignment.assign_attributes results
106
+ results
107
+ end
108
+
109
+ end
110
+
111
+ Incognito = IncognitoClass.new
112
+ end
@@ -11,7 +11,8 @@ class Mumuki::Domain::Organization::Profile < Mumukit::Platform::Model
11
11
  :contact_email,
12
12
  :terms_of_service,
13
13
  :community_link,
14
- :errors_explanations
14
+ :errors_explanations,
15
+ :welcome_email_template
15
16
 
16
17
  def locale_json
17
18
  locale_h.to_json
@@ -15,7 +15,8 @@ class Mumuki::Domain::Organization::Settings < Mumukit::Platform::Model
15
15
  :login_provider_settings,
16
16
  :public?,
17
17
  :raise_hand_enabled?,
18
- :report_issue_enabled?
18
+ :report_issue_enabled?,
19
+ :greet_new_users?
19
20
 
20
21
  def private?
21
22
  !public?
@@ -21,12 +21,16 @@ class Mumuki::Domain::Submission::Base
21
21
 
22
22
  def run!(assignment, evaluation)
23
23
  save_submission! assignment
24
- results = evaluation.evaluate! assignment, self
24
+ results = dry_run! assignment, evaluation
25
25
  save_results! results, assignment
26
26
  notify_results! results, assignment
27
27
  results
28
28
  end
29
29
 
30
+ def dry_run!(assignment, evaluation)
31
+ evaluation.evaluate! assignment, self
32
+ end
33
+
30
34
  def with_client_result(result)
31
35
  self.client_result = result if result.present?
32
36
  self
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '7.7.2'
3
+ VERSION = '7.8.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-domain
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.7.2
4
+ version: 7.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-07 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '7.6'
33
+ version: '7.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '7.6'
40
+ version: '7.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mumukit-assistant
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -613,6 +613,7 @@ files:
613
613
  - db/migrate/20200728163038_add_requires_moderator_response_to_discussions.rb
614
614
  - db/migrate/20200730221001_add_trusted_for_forum_to_user.rb
615
615
  - db/migrate/20200731081757_add_last_moderator_access_fields_to_discussion.rb
616
+ - db/migrate/20200804191643_add_incognito_mode_enabled_to_organization.rb
616
617
  - lib/mumuki/domain.rb
617
618
  - lib/mumuki/domain/area.rb
618
619
  - lib/mumuki/domain/engine.rb
@@ -657,6 +658,7 @@ files:
657
658
  - lib/mumuki/domain/helpers/course.rb
658
659
  - lib/mumuki/domain/helpers/organization.rb
659
660
  - lib/mumuki/domain/helpers/user.rb
661
+ - lib/mumuki/domain/incognito.rb
660
662
  - lib/mumuki/domain/locales/activerecord/en.yml
661
663
  - lib/mumuki/domain/locales/activerecord/es.yml
662
664
  - lib/mumuki/domain/locales/activerecord/pt.yml