mumuki-domain 8.3.1 → 8.4.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 +4 -0
- data/app/models/concerns/guide_container.rb +2 -1
- data/app/models/concerns/with_assignments.rb +1 -0
- data/app/models/concerns/with_assignments_batch.rb +31 -0
- data/app/models/concerns/with_preferences.rb +7 -0
- data/app/models/guide.rb +2 -1
- data/app/models/preferences.rb +17 -0
- data/app/models/stats.rb +4 -0
- data/app/models/topic.rb +8 -7
- data/app/models/user.rb +2 -1
- data/app/models/with_stats.rb +1 -1
- data/db/migrate/20210111125810_add_uppercase_mode_to_user.rb +5 -0
- data/lib/mumuki/domain/incognito.rb +1 -1
- 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: 945a8212dc38bd06d9ce3a7ba70f58fd5ea3fc2ae7076c81727ef2bdfee05979
|
|
4
|
+
data.tar.gz: 79dbe9e02af53932d78b403777c3d03f92dff40844047ce40052a43dbbb361c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a59255b4f0dcf4bb464dea4d0c1efb86cd28b3ce85b7e3f0ba2d74ad735505d82d795425bc704dd7b8e2e0bcb45a4a6ebd6e26d6f942971b4149ee0b09dd21c2
|
|
7
|
+
data.tar.gz: a904b0a41d0c04b09f3dc5afbc4abaf4a228112f57d4f7279798be91a9405b2a9a5bf4d7f0962c55773f3be0add354fecd5ba0e5cc0d5c2e3c91c2b3cea3a38f
|
data/app/models/assignment.rb
CHANGED
|
@@ -263,6 +263,10 @@ class Assignment < Progress
|
|
|
263
263
|
update! misplaced: value if value != misplaced?
|
|
264
264
|
end
|
|
265
265
|
|
|
266
|
+
def self.build_for(user, exercise, organization)
|
|
267
|
+
Assignment.new submitter: user, exercise: exercise, organization: organization
|
|
268
|
+
end
|
|
269
|
+
|
|
266
270
|
private
|
|
267
271
|
|
|
268
272
|
def duplicates_key
|
|
@@ -19,6 +19,7 @@ module WithAssignments
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# TODO: When the organization is used in this one, please change guide.pending_exercises
|
|
22
|
+
# TODO: Please do the same on WithAssignmentsBatch
|
|
22
23
|
def find_assignment_for(user, _organization)
|
|
23
24
|
assignments.find_by(submitter: user)
|
|
24
25
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# WithAssignmentsBatch mirrors the WithAssignment mixin
|
|
2
|
+
# but implements operations in batches, so that they outperform
|
|
3
|
+
# their counterparts
|
|
4
|
+
module WithAssignmentsBatch
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
def find_assignments_for(user, _organization = Organization.current, &block)
|
|
8
|
+
block = block_given? ? block : lambda { |it, _e| it }
|
|
9
|
+
|
|
10
|
+
return exercises.map { |it| block.call nil, it } unless user
|
|
11
|
+
|
|
12
|
+
pairs = exercises.map { |it| [it.id, [nil, it]] }.to_h
|
|
13
|
+
Assignment.where(submitter: user, exercise: exercises).each do |it|
|
|
14
|
+
pairs[it.exercise_id][0] = it
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
pairs.values.map { |assignment, exercise| block.call assignment, exercise }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def statuses_for(user, organization = Organization.current)
|
|
21
|
+
find_assignments_for user, organization do |it|
|
|
22
|
+
it&.status || Mumuki::Domain::Status::Submission::Pending
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def assignments_for(user, organization = Organization.current)
|
|
27
|
+
find_assignments_for user, organization do |it, exercise|
|
|
28
|
+
it || Assignment.build_for(user, exercise, organization)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/app/models/guide.rb
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class Preferences
|
|
2
|
+
include ActiveModel::Model
|
|
3
|
+
|
|
4
|
+
def self.attributes
|
|
5
|
+
[:uppercase_mode]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
attr_accessor *self.attributes
|
|
9
|
+
|
|
10
|
+
def self.from_attributes(*args)
|
|
11
|
+
new self.attributes.zip(args).to_h
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def uppercase?
|
|
15
|
+
uppercase_mode
|
|
16
|
+
end
|
|
17
|
+
end
|
data/app/models/stats.rb
CHANGED
data/app/models/topic.rb
CHANGED
|
@@ -50,18 +50,19 @@ class Topic < Content
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def pending_lessons(user)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
joins(
|
|
53
|
+
lessons
|
|
54
|
+
.includes(:guide)
|
|
55
|
+
.references(:guide)
|
|
56
|
+
.joins('left join exercises exercises on exercises.guide_id = guides.id')
|
|
57
|
+
.joins("left join assignments assignments
|
|
57
58
|
on assignments.exercise_id = exercises.id
|
|
58
59
|
and assignments.submitter_id = #{user.id}
|
|
59
60
|
and assignments.submission_status in (
|
|
60
61
|
#{Mumuki::Domain::Status::Submission::Passed.to_i},
|
|
61
62
|
#{Mumuki::Domain::Status::Submission::ManualEvaluationPending.to_i}
|
|
62
|
-
)")
|
|
63
|
-
where('assignments.id is null')
|
|
64
|
-
group('
|
|
63
|
+
)")
|
|
64
|
+
.where('assignments.id is null')
|
|
65
|
+
.group('guides.id', 'lessons.number', 'lessons.id')
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
private
|
data/app/models/user.rb
CHANGED
|
@@ -7,6 +7,7 @@ class User < ApplicationRecord
|
|
|
7
7
|
Awardee,
|
|
8
8
|
Disabling,
|
|
9
9
|
WithTermsAcceptance,
|
|
10
|
+
WithPreferences,
|
|
10
11
|
Mumuki::Domain::Helpers::User
|
|
11
12
|
|
|
12
13
|
serialize :permissions, Mumukit::Auth::Permissions
|
|
@@ -211,7 +212,7 @@ class User < ApplicationRecord
|
|
|
211
212
|
end
|
|
212
213
|
|
|
213
214
|
def build_assignment(exercise, organization)
|
|
214
|
-
|
|
215
|
+
Assignment.build_for(self, exercise, organization)
|
|
215
216
|
end
|
|
216
217
|
|
|
217
218
|
def pending_siblings_at(content)
|
data/app/models/with_stats.rb
CHANGED
|
@@ -107,7 +107,7 @@ module Mumuki::Domain
|
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
def build_assignment(exercise, organization)
|
|
110
|
-
Assignment.
|
|
110
|
+
Assignment.build_for(self, exercise, organization)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
def pending_siblings_at(content)
|
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.4.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: 2021-01-
|
|
11
|
+
date: 2021-01-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -270,6 +270,7 @@ files:
|
|
|
270
270
|
- app/models/concerns/submittable/triable.rb
|
|
271
271
|
- app/models/concerns/topic_container.rb
|
|
272
272
|
- app/models/concerns/with_assignments.rb
|
|
273
|
+
- app/models/concerns/with_assignments_batch.rb
|
|
273
274
|
- app/models/concerns/with_case_insensitive_search.rb
|
|
274
275
|
- app/models/concerns/with_description.rb
|
|
275
276
|
- app/models/concerns/with_discussion_creation.rb
|
|
@@ -286,6 +287,7 @@ files:
|
|
|
286
287
|
- app/models/concerns/with_messages.rb
|
|
287
288
|
- app/models/concerns/with_name.rb
|
|
288
289
|
- app/models/concerns/with_number.rb
|
|
290
|
+
- app/models/concerns/with_preferences.rb
|
|
289
291
|
- app/models/concerns/with_profile.rb
|
|
290
292
|
- app/models/concerns/with_progress.rb
|
|
291
293
|
- app/models/concerns/with_randomizations.rb
|
|
@@ -326,6 +328,7 @@ files:
|
|
|
326
328
|
- app/models/message.rb
|
|
327
329
|
- app/models/notification.rb
|
|
328
330
|
- app/models/organization.rb
|
|
331
|
+
- app/models/preferences.rb
|
|
329
332
|
- app/models/progress.rb
|
|
330
333
|
- app/models/stats.rb
|
|
331
334
|
- app/models/subscription.rb
|
|
@@ -642,6 +645,7 @@ files:
|
|
|
642
645
|
- db/migrate/20201027134205_add_immersible_to_organization.rb
|
|
643
646
|
- db/migrate/20201027152806_create_terms.rb
|
|
644
647
|
- db/migrate/20201130163114_add_banned_from_forum_to_users.rb
|
|
648
|
+
- db/migrate/20210111125810_add_uppercase_mode_to_user.rb
|
|
645
649
|
- db/migrate/20210114200545_create_exam_registrations.rb
|
|
646
650
|
- db/migrate/20210118180941_create_exam_authorization_request.rb
|
|
647
651
|
- db/migrate/20210118194904_create_notification.rb
|