mumuki-domain 9.0.2 → 9.0.3

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: 5db86a9ea25dfdc219c9555b5c116413352e4fb080af117985e93ca5bb2c4889
4
- data.tar.gz: '0913300a86ea7880f65997a6bcbf418023c74a3f58dac21361d286d69e1ab528'
3
+ metadata.gz: 07771f9e0e712988ad05c336cabef30fea9af24bbfd6da99dc48d7ab19aee1ba
4
+ data.tar.gz: 52c848e349daf6f371daf73d5ef675c06af6da0eee19ce25f6329db5ff5a9383
5
5
  SHA512:
6
- metadata.gz: 6ae200ee06fe4ef89e24836256fe3be80c99b53d24daa1e6056630f8daf78e55ad391b88b919f07db12e62365f28222c68a7e472ad91b37266bb340ef15e4141
7
- data.tar.gz: 91aceaf7b84e5c014d9d7f600a4a8b205956427615c01fbbca6a581a3f572034aa99a9b12c0f323df21e1772870998ab6c220859361dcc244f22f3f2d95e16a0
6
+ metadata.gz: 556d16f80533171f7e67f9652f84c955a5d9f8d7efdd981ec7b141afb845f4bb880c391486c2a5f2adad434410c0a789a1552b0dd1019d22b24ee149d335c1e7
7
+ data.tar.gz: 00cbc6852719e47a496f2bb2569cd98db9499df559bc9958ca6e482b3ece6c03498540b65cb38c8e0bee813c70e10eeca7ed2c87fc70c80d1a59bc9b407efee0
@@ -275,11 +275,11 @@ class Assignment < Progress
275
275
 
276
276
  def update_submissions_count!
277
277
  self.class.connection.execute(
278
- "update public.exercises
278
+ "update exercises
279
279
  set submissions_count = submissions_count + 1
280
280
  where id = #{exercise.id}")
281
281
  self.class.connection.execute(
282
- "update public.assignments
282
+ "update assignments
283
283
  set submissions_count = submissions_count + 1
284
284
  where id = #{id}")
285
285
  exercise.reload
data/app/models/course.rb CHANGED
@@ -11,7 +11,7 @@ class Course < ApplicationRecord
11
11
 
12
12
  alias_attribute :name, :code
13
13
 
14
- resource_fields :slug, :shifts, :code, :days, :period, :description
14
+ resource_fields :slug, :shifts, :code, :days, :period, :description, :period_start, :period_end
15
15
 
16
16
  def current_invitation
17
17
  invitations.where('expiration_date > ?', Time.now).first
@@ -35,6 +35,26 @@ class Course < ApplicationRecord
35
35
  end
36
36
  end
37
37
 
38
+ def ended?
39
+ period_end.present? && period_end.past?
40
+ end
41
+
42
+ def started?
43
+ period_start.present? && period_start.past?
44
+ end
45
+
46
+ def infer_period_range!
47
+ return if period_start || period_end
48
+
49
+ period =~ /^(\d{4})?/
50
+ year = $1.to_i
51
+
52
+ return nil unless year.between? 2014, (DateTime.now.year + 1)
53
+
54
+ self.period_start = DateTime.new(year).beginning_of_year
55
+ self.period_end = DateTime.new(year).end_of_year
56
+ end
57
+
38
58
  def canonical_code
39
59
  "#{period}-#{code}".downcase
40
60
  end
@@ -167,7 +167,7 @@ class Discussion < ApplicationRecord
167
167
  end
168
168
 
169
169
  def being_accessed_by_moderator?
170
- last_moderator_access_at.present? && last_moderator_access_at > Time.now - MODERATOR_REVIEW_AVERAGE_TIME
170
+ last_moderator_access_at.present? && last_moderator_access_at.future? - MODERATOR_REVIEW_AVERAGE_TIME
171
171
  end
172
172
 
173
173
  def last_moderator_access_visible_for?(user)
@@ -267,4 +267,17 @@ class Exercise < ApplicationRecord
267
267
  def self.default_layout
268
268
  layouts.keys[0]
269
269
  end
270
+
271
+ def self.with_pending_assignments_for(user, relation)
272
+ relation.
273
+ joins("left join assignments assignments
274
+ on assignments.exercise_id = exercises.id
275
+ and assignments.submitter_id = #{user.id}
276
+ and assignments.organization_id = #{Organization.current.id}
277
+ and assignments.submission_status in (
278
+ #{Mumuki::Domain::Status::Submission::Passed.to_i},
279
+ #{Mumuki::Domain::Status::Submission::ManualEvaluationPending.to_i}
280
+ )").
281
+ where('assignments.id is null')
282
+ end
270
283
  end
data/app/models/guide.rb CHANGED
@@ -50,17 +50,8 @@ class Guide < Content
50
50
  end
51
51
  end
52
52
 
53
- # TODO: Make use of pending_siblings logic
54
53
  def pending_exercises(user)
55
- exercises.
56
- joins("left join public.assignments assignments
57
- on assignments.exercise_id = exercises.id
58
- and assignments.submitter_id = #{user.id}
59
- and assignments.submission_status in (
60
- #{Mumuki::Domain::Status::Submission::Passed.to_i},
61
- #{Mumuki::Domain::Status::Submission::ManualEvaluationPending.to_i}
62
- )").
63
- where('assignments.id is null')
54
+ Exercise.with_pending_assignments_for(user, exercises)
64
55
  end
65
56
 
66
57
  def first_exercise
@@ -39,7 +39,7 @@ class Invitation < ApplicationRecord
39
39
  end
40
40
 
41
41
  def expired?
42
- Time.now > expiration_date
42
+ expiration_date.past?
43
43
  end
44
44
 
45
45
  def unexpired
data/app/models/topic.rb CHANGED
@@ -50,18 +50,13 @@ class Topic < Content
50
50
  end
51
51
 
52
52
  def pending_lessons(user)
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
58
- on assignments.exercise_id = exercises.id
59
- and assignments.submitter_id = #{user.id}
60
- and assignments.submission_status in (
61
- #{Mumuki::Domain::Status::Submission::Passed.to_i},
62
- #{Mumuki::Domain::Status::Submission::ManualEvaluationPending.to_i}
63
- )")
64
- .where('assignments.id is null')
53
+ Exercise
54
+ .with_pending_assignments_for(
55
+ user,
56
+ lessons
57
+ .includes(:guide)
58
+ .references(:guide)
59
+ .joins('left join exercises exercises on exercises.guide_id = guides.id'))
65
60
  .group('guides.id', 'lessons.number', 'lessons.id')
66
61
  end
67
62
 
data/app/models/user.rb CHANGED
@@ -223,7 +223,7 @@ class User < ApplicationRecord
223
223
  end
224
224
 
225
225
  def next_exercise_at(guide)
226
- guide.pending_exercises(self).order('public.exercises.number asc').first
226
+ guide.pending_exercises(self).order('exercises.number asc').first
227
227
  end
228
228
 
229
229
  def run_submission!(submission, assignment, evaluation)
@@ -0,0 +1,7 @@
1
+ class AddPeriodStartAndEndToCourse < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :courses, :period_start, :datetime
4
+ add_column :courses, :period_end, :datetime
5
+ end
6
+
7
+ end
@@ -40,10 +40,10 @@ class Mumuki::Domain::Organization::Settings < Mumukit::Platform::Model
40
40
  end
41
41
 
42
42
  def disabled?
43
- disabled_from.present? && disabled_from < Time.now
43
+ disabled_from.present? && disabled_from.past?
44
44
  end
45
45
 
46
46
  def in_preparation?
47
- in_preparation_until.present? && in_preparation_until > Time.now
47
+ in_preparation_until.present? && in_preparation_until.future?
48
48
  end
49
49
  end
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '9.0.2'
3
+ VERSION = '9.0.3'
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.0.2
4
+ version: 9.0.3
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-03-09 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -657,6 +657,7 @@ files:
657
657
  - db/migrate/20210119174504_create_certificate_programs.rb
658
658
  - db/migrate/20210119174835_create_certificates.rb
659
659
  - db/migrate/20210119190204_create_exam_registration_exam_join_table.rb
660
+ - db/migrate/20210301210530_add_period_start_and_end_to_course.rb
660
661
  - db/migrate/20210302181654_add_faqs_to_organizations.rb
661
662
  - lib/mumuki/domain.rb
662
663
  - lib/mumuki/domain/area.rb