mumuki-domain 7.5.1 → 7.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/assignment.rb +2 -0
  3. data/app/models/book.rb +17 -2
  4. data/app/models/concerns/{with_content.rb → container.rb} +1 -1
  5. data/app/models/concerns/contextualization.rb +1 -1
  6. data/app/models/concerns/guide_container.rb +1 -1
  7. data/app/models/concerns/submittable/solvable.rb +9 -3
  8. data/app/models/concerns/topic_container.rb +1 -1
  9. data/app/models/concerns/with_discussions.rb +9 -6
  10. data/app/models/concerns/with_layout.rb +5 -1
  11. data/app/models/concerns/with_progress.rb +4 -0
  12. data/app/models/concerns/with_scoped_queries.rb +9 -9
  13. data/app/models/concerns/with_scoped_queries/page.rb +1 -1
  14. data/app/models/concerns/with_scoped_queries/sort.rb +6 -1
  15. data/app/models/course.rb +18 -7
  16. data/app/models/discussion.rb +51 -13
  17. data/app/models/exam.rb +53 -23
  18. data/app/models/exam/passing_criterion.rb +53 -0
  19. data/app/models/exercise/challenge.rb +1 -1
  20. data/app/models/exercise/problem.rb +6 -0
  21. data/app/models/exercise/reading.rb +4 -0
  22. data/app/models/invitation.rb +7 -1
  23. data/app/models/message.rb +28 -4
  24. data/app/models/organization.rb +18 -11
  25. data/app/models/user.rb +36 -4
  26. data/db/migrate/20200601203033_add_course_to_exam.rb +5 -0
  27. data/db/migrate/20200605161350_add_passing_criterions_to_exam.rb +6 -0
  28. data/db/migrate/20200608132959_add_progressive_display_lookahead_to_organizations.rb +5 -0
  29. data/db/migrate/20200702165503_add_messages_count_to_discussion.rb +6 -0
  30. data/db/migrate/20200728162727_add_not_actually_a_question_field_to_messages.rb +5 -0
  31. data/db/migrate/20200728163038_add_requires_moderator_response_to_discussions.rb +5 -0
  32. data/db/migrate/20200730221001_add_trusted_for_forum_to_user.rb +5 -0
  33. data/db/migrate/20200731081757_add_last_moderator_access_fields_to_discussion.rb +6 -0
  34. data/lib/mumuki/domain.rb +2 -0
  35. data/lib/mumuki/domain/area.rb +13 -0
  36. data/lib/mumuki/domain/exceptions.rb +2 -0
  37. data/lib/mumuki/domain/exceptions/disabled_organization_error.rb +2 -0
  38. data/lib/mumuki/domain/exceptions/unprepared_organization_error.rb +2 -0
  39. data/lib/mumuki/domain/factories/course_factory.rb +2 -0
  40. data/lib/mumuki/domain/factories/discussion_factory.rb +2 -2
  41. data/lib/mumuki/domain/factories/exam_factory.rb +1 -0
  42. data/lib/mumuki/domain/factories/message_factory.rb +1 -6
  43. data/lib/mumuki/domain/helpers/organization.rb +6 -1
  44. data/lib/mumuki/domain/helpers/user.rb +6 -6
  45. data/lib/mumuki/domain/locales/activerecord/en.yml +1 -0
  46. data/lib/mumuki/domain/locales/activerecord/es.yml +1 -0
  47. data/lib/mumuki/domain/locales/activerecord/pt.yml +1 -0
  48. data/lib/mumuki/domain/organization/settings.rb +19 -7
  49. data/lib/mumuki/domain/status/discussion/discussion.rb +2 -6
  50. data/lib/mumuki/domain/submission/base.rb +6 -0
  51. data/lib/mumuki/domain/submission/solution.rb +3 -1
  52. data/lib/mumuki/domain/version.rb +1 -1
  53. data/lib/mumuki/domain/workspace.rb +38 -0
  54. metadata +17 -5
@@ -28,9 +28,9 @@ module Mumuki::Domain::Helpers::User
28
28
  role_here = "#{role}_here?"
29
29
 
30
30
  # Tells whether this user has #{role} permissions in
31
- # the given organization
32
- define_method role_of do |organization|
33
- has_permission? role, organization.slug
31
+ # the given `slug_like`
32
+ define_method role_of do |slug_like|
33
+ has_permission? role, slug_like.to_mumukit_slug
34
34
  end
35
35
 
36
36
  # Tells whether this user has #{role} permissions in
@@ -49,9 +49,9 @@ module Mumuki::Domain::Helpers::User
49
49
  (Mumukit::Auth::Roles::ROLES - [:owner]).each do |role|
50
50
 
51
51
  # Assignes the #{role} role to this user
52
- # for the given slug
53
- define_method "make_#{role}_of!" do |slug|
54
- add_permission! role, slug
52
+ # for the given `grant_like`
53
+ define_method "make_#{role}_of!" do |grant_like|
54
+ add_permission! role, grant_like.to_mumukit_grant
55
55
  end
56
56
  end
57
57
 
@@ -27,3 +27,4 @@ en:
27
27
  attributes:
28
28
  base:
29
29
  consistent_public_login: 'A public organization can not restrict login methods'
30
+ invalid_activity_range: 'The organization activity range are not valid'
@@ -44,6 +44,7 @@ es:
44
44
  attributes:
45
45
  base:
46
46
  consistent_public_login: 'Una organización pública no puede restringir los métodos de login'
47
+ invalid_activity_range: 'La fecha de deshabilitación no puede ser anterior a la de inicio del recorrido'
47
48
  models:
48
49
  exercise:
49
50
  one: Ejercicio
@@ -27,3 +27,4 @@ pt:
27
27
  attributes:
28
28
  base:
29
29
  consistent_public_login: 'Uma organização pública não pode restringir métodos de login'
30
+ invalid_activity_range: 'O intervalo de atividades da organização não é válido'
@@ -1,16 +1,20 @@
1
1
  class Mumuki::Domain::Organization::Settings < Mumukit::Platform::Model
2
2
  include Mumukit::Login::LoginSettingsHelpers
3
3
 
4
- model_attr_accessor :login_methods,
4
+ model_attr_accessor :disabled_from,
5
+ :embeddable?,
6
+ :feedback_suggestions_enabled?,
7
+ :forum_discussions_minimal_role,
8
+ :forum_enabled?,
9
+ :forum_only_for_trusted?,
10
+ :gamification_enabled?,
11
+ :immersive?,
12
+ :in_preparation_until,
13
+ :login_methods,
5
14
  :login_provider,
6
15
  :login_provider_settings,
7
- :forum_discussions_minimal_role,
8
- :raise_hand_enabled?,
9
- :feedback_suggestions_enabled?,
10
16
  :public?,
11
- :embeddable?,
12
- :immersive?,
13
- :forum_enabled?,
17
+ :raise_hand_enabled?,
14
18
  :report_issue_enabled?
15
19
 
16
20
  def private?
@@ -24,4 +28,12 @@ class Mumuki::Domain::Organization::Settings < Mumukit::Platform::Model
24
28
  def forum_discussions_minimal_role
25
29
  (@forum_discussions_minimal_role || 'student').to_sym
26
30
  end
31
+
32
+ def disabled?
33
+ disabled_from.present? && disabled_from.to_datetime < DateTime.now
34
+ end
35
+
36
+ def in_preparation?
37
+ in_preparation_until.present? && in_preparation_until.to_datetime > DateTime.now
38
+ end
27
39
  end
@@ -14,10 +14,6 @@ module Mumuki::Domain::Status::Discussion
14
14
  define_method(selector) { false }
15
15
  end
16
16
 
17
- def allowed_for?(*)
18
- true
19
- end
20
-
21
17
  def reachable_statuses_for_moderator(*)
22
18
  []
23
19
  end
@@ -38,7 +34,7 @@ module Mumuki::Domain::Status::Discussion
38
34
  end
39
35
  end
40
36
 
41
- def allowed_statuses_for(user, discussion)
42
- STATUSES.select { |it| it.allowed_for?(user, discussion) }
37
+ def as_json(_options={})
38
+ to_s
43
39
  end
44
40
  end
@@ -9,6 +9,7 @@ class Mumuki::Domain::Submission::Base
9
9
  :submission_id, :queries, :query_results, :manual_evaluation_comment]
10
10
 
11
11
  attr_accessor *ATTRIBUTES
12
+ attr_accessor :client_result
12
13
 
13
14
  def self.from_attributes(*args)
14
15
  new ATTRIBUTES.zip(args).to_h
@@ -26,6 +27,11 @@ class Mumuki::Domain::Submission::Base
26
27
  results
27
28
  end
28
29
 
30
+ def with_client_result(result)
31
+ self.client_result = result if result.present?
32
+ self
33
+ end
34
+
29
35
  def evaluate!(assignment)
30
36
  try_evaluate! assignment
31
37
  rescue => e
@@ -2,6 +2,8 @@ class Mumuki::Domain::Submission::Solution < Mumuki::Domain::Submission::Persist
2
2
  attr_accessor :content
3
3
 
4
4
  def try_evaluate!(assignment)
5
- assignment.run_tests!(content: content).except(:response_type)
5
+ assignment
6
+ .run_tests!({client_result: client_result}.compact.merge(content: content))
7
+ .except(:response_type)
6
8
  end
7
9
  end
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '7.5.1'
3
+ VERSION = '7.7.2'
4
4
  end
5
5
  end
@@ -0,0 +1,38 @@
1
+ class Mumuki::Domain::Workspace
2
+ attr_accessor :user, :area
3
+
4
+ # area is a organization-like or course-like object
5
+ # that can be converted into slugs, has content and access-rules information
6
+ def initialize(user, area)
7
+ @user = user
8
+ @area = area
9
+ end
10
+
11
+ def annonymous?
12
+ user.nil?
13
+ end
14
+
15
+ def teacher?
16
+ user.teacher_of? area
17
+ end
18
+
19
+ # Takes a didactic sequence of containers and retuns the enabled containers
20
+ # for this user in this workspace.
21
+ #
22
+ # This method does not check the user is actually member of the area,
23
+ # you should check that before sending this message
24
+ #
25
+ def enabled_containers(sequence)
26
+ return sequence if annonymous? || teacher?
27
+
28
+ # TODO refactor when introducing access rules
29
+ if area.progressive_display_lookahead
30
+ user.completed_containers_with_lookahead(
31
+ sequence,
32
+ area.to_organization,
33
+ lookahead: area.progressive_display_lookahead)
34
+ else
35
+ sequence
36
+ end
37
+ end
38
+ 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.5.1
4
+ version: 7.7.2
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-06-05 00:00:00.000000000 Z
11
+ date: 2020-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -252,6 +252,7 @@ files:
252
252
  - app/models/chapter.rb
253
253
  - app/models/complement.rb
254
254
  - app/models/concerns/assistable.rb
255
+ - app/models/concerns/container.rb
255
256
  - app/models/concerns/contextualization.rb
256
257
  - app/models/concerns/disabling.rb
257
258
  - app/models/concerns/friendly_name.rb
@@ -268,7 +269,6 @@ files:
268
269
  - app/models/concerns/topic_container.rb
269
270
  - app/models/concerns/with_assignments.rb
270
271
  - app/models/concerns/with_case_insensitive_search.rb
271
- - app/models/concerns/with_content.rb
272
272
  - app/models/concerns/with_description.rb
273
273
  - app/models/concerns/with_discussion_creation.rb
274
274
  - app/models/concerns/with_discussion_creation/subscription.rb
@@ -299,6 +299,7 @@ files:
299
299
  - app/models/discussion.rb
300
300
  - app/models/event.rb
301
301
  - app/models/exam.rb
302
+ - app/models/exam/passing_criterion.rb
302
303
  - app/models/exam_authorization.rb
303
304
  - app/models/exercise.rb
304
305
  - app/models/exercise/challenge.rb
@@ -604,7 +605,16 @@ files:
604
605
  - db/migrate/20200508191543_create_avatars.rb
605
606
  - db/migrate/20200518135658_add_avatar_to_users.rb
606
607
  - db/migrate/20200527180729_add_disabled_at_to_users.rb
608
+ - db/migrate/20200601203033_add_course_to_exam.rb
609
+ - db/migrate/20200605161350_add_passing_criterions_to_exam.rb
610
+ - db/migrate/20200608132959_add_progressive_display_lookahead_to_organizations.rb
611
+ - db/migrate/20200702165503_add_messages_count_to_discussion.rb
612
+ - db/migrate/20200728162727_add_not_actually_a_question_field_to_messages.rb
613
+ - db/migrate/20200728163038_add_requires_moderator_response_to_discussions.rb
614
+ - db/migrate/20200730221001_add_trusted_for_forum_to_user.rb
615
+ - db/migrate/20200731081757_add_last_moderator_access_fields_to_discussion.rb
607
616
  - lib/mumuki/domain.rb
617
+ - lib/mumuki/domain/area.rb
608
618
  - lib/mumuki/domain/engine.rb
609
619
  - lib/mumuki/domain/evaluation.rb
610
620
  - lib/mumuki/domain/evaluation/automated.rb
@@ -612,10 +622,12 @@ files:
612
622
  - lib/mumuki/domain/exceptions.rb
613
623
  - lib/mumuki/domain/exceptions/blocked_forum_error.rb
614
624
  - lib/mumuki/domain/exceptions/disabled_error.rb
625
+ - lib/mumuki/domain/exceptions/disabled_organization_error.rb
615
626
  - lib/mumuki/domain/exceptions/forbidden_error.rb
616
627
  - lib/mumuki/domain/exceptions/gone_error.rb
617
628
  - lib/mumuki/domain/exceptions/not_found_error.rb
618
629
  - lib/mumuki/domain/exceptions/unauthorized_error.rb
630
+ - lib/mumuki/domain/exceptions/unprepared_organization_error.rb
619
631
  - lib/mumuki/domain/extensions.rb
620
632
  - lib/mumuki/domain/extensions/array.rb
621
633
  - lib/mumuki/domain/extensions/hash.rb
@@ -690,6 +702,7 @@ files:
690
702
  - lib/mumuki/domain/syncable.rb
691
703
  - lib/mumuki/domain/syncable/with_resource_fields.rb
692
704
  - lib/mumuki/domain/version.rb
705
+ - lib/mumuki/domain/workspace.rb
693
706
  homepage: https://mumuki.org
694
707
  licenses:
695
708
  - AGPL-3.0
@@ -709,8 +722,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
709
722
  - !ruby/object:Gem::Version
710
723
  version: '0'
711
724
  requirements: []
712
- rubyforge_project:
713
- rubygems_version: 2.7.7
725
+ rubygems_version: 3.0.8
714
726
  signing_key:
715
727
  specification_version: 4
716
728
  summary: Mumuki Platform's Domain Model