mumuki-domain 7.12.0 → 8.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/application_record.rb +3 -4
- data/app/models/assignment.rb +13 -1
- data/app/models/concerns/container.rb +8 -0
- data/app/models/concerns/with_terms_acceptance.rb +8 -0
- data/app/models/concerns/with_usages.rb +12 -0
- data/app/models/discussion.rb +4 -0
- data/app/models/exam.rb +1 -3
- data/app/models/exercise.rb +12 -0
- data/app/models/guide.rb +4 -1
- data/app/models/topic.rb +4 -1
- data/app/models/user.rb +27 -6
- data/db/migrate/20201130163114_add_banned_from_forum_to_users.rb +5 -0
- data/lib/mumuki/domain/extensions/array.rb +4 -0
- data/lib/mumuki/domain/factories/term_factory.rb +1 -1
- data/lib/mumuki/domain/helpers/organization.rb +2 -2
- data/lib/mumuki/domain/helpers/user.rb +23 -5
- data/lib/mumuki/domain/incognito.rb +14 -7
- data/lib/mumuki/domain/organization/profile.rb +1 -1
- data/lib/mumuki/domain/submission/base.rb +1 -1
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd4418eebed893926b600b43b22080be43205ef4b857e16df1be7e50ea625e9b
|
4
|
+
data.tar.gz: 69d81e7072172101767cc3655cfad7bafdcf9fc726c3438432a9777792e744c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d28c8e9e981e2669f11a5f581f25639c318df1dc17bdf1c94bcd127010426f2b846ff801f7ee2362941f2fb42ea188a36694b91add542555085f5d363603cc11
|
7
|
+
data.tar.gz: 2e95982034e482f748425c8445791349b5eb9c206a962b6620aea4412d4ef01a17ecf2d79ac0ca12cca75a458a51e0f4ce671951213ac434381475592e235ac2
|
@@ -70,9 +70,8 @@ class ApplicationRecord < ActiveRecord::Base
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def update_and_notify!(data)
|
73
|
-
|
74
|
-
|
75
|
-
self
|
73
|
+
assign_attributes data
|
74
|
+
save_and_notify!
|
76
75
|
end
|
77
76
|
|
78
77
|
def self.aggregate_of(association)
|
@@ -105,7 +104,7 @@ class ApplicationRecord < ActiveRecord::Base
|
|
105
104
|
obj
|
106
105
|
end
|
107
106
|
|
108
|
-
def self.whitelist_attributes(a_hash, options={})
|
107
|
+
def self.whitelist_attributes(a_hash, options = {})
|
109
108
|
attributes = attribute_names
|
110
109
|
attributes += reflections.keys if options[:relations]
|
111
110
|
a_hash.with_indifferent_access.slice(*attributes).except(*options[:except])
|
data/app/models/assignment.rb
CHANGED
@@ -52,6 +52,14 @@ class Assignment < Progress
|
|
52
52
|
self.organization = Organization.current
|
53
53
|
end
|
54
54
|
|
55
|
+
def recontextualize!(new_organization = Organization.current)
|
56
|
+
if organization != new_organization
|
57
|
+
dirty_parent_by_submission! if organization.present? && exercise.used_in?(organization)
|
58
|
+
self.organization = new_organization
|
59
|
+
self.parent_id = nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
55
63
|
def set_default_top_submission_status
|
56
64
|
self.top_submission_status ||= 0
|
57
65
|
end
|
@@ -118,7 +126,7 @@ class Assignment < Progress
|
|
118
126
|
end
|
119
127
|
|
120
128
|
def content=(content)
|
121
|
-
|
129
|
+
unless exercise.reading?
|
122
130
|
self.solution = exercise.single_choice? ? exercise.choice_index_for(content) : content
|
123
131
|
end
|
124
132
|
end
|
@@ -145,6 +153,10 @@ class Assignment < Progress
|
|
145
153
|
end
|
146
154
|
end
|
147
155
|
|
156
|
+
def manual_evaluation_pending!
|
157
|
+
update! submission_status: :manual_evaluation_pending
|
158
|
+
end
|
159
|
+
|
148
160
|
def passed!
|
149
161
|
update! submission_status: :passed
|
150
162
|
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
|
@@ -7,6 +7,14 @@ module WithTermsAcceptance
|
|
7
7
|
!has_accepted_all?(profile_terms)
|
8
8
|
end
|
9
9
|
|
10
|
+
def has_role_terms_to_accept?
|
11
|
+
!has_accepted_all?(role_specific_terms)
|
12
|
+
end
|
13
|
+
|
14
|
+
def role_specific_terms
|
15
|
+
@role_specific_terms ||= Term.role_specific_terms_for(self)
|
16
|
+
end
|
17
|
+
|
10
18
|
def forum_terms
|
11
19
|
@forum_terms ||= Term.forum_related_terms
|
12
20
|
end
|
@@ -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
|
data/app/models/discussion.rb
CHANGED
data/app/models/exam.rb
CHANGED
@@ -5,7 +5,7 @@ class Exam < ApplicationRecord
|
|
5
5
|
include TerminalNavigation
|
6
6
|
|
7
7
|
belongs_to :organization
|
8
|
-
belongs_to :course
|
8
|
+
belongs_to :course
|
9
9
|
|
10
10
|
has_many :authorizations, class_name: 'ExamAuthorization', dependent: :destroy
|
11
11
|
has_many :users, through: :authorizations
|
@@ -186,8 +186,6 @@ class Exam < ApplicationRecord
|
|
186
186
|
exam[:start_time] = exam[:start_time].to_time
|
187
187
|
exam[:end_time] = exam[:end_time].to_time
|
188
188
|
exam[:classroom_id] = exam[:eid] if exam[:eid].present?
|
189
|
-
exam[:passing_criterion_type] = exam.dig(:passing_criterion, :type)
|
190
|
-
exam[:passing_criterion_value] = exam.dig(:passing_criterion, :value)
|
191
189
|
end
|
192
190
|
|
193
191
|
def self.remove_previous_version(eid, guide_id)
|
data/app/models/exercise.rb
CHANGED
@@ -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
|
data/app/models/guide.rb
CHANGED
@@ -51,7 +51,10 @@ class Guide < Content
|
|
51
51
|
joins("left join public.assignments assignments
|
52
52
|
on assignments.exercise_id = exercises.id
|
53
53
|
and assignments.submitter_id = #{user.id}
|
54
|
-
and assignments.submission_status
|
54
|
+
and assignments.submission_status in (
|
55
|
+
#{Mumuki::Domain::Status::Submission::Passed.to_i},
|
56
|
+
#{Mumuki::Domain::Status::Submission::ManualEvaluationPending.to_i}
|
57
|
+
)").
|
55
58
|
where('assignments.id is null')
|
56
59
|
end
|
57
60
|
|
data/app/models/topic.rb
CHANGED
@@ -48,7 +48,10 @@ class Topic < Content
|
|
48
48
|
joins("left join public.assignments assignments
|
49
49
|
on assignments.exercise_id = exercises.id
|
50
50
|
and assignments.submitter_id = #{user.id}
|
51
|
-
and assignments.submission_status
|
51
|
+
and assignments.submission_status in (
|
52
|
+
#{Mumuki::Domain::Status::Submission::Passed.to_i},
|
53
|
+
#{Mumuki::Domain::Status::Submission::ManualEvaluationPending.to_i}
|
54
|
+
)").
|
52
55
|
where('assignments.id is null').
|
53
56
|
group('public.guides.id', 'lessons.number').map(&:lesson)
|
54
57
|
end
|
data/app/models/user.rb
CHANGED
@@ -139,9 +139,9 @@ class User < ApplicationRecord
|
|
139
139
|
|
140
140
|
def interpolations
|
141
141
|
{
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
'user_email' => email,
|
143
|
+
'user_first_name' => first_name,
|
144
|
+
'user_last_name' => last_name
|
145
145
|
}
|
146
146
|
end
|
147
147
|
|
@@ -182,7 +182,7 @@ class User < ApplicationRecord
|
|
182
182
|
# This is true only when this organization has the forum enabled and the user
|
183
183
|
# has the discusser pseudo-permission and the discusser is trusted
|
184
184
|
def can_discuss_in?(organization)
|
185
|
-
organization.forum_enabled? && discusser_of?(organization) && trusted_as_discusser_in?(organization)
|
185
|
+
organization.forum_enabled? && discusser_of?(organization) && trusted_as_discusser_in?(organization) && !banned_from_forum?
|
186
186
|
end
|
187
187
|
|
188
188
|
def trusted_as_discusser_in?(organization)
|
@@ -243,14 +243,35 @@ class User < ApplicationRecord
|
|
243
243
|
Organization.current? ? Organization.current : main_organization
|
244
244
|
end
|
245
245
|
|
246
|
-
def current_immersive_context_at(
|
246
|
+
def current_immersive_context_at(path_item)
|
247
247
|
if Organization.current?
|
248
|
-
immersive_organization_at(
|
248
|
+
immersive_organization_at(path_item) || Organization.current
|
249
249
|
else
|
250
250
|
main_organization
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
254
|
+
def notify_permissions_changed!
|
255
|
+
return if permissions_before_last_save == permissions
|
256
|
+
Mumukit::Nuntius.notify! 'user-permissions-changed', user: {
|
257
|
+
uid: uid,
|
258
|
+
old_permissions: permissions_before_last_save.as_json,
|
259
|
+
new_permissions: permissions.as_json
|
260
|
+
}
|
261
|
+
end
|
262
|
+
|
263
|
+
def save_and_notify!
|
264
|
+
save!
|
265
|
+
notify_permissions_changed!
|
266
|
+
self
|
267
|
+
end
|
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
|
+
|
254
275
|
private
|
255
276
|
|
256
277
|
def welcome_to_new_organizations!
|
@@ -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!
|
@@ -41,7 +41,7 @@ module Mumuki::Domain::Helpers::Organization
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def url_for(path)
|
44
|
-
Mumukit::Platform.
|
44
|
+
Mumukit::Platform.laboratory.organic_url_for(name, path)
|
45
45
|
end
|
46
46
|
|
47
47
|
def url
|
@@ -8,6 +8,7 @@ module Mumuki::Domain::Helpers::User
|
|
8
8
|
delegate :has_role?,
|
9
9
|
:add_permission!,
|
10
10
|
:remove_permission!,
|
11
|
+
:update_permission!,
|
11
12
|
:has_permission?,
|
12
13
|
:has_permission_delegation?,
|
13
14
|
:protect!,
|
@@ -100,12 +101,21 @@ module Mumuki::Domain::Helpers::User
|
|
100
101
|
end
|
101
102
|
|
102
103
|
def immersive_organizations_at(path_item, current = Organization.current)
|
103
|
-
return [] unless current.immersible?
|
104
|
-
|
105
104
|
usage_filter = path_item ? lambda { |it| path_item.used_in?(it) } : lambda { |_| true }
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
109
119
|
end
|
110
120
|
|
111
121
|
## API Exposure
|
@@ -119,4 +129,12 @@ module Mumuki::Domain::Helpers::User
|
|
119
129
|
[:first_name, :last_name, :gender, :birthdate]
|
120
130
|
end
|
121
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
|
122
140
|
end
|
@@ -52,7 +52,15 @@ module Mumuki::Domain
|
|
52
52
|
nil
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
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
|
|
@@ -64,14 +72,13 @@ module Mumuki::Domain
|
|
64
72
|
# Terms
|
65
73
|
# ========
|
66
74
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def accepted_forum_terms?
|
72
|
-
true
|
75
|
+
# It avoids role terms acceptance redirections
|
76
|
+
def has_role_terms_to_accept?
|
77
|
+
false
|
73
78
|
end
|
74
79
|
|
80
|
+
# It makes terms UI to be shown as if no terms were accepted
|
81
|
+
# It does not force any term to be accepted though
|
75
82
|
def has_accepted?(term)
|
76
83
|
false
|
77
84
|
end
|
@@ -36,6 +36,6 @@ class Mumuki::Domain::Organization::Profile < Mumukit::Platform::Model
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def open_graph_image_url
|
39
|
-
@open_graph_image_url ||= Mumukit::Platform.
|
39
|
+
@open_graph_image_url ||= Mumukit::Platform.laboratory.url_for("logo-alt.png") # Best image size: 256x256
|
40
40
|
end
|
41
41
|
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:
|
4
|
+
version: 8.1.1
|
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
|
+
date: 2020-12-03 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: '
|
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: '
|
138
|
+
version: '6.1'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: mumukit-sync
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -636,6 +636,7 @@ files:
|
|
636
636
|
- db/migrate/20201026225312_add_organization_wins_page_flag.rb
|
637
637
|
- db/migrate/20201027134205_add_immersible_to_organization.rb
|
638
638
|
- db/migrate/20201027152806_create_terms.rb
|
639
|
+
- db/migrate/20201130163114_add_banned_from_forum_to_users.rb
|
639
640
|
- lib/mumuki/domain.rb
|
640
641
|
- lib/mumuki/domain/area.rb
|
641
642
|
- lib/mumuki/domain/engine.rb
|
@@ -756,7 +757,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
756
757
|
- !ruby/object:Gem::Version
|
757
758
|
version: '0'
|
758
759
|
requirements: []
|
759
|
-
rubygems_version: 3.
|
760
|
+
rubygems_version: 3.1.2
|
760
761
|
signing_key:
|
761
762
|
specification_version: 4
|
762
763
|
summary: Mumuki Platform's Domain Model
|