mumuki-domain 7.0.6 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -15
- data/app/models/application_record.rb +2 -2
- data/app/models/book.rb +5 -12
- data/app/models/concerns/guide_container.rb +1 -0
- data/app/models/concerns/with_content.rb +13 -0
- data/app/models/concerns/with_usages.rb +15 -0
- data/app/models/exercise.rb +1 -1
- data/app/models/guide.rb +2 -0
- data/app/models/topic.rb +2 -2
- data/app/models/topic_container.rb +3 -1
- data/app/models/usage.rb +14 -1
- data/db/migrate/20191022180238_remove_choice_values_from_exercises.rb +5 -0
- data/lib/mumuki/domain/factories/exercise_factory.rb +4 -0
- data/lib/mumuki/domain/factories/guide_factory.rb +7 -0
- data/lib/mumuki/domain/factories/topic_factory.rb +6 -0
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe0f9389e1714c564320f373c82d35b3b84a3c27bd68af16584c68c4f38639f8
|
4
|
+
data.tar.gz: ca0b57c648127393d93ffab7c5beee55d6abdb31e80f37f33b787f33470ec171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cd397c42e1b6f16d4b903a5829087758eeb75ca190c2eb0902866a688a124f982e18fca28ca997d26b118eb8a0efa3a35f37b23b3e0a3ffab292fd7ee6c70ee
|
7
|
+
data.tar.gz: 49a329e6663553e44e6865e44224d9f27fa0befefd6bdcfb04fe460800a9b42a5f7aadd56c09793dbf7c8983531aae6a54f7a75659676e0eb3b9e23795590e7c
|
data/README.md
CHANGED
@@ -5,28 +5,32 @@
|
|
5
5
|
### `Language`
|
6
6
|
|
7
7
|
```
|
8
|
-
name
|
9
8
|
comment_type
|
10
|
-
runner_url
|
11
|
-
output_content_type
|
12
|
-
prompt
|
13
|
-
extension
|
14
|
-
highlight_mode
|
15
|
-
visible_success_output
|
16
9
|
devicon
|
17
|
-
|
10
|
+
editor_css_urls
|
11
|
+
editor_html_urls
|
12
|
+
editor_js_urls
|
13
|
+
editor_shows_loading_content
|
14
|
+
expectations
|
15
|
+
extension
|
18
16
|
feedback
|
19
|
-
|
17
|
+
highlight_mode
|
18
|
+
layout_css_urls
|
19
|
+
layout_html_urls
|
20
|
+
layout_js_urls
|
21
|
+
layout_shows_loading_content
|
20
22
|
multifile
|
23
|
+
name
|
24
|
+
output_content_type
|
25
|
+
prompt
|
26
|
+
queriable
|
27
|
+
runner_url
|
28
|
+
settings
|
21
29
|
stateful_console
|
22
30
|
test_extension
|
23
31
|
test_template
|
24
|
-
|
25
|
-
|
26
|
-
layout_css_urls
|
27
|
-
editor_js_urls
|
28
|
-
editor_html_urls
|
29
|
-
editor_css_urls
|
32
|
+
triable
|
33
|
+
visible_success_output
|
30
34
|
```
|
31
35
|
|
32
36
|
_as defined in `Language#to_resource_h`_
|
@@ -67,9 +67,9 @@ class ApplicationRecord < ActiveRecord::Base
|
|
67
67
|
|
68
68
|
def self.aggregate_of(association)
|
69
69
|
class_eval do
|
70
|
-
define_method(
|
70
|
+
define_method("rebuild_#{association}!") do |children|
|
71
71
|
transaction do
|
72
|
-
self.send(association).all_except(children).
|
72
|
+
self.send(association).all_except(children).destroy_all
|
73
73
|
self.update! association => children
|
74
74
|
children.each &:save!
|
75
75
|
end
|
data/app/models/book.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
class Book < Content
|
2
2
|
numbered :chapters
|
3
3
|
aggregate_of :chapters
|
4
|
+
aggregate_of :complements
|
4
5
|
|
5
6
|
has_many :chapters, -> { order(number: :asc) }, dependent: :destroy
|
7
|
+
has_many :topics, through: :chapters
|
6
8
|
has_many :complements, dependent: :destroy
|
7
9
|
|
8
10
|
has_many :exercises, through: :chapters
|
@@ -11,6 +13,8 @@ class Book < Content
|
|
11
13
|
|
12
14
|
delegate :first_lesson, to: :first_chapter
|
13
15
|
|
16
|
+
alias_method :children, :topics
|
17
|
+
|
14
18
|
def to_s
|
15
19
|
slug
|
16
20
|
end
|
@@ -23,13 +27,11 @@ class Book < Content
|
|
23
27
|
user.try(:last_lesson)|| first_lesson
|
24
28
|
end
|
25
29
|
|
26
|
-
after_save :reindex_usages!
|
27
|
-
|
28
30
|
def import_from_resource_h!(resource_h)
|
29
31
|
self.assign_attributes resource_h.except(:chapters, :complements, :id, :description)
|
30
32
|
self.description = resource_h[:description]&.squeeze(' ')
|
31
33
|
|
32
|
-
|
34
|
+
rebuild_chapters! resource_h[:chapters].map { |it| Topic.find_by!(slug: it).as_chapter_of(self) }
|
33
35
|
rebuild_complements! resource_h[:complements].to_a.map { |it| Guide.find_by(slug: it)&.as_complement_of(self) }.compact
|
34
36
|
end
|
35
37
|
|
@@ -39,15 +41,6 @@ class Book < Content
|
|
39
41
|
complements: complements.map(&:slug))
|
40
42
|
end
|
41
43
|
|
42
|
-
def rebuild_complements!(complements) #FIXME use rebuild
|
43
|
-
transaction do
|
44
|
-
self.complements.all_except(complements).delete_all
|
45
|
-
self.update! :complements => complements
|
46
|
-
complements.each &:save!
|
47
|
-
end
|
48
|
-
reload
|
49
|
-
end
|
50
|
-
|
51
44
|
def index_usage!(organization)
|
52
45
|
organization.index_usage_of! self, self
|
53
46
|
[chapters, complements].flatten.each { |item| item.index_usage! organization }
|
@@ -16,6 +16,21 @@ module WithUsages
|
|
16
16
|
item.is_a?(type) ? item : nil
|
17
17
|
end
|
18
18
|
|
19
|
+
class_methods do
|
20
|
+
def aggregate_of(association)
|
21
|
+
super
|
22
|
+
|
23
|
+
revamp "rebuild_#{association}!" do |_, this, children, hyper|
|
24
|
+
old_children = this.send association
|
25
|
+
added_children = children - old_children
|
26
|
+
hyper.(children)
|
27
|
+
this.usages.each { |it| it.index_children!(added_children) }
|
28
|
+
|
29
|
+
this
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
19
34
|
private
|
20
35
|
|
21
36
|
def ensure_unused!
|
data/app/models/exercise.rb
CHANGED
data/app/models/guide.rb
CHANGED
data/app/models/topic.rb
CHANGED
@@ -9,7 +9,7 @@ class Topic < Content
|
|
9
9
|
|
10
10
|
markdown_on :appendix
|
11
11
|
|
12
|
-
|
12
|
+
alias_method :children, :guides
|
13
13
|
|
14
14
|
def pending_lessons(user)
|
15
15
|
guides.
|
@@ -30,7 +30,7 @@ class Topic < Content
|
|
30
30
|
def import_from_resource_h!(resource_h)
|
31
31
|
self.assign_attributes resource_h.except(:lessons, :description)
|
32
32
|
self.description = resource_h[:description].squeeze(' ')
|
33
|
-
|
33
|
+
rebuild_lessons! resource_h[:lessons].to_a.map { |it| lesson_for(it) }
|
34
34
|
end
|
35
35
|
|
36
36
|
def to_expanded_resource_h
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module TopicContainer
|
2
2
|
extend ActiveSupport::Concern
|
3
|
+
include WithContent
|
4
|
+
|
3
5
|
included do
|
4
6
|
validates_presence_of :topic
|
5
7
|
|
@@ -10,7 +12,7 @@ module TopicContainer
|
|
10
12
|
:description,
|
11
13
|
:description_html,
|
12
14
|
:description_teaser_html,
|
13
|
-
:
|
15
|
+
:rebuild_lessons!,
|
14
16
|
:lessons,
|
15
17
|
:guides,
|
16
18
|
:pending_guides,
|
data/app/models/usage.rb
CHANGED
@@ -7,9 +7,22 @@ class Usage < ApplicationRecord
|
|
7
7
|
scope :in_organization, ->(organization = Organization.current) { where(organization_id: organization.id) }
|
8
8
|
|
9
9
|
before_save :set_slug
|
10
|
+
before_destroy :destroy_children_usages!
|
11
|
+
|
12
|
+
def self.destroy_all_where(query)
|
13
|
+
where(query).destroy_all
|
14
|
+
end
|
10
15
|
|
11
16
|
def self.destroy_usages_for(record)
|
12
|
-
|
17
|
+
destroy_all_where(parent_item: record)
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy_children_usages!
|
21
|
+
item.children.each { |child| Usage.destroy_all_where(item: child, organization: organization) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def index_children!(children)
|
25
|
+
children.each { |it| it.index_usage! organization }
|
13
26
|
end
|
14
27
|
|
15
28
|
private
|
@@ -65,6 +65,10 @@ FactoryBot.define do
|
|
65
65
|
|
66
66
|
factory :exercise, parent: :problem
|
67
67
|
|
68
|
+
factory :indexed_exercise, parent: :exercise do
|
69
|
+
guide { create(:indexed_guide) }
|
70
|
+
end
|
71
|
+
|
68
72
|
factory :x_equal_5_exercise, parent: :exercise do
|
69
73
|
test { 'describe "x" $ do
|
70
74
|
it "should be equal 5" $ do
|
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.0
|
4
|
+
version: 7.1.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:
|
11
|
+
date: 2020-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- app/models/concerns/submittable/triable.rb
|
266
266
|
- app/models/concerns/with_assignments.rb
|
267
267
|
- app/models/concerns/with_case_insensitive_search.rb
|
268
|
+
- app/models/concerns/with_content.rb
|
268
269
|
- app/models/concerns/with_description.rb
|
269
270
|
- app/models/concerns/with_discussion_creation.rb
|
270
271
|
- app/models/concerns/with_discussion_creation/subscription.rb
|
@@ -587,6 +588,7 @@ files:
|
|
587
588
|
- db/migrate/20190918134321_remove_new_expectations.rb
|
588
589
|
- db/migrate/20190918140026_add_custom_expectations.rb
|
589
590
|
- db/migrate/20190929180601_add_expectations_to_language.rb
|
591
|
+
- db/migrate/20191022180238_remove_choice_values_from_exercises.rb
|
590
592
|
- lib/mumuki/domain.rb
|
591
593
|
- lib/mumuki/domain/engine.rb
|
592
594
|
- lib/mumuki/domain/evaluation.rb
|