mumuki-domain 8.1.3 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/assignment.rb +6 -1
- data/app/models/indicator.rb +35 -0
- data/app/models/progress.rb +35 -0
- data/lib/mumuki/domain.rb +1 -0
- data/lib/mumuki/domain/progress_transfer.rb +8 -0
- data/lib/mumuki/domain/progress_transfer/base.rb +44 -0
- data/lib/mumuki/domain/progress_transfer/copy.rb +9 -0
- data/lib/mumuki/domain/progress_transfer/move.rb +14 -0
- data/lib/mumuki/domain/status/submission/manual_evaluation_pending.rb +1 -1
- data/lib/mumuki/domain/status/submission/submission.rb +4 -0
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ea9b10953e5031cfcfa680763efb0eac02e63b91219c3dbf71b0d30b5dd3250
|
|
4
|
+
data.tar.gz: 8fda448216e9d80cb4de41a7f43825882e043895705c66c1c6b9b4bc68c5bfec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2f8f341502367fa4a7ba037eb086f0506c19fede8290aba4921430fb22e33cc338faf01bc85d23d9df89fca006dba97705e377f48c3eae789170291644562e5
|
|
7
|
+
data.tar.gz: e5044aa8475aba10ea9d1140eceefccd9fc36de384cf215007f4f239568aebf9f06583074249af630fff81db9da8d429604fa428db0c509a55c4f9092b25965d
|
data/app/models/assignment.rb
CHANGED
|
@@ -23,6 +23,8 @@ class Assignment < Progress
|
|
|
23
23
|
|
|
24
24
|
delegate :completed?, :solved?, to: :submission_status
|
|
25
25
|
|
|
26
|
+
delegate :content_available_in?, to: :parent
|
|
27
|
+
|
|
26
28
|
alias_attribute :status, :submission_status
|
|
27
29
|
alias_attribute :attempts_count, :attemps_count
|
|
28
30
|
|
|
@@ -263,6 +265,10 @@ class Assignment < Progress
|
|
|
263
265
|
|
|
264
266
|
private
|
|
265
267
|
|
|
268
|
+
def duplicates_key
|
|
269
|
+
{ exercise: exercise, submitter: submitter }
|
|
270
|
+
end
|
|
271
|
+
|
|
266
272
|
def update_submissions_count!
|
|
267
273
|
self.class.connection.execute(
|
|
268
274
|
"update public.exercises
|
|
@@ -278,5 +284,4 @@ class Assignment < Progress
|
|
|
278
284
|
def update_last_submission!
|
|
279
285
|
submitter.update!(last_submission_date: DateTime.current, last_exercise: exercise)
|
|
280
286
|
end
|
|
281
|
-
|
|
282
287
|
end
|
data/app/models/indicator.rb
CHANGED
|
@@ -66,8 +66,43 @@ class Indicator < Progress
|
|
|
66
66
|
where(content: content, organization: organization).delete_all
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
def _move_to!(organization)
|
|
70
|
+
move_children_to!(organization)
|
|
71
|
+
super
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def _copy_to!(organization)
|
|
75
|
+
progress_item = super
|
|
76
|
+
children.each { |it| it._copy_to! organization }
|
|
77
|
+
progress_item
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def move_children_to!(organization)
|
|
81
|
+
children.update_all(organization_id: organization.id)
|
|
82
|
+
|
|
83
|
+
indicators.each { |it| it.move_children_to!(organization) }
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def cascade_delete_children!
|
|
87
|
+
indicators.each(&:cascade_delete_children!)
|
|
88
|
+
children.delete_all(:delete_all)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def content_available_in?(organization)
|
|
92
|
+
content.usage_in_organization(organization).present?
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def delete_duplicates_in!(organization)
|
|
96
|
+
duplicates_in(organization).each(&:cascade_delete_children!)
|
|
97
|
+
super
|
|
98
|
+
end
|
|
99
|
+
|
|
69
100
|
private
|
|
70
101
|
|
|
102
|
+
def duplicates_key
|
|
103
|
+
{ content: content, user: user }
|
|
104
|
+
end
|
|
105
|
+
|
|
71
106
|
def children
|
|
72
107
|
indicators.presence || assignments
|
|
73
108
|
end
|
data/app/models/progress.rb
CHANGED
|
@@ -12,4 +12,39 @@ class Progress < ApplicationRecord
|
|
|
12
12
|
def dirty_parent_by_submission!
|
|
13
13
|
parent&.dirty_by_submission!
|
|
14
14
|
end
|
|
15
|
+
|
|
16
|
+
def _copy_to!(organization)
|
|
17
|
+
dup.transfer_to!(organization)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def transfer_to!(organization)
|
|
21
|
+
update! organization: organization, parent: nil
|
|
22
|
+
self
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
alias_method :_move_to!, :transfer_to!
|
|
26
|
+
|
|
27
|
+
%w(copy move).each do |transfer_type|
|
|
28
|
+
define_method "#{transfer_type}_to!" do |organization|
|
|
29
|
+
"Mumuki::Domain::ProgressTransfer::#{transfer_type.camelize}".constantize.new(self, organization).execute!
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def guide_indicator?
|
|
34
|
+
is_a?(Indicator) && content_type == 'Guide'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def has_duplicates_in?(organization)
|
|
38
|
+
duplicates_in(organization).present?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def delete_duplicates_in!(organization)
|
|
42
|
+
duplicates_in(organization).delete_all
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def duplicates_in(organization)
|
|
48
|
+
self.class.where(duplicates_key.merge(organization: organization)).where.not(id: id)
|
|
49
|
+
end
|
|
15
50
|
end
|
data/lib/mumuki/domain.rb
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class Mumuki::Domain::ProgressTransfer::Base
|
|
2
|
+
attr_reader *%i(source_organization destination_organization progress_item transferred_item)
|
|
3
|
+
|
|
4
|
+
delegate :user, to: :progress_item
|
|
5
|
+
|
|
6
|
+
def initialize(progress_item, destination_organization)
|
|
7
|
+
@progress_item = progress_item
|
|
8
|
+
@destination_organization = destination_organization
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def execute!
|
|
12
|
+
ActiveRecord::Base.transaction do
|
|
13
|
+
pre_transfer!
|
|
14
|
+
transfer!
|
|
15
|
+
post_transfer!
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def pre_transfer!
|
|
20
|
+
validate_transferrable!
|
|
21
|
+
@source_organization = progress_item.organization
|
|
22
|
+
progress_item.delete_duplicates_in!(destination_organization)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def transfer!
|
|
26
|
+
@transferred_item = do_transfer!
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def post_transfer!
|
|
30
|
+
transferred_item.dirty_parent_by_submission!
|
|
31
|
+
notify_transfer!
|
|
32
|
+
transferred_item
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def validate_transferrable!
|
|
36
|
+
raise "Transferred progress' content must be available in destination!" unless progress_item.content_available_in?(destination_organization)
|
|
37
|
+
raise 'User must be student in destination organization' unless user.student_of?(destination_organization)
|
|
38
|
+
raise 'Transfer only supported for guide indicators' unless progress_item.guide_indicator?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def notify_transfer!
|
|
42
|
+
Mumukit::Nuntius.notify! 'progress-transfers', { from: source_organization.name, to: destination_organization.name, item_type: transferred_item.class.to_s, item_id: transferred_item.id, transfer_type: transfer_type }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class Mumuki::Domain::ProgressTransfer::Move < Mumuki::Domain::ProgressTransfer::Base
|
|
2
|
+
def transfer_type
|
|
3
|
+
:move
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def pre_transfer!
|
|
7
|
+
super
|
|
8
|
+
progress_item.dirty_parent_by_submission!
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def do_transfer!
|
|
12
|
+
progress_item._move_to!(destination_organization)
|
|
13
|
+
end
|
|
14
|
+
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.
|
|
4
|
+
version: 8.2.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:
|
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -704,6 +704,10 @@ files:
|
|
|
704
704
|
- lib/mumuki/domain/organization/profile.rb
|
|
705
705
|
- lib/mumuki/domain/organization/settings.rb
|
|
706
706
|
- lib/mumuki/domain/organization/theme.rb
|
|
707
|
+
- lib/mumuki/domain/progress_transfer.rb
|
|
708
|
+
- lib/mumuki/domain/progress_transfer/base.rb
|
|
709
|
+
- lib/mumuki/domain/progress_transfer/copy.rb
|
|
710
|
+
- lib/mumuki/domain/progress_transfer/move.rb
|
|
707
711
|
- lib/mumuki/domain/seed.rb
|
|
708
712
|
- lib/mumuki/domain/status.rb
|
|
709
713
|
- lib/mumuki/domain/status/discussion/closed.rb
|