mumuki-domain 9.0.6 → 9.2.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 +1 -1
- data/app/models/chapter.rb +1 -5
- data/app/models/concerns/navigation/siblings_navigation.rb +3 -4
- data/app/models/concerns/navigation/terminal_navigation.rb +4 -0
- data/app/models/concerns/with_soft_deletion.rb +16 -0
- data/app/models/discussion.rb +9 -5
- data/app/models/exam_authorization_request.rb +11 -0
- data/app/models/exercise.rb +7 -2
- data/app/models/message.rb +3 -2
- data/app/models/organization.rb +1 -1
- data/app/models/user.rb +6 -2
- data/db/migrate/20210318191512_add_deletion_fields_to_message.rb +7 -0
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f51de9222a3fb2a4f3a4e1f8498d90baf49b4b47b87662193510a601e5c7905
|
4
|
+
data.tar.gz: b12cf9c00c8b1a2e77e5f758205c89874de9c94e2e5ee8ac3f30f39f6210f272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ec4c49f78dde3d0422309cf38db8049909eba137b0d4c0ea6b0a27a5d7b475139a351e9c2e272771f9e2b8b59c42c00395511050e3c424369b118b3b23e3d6
|
7
|
+
data.tar.gz: 3bc5e9b62d860e7ec0092352be7ae556ae93c19a2e4173667e3ed8ff3576de8a2bd6bf07128808c64a3ad791c06d8bb358ddfe8d248766b08a3eb1ab54ad51b0
|
@@ -29,7 +29,7 @@ class ApplicationRecord < ActiveRecord::Base
|
|
29
29
|
def self.serialize_symbolized_hash_array(*keys)
|
30
30
|
keys.each do |field|
|
31
31
|
serialize field
|
32
|
-
define_method(field) { self[field]&.map { |it| it.
|
32
|
+
define_method(field) { self[field]&.map { |it| it.deep_symbolize_keys } }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
data/app/models/chapter.rb
CHANGED
@@ -2,8 +2,8 @@ class Chapter < ApplicationRecord
|
|
2
2
|
include WithStats
|
3
3
|
include WithNumber
|
4
4
|
|
5
|
-
include SiblingsNavigation
|
6
5
|
include TerminalNavigation
|
6
|
+
include SiblingsNavigation
|
7
7
|
|
8
8
|
include FriendlyName
|
9
9
|
|
@@ -29,8 +29,4 @@ class Chapter < ApplicationRecord
|
|
29
29
|
def structural_parent
|
30
30
|
book
|
31
31
|
end
|
32
|
-
|
33
|
-
def pending_siblings_for(user)
|
34
|
-
book.pending_chapters(user)
|
35
|
-
end
|
36
32
|
end
|
@@ -12,10 +12,9 @@ module SiblingsNavigation
|
|
12
12
|
structural_parent.structural_children
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# end
|
15
|
+
def pending_siblings_for(user, organization=Organization.current)
|
16
|
+
siblings.reject { |it| it.progress_for(user, organization).completed? }
|
17
|
+
end
|
19
18
|
|
20
19
|
# Names
|
21
20
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module WithSoftDeletion
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
enum deletion_motive: %i(self_deleted inappropriate_content shares_solution discloses_personal_information)
|
6
|
+
belongs_to :deleted_by, class_name: 'User', optional: true
|
7
|
+
end
|
8
|
+
|
9
|
+
def soft_delete!(motive, deleter)
|
10
|
+
update! deletion_motive: motive, deleted_by: deleter, deleted_at: Time.now
|
11
|
+
end
|
12
|
+
|
13
|
+
def deleted?
|
14
|
+
deleted_at.present?
|
15
|
+
end
|
16
|
+
end
|
data/app/models/discussion.rb
CHANGED
@@ -28,7 +28,7 @@ class Discussion < ApplicationRecord
|
|
28
28
|
delegate :language, to: :item
|
29
29
|
delegate :to_discussion_status, to: :status
|
30
30
|
|
31
|
-
MODERATOR_REVIEW_AVERAGE_TIME =
|
31
|
+
MODERATOR_REVIEW_AVERAGE_TIME = 17.minutes
|
32
32
|
|
33
33
|
scope :for_user, -> (user) do
|
34
34
|
if user.try(:moderator_here?)
|
@@ -38,6 +38,10 @@ class Discussion < ApplicationRecord
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def visible_messages
|
42
|
+
messages.where.not(deletion_motive: :self_deleted).or(messages.where(deletion_motive: nil))
|
43
|
+
end
|
44
|
+
|
41
45
|
def try_solve!
|
42
46
|
if opened?
|
43
47
|
update! status: reachable_statuses_for(initiator).first
|
@@ -73,7 +77,7 @@ class Discussion < ApplicationRecord
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def last_message_date
|
76
|
-
|
80
|
+
visible_messages.last&.created_at || created_at
|
77
81
|
end
|
78
82
|
|
79
83
|
def friendly
|
@@ -125,11 +129,11 @@ class Discussion < ApplicationRecord
|
|
125
129
|
end
|
126
130
|
|
127
131
|
def has_messages?
|
128
|
-
|
132
|
+
visible_messages.exists? || description.present?
|
129
133
|
end
|
130
134
|
|
131
135
|
def responses_count
|
132
|
-
|
136
|
+
visible_messages.where.not(sender: initiator.uid).count
|
133
137
|
end
|
134
138
|
|
135
139
|
def has_responses?
|
@@ -186,6 +190,6 @@ class Discussion < ApplicationRecord
|
|
186
190
|
private
|
187
191
|
|
188
192
|
def messages_by_updated_at(direction = :desc)
|
189
|
-
messages.reorder(updated_at: direction)
|
193
|
+
messages.where(deletion_motive: nil).reorder(updated_at: direction)
|
190
194
|
end
|
191
195
|
end
|
@@ -18,6 +18,17 @@ class ExamAuthorizationRequest < ApplicationRecord
|
|
18
18
|
exam_registration.description
|
19
19
|
end
|
20
20
|
|
21
|
+
def icon
|
22
|
+
case status.to_sym
|
23
|
+
when :pending
|
24
|
+
{ class: 'info-circle', type: 'info' }
|
25
|
+
when :approved
|
26
|
+
{ class: 'check-circle', type: 'success' }
|
27
|
+
when :rejected
|
28
|
+
{ class: 'times-circle', type: 'danger' }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
21
32
|
private
|
22
33
|
|
23
34
|
def notify_user!
|
data/app/models/exercise.rb
CHANGED
@@ -29,7 +29,7 @@ class Exercise < ApplicationRecord
|
|
29
29
|
defaults { self.submissions_count = 0 }
|
30
30
|
|
31
31
|
def self.default_scope
|
32
|
-
where(manual_evaluation: false) if
|
32
|
+
where(manual_evaluation: false) if hide_manual_evaluation?
|
33
33
|
end
|
34
34
|
|
35
35
|
alias_method :progress_for, :assignment_for
|
@@ -256,6 +256,10 @@ class Exercise < ApplicationRecord
|
|
256
256
|
layouts.keys[0]
|
257
257
|
end
|
258
258
|
|
259
|
+
def self.hide_manual_evaluation?
|
260
|
+
Organization.safe_current&.prevent_manual_evaluation_content
|
261
|
+
end
|
262
|
+
|
259
263
|
def self.with_pending_assignments_for(user, relation)
|
260
264
|
relation.
|
261
265
|
joins("left join assignments assignments
|
@@ -266,6 +270,7 @@ class Exercise < ApplicationRecord
|
|
266
270
|
#{Mumuki::Domain::Status::Submission::Passed.to_i},
|
267
271
|
#{Mumuki::Domain::Status::Submission::ManualEvaluationPending.to_i}
|
268
272
|
)").
|
269
|
-
where('assignments.id is null')
|
273
|
+
where('assignments.id is null').
|
274
|
+
where(('exercises.manual_evaluation = false' if hide_manual_evaluation?))
|
270
275
|
end
|
271
276
|
end
|
data/app/models/message.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
class Message < ApplicationRecord
|
2
|
+
include WithSoftDeletion
|
2
3
|
|
3
4
|
belongs_to :discussion, optional: true
|
4
5
|
belongs_to :assignment, foreign_key: :submission_id, primary_key: :submission_id, optional: true
|
@@ -10,7 +11,6 @@ class Message < ApplicationRecord
|
|
10
11
|
validates_presence_of :submission_id, :unless => :discussion_id?
|
11
12
|
|
12
13
|
after_save :update_counters_cache!
|
13
|
-
after_destroy :update_counters_cache!
|
14
14
|
|
15
15
|
markdown_on :content
|
16
16
|
|
@@ -43,7 +43,8 @@ class Message < ApplicationRecord
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def to_resource_h
|
46
|
-
as_json(except: [:id, :type, :discussion_id, :approved, :
|
46
|
+
as_json(except: [:id, :type, :discussion_id, :approved, :approved_at, :approved_by_id,
|
47
|
+
:not_actually_a_question, :deletion_motive, :deleted_at, :deleted_by_id],
|
47
48
|
include: {exercise: {only: [:bibliotheca_id]}})
|
48
49
|
.merge(organization: Organization.current.name)
|
49
50
|
end
|
data/app/models/organization.rb
CHANGED
@@ -33,7 +33,7 @@ class Organization < ApplicationRecord
|
|
33
33
|
after_create :reindex_usages!
|
34
34
|
after_update :reindex_usages!, if: lambda { |user| user.saved_change_to_book_id? }
|
35
35
|
|
36
|
-
has_many :guides, through: 'usages', source: 'item', source_type: 'Guide'
|
36
|
+
has_many :guides, -> { where 'usages.parent_item_type' => 'Lesson' }, through: 'usages', source: 'item', source_type: 'Guide'
|
37
37
|
has_many :exercises, through: :guides
|
38
38
|
has_many :assignments, through: :exercises
|
39
39
|
has_many :exams
|
data/app/models/user.rb
CHANGED
@@ -211,6 +211,10 @@ class User < ApplicationRecord
|
|
211
211
|
name.split.map(&:first).map(&:capitalize).join(' ')
|
212
212
|
end
|
213
213
|
|
214
|
+
def abbreviated_name
|
215
|
+
"#{first_name} #{last_name.first.capitalize + '.' if last_name.present?}".strip
|
216
|
+
end
|
217
|
+
|
214
218
|
def progress_at(content, organization)
|
215
219
|
Indicator.find_or_initialize_by(user: self, organization: organization, content: content)
|
216
220
|
end
|
@@ -283,11 +287,11 @@ class User < ApplicationRecord
|
|
283
287
|
end
|
284
288
|
|
285
289
|
def formal_first_name
|
286
|
-
verified_first_name || first_name
|
290
|
+
verified_first_name.presence || first_name
|
287
291
|
end
|
288
292
|
|
289
293
|
def formal_last_name
|
290
|
-
verified_last_name || last_name
|
294
|
+
verified_last_name.presence || last_name
|
291
295
|
end
|
292
296
|
|
293
297
|
def formal_full_name
|
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: 9.
|
4
|
+
version: 9.2.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: 2021-
|
11
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -301,6 +301,7 @@ files:
|
|
301
301
|
- app/models/concerns/with_scoped_queries/page.rb
|
302
302
|
- app/models/concerns/with_scoped_queries/sort.rb
|
303
303
|
- app/models/concerns/with_slug.rb
|
304
|
+
- app/models/concerns/with_soft_deletion.rb
|
304
305
|
- app/models/concerns/with_target_audience.rb
|
305
306
|
- app/models/concerns/with_terms_acceptance.rb
|
306
307
|
- app/models/concerns/with_timed_enablement.rb
|
@@ -661,6 +662,7 @@ files:
|
|
661
662
|
- db/migrate/20210302181654_add_faqs_to_organizations.rb
|
662
663
|
- db/migrate/20210308145910_add_approved_by_and_at_to_message.rb
|
663
664
|
- db/migrate/20210310195602_add_delete_account_token_to_user.rb
|
665
|
+
- db/migrate/20210318191512_add_deletion_fields_to_message.rb
|
664
666
|
- db/migrate/20210318194559_add_dates_to_certificate_program.rb
|
665
667
|
- db/migrate/20210318195238_rename_certificate_dates.rb
|
666
668
|
- db/migrate/20210330175706_create_exam_registration_user_join_table.rb
|