mumuki-domain 8.0.0 → 8.1.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: 2e3057a4511ba66a280fe3f5bf53052a33161ecd9a45dfb6851d2dc21ea7ad20
4
- data.tar.gz: bb89fde6326417de9590369040b1d61a13ec35ea1abe8d365c0d21aa66777315
3
+ metadata.gz: 9075756cb0cd46b955959afe62c837fb11a293cf520f7e7a3e0666c88e9bc014
4
+ data.tar.gz: a775162a5319a08a2a2953586bd59efd3cca7ebffddb9c72b236175c5dcbb1a8
5
5
  SHA512:
6
- metadata.gz: 586446caac1b0eeecf18d5754e1fb1120e1d0f5a87a4d386152f64af9d6f0b5f18b089676cc994c7f717baa3382b120d7ea71e011263e8761ad5b830dbfefb02
7
- data.tar.gz: 77d0ddcfaea1ffaae2d22e5cb7e9b30e08b3d6ef4d303fad9df0062294353dab7834f35fd8fdf339fa770cc233c293f6bf6173442262f11e98eef2521bf3d952
6
+ metadata.gz: '08190f559ca10836c7d2cfd9c98a864ea18d31fb1f13115727ffc9738a7913fe4af136571b0036c1701b166162e61d2d726653a0cb8f3f1711f9677bde815e03'
7
+ data.tar.gz: ed6f365ac0c552ccd2f5136fd825052b51da29846a6ea042d27a57e991008d5cfe02265a5450eb2a9b62756ddfb96300c5be1f47dd699b26a8d47b57883c3758
@@ -52,10 +52,10 @@ class Assignment < Progress
52
52
  self.organization = Organization.current
53
53
  end
54
54
 
55
- def recontextualize!
56
- if organization != Organization.current
55
+ def recontextualize!(new_organization = Organization.current)
56
+ if organization != new_organization
57
57
  dirty_parent_by_submission! if organization.present? && exercise.used_in?(organization)
58
- self.organization = Organization.current
58
+ self.organization = new_organization
59
59
  self.parent_id = nil
60
60
  end
61
61
  end
@@ -126,7 +126,7 @@ class Assignment < Progress
126
126
  end
127
127
 
128
128
  def content=(content)
129
- if content.present?
129
+ unless exercise.reading?
130
130
  self.solution = exercise.single_choice? ? exercise.choice_index_for(content) : content
131
131
  end
132
132
  end
@@ -20,6 +20,14 @@ module Container
20
20
  content.progress_for(user, organization)
21
21
  end
22
22
 
23
+ def navigable_content_in(organization = Organization.current)
24
+ content.usage_in_organization(organization)
25
+ end
26
+
27
+ def content_used_in?(organization)
28
+ navigable_content_in(organization).present?
29
+ end
30
+
23
31
  private
24
32
 
25
33
  # Generally we are calling progress_for for each sibling. That method needs the
@@ -16,6 +16,18 @@ module WithUsages
16
16
  item.is_a?(type) ? item : nil
17
17
  end
18
18
 
19
+ def navigable_content_in(organization = Organization.current)
20
+ self if used_in?(organization)
21
+ end
22
+
23
+ def content_used_in?(organization)
24
+ navigable_content_in(organization).present?
25
+ end
26
+
27
+ def used_in?(organization)
28
+ usage_in_organization(organization).present?
29
+ end
30
+
19
31
  class_methods do
20
32
  def aggregate_of(association)
21
33
  super
@@ -44,6 +44,10 @@ class Discussion < ApplicationRecord
44
44
  end
45
45
  end
46
46
 
47
+ def navigable_content_in(_)
48
+ nil
49
+ end
50
+
47
51
  def used_in?(organization)
48
52
  organization == self.organization
49
53
  end
@@ -47,6 +47,14 @@ class Exercise < ApplicationRecord
47
47
  guide.usage_in_organization(organization).present?
48
48
  end
49
49
 
50
+ def navigable_content_in(organization = Organization.current)
51
+ self if used_in?(organization)
52
+ end
53
+
54
+ def content_used_in?(organization)
55
+ navigable_content_in(organization).present?
56
+ end
57
+
50
58
  def structural_parent
51
59
  guide
52
60
  end
@@ -231,6 +239,10 @@ class Exercise < ApplicationRecord
231
239
  guide.pending_exercises(user)
232
240
  end
233
241
 
242
+ def reading?
243
+ is_a? Reading
244
+ end
245
+
234
246
  private
235
247
 
236
248
  def evaluation_class
@@ -243,9 +243,9 @@ class User < ApplicationRecord
243
243
  Organization.current? ? Organization.current : main_organization
244
244
  end
245
245
 
246
- def current_immersive_context_at(exercise)
246
+ def current_immersive_context_at(path_item)
247
247
  if Organization.current?
248
- immersive_organization_at(exercise) || Organization.current
248
+ immersive_organization_at(path_item) || Organization.current
249
249
  else
250
250
  main_organization
251
251
  end
@@ -259,13 +259,19 @@ class User < ApplicationRecord
259
259
  new_permissions: permissions.as_json
260
260
  }
261
261
  end
262
-
262
+
263
263
  def save_and_notify!
264
264
  save!
265
265
  notify_permissions_changed!
266
266
  self
267
267
  end
268
268
 
269
+ def current_immersive_context_and_content_at(path_item)
270
+ immersive_organization_with_content_at(path_item).tap do |orga, _|
271
+ return [Organization.current, path_item] unless orga.present?
272
+ end
273
+ end
274
+
269
275
  private
270
276
 
271
277
  def welcome_to_new_organizations!
@@ -15,6 +15,10 @@ class Array
15
15
  def single?
16
16
  size == 1
17
17
  end
18
+
19
+ def multiple?
20
+ size > 1
21
+ end
18
22
  end
19
23
 
20
24
  class NilClass
@@ -29,7 +29,7 @@ module Mumuki::Domain::Helpers::Organization
29
29
  end
30
30
 
31
31
  def immersed_in?(other)
32
- immersible? && other.immersive? && target_audience == other.target_audience
32
+ immersible? && other.immersive? && !other.disabled? && target_audience == other.target_audience
33
33
  end
34
34
 
35
35
  def switch!
@@ -101,12 +101,21 @@ module Mumuki::Domain::Helpers::User
101
101
  end
102
102
 
103
103
  def immersive_organizations_at(path_item, current = Organization.current)
104
- return [] unless current.immersible?
105
-
106
104
  usage_filter = path_item ? lambda { |it| path_item.used_in?(it) } : lambda { |_| true }
107
- student_granted_organizations
108
- .select { |it| current.immersed_in?(it) }
109
- .select(&usage_filter)
105
+ immersive_organizations_for(current).select(&usage_filter)
106
+ end
107
+
108
+ def immersive_organization_with_content_at(path_item, current = Organization.current)
109
+ orga = immersive_organizations_with_content_at(path_item, current).single
110
+ [orga, path_item&.navigable_content_in(orga)]
111
+ end
112
+
113
+ def immersive_organizations_with_content_at(path_item, current = Organization.current)
114
+ immersive_without_usage = immersive_organizations_for(current)
115
+ return immersive_without_usage unless path_item.present?
116
+
117
+ immersive_with_usage = immersive_without_usage.select { |it| path_item.content_used_in? it }
118
+ immersive_with_usage.empty? ? immersive_without_usage : immersive_with_usage
110
119
  end
111
120
 
112
121
  ## API Exposure
@@ -120,4 +129,12 @@ module Mumuki::Domain::Helpers::User
120
129
  [:first_name, :last_name, :gender, :birthdate]
121
130
  end
122
131
  end
132
+
133
+ private
134
+
135
+ def immersive_organizations_for(organization)
136
+ return [] unless organization.immersible?
137
+
138
+ student_granted_organizations.select { |it| organization.immersed_in?(it) }
139
+ end
123
140
  end
@@ -52,7 +52,15 @@ module Mumuki::Domain
52
52
  nil
53
53
  end
54
54
 
55
- def immersive_organizations_at(_)
55
+ def current_immersive_context_and_content_at(_)
56
+ [nil, nil]
57
+ end
58
+
59
+ def immersive_organizations_with_content_at(_, _ = nil)
60
+ []
61
+ end
62
+
63
+ def immersive_organizations_at(_, _ = nil)
56
64
  []
57
65
  end
58
66
 
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '8.0.0'
3
+ VERSION = '8.1.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: 8.0.0
4
+ version: 8.1.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-11-20 00:00:00.000000000 Z
11
+ date: 2020-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '6.0'
131
+ version: '6.1'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '6.0'
138
+ version: '6.1'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: mumukit-sync
141
141
  requirement: !ruby/object:Gem::Requirement