mumuki-domain 9.13.0 → 9.15.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: cce9f2ab048f758a4122c66f8a3da650a28c3a2ef10aefd8887a89091ba7a2af
4
- data.tar.gz: c55a063f04e3ae7d32750db8b7f520a2bd3f8d37f4411201011fec953ee99079
3
+ metadata.gz: 304bef838324905dba928e6099d897752778b1781ce9c445448f8e9a6601c76d
4
+ data.tar.gz: 28b4571ce4c641fec10223786b7e9ddd367d85e8b45fda84e315ef990efe35a7
5
5
  SHA512:
6
- metadata.gz: d203713ba3bcb38b7d36971a77718ff3887e82d51199e9423635f62a5a244d75433f5aefb7fbfe9c0994971b178dafc655eae03a4b8c9d48bcd0ccc655785441
7
- data.tar.gz: c3b3db4bc2faac6b2ec976aa380fdd5ad203ee248f6fc96a7dccee55c58a794d7c7f11944be3ef75f311bd5f791e87590c676192194c3c4247e4dc53a51f67cf
6
+ metadata.gz: 1727cf0e4115b793e472529251ed7754a2ec4adee510910f0a4d09ebd5c5aa04c2c59dc7b2459b8ab316391e4b0b26422d9c38c4321988b14ca5a27bfc965bcc
7
+ data.tar.gz: e30036eb0b135ebdd26f8ec9fbb782b445955bc2c24695d6ec298f6b7229f26e54360fe7093a1640540081254f0e0e9f6ad469aa56fdf4af1e000b2c48ffde65
@@ -1,6 +1,8 @@
1
1
  class ApplicationRecord < ActiveRecord::Base
2
2
  self.abstract_class = true
3
3
 
4
+ include WithPgLock
5
+
4
6
  delegate :whitelist_attributes, to: :class
5
7
 
6
8
  def self.teaser_on(*args)
@@ -43,20 +43,6 @@ class Assignment < Progress
43
43
  after_initialize :set_default_top_submission_status
44
44
  before_save :award_experience_points!, :update_top_submission!, if: :submission_status_changed?
45
45
  after_save :dirty_parent_by_submission!, if: :completion_changed?
46
- before_validation :set_current_organization!, unless: :organization
47
-
48
- # TODO: Momentary as some assignments may not have an associated organization
49
- def set_current_organization!
50
- self.organization = Organization.current
51
- end
52
-
53
- def recontextualize!(new_organization = Organization.current)
54
- if organization != new_organization
55
- dirty_parent_by_submission! if organization.present? && exercise.used_in?(organization)
56
- self.organization = new_organization
57
- self.parent_id = nil
58
- end
59
- end
60
46
 
61
47
  def set_default_top_submission_status
62
48
  self.top_submission_status ||= 0
@@ -19,4 +19,8 @@ class Organization::Status::Base
19
19
  outsider_access_mode(user)
20
20
  end
21
21
  end
22
+
23
+ def validate!(user = nil)
24
+ validate_enabled! unless user
25
+ end
22
26
  end
@@ -20,9 +20,8 @@ class Organization::Status::Disabled < Organization::Status::Base
20
20
  end
21
21
  end
22
22
 
23
- def validate!(user = nil)
24
- raise Mumuki::Domain::DisabledOrganizationError unless user
23
+ def validate_enabled!
24
+ raise Mumuki::Domain::DisabledOrganizationError
25
25
  end
26
-
27
26
  end
28
27
 
@@ -20,7 +20,6 @@ class Organization::Status::Enabled < Organization::Status::Base
20
20
  end
21
21
  end
22
22
 
23
- def validate!(_user = nil)
23
+ def validate_enabled!
24
24
  end
25
-
26
25
  end
@@ -20,8 +20,7 @@ class Organization::Status::InPreparation < Organization::Status::Base
20
20
  end
21
21
  end
22
22
 
23
- def validate!(user = nil)
24
- raise Mumuki::Domain::UnpreparedOrganizationError unless user
23
+ def validate_enabled!
24
+ raise Mumuki::Domain::UnpreparedOrganizationError
25
25
  end
26
-
27
26
  end
@@ -1,13 +1,11 @@
1
1
  module WithOrganizationStatus
2
2
 
3
+ delegate :validate_enabled!, :access_mode, to: :status
4
+
3
5
  def status
4
6
  @status ||= _status
5
7
  end
6
8
 
7
- def access_mode(user)
8
- status.access_mode(user)
9
- end
10
-
11
9
  def validate_active!
12
10
  status.validate!
13
11
  end
@@ -1,6 +1,5 @@
1
1
  module WithReminders
2
2
  extend ActiveSupport::Concern
3
- include WithPgLock
4
3
 
5
4
  def build_reminder
6
5
  mailer = UserMailer.new
@@ -1,5 +1,4 @@
1
1
  class ExamRegistration < ApplicationRecord
2
- include WithPgLock
3
2
  include WithTimedEnablement
4
3
  include TerminalNavigation
5
4
 
@@ -77,6 +76,14 @@ class ExamRegistration < ApplicationRecord
77
76
  authorization_criterion.meets_criterion?(user, organization)
78
77
  end
79
78
 
79
+ def multiple_options?
80
+ exams.count > 1
81
+ end
82
+
83
+ def ended?
84
+ end_time.past?
85
+ end
86
+
80
87
  private
81
88
 
82
89
  def notify_registree!(registree)
@@ -34,6 +34,14 @@ class OrganizationAccessMode::Base
34
34
  false
35
35
  end
36
36
 
37
+ def restore_indicators?(_content)
38
+ false
39
+ end
40
+
41
+ def read_only?
42
+ false
43
+ end
44
+
37
45
  def validate_discuss_here!(_discussion)
38
46
  raise Mumuki::Domain::ForbiddenError
39
47
  end
@@ -25,6 +25,14 @@ class OrganizationAccessMode::ReadOnly < OrganizationAccessMode::Base
25
25
  (has_scope(:exercises, :submitted) && content.has_progress_for?(user, organization))
26
26
  end
27
27
 
28
+ def restore_indicators?(book)
29
+ !book.has_progress_for?(user, organization) && user.has_assignments_in_organization?(organization)
30
+ end
31
+
32
+ def read_only?
33
+ true
34
+ end
35
+
28
36
  private
29
37
 
30
38
  def has_scope(key, value = :all)
data/app/models/user.rb CHANGED
@@ -54,7 +54,7 @@ class User < ApplicationRecord
54
54
  resource_fields :uid, :social_id, :email, :permissions, :verified_first_name, :verified_last_name, *profile_fields
55
55
  with_temporary_token :delete_account_token
56
56
 
57
- organic_on :notifications
57
+ organic_on :notifications, :assignments
58
58
 
59
59
  def last_lesson
60
60
  last_guide.try(:lesson)
@@ -64,10 +64,6 @@ class User < ApplicationRecord
64
64
  messages.where('assignments.organization': organization)
65
65
  end
66
66
 
67
- def notifications_in_organization(organization = Organization.current)
68
- notifications.where(organization: organization)
69
- end
70
-
71
67
  def passed_submissions_count_in(organization)
72
68
  assignments.where(top_submission_status: Mumuki::Domain::Status::Submission::Passed.to_i, organization: organization).count
73
69
  end
@@ -111,6 +107,16 @@ class User < ApplicationRecord
111
107
  end
112
108
  end
113
109
 
110
+ def restore_organization_progress!(organization)
111
+ assignments_in_organization(organization).each do |assignment|
112
+ assignment.tap(&:parent).save!
113
+ end
114
+ end
115
+
116
+ def has_assignments_in_organization?(organization)
117
+ assignments_in_organization(organization).exists?
118
+ end
119
+
114
120
  def accept_invitation!(invitation)
115
121
  make_student_of! invitation.course_slug
116
122
  end
@@ -52,8 +52,6 @@ class Mumuki::Domain::Submission::Base
52
52
  private
53
53
 
54
54
  def save_submission!(assignment)
55
- assignment.content = content
56
- assignment.recontextualize!
57
55
  assignment.save!
58
56
  end
59
57
 
@@ -1,5 +1,6 @@
1
1
  class Mumuki::Domain::Submission::PersistentSubmission < Mumuki::Domain::Submission::Base
2
2
  def save_submission!(assignment)
3
+ assignment.content = content
3
4
  assignment.running!
4
5
  super
5
6
  assignment.save_submission! self
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '9.13.0'
3
+ VERSION = '9.15.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: 9.13.0
4
+ version: 9.15.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-08-19 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails