mumuki-domain 6.0.1 → 6.0.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
  SHA1:
3
- metadata.gz: 8de38eb3b005bdc6be72a0f6b3cb4060a603e392
4
- data.tar.gz: 68f6165be4f58de7385cede169282eddfef7c2a2
3
+ metadata.gz: 0fad2ecd67525418ebd21e6b6b7bb9e190aa0221
4
+ data.tar.gz: afb33d70f417502e0077083012e9ad6eb0cbb4b8
5
5
  SHA512:
6
- metadata.gz: e6bab10083bbeb4c0fea8f7e06363bc72d475cbfab69c2d4356b6fbab1d3af6486144d9cdb5d78eb46d2c2351fd9f81bd5c637cd8d096c93fda63db3b8076d03
7
- data.tar.gz: d9eed1ded3391f627f974d2156069617700263d58ed579ad573cded713b92fc44512688338ac4e0fb7ab70f3fab329961e377cbe0ac8ca80bd6b51e440a2778f
6
+ metadata.gz: e050c244b1937af8a0b78c18e0a69b0d2cf324b32bef213ea5dd0bd83cc657182605791e7927d43fc1f9ac6813b29915ed9cba2c2e15964bebf4bbe734223e53
7
+ data.tar.gz: 96c5eab7647489c35cc5b8d4e4f7d52b52a65c43aada24def22cc51477790147d997dcf0d55fa0a1af26c8b0c6f223fb4997488547f64df431ee70ebe47c2294
@@ -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.0.1'
3
+ VERSION = '6.0.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: 6.0.1
4
+ version: 6.0.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: 2018-11-20 00:00:00.000000000 Z
11
+ date: 2018-11-22 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