mumuki-domain 6.1.3 → 6.1.4

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
  SHA1:
3
- metadata.gz: 1015d1992dc8a0826caf33b125a04ad1a76e0f36
4
- data.tar.gz: 68256c60ca438d64364fdc368c3e1de86d3e963e
3
+ metadata.gz: bb99fbaf15499ef0b00d1767fa05b708ad0c216c
4
+ data.tar.gz: a71ee03b993434f5a2e95d64036868aca0f06270
5
5
  SHA512:
6
- metadata.gz: 6222785a7d4c84c2483d05175b72df0af34112356a041003cfe6fdb54b087106e1c7a1ae9673925298cd64e9f58ab9421b3fd6d1368d68be5a4f261bb9ab8dbb
7
- data.tar.gz: 5f98506d27dfe6d713bdc19cfae00ec8558cb4db92e65966033e78f95e5dc4c2de5e75e6ae6b2b0864bcf6ebb1a5777925b606e8b1b58bf5611e23c32b49c5e3
6
+ metadata.gz: 522983d0523374e99da3cf410ff620cc3f6c570a7b7487d1ace5e4467c46f7144a34da2d4ecdf962cfbf1e394c1984ecdc9f37a3b3de2a44682a53a9989bfdd0
7
+ data.tar.gz: 11ab111e86471b8b777d8e0736fe5decf56102a612fcf13986c465e6dc8bae92f421d00c03e601b22c6aab2a7733ec7e9b81a95347713df160de3c9f59e3bc37
@@ -65,7 +65,7 @@ class Assignment < ApplicationRecord
65
65
 
66
66
  def content=(content)
67
67
  if content.present?
68
- self.solution = exercise.single_choice? ? exercise.choices.index(content) : content
68
+ self.solution = exercise.single_choice? ? exercise.choice_index_for(content) : content
69
69
  end
70
70
  end
71
71
 
@@ -15,7 +15,7 @@ module WithEditor
15
15
  end
16
16
 
17
17
  def pretty_choices
18
- choices.each_with_index.map do |choice, index|
18
+ choice_values.each_with_index.map do |choice, index|
19
19
  struct id: "content_choice_#{index}",
20
20
  index: index,
21
21
  value: choice,
@@ -19,6 +19,7 @@ class Exercise < ApplicationRecord
19
19
  belongs_to :guide
20
20
  defaults { self.submissions_count = 0 }
21
21
 
22
+ serialize :choices, Array
22
23
  validates_presence_of :submissions_count,
23
24
  :guide, :bibliotheca_id
24
25
 
@@ -85,7 +86,7 @@ class Exercise < ApplicationRecord
85
86
  reset!
86
87
 
87
88
  attrs = whitelist_attributes(resource_h, except: [:type, :id])
88
- attrs[:choices] = resource_h[:choices]&.map { |choice| choice[:value] }.to_a
89
+ attrs[:choices] = resource_h[:choices].to_a
89
90
  attrs[:bibliotheca_id] = resource_h[:id]
90
91
  attrs[:number] = number
91
92
  attrs[:manual_evaluation] ||= false
@@ -95,6 +96,14 @@ class Exercise < ApplicationRecord
95
96
  save!
96
97
  end
97
98
 
99
+ def choice_values
100
+ self[:choice_values].presence || choices.map { |it| it.indifferent_get(:value) }
101
+ end
102
+
103
+ def choice_index_for(value)
104
+ choice_values.index(value)
105
+ end
106
+
98
107
  def to_resource_h
99
108
  language_resource_h = language.to_embedded_resource_h if language != guide.language
100
109
  as_json(only: %i(name layout editor description corollary teacher_info hint test manual_evaluation locale extra
@@ -0,0 +1,6 @@
1
+ class RenameChoicesColumn < ActiveRecord::Migration[5.1]
2
+ def change
3
+ rename_column :exercises, :choices, :choice_values
4
+ add_column :exercises, :choices, :text
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '6.1.3'
3
+ VERSION = '6.1.4'
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.1.3
4
+ version: 6.1.4
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-11-23 00:00:00.000000000 Z
11
+ date: 2018-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.10'
89
+ version: '1.11'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.10'
96
+ version: '1.11'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: mumukit-directives
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -500,6 +500,7 @@ files:
500
500
  - db/migrate/20181113183935_rename_guide_contributors_to_collaborators.rb
501
501
  - db/migrate/20181114201620_add_test_template_to_languages.rb
502
502
  - db/migrate/20181117190241_add_feedback_to_language.rb
503
+ - db/migrate/20181121165956_rename_choices_column.rb
503
504
  - lib/mumuki/domain.rb
504
505
  - lib/mumuki/domain/engine.rb
505
506
  - lib/mumuki/domain/evaluation.rb