mumuki-domain 8.1.2 → 8.1.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: d712b0423cb797044b5a152a3b5bf64e6d81dea496582fb25327e5e991e0b095
4
- data.tar.gz: 23713d6d62039d41dbc7afa5fc24c539adcca97096f4715fe0b0085a0a05509b
3
+ metadata.gz: 9495d00fe4f85bdc27f5cf67b94e5f09de465a31a795e9e3d56b3f4cd91433e1
4
+ data.tar.gz: 209256d417ff7c98c309b517cd7076a9743ea00de79124b6bec3e735a49a5238
5
5
  SHA512:
6
- metadata.gz: a6371b30ee3e79073e4659645960433008657ed84d8e483417985cf4f69ea99a86567e4a7f609aa2717d56a7941f81287bde7c371e2ef578c50cda142fd3a8bf
7
- data.tar.gz: b3bb549da8ba32b9b870afe4e438d2cc7cfb84f15cca3d7e3ac83be7938f5f7126d68a18fb48ce42f34cbc6e80d70872cae7267c2617af88bc5956765b0e8474
6
+ metadata.gz: 88ccf91cbccb01f15ec513e232d48832e69a0ec9f5153992e91eab56c44183f10a10dc2a4bcd894509708ab97461b4698ecb73485da8d7dfa8826196837e0c3d
7
+ data.tar.gz: 80b0c3ec21c9444dedb05c1c1060035cdd0d5f0f731635ae79e4738c0a0d23c6fbf4ac67d48c6bb0ea70a76ee7e825a05a2afaaad95e8d2be54096636e0e2af0
@@ -126,7 +126,7 @@ class Assignment < Progress
126
126
  end
127
127
 
128
128
  def content=(content)
129
- if content.present?
129
+ if exercise.solvable?
130
130
  self.solution = exercise.single_choice? ? exercise.choice_index_for(content) : content
131
131
  end
132
132
  end
@@ -18,16 +18,12 @@ module WithExpectations
18
18
  self[:expectations] = expectations.map(&:stringify_keys)
19
19
  end
20
20
 
21
- def own_expectations
21
+ def raw_expectations
22
22
  self[:expectations]
23
23
  end
24
24
 
25
- def own_custom_expectations
26
- self[:custom_expectations]
27
- end
28
-
29
25
  def ensure_expectations_format
30
- errors.add :own_expectations,
31
- :invalid_format unless own_expectations.to_a.all? { |it| Mulang::Expectation.valid? it }
26
+ errors.add :raw_expectations,
27
+ :invalid_format unless raw_expectations.to_a.all? { |it| Mulang::Expectation.valid? it }
32
28
  end
33
29
  end
@@ -35,8 +35,7 @@ module WithRandomizations
35
35
 
36
36
  def randomize_field(selector)
37
37
  define_method(selector) do |*args|
38
- return unless super(*args)
39
- randomizer.randomize!(super(*args), seed)
38
+ super(*args).randomize_with randomizer, seed
40
39
  end
41
40
  end
42
41
  end
@@ -1,5 +1,5 @@
1
1
  class Exercise < ApplicationRecord
2
- RANDOMIZED_FIELDS = [:default_content, :description, :extra, :hint, :test]
2
+ RANDOMIZED_FIELDS = [:default_content, :description, :extra, :hint, :test, :expectations, :custom_expectations]
3
3
  BASIC_RESOURCE_FIELDS = %i(
4
4
  name layout editor corollary teacher_info manual_evaluation locale
5
5
  choices assistance_rules randomizations tag_list extra_visible goal
@@ -135,8 +135,6 @@ class Exercise < ApplicationRecord
135
135
  language_resource_h = language.to_embedded_resource_h if language != guide.language
136
136
  as_json(only: BASIC_RESOURCE_FIELDS)
137
137
  .merge(id: bibliotheca_id, language: language_resource_h, type: type.underscore)
138
- .merge(expectations: self[:expectations])
139
- .merge(custom_expectations: self[:custom_expectations])
140
138
  .merge(settings: self[:settings])
141
139
  .merge(RANDOMIZED_FIELDS.map { |it| [it, self[it]] }.to_h)
142
140
  .symbolize_keys
@@ -239,8 +237,8 @@ class Exercise < ApplicationRecord
239
237
  guide.pending_exercises(user)
240
238
  end
241
239
 
242
- def reading?
243
- is_a? ::Reading
240
+ def solvable?
241
+ is_a? ::Problem
244
242
  end
245
243
 
246
244
  private
@@ -8,8 +8,10 @@ class Challenge < Exercise
8
8
  self.layout = self.class.default_layout
9
9
  end
10
10
 
11
- def extra(*)
12
- [guide.extra, super]
11
+ alias_method :own_extra, :extra
12
+
13
+ def extra
14
+ [guide.extra, own_extra]
13
15
  .compact
14
16
  .join("\n")
15
17
  .strip
@@ -21,20 +21,15 @@ class Problem < QueriableChallenge
21
21
  self.expectations = []
22
22
  end
23
23
 
24
+ alias_method :own_expectations, :expectations
25
+ alias_method :own_custom_expectations, :custom_expectations
26
+
24
27
  def expectations
25
- own_expectations + guide_expectations
28
+ own_expectations + guide.expectations
26
29
  end
27
30
 
28
31
  def custom_expectations
29
- "#{own_custom_expectations}\n#{guide_custom_expectations}"
30
- end
31
-
32
- def guide_expectations
33
- guide.expectations
34
- end
35
-
36
- def guide_custom_expectations
37
- guide.custom_expectations
32
+ "#{own_custom_expectations}\n#{guide.custom_expectations}"
38
33
  end
39
34
 
40
35
  def evaluation_criteria?
@@ -1,5 +1,7 @@
1
1
  require_relative './extensions/string'
2
+ require_relative './extensions/symbol'
2
3
  require_relative './extensions/array'
3
4
  require_relative './extensions/module'
4
5
  require_relative './extensions/hash'
6
+ require_relative './extensions/nil'
5
7
  require_relative './extensions/time'
@@ -19,10 +19,8 @@ class Array
19
19
  def multiple?
20
20
  size > 1
21
21
  end
22
- end
23
22
 
24
- class NilClass
25
- def insert_last(element)
26
- [element]
23
+ def randomize_with(randomizer, seed)
24
+ map { |it| it.randomize_with randomizer, seed }
27
25
  end
28
26
  end
@@ -11,4 +11,8 @@ class Hash
11
11
  def markdownified(*keys, **options)
12
12
  map { |k, v| key.in?(keys) ? v.markdownified(options) : v }.to_h
13
13
  end
14
+
15
+ def randomize_with(randomizer, seed)
16
+ transform_values { |v| v.randomize_with randomizer, seed }
17
+ end
14
18
  end
@@ -0,0 +1,17 @@
1
+ class NilClass
2
+ def affable
3
+ end
4
+
5
+ def markdownified(**options)
6
+ end
7
+
8
+ def sanitized
9
+ end
10
+
11
+ def randomize_with(randomizer, seed)
12
+ end
13
+
14
+ def insert_last(element)
15
+ [element]
16
+ end
17
+ end
@@ -59,15 +59,8 @@ class String
59
59
  def sanitized
60
60
  Mumukit::ContentType::Sanitizer.sanitize self
61
61
  end
62
- end
63
-
64
- class NilClass
65
- def affable
66
- end
67
62
 
68
- def markdownified(**options)
69
- end
70
-
71
- def sanitized
63
+ def randomize_with(randomizer, seed)
64
+ randomizer.randomize!(self, seed)
72
65
  end
73
66
  end
@@ -0,0 +1,5 @@
1
+ class Symbol
2
+ def randomize_with(randomizer, seed)
3
+ self.to_s.randomize_with(randomizer, seed).to_sym
4
+ end
5
+ end
@@ -15,7 +15,7 @@ en:
15
15
  attributes:
16
16
  randomizations:
17
17
  invalid_format: 'format is invalid'
18
- own_expectations:
18
+ raw_expectations:
19
19
  invalid_format: 'format is invalid'
20
20
  assistance_rules:
21
21
  invalid_format: 'format is invalid'
@@ -32,7 +32,7 @@ es-CL:
32
32
  attributes:
33
33
  randomizations:
34
34
  invalid_format: 'formato inválido'
35
- own_expectations:
35
+ raw_expectations:
36
36
  invalid_format: 'formato inválido'
37
37
  assistance_rules:
38
38
  invalid_format: 'formato inválido'
@@ -32,7 +32,7 @@ es:
32
32
  attributes:
33
33
  randomizations:
34
34
  invalid_format: 'formato inválido'
35
- own_expectations:
35
+ raw_expectations:
36
36
  invalid_format: 'formato inválido'
37
37
  assistance_rules:
38
38
  invalid_format: 'formato inválido'
@@ -15,7 +15,7 @@ pt:
15
15
  attributes:
16
16
  randomizations:
17
17
  invalid_format: 'o formato é inválido'
18
- own_expectations:
18
+ raw_expectations:
19
19
  invalid_format: 'o formato é inválido'
20
20
  assistance_rules:
21
21
  invalid_format: 'o formato é inválido'
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '8.1.2'
3
+ VERSION = '8.1.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: 8.1.2
4
+ version: 8.1.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: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -656,7 +656,9 @@ files:
656
656
  - lib/mumuki/domain/extensions/array.rb
657
657
  - lib/mumuki/domain/extensions/hash.rb
658
658
  - lib/mumuki/domain/extensions/module.rb
659
+ - lib/mumuki/domain/extensions/nil.rb
659
660
  - lib/mumuki/domain/extensions/string.rb
661
+ - lib/mumuki/domain/extensions/symbol.rb
660
662
  - lib/mumuki/domain/extensions/time.rb
661
663
  - lib/mumuki/domain/factories.rb
662
664
  - lib/mumuki/domain/factories/api_client_factory.rb