mumuki-domain 7.7.3 → 7.8.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: 2d90b804c5db198580621210484a9cf0f11fa731691ee6186f98182ca9451dbc
4
- data.tar.gz: 29d6e0e3a262005498185ba6840b1fde83b36d0981c378734022099783981d36
3
+ metadata.gz: 14a6d0b035451e69ddc77479e3f32854ecae51ca0a3c6bc3031f8d68a4b7fcdd
4
+ data.tar.gz: a1dbea618e7a152e55417174cecf35a0338a464cd199b02114d524c65c7c23c5
5
5
  SHA512:
6
- metadata.gz: 81415fdb4e315df30ee1b4556d5cc56fe1252a5bb967fa338606aca498cc7fed213ff54230a5c93e9402a4b2acdd9df86180106ff4d3c1ae04e1aca8448901ec
7
- data.tar.gz: 1296ed07fbc39995631d85b440982b6b8100a46c2b99f7d9c22dbc9a5b5aab1f3544ea833d1646897f6309d38aa0f6a68c7de606290d38f6cc8f1881b54842aa
6
+ metadata.gz: d3e2039abf83cd21c0ef3d6b33bcfcef54db1dc7df1eb91fb771ab218076b484b34a4a7c034a1e945d5ab3f84e739fdffbdba05999e2bb1878430af4698e4678
7
+ data.tar.gz: 1cc3cb4565b4999bfac4f351fffb0d937c28db74c93e26a94267332b9c15ca8812f0bce4c19e2298169a957d008546bde95442a2ca7d798f9912b2bd3c9c39e8
@@ -1,11 +1,11 @@
1
1
  module SiblingsNavigation
2
2
 
3
3
  def next_for(user)
4
- pending_siblings_for(user).select { |it| it.number > number }.sort_by(&:number).first
4
+ user.pending_siblings_at(self).select { |it| it.number > number }.sort_by(&:number).first
5
5
  end
6
6
 
7
7
  def restart(user)
8
- pending_siblings_for(user).sort_by(&:number).first
8
+ user.pending_siblings_at(self).sort_by(&:number).first
9
9
  end
10
10
 
11
11
  def siblings
@@ -5,7 +5,7 @@ module Submittable
5
5
 
6
6
  def find_assignment_and_submit!(user, submission)
7
7
  assignment = assignment_for user
8
- results = submission.run! assignment, evaluation_class.new
8
+ results = user.run_submission! submission, assignment, evaluation_class.new
9
9
  [assignment, results]
10
10
  end
11
11
  end
@@ -28,6 +28,6 @@ module WithAssignments
28
28
  end
29
29
 
30
30
  def assignment_for(user, organization=Organization.current)
31
- find_assignment_for(user, organization) || user.assignments.build(exercise: self, organization: organization)
31
+ find_assignment_for(user, organization) || user.build_assignment(self, organization)
32
32
  end
33
33
  end
@@ -1,6 +1,6 @@
1
1
  module WithProgress
2
2
  def progress_for(user, organization)
3
- Indicator.find_or_initialize_by(user: user, organization: organization, content: self)
3
+ user.progress_at(self, organization)
4
4
  end
5
5
 
6
6
  def completion_percentage_for(user, organization=Organization.current)
data/app/models/guide.rb CHANGED
@@ -42,7 +42,7 @@ class Guide < Content
42
42
  end
43
43
 
44
44
  def next_exercise(user)
45
- pending_exercises(user).order('public.exercises.number asc').first
45
+ user.next_exercise_at(self)
46
46
  end
47
47
 
48
48
  # TODO: Make use of pending_siblings logic
@@ -18,6 +18,7 @@ class Organization < ApplicationRecord
18
18
  has_many :usages
19
19
 
20
20
  validates_presence_of :contact_email, :locale
21
+ validates_presence_of :welcome_email_template, if: :greet_new_users?
21
22
  validates :name, uniqueness: true,
22
23
  presence: true,
23
24
  format: { with: Mumukit::Platform::Organization.anchored_valid_name_regex }
data/app/models/user.rb CHANGED
@@ -39,6 +39,8 @@ class User < ApplicationRecord
39
39
  before_validation :set_uid!
40
40
  validates :uid, presence: true
41
41
 
42
+ after_save :welcome_to_new_organizations!, if: :gained_access_to_new_orga?
43
+
42
44
  resource_fields :uid, :social_id, :email, :permissions, :verified_first_name, :verified_last_name, *profile_fields
43
45
 
44
46
  def last_lesson
@@ -189,8 +191,50 @@ class User < ApplicationRecord
189
191
  name.split.map(&:first).map(&:capitalize).join(' ')
190
192
  end
191
193
 
194
+ def progress_at(content, organization)
195
+ Indicator.find_or_initialize_by(user: self, organization: organization, content: content)
196
+ end
197
+
198
+ def build_assignment(exercise, organization)
199
+ assignments.build(exercise: exercise, organization: organization)
200
+ end
201
+
202
+ def pending_siblings_at(content)
203
+ content.pending_siblings_for(self)
204
+ end
205
+
206
+ def next_exercise_at(guide)
207
+ guide.pending_exercises(self).order('public.exercises.number asc').first
208
+ end
209
+
210
+ def run_submission!(submission, assignment, evaluation)
211
+ submission.run! assignment, evaluation
212
+ end
213
+
214
+ def incognito?
215
+ false
216
+ end
217
+
192
218
  private
193
219
 
220
+ def welcome_to_new_organizations!
221
+ new_accessible_organizations.each do |organization|
222
+ UserMailer.welcome_email(self, organization).deliver_later if organization.greet_new_users?
223
+ end
224
+ end
225
+
226
+ def gained_access_to_new_orga?
227
+ new_accessible_organizations.present?
228
+ end
229
+
230
+ def new_accessible_organizations
231
+ return [] unless saved_change_to_permissions?
232
+
233
+ old, new = saved_change_to_permissions
234
+ new_organizations = (new.any_granted_organizations - old.any_granted_organizations).to_a
235
+ Organization.where(name: new_organizations)
236
+ end
237
+
194
238
  def set_uid!
195
239
  self.uid ||= email
196
240
  end
@@ -0,0 +1,5 @@
1
+ class AddIncognitoModeEnabledToOrganization < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :organizations, :incognito_mode_enabled, :boolean
4
+ end
5
+ end
data/lib/mumuki/domain.rb CHANGED
@@ -26,6 +26,7 @@ Mumukit::Platform.configure do |config|
26
26
  end
27
27
 
28
28
  require_relative './domain/area'
29
+ require_relative './domain/incognito'
29
30
  require_relative './domain/evaluation'
30
31
  require_relative './domain/submission'
31
32
  require_relative './domain/status'
@@ -0,0 +1,112 @@
1
+ module Mumuki::Domain
2
+ class IncognitoClass
3
+
4
+ def incognito?
5
+ true
6
+ end
7
+
8
+ # ============
9
+ # Permissions
10
+ # ============
11
+
12
+ def ensure_enabled!
13
+ end
14
+
15
+ def has_student_granted_organizations?
16
+ false
17
+ end
18
+
19
+ def teacher_here?
20
+ false
21
+ end
22
+
23
+ def teacher_of?(*)
24
+ false
25
+ end
26
+
27
+ def profile_completed?
28
+ true
29
+ end
30
+
31
+ def writer?
32
+ false
33
+ end
34
+
35
+ def moderator_here?
36
+ false
37
+ end
38
+
39
+ def can_discuss_here?
40
+ false
41
+ end
42
+
43
+ # ========
44
+ # Visiting
45
+ # ========
46
+
47
+ def visit!(*)
48
+ end
49
+
50
+ # ========
51
+ # Progress
52
+ # ========
53
+
54
+ def next_exercise_at(guide)
55
+ guide.exercises.first
56
+ end
57
+
58
+ # def completed_containers_with_lookahead(*)
59
+ # raise 'Unsupported operation. Userless mode and progressive display modes are incompatible'
60
+ # end
61
+
62
+ def progress_at(content, organization)
63
+ Indicator.new content: content, organization: organization
64
+ end
65
+
66
+ def build_assignment(exercise, organization)
67
+ Assignment.new exercise: exercise, organization: organization, submitter: self
68
+ end
69
+
70
+ def pending_siblings_at(content)
71
+ []
72
+ end
73
+
74
+ # ============
75
+ # ActiveRecord
76
+ # ============
77
+
78
+ def id
79
+ '<incognito>'
80
+ end
81
+
82
+ def is_a?(other)
83
+ other.is_a?(Class) && other.name == 'User' || super
84
+ end
85
+
86
+ def _read_attribute(key)
87
+ return id if key == 'id'
88
+ raise "unknown attribute #{key}"
89
+ end
90
+
91
+ def self.primary_key
92
+ 'id'
93
+ end
94
+
95
+ # ==========
96
+ # Evaluation
97
+ # ==========
98
+
99
+ def interpolations
100
+ []
101
+ end
102
+
103
+ def run_submission!(submission, assignment, evaluation)
104
+ results = submission.dry_run! assignment, evaluation
105
+ assignment.assign_attributes results
106
+ results
107
+ end
108
+
109
+ end
110
+
111
+ Incognito = IncognitoClass.new
112
+ end
@@ -11,7 +11,8 @@ class Mumuki::Domain::Organization::Profile < Mumukit::Platform::Model
11
11
  :contact_email,
12
12
  :terms_of_service,
13
13
  :community_link,
14
- :errors_explanations
14
+ :errors_explanations,
15
+ :welcome_email_template
15
16
 
16
17
  def locale_json
17
18
  locale_h.to_json
@@ -15,7 +15,8 @@ class Mumuki::Domain::Organization::Settings < Mumukit::Platform::Model
15
15
  :login_provider_settings,
16
16
  :public?,
17
17
  :raise_hand_enabled?,
18
- :report_issue_enabled?
18
+ :report_issue_enabled?,
19
+ :greet_new_users?
19
20
 
20
21
  def private?
21
22
  !public?
@@ -21,12 +21,16 @@ class Mumuki::Domain::Submission::Base
21
21
 
22
22
  def run!(assignment, evaluation)
23
23
  save_submission! assignment
24
- results = evaluation.evaluate! assignment, self
24
+ results = dry_run! assignment, evaluation
25
25
  save_results! results, assignment
26
26
  notify_results! results, assignment
27
27
  results
28
28
  end
29
29
 
30
+ def dry_run!(assignment, evaluation)
31
+ evaluation.evaluate! assignment, self
32
+ end
33
+
30
34
  def with_client_result(result)
31
35
  self.client_result = result if result.present?
32
36
  self
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '7.7.3'
3
+ VERSION = '7.8.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: 7.7.3
4
+ version: 7.8.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: 2020-08-31 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '7.6'
33
+ version: '7.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '7.6'
40
+ version: '7.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mumukit-assistant
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '5.2'
131
+ version: '5.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: '5.2'
138
+ version: '5.1'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: mumukit-sync
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -613,6 +613,7 @@ files:
613
613
  - db/migrate/20200728163038_add_requires_moderator_response_to_discussions.rb
614
614
  - db/migrate/20200730221001_add_trusted_for_forum_to_user.rb
615
615
  - db/migrate/20200731081757_add_last_moderator_access_fields_to_discussion.rb
616
+ - db/migrate/20200804191643_add_incognito_mode_enabled_to_organization.rb
616
617
  - lib/mumuki/domain.rb
617
618
  - lib/mumuki/domain/area.rb
618
619
  - lib/mumuki/domain/engine.rb
@@ -657,12 +658,11 @@ files:
657
658
  - lib/mumuki/domain/helpers/course.rb
658
659
  - lib/mumuki/domain/helpers/organization.rb
659
660
  - lib/mumuki/domain/helpers/user.rb
661
+ - lib/mumuki/domain/incognito.rb
660
662
  - lib/mumuki/domain/locales/activerecord/en.yml
661
- - lib/mumuki/domain/locales/activerecord/es-CL.yml
662
663
  - lib/mumuki/domain/locales/activerecord/es.yml
663
664
  - lib/mumuki/domain/locales/activerecord/pt.yml
664
665
  - lib/mumuki/domain/locales/console_submission/en.yml
665
- - lib/mumuki/domain/locales/console_submission/es-CL.yml
666
666
  - lib/mumuki/domain/locales/console_submission/es.yml
667
667
  - lib/mumuki/domain/locales/console_submission/pt.yml
668
668
  - lib/mumuki/domain/organization.rb
@@ -1,59 +0,0 @@
1
- ---
2
- es-CL:
3
- activerecord:
4
- attributes:
5
- exercise:
6
- description: Descripción
7
- extra: Biblioteca
8
- hint: Ayudas
9
- language: Lenguaje
10
- locale: Idioma
11
- tag_list: Etiquetas
12
- title: Título
13
- guide:
14
- description: Descripción
15
- github_repository: Repositorio Github
16
- language: Lenguaje
17
- locale: Idioma
18
- name: Nombre
19
- submission:
20
- content: Contenido
21
- errors:
22
- models:
23
- guide:
24
- attributes:
25
- base:
26
- in_use: 'La guía aún está siendo utilizada en la organización %{organization}'
27
- topic:
28
- attributes:
29
- base:
30
- in_use: 'El tema aún está siendo utilizado en la organización %{organization}'
31
- exercise:
32
- attributes:
33
- randomizations:
34
- invalid_format: 'formato inválido'
35
- own_expectations:
36
- invalid_format: 'formato inválido'
37
- assistance_rules:
38
- invalid_format: 'formato inválido'
39
- name:
40
- invalid_format: 'no debe contener /'
41
- base:
42
- evaluation_criteria_required: 'Tienes que proveer tests y/o expectativas'
43
- organization:
44
- attributes:
45
- base:
46
- consistent_public_login: 'Una organización pública no puede restringir los métodos de login'
47
- invalid_activity_range: 'La fecha de inhabilitación no puede ser anterior a la de inicio del recorrido'
48
- models:
49
- exercise:
50
- one: Ejercicio
51
- other: Ejercicios
52
- chapter:
53
- one: Capítulo
54
- other: Capítulos
55
- guide: Guía
56
- language: Lenguaje
57
- submission:
58
- one: Solución
59
- other: Soluciones
@@ -1,3 +0,0 @@
1
- es-CL:
2
- console_submission:
3
- try_again: ¡Ups! Algo salió mal en mumuki. Reinicia el ejercicio, espera unos segundos y vuelve a intentar.