mumuki-domain 6.2.2 → 6.3.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: ea320c239feb33a124423439523f74cacc6a96b3fe33af3675cef777eb915580
4
- data.tar.gz: 066d47d6f4074663020d203984e2b48fd4882191a8984bd3b2f7e88e664b528a
3
+ metadata.gz: f3af22410021f5f748fe3b4662ba1703fc03211261181377dc3b10fcbcca24d9
4
+ data.tar.gz: 0e1b4ee077345dcfd7b22634f9f818ad5d70b24a923bb2a5d9617d27145c3ac2
5
5
  SHA512:
6
- metadata.gz: b0e75aa069c6a953691c93b626af83fe7b061af7095c0b082e78061387233d936bcd60e50515663ce8df4411e5b2440e70822c4941b8941f8817e411a975816c
7
- data.tar.gz: ba6e31a9d987788f7dc5b6422e9a1caa7897b870304d68e06bee4b1f5d82b247e30d8581dc68166892b5f22f61727029069c4e70d3bfc8b4b74268b38561f75a
6
+ metadata.gz: 388263f0fc37694d2cb4c15e5e5e867258dc421f2175d9f41845d9eba97a76ac26586a38e4a24da3a778ce7032be0e1141963a7766b319b3108fd0200cf3a899
7
+ data.tar.gz: 0ab961c7820e7c8ac9115b9a41340b0586122ce6a87fbc4f2be54cb5307f0947f7105f5563b6bbeb531fa41bae60ac59f5cc0fd790f603c7bb32f2802d5695ef
@@ -0,0 +1,23 @@
1
+ module WithEditionMode
2
+ extend ActiveSupport::Concern
3
+
4
+ attr_accessor :edition_mode
5
+
6
+ def edit!
7
+ self.edition_mode = true
8
+ end
9
+
10
+ module ClassMethods
11
+ def editable(*selectors)
12
+ selectors.each { |selector| editable_field selector }
13
+ end
14
+
15
+ private
16
+
17
+ def editable_field(selector)
18
+ patch selector do |*args, hyper|
19
+ edition_mode ? self[selector] : hyper.(*args)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,6 +1,4 @@
1
1
  class Exercise < ApplicationRecord
2
- RANDOMIZED_FIELDS = [:default_content, :description, :extra, :hint, :test]
3
-
4
2
  include WithDescription
5
3
  include WithLocale
6
4
  include WithNumber,
@@ -10,7 +8,8 @@ class Exercise < ApplicationRecord
10
8
  WithLanguage,
11
9
  Assistable,
12
10
  WithRandomizations,
13
- WithDiscussions
11
+ WithDiscussions,
12
+ WithEditionMode
14
13
 
15
14
  include Submittable,
16
15
  Questionable
@@ -25,9 +24,11 @@ class Exercise < ApplicationRecord
25
24
  validates_presence_of :submissions_count,
26
25
  :guide, :bibliotheca_id
27
26
 
28
- randomize(*RANDOMIZED_FIELDS)
27
+ randomize :description, :hint, :extra, :test, :default_content
29
28
  delegate :timed?, to: :navigable_parent
30
29
 
30
+ editable :description, :hint, :test, :default_content
31
+
31
32
  def console?
32
33
  queriable?
33
34
  end
@@ -108,12 +109,10 @@ class Exercise < ApplicationRecord
108
109
 
109
110
  def to_resource_h
110
111
  language_resource_h = language.to_embedded_resource_h if language != guide.language
111
- as_json(only: %i(name layout editor corollary teacher_info manual_evaluation locale
112
- choices assistance_rules randomizations tag_list extra_visible goal
112
+ as_json(only: %i(name layout editor description corollary teacher_info hint test manual_evaluation locale extra
113
+ choices expectations assistance_rules randomizations tag_list extra_visible goal default_content
113
114
  free_form_editor_source initial_state final_state))
114
115
  .merge(id: bibliotheca_id, language: language_resource_h, type: type.underscore)
115
- .merge(expectations: self[:expectations])
116
- .merge(RANDOMIZED_FIELDS.map { |it| [it, self[it]] }.to_h)
117
116
  .symbolize_keys
118
117
  .compact
119
118
  end
@@ -168,6 +167,10 @@ class Exercise < ApplicationRecord
168
167
  {}
169
168
  end
170
169
 
170
+ def default_content
171
+ self[:default_content] || ''
172
+ end
173
+
171
174
  # Submits the user solution
172
175
  # only if the corresponding assignment has attemps left
173
176
  def try_submit_solution!(user, solution={})
@@ -16,6 +16,8 @@ class Challenge < Exercise
16
16
  .ensure_newline
17
17
  end
18
18
 
19
+ editable :extra
20
+
19
21
  private
20
22
 
21
23
  def defaults
@@ -25,6 +25,8 @@ class Problem < QueriableChallenge
25
25
  own_expectations + guide_expectations
26
26
  end
27
27
 
28
+ editable :expectations
29
+
28
30
  def guide_expectations
29
31
  guide.expectations
30
32
  end
@@ -75,7 +75,6 @@ class Language < ApplicationRecord
75
75
 
76
76
  # TODO we should use Mumukit::Directives::Pipeline
77
77
  def interpolate(interpolee, *interpolations)
78
- interpolee = interpolee || ''
79
78
  interpolations.inject(interpolee) { |content, interpolation| directives_interpolations.interpolate(content, interpolation).first }
80
79
  end
81
80
 
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '6.2.2'
3
+ VERSION = '6.3.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: 6.2.2
4
+ version: 6.3.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: 2018-12-27 00:00:00.000000000 Z
11
+ date: 2018-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -230,6 +230,7 @@ files:
230
230
  - app/models/concerns/with_discussion_creation/upvote.rb
231
231
  - app/models/concerns/with_discussion_status.rb
232
232
  - app/models/concerns/with_discussions.rb
233
+ - app/models/concerns/with_edition_mode.rb
233
234
  - app/models/concerns/with_editor.rb
234
235
  - app/models/concerns/with_expectations.rb
235
236
  - app/models/concerns/with_language.rb
@@ -618,7 +619,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
618
619
  - !ruby/object:Gem::Version
619
620
  version: '0'
620
621
  requirements: []
621
- rubygems_version: 3.0.1
622
+ rubygems_version: 3.0.0
622
623
  signing_key:
623
624
  specification_version: 4
624
625
  summary: Mumuki Platform's Domain Model