unidom-score 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/app/models/unidom/score/score_item.rb +4 -4
- data/app/models/unidom/score/score_item_template.rb +20 -0
- data/app/models/unidom/score/score_sheet.rb +3 -2
- data/app/models/unidom/score/score_sheet_template.rb +5 -4
- data/db/migrate/20060102000000_create_unidom_score_item_templates.rb +29 -0
- data/db/migrate/20060111000000_create_unidom_score_sheets.rb +4 -4
- data/db/migrate/20060112000000_create_unidom_score_items.rb +5 -5
- data/lib/unidom/score/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d8181349266ef32d4541da8cc80fbd3f99bb0cc
|
4
|
+
data.tar.gz: 7efba97555ffc2d5b331aefa9c0fa217ab989ae5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6599866a95d476f255d623716f6b4f74aaf7f4fde739bcf5327157297346bda71923c87500e7ca9b908440d020a1f301686008f57b2f30f2c8cf4ce98859ed
|
7
|
+
data.tar.gz: a8713c30552a6870496b66f60c3d5d9d71475e5ed8a7af324c87040d9c90c6f7419ec7e321fbe3be4174bda3e59e917f85b99c0eb56f821e7d3747c9f9015963
|
data/README.md
CHANGED
@@ -37,13 +37,17 @@ The migration versions start with 200601.
|
|
37
37
|
|
38
38
|
```ruby
|
39
39
|
company = Unidom::Party::Company.create! name: 'Xerox'
|
40
|
-
|
40
|
+
sheet_template = Unidom::Score::ScoreSheetTemplate.create! subject: company, name: 'Survey 2003', total_score: 100
|
41
|
+
|
42
|
+
item_template_1 = Unidom::Score::ScoreItemTemplate.create! sheet: sheet_template, title: 'Q1: What is your name?', score: 60
|
43
|
+
item_template_2 = Unidom::Score::ScoreItemTemplate.create! sheet: sheet_template, title: 'Q2: How old are you?', score: 40
|
41
44
|
|
42
45
|
scorer = Unidom::Party::Person.create! name: 'Tim'
|
43
46
|
score_keeper = Unidom::Party::Shop.create! name: 'WalMart'
|
44
|
-
score_sheet = Unidom::Score::ScoreSheet.score! scorer: scorer, score_keeper: score_keeper, template:
|
47
|
+
score_sheet = Unidom::Score::ScoreSheet.score! scorer: scorer, score_keeper: score_keeper, template: sheet_template, name: nil, score: 98, scored_on: Date.current, opened_at: Time.now, description: nil, instruction: nil
|
45
48
|
# The template could be nil
|
46
49
|
|
47
|
-
item_1 = Unidom::Score::ScoreItem.score! sheet: score_sheet, scorer: score_sheet.try(:scorer), template:
|
48
|
-
item_2 = Unidom::Score::ScoreItem.score! sheet: score_sheet, scorer: score_sheet.try(:scorer), template:
|
50
|
+
item_1 = Unidom::Score::ScoreItem.score! sheet: score_sheet, scorer: score_sheet.try(:scorer), template: item_template_1, title: item_template_1.try(:title), score: 59, scored_on: Date.current, opened_at: Time.now, description: nil, instruction: nil
|
51
|
+
item_2 = Unidom::Score::ScoreItem.score! sheet: score_sheet, scorer: score_sheet.try(:scorer), template: item_template_2, title: item_template_2.try(:title), score: 39, scored_on: Date.current, opened_at: Time.now, description: nil, instruction: nil
|
52
|
+
# The template could be nil
|
49
53
|
```
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Score Item 是评分项。
|
2
|
+
# #sheet 是评分表。
|
2
3
|
# #template 是评分项模版。
|
3
4
|
# #scorer 是评分者。
|
4
|
-
# #score_keeper 是得分者。
|
5
5
|
|
6
6
|
class Unidom::Score::ScoreItem < Unidom::Score::ApplicationRecord
|
7
7
|
|
@@ -12,11 +12,11 @@ class Unidom::Score::ScoreItem < Unidom::Score::ApplicationRecord
|
|
12
12
|
validates :title, allow_blank: true, length: { in: 2..columns_hash['title'].limit }
|
13
13
|
validates :score, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
|
14
14
|
|
15
|
-
belongs_to :sheet, class_name: 'Unidom::Score::ScoreSheet', foreign_key: :
|
16
|
-
belongs_to :template, class_name: 'Unidom::Score::ScoreItemTemplate', foreign_key: :
|
15
|
+
belongs_to :sheet, class_name: 'Unidom::Score::ScoreSheet', foreign_key: :sheet_id
|
16
|
+
belongs_to :template, class_name: 'Unidom::Score::ScoreItemTemplate', foreign_key: :template_id
|
17
17
|
belongs_to :scorer, polymorphic: true
|
18
18
|
|
19
|
-
scope :sheet_is, ->(sheet) { where
|
19
|
+
scope :sheet_is, ->(sheet) { where sheet_id: to_id(sheet) }
|
20
20
|
scope :template_is, ->(template) { where template_id: to_id(template) }
|
21
21
|
scope :scored_by, ->(scorer) { where scorer: scorer }
|
22
22
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Score Item Tempalte 是评分项模版。
|
2
|
+
# #sheet 是评分表模版。
|
3
|
+
# #scorings 是评分项。
|
4
|
+
|
5
|
+
class Unidom::Score::ScoreItemTemplate < Unidom::Score::ApplicationRecord
|
6
|
+
|
7
|
+
self.table_name = 'unidom_score_item_templates'
|
8
|
+
|
9
|
+
include Unidom::Common::Concerns::ModelExtension
|
10
|
+
|
11
|
+
validates :title, presence: true, length: { in: 2..columns_hash['title'].limit }
|
12
|
+
validates :score, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
|
13
|
+
|
14
|
+
belongs_to :sheet, class_name: 'Unidom::Score::ScoreSheetTemplate'
|
15
|
+
|
16
|
+
has_many :scorings, class_name: 'Unidom::Score::ScoreItem', foreign_key: :template_id
|
17
|
+
|
18
|
+
scope :sheet_is, ->(sheet) { where sheet_id: to_id(sheet) }
|
19
|
+
|
20
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# #template 是评分表模版。
|
3
3
|
# #scorer 是评分者。
|
4
4
|
# #score_keeper 是得分者。
|
5
|
+
# #items 是评分项。
|
5
6
|
|
6
7
|
class Unidom::Score::ScoreSheet < Unidom::Score::ApplicationRecord
|
7
8
|
|
@@ -12,11 +13,11 @@ class Unidom::Score::ScoreSheet < Unidom::Score::ApplicationRecord
|
|
12
13
|
validates :name, allow_blank: true, length: { in: 2..columns_hash['name'].limit }
|
13
14
|
validates :score, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
|
14
15
|
|
15
|
-
belongs_to :template, class_name: 'Unidom::Score::ScoreSheetTemplate', foreign_key: :
|
16
|
+
belongs_to :template, class_name: 'Unidom::Score::ScoreSheetTemplate', foreign_key: :template_id
|
16
17
|
belongs_to :scorer, polymorphic: true
|
17
18
|
belongs_to :score_keeper, polymorphic: true
|
18
19
|
|
19
|
-
has_many :items, class_name: 'Unidom::Score::ScoreItem', foreign_key: :
|
20
|
+
has_many :items, class_name: 'Unidom::Score::ScoreItem', foreign_key: :sheet_id
|
20
21
|
|
21
22
|
scope :template_is, ->(template) { where template_id: to_id(template) }
|
22
23
|
scope :scored_by, ->(scorer) { where scorer: scorer }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Score Sheet Tempalte 是评分表模版。
|
2
|
-
# #
|
3
|
-
# #
|
4
|
-
# #
|
2
|
+
# #subject 是主题。
|
3
|
+
# #items 是评分项模版。
|
4
|
+
# #scorings 是评分表。
|
5
5
|
|
6
6
|
class Unidom::Score::ScoreSheetTemplate < Unidom::Score::ApplicationRecord
|
7
7
|
|
@@ -14,7 +14,8 @@ class Unidom::Score::ScoreSheetTemplate < Unidom::Score::ApplicationRecord
|
|
14
14
|
|
15
15
|
belongs_to :subject, polymorphic: true
|
16
16
|
|
17
|
-
has_many :
|
17
|
+
has_many :items, class_name: 'Unidom::Score::ScoreItemTemplate', foreign_key: :sheet_id
|
18
|
+
has_many :scorings, class_name: 'Unidom::Score::ScoreSheet', foreign_key: :template_id
|
18
19
|
|
19
20
|
scope :subject_is, ->(subject) { where subject: subject }
|
20
21
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateUnidomScoreItemTemplates < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :unidom_score_item_templates, id: :uuid do |t|
|
6
|
+
|
7
|
+
t.references :sheet, type: :uuid, null: false
|
8
|
+
|
9
|
+
t.string :title, null: false, default: '', limit: 200
|
10
|
+
t.decimal :score, null: false, default: 0.0, precision: 12, scale: 2
|
11
|
+
|
12
|
+
t.text :description
|
13
|
+
t.text :instruction
|
14
|
+
|
15
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
16
|
+
t.datetime :opened_at, null: false, default: Time.utc(1970)
|
17
|
+
t.datetime :closed_at, null: false, default: Time.utc(3000)
|
18
|
+
t.boolean :defunct, null: false, default: false
|
19
|
+
t.jsonb :notation, null: false, default: {}
|
20
|
+
|
21
|
+
t.timestamps null: false
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index :unidom_score_item_templates, :sheet_id
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -4,10 +4,10 @@ class CreateUnidomScoreSheets < ActiveRecord::Migration
|
|
4
4
|
|
5
5
|
create_table :unidom_score_sheets, id: :uuid do |t|
|
6
6
|
|
7
|
-
t.references :
|
8
|
-
t.references :scorer,
|
7
|
+
t.references :template, type: :uuid, null: true
|
8
|
+
t.references :scorer, type: :uuid, null: false,
|
9
9
|
polymorphic: { null: false, default: '', limit: 200 }
|
10
|
-
t.references :score_keeper,
|
10
|
+
t.references :score_keeper, type: :uuid, null: false,
|
11
11
|
polymorphic: { null: false, default: '', limit: 200 }
|
12
12
|
|
13
13
|
t.string :name, null: true, default: nil, limit: 200
|
@@ -27,7 +27,7 @@ class CreateUnidomScoreSheets < ActiveRecord::Migration
|
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
|
-
add_index :unidom_score_sheets, :
|
30
|
+
add_index :unidom_score_sheets, :template_id
|
31
31
|
add_index :unidom_score_sheets, :scorer_id
|
32
32
|
add_index :unidom_score_sheets, :score_keeper_id
|
33
33
|
|
@@ -4,9 +4,9 @@ class CreateUnidomScoreItems < ActiveRecord::Migration
|
|
4
4
|
|
5
5
|
create_table :unidom_score_items, id: :uuid do |t|
|
6
6
|
|
7
|
-
t.references :
|
8
|
-
t.references :
|
9
|
-
t.references :scorer,
|
7
|
+
t.references :sheet, type: :uuid, null: false
|
8
|
+
t.references :template, type: :uuid, null: true
|
9
|
+
t.references :scorer, type: :uuid, null: false,
|
10
10
|
polymorphic: { null: false, default: '', limit: 200 }
|
11
11
|
|
12
12
|
t.string :title, null: true, default: nil, limit: 200
|
@@ -26,8 +26,8 @@ class CreateUnidomScoreItems < ActiveRecord::Migration
|
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
-
add_index :unidom_score_items, :
|
30
|
-
add_index :unidom_score_items, :
|
29
|
+
add_index :unidom_score_items, :sheet_id
|
30
|
+
add_index :unidom_score_items, :template_id
|
31
31
|
add_index :unidom_score_items, :scorer_id
|
32
32
|
|
33
33
|
end
|
data/lib/unidom/score/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-score
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -45,11 +45,13 @@ files:
|
|
45
45
|
- app/mailers/unidom/score/application_mailer.rb
|
46
46
|
- app/models/unidom/score/application_record.rb
|
47
47
|
- app/models/unidom/score/score_item.rb
|
48
|
+
- app/models/unidom/score/score_item_template.rb
|
48
49
|
- app/models/unidom/score/score_sheet.rb
|
49
50
|
- app/models/unidom/score/score_sheet_template.rb
|
50
51
|
- app/views/layouts/unidom/score/application.html.erb
|
51
52
|
- config/routes.rb
|
52
53
|
- db/migrate/20060101000000_create_unidom_score_sheet_templates.rb
|
54
|
+
- db/migrate/20060102000000_create_unidom_score_item_templates.rb
|
53
55
|
- db/migrate/20060111000000_create_unidom_score_sheets.rb
|
54
56
|
- db/migrate/20060112000000_create_unidom_score_items.rb
|
55
57
|
- lib/tasks/score_tasks.rake
|