effective_cpd 0.3.3 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6bed34a47adc51ccbd8130374137416ce8c7eb58ad7d3594db16b4498ee889c
4
- data.tar.gz: 8ef171411108e7e5d203c72733e12c597b99fed21ab7bb74f27097d6da4f797c
3
+ metadata.gz: 9945aa741b29b6997f437ba5eb0b7d9fc4d838c5f1c5c45f23d7588e13d28dfe
4
+ data.tar.gz: 503cf57539255dc4b2af5e3ef8b0cd590ca06dc1e12d651eeadbc3a3746e9600
5
5
  SHA512:
6
- metadata.gz: dda9b3ec1334ebe58aad35f13e47cca0a69c9711018046454a49aa0ae3d293b2813b871678681c360d2057923877103f2f9831ed02787e0dfadd66a93a435ae9
7
- data.tar.gz: c7e0f49c69d1fc1c1513fc4bee4d5acd16ff4c28833c6d56179c805db928f5a0efe2bd4c35ee8af5f688c2a2a51745b62a2a967b5dbdab5bdb49a64a04257434
6
+ metadata.gz: 1d37582e54373eaaba6ffd9a35145a896fd85d25e7fcd44fb493f9979ce8ac82e5de7d2ee85e72f9dd95f4ff0995c949ea551704fb5413d1446b482b12ba49a5
7
+ data.tar.gz: 30ea4652b91215b6ff969d17fe0316771b75ebe8fd0f1dcd5800e686fb47013de4d21b77f63cca5dfdbb19ffe57218e8a3482b3d39664e45c0bcbd72530c716b
@@ -13,9 +13,11 @@ module EffectiveCpdUser
13
13
  end
14
14
 
15
15
  included do
16
- has_many :cpd_statements, -> { Effective::CpdStatement.sorted }, class_name: 'Effective::CpdStatement'
16
+ has_many :cpd_statements, -> { Effective::CpdStatement.sorted }, inverse_of: :user, class_name: 'Effective::CpdStatement'
17
17
  has_many :cpd_audits, -> { Effective::CpdAudit.sorted }, inverse_of: :user, class_name: 'Effective::CpdAudit'
18
18
  has_many :cpd_audit_reviews, -> { Effective::CpdAuditReview.sorted }, inverse_of: :user, class_name: 'Effective::CpdAuditReview'
19
+
20
+ accepts_nested_attributes_for :cpd_statements
19
21
  end
20
22
 
21
23
  def cpd_statement_required_score(cpd_statement)
@@ -26,6 +28,18 @@ module EffectiveCpdUser
26
28
  true
27
29
  end
28
30
 
31
+ def cpd_statement(cpd_cycle:)
32
+ raise('expected an Effective::CpdCycle') unless cpd_cycle.kind_of?(Effective::CpdCycle)
33
+ cpd_statements.find { |cpd_statement| cpd_statement.cpd_cycle_id == cpd_cycle.id }
34
+ end
35
+
36
+ # Find or build
37
+ def build_cpd_statement(cpd_cycle:)
38
+ raise('expected an Effective::CpdCycle') unless cpd_cycle.kind_of?(Effective::CpdCycle)
39
+
40
+ cpd_statement(cpd_cycle: cpd_cycle) || cpd_statements.build(cpd_cycle: cpd_cycle)
41
+ end
42
+
29
43
  module ClassMethods
30
44
  def effective_cpd_user?; true; end
31
45
  end
@@ -72,6 +72,16 @@ module Effective
72
72
  cpd_cycle.present? ? "#{cpd_cycle} Statement" : 'statement'
73
73
  end
74
74
 
75
+ def import!(date: nil)
76
+ date ||= Time.zone.now
77
+
78
+ wizard_steps[:start] ||= date
79
+ wizard_steps[:activities] ||= date
80
+ cpd_statement_activities.each { |activity| activity.importing = true }
81
+
82
+ save!
83
+ end
84
+
75
85
  # This is the review step where they click Submit Ballot
76
86
  def submit!
77
87
  wizard_steps[:complete] ||= Time.zone.now
@@ -1,6 +1,7 @@
1
1
  module Effective
2
2
  class CpdStatementActivity < ActiveRecord::Base
3
3
  attr_accessor :max_score
4
+ attr_accessor :importing
4
5
 
5
6
  belongs_to :cpd_statement
6
7
  belongs_to :cpd_category
@@ -38,7 +39,7 @@ module Effective
38
39
  validates :original, presence: true, if: -> { (carry_over || 0) > 0 }
39
40
  validates :description, presence: true
40
41
 
41
- validate(if: -> { new_record? && cpd_statement.present? }) do
42
+ validate(if: -> { new_record? && cpd_statement.present? }, unless: -> { importing }) do
42
43
  self.errors.add(:base, "statement has already been completed") if cpd_statement.completed?
43
44
  self.errors.add(:base, "cycle is unavailable") unless cpd_statement.cpd_cycle.available?
44
45
  end
@@ -7,7 +7,12 @@
7
7
  .row
8
8
  .col
9
9
  = f.text_field :title, label: 'Title'
10
- = f.rich_text_area :body, label: 'Body (optional)'
10
+
11
+ - if defined?(EffectiveArticleEditor)
12
+ = f.article_editor :body, label: 'Body (optional)'
13
+ - else
14
+ = f.rich_text_area :body, label: 'Body (optional)'
15
+
11
16
  .col
12
17
  = f.text_field :amount_label,
13
18
  hint: 'hours of work, papers written, courses attended'
@@ -5,7 +5,11 @@
5
5
  = f.select :cpd_audit_level_section_id, Effective::CpdAuditLevelSection.sorted.all
6
6
 
7
7
  = f.text_field :title, label: 'Question Title'
8
- = f.rich_text_area :body, label: 'Body (optional)'
8
+
9
+ - if defined?(EffectiveArticleEditor)
10
+ = f.article_editor :body, label: 'Body (optional)'
11
+ - else
12
+ = f.rich_text_area :body, label: 'Body (optional)'
9
13
 
10
14
  = f.check_box :required, hint: 'A response to this question will be required'
11
15
  = f.select :category, Effective::CpdAuditLevelQuestion::CATEGORIES
@@ -2,14 +2,18 @@
2
2
 
3
3
  = effective_form_with(model: [:admin, cpd_audit_level], engine: true) do |f|
4
4
  = card("All Steps Content") do
5
- = f.rich_text_area "rich_text_all_steps_audit_content", label: false,
6
- hint: "displayed on all steps"
5
+ - if defined?(EffectiveArticleEditor)
6
+ = f.article_editor "rich_text_all_steps_audit_content", label: false, hint: "displayed on all steps"
7
+ - else
8
+ = f.rich_text_area "rich_text_all_steps_audit_content", label: false, hint: "displayed on all steps"
7
9
 
8
10
  %hr
9
11
 
10
12
  - Effective::CpdAudit::WIZARD_STEPS.each do |step, title|
11
13
  = card("#{title} Content") do
12
- = f.rich_text_area "rich_text_#{step}_audit_content", label: false,
13
- hint: "displayed on the auditee wizard #{step} wizard step only"
14
+ - if defined?(EffectiveArticleEditor)
15
+ = f.article_editor "rich_text_#{step}_audit_content", label: false, hint: "displayed on the auditee wizard #{step} wizard step only"
16
+ - else
17
+ = f.rich_text_area "rich_text_#{step}_audit_content", label: false, hint: "displayed on the auditee wizard #{step} wizard step only"
14
18
 
15
19
  = f.submit
@@ -2,14 +2,18 @@
2
2
 
3
3
  = effective_form_with(model: [:admin, cpd_audit_level], engine: true) do |f|
4
4
  = card("All Steps Content") do
5
- = f.rich_text_area "rich_text_all_steps_audit_review_content", label: false,
6
- hint: "displayed on all steps"
5
+ - if defined?(EffectiveArticleEditor)
6
+ = f.article_editor "rich_text_all_steps_audit_review_content", label: false, hint: "displayed on all steps"
7
+ - else
8
+ = f.rich_text_area "rich_text_all_steps_audit_review_content", label: false, hint: "displayed on all steps"
7
9
 
8
10
  %hr
9
11
 
10
12
  - Effective::CpdAuditReview::WIZARD_STEPS.each do |step, title|
11
13
  = card("#{title} Content") do
12
- = f.rich_text_area "rich_text_#{step}_audit_review_content", label: false,
13
- hint: "displayed on the audit reviewer #{step} wizard step only"
14
+ - if defined?(EffectiveArticleEditor)
15
+ = f.article_editor "rich_text_#{step}_audit_review_content", label: false, hint: "displayed on the audit reviewer #{step} wizard step only"
16
+ - else
17
+ = f.rich_text_area "rich_text_#{step}_audit_review_content", label: false, hint: "displayed on the audit reviewer #{step} wizard step only"
14
18
 
15
19
  = f.submit
@@ -1,7 +1,11 @@
1
1
  = effective_form_with(model: [:admin, cpd_audit_level], engine: true) do |f|
2
2
  = f.fields_for :cpd_audit_level_sections, cpd_audit_level_section do |fas|
3
- = fas.rich_text_area :top_content
4
- = fas.rich_text_area :bottom_content
3
+ - if defined?(EffectiveArticleEditor)
4
+ = fas.article_editor :top_content
5
+ = fas.article_editor :bottom_content
6
+ - else
7
+ = fas.rich_text_area :top_content
8
+ = fas.rich_text_area :bottom_content
5
9
 
6
10
  = f.submit
7
11
 
@@ -1,5 +1,9 @@
1
1
  = effective_form_with(model: [:admin, cpd_category], engine: true) do |f|
2
2
  = f.text_field :title
3
- = f.rich_text_area :body
3
+
4
+ - if defined?(EffectiveArticleEditor)
5
+ = f.article_editor :body
6
+ - else
7
+ = f.rich_text_area :body
4
8
 
5
9
  = effective_submit(f)
@@ -4,37 +4,58 @@
4
4
  .card.mb-4
5
5
  .card-body
6
6
  %h5.card-title All Steps Content
7
- = f.rich_text_area :all_steps_content, label: false, hint: 'displayed on all statement steps'
7
+ - if defined?(EffectiveArticleEditor)
8
+ = f.article_editor :all_steps_content, label: false, hint: 'displayed on all statement steps'
9
+ - else
10
+ = f.rich_text_area :all_steps_content, label: false, hint: 'displayed on all statement steps'
8
11
 
9
12
  .card.mb-4
10
13
  .card-body
11
14
  %h5.card-title Sidebar Content
12
- = f.rich_text_area :sidebar_content, label: false, hint: 'displayed on the sidebar on all statement steps'
15
+ - if defined?(EffectiveArticleEditor)
16
+ = f.article_editor :sidebar_content, label: false, hint: 'displayed on the sidebar on all statement steps'
17
+ - else
18
+ = f.rich_text_area :sidebar_content, label: false, hint: 'displayed on the sidebar on all statement steps'
13
19
 
14
20
  %h2 Individual Steps Content
15
21
  .card.mb-4
16
22
  .card-body
17
23
  %h5.card-title Start Step
18
- = f.rich_text_area :start_content, label: false, hint: 'displayed on the start step only'
24
+ - if defined?(EffectiveArticleEditor)
25
+ = f.article_editor :start_content, label: false, hint: 'displayed on the start step only'
26
+ - else
27
+ = f.rich_text_area :start_content, label: false, hint: 'displayed on the start step only'
19
28
 
20
29
  .card.mb-4
21
30
  .card-body
22
31
  %h5.card-title Activities Step
23
- = f.rich_text_area :activities_content, label: false, hint: 'displayed on the activities step only'
32
+ - if defined?(EffectiveArticleEditor)
33
+ = f.article_editor :activities_content, label: false, hint: 'displayed on the activities step only'
34
+ - else
35
+ = f.rich_text_area :activities_content, label: false, hint: 'displayed on the activities step only'
24
36
 
25
37
  .card.mb-4
26
38
  .card-body
27
39
  %h5.card-title Agreements Step
28
- = f.rich_text_area :agreements_content, label: false, hint: 'displayed on the agreements step only'
40
+ - if defined?(EffectiveArticleEditor)
41
+ = f.article_editor :agreements_content, label: false, hint: 'displayed on the agreements step only'
42
+ - else
43
+ = f.rich_text_area :agreements_content, label: false, hint: 'displayed on the agreements step only'
29
44
 
30
45
  .card.mb-4
31
46
  .card-body
32
47
  %h5.card-title Submit Step
33
- = f.rich_text_area :submit_content, label: false, hint: 'displayed on the submit step only'
48
+ - if defined?(EffectiveArticleEditor)
49
+ = f.article_editor :submit_content, label: false, hint: 'displayed on the submit step only'
50
+ - else
51
+ = f.rich_text_area :submit_content, label: false, hint: 'displayed on the submit step only'
34
52
 
35
53
  .card.mb-4
36
54
  .card-body
37
55
  %h5.card-title Complete Step
38
- = f.rich_text_area :complete_content, label: false, hint: 'displayed on the complete step only'
56
+ - if defined?(EffectiveArticleEditor)
57
+ = f.article_editor :complete_content, label: false, hint: 'displayed on the complete step only'
58
+ - else
59
+ = f.rich_text_area :complete_content, label: false, hint: 'displayed on the complete step only'
39
60
 
40
61
  = f.submit
@@ -16,8 +16,10 @@
16
16
  = fc.select :cpd_special_rule_ids, cpd_cycle.cpd_special_rules, multiple: true,
17
17
  label: 'Special Rules', hint: "Special rules operate on more than one category at a time"
18
18
 
19
- = fc.rich_text_area :category_credit_description,
20
- hint: "A description of the maximum #{cpd_credits_label} and carry forward policy of activities for this category"
19
+ - if defined?(EffectiveArticleEditor)
20
+ = fc.article_editor :category_credit_description, hint: "A description of the maximum #{cpd_credits_label} and carry forward policy of activities for this category"
21
+ - else
22
+ = fc.rich_text_area :category_credit_description, hint: "A description of the maximum #{cpd_credits_label} and carry forward policy of activities for this category"
21
23
 
22
24
  = fc.check_box :unavailable, label: "Unavailable in this #{cpd_cycle_label}"
23
25
 
@@ -0,0 +1,39 @@
1
+ %h2 Continuing Professional Development
2
+
3
+ - # Auditee datatables (4)
4
+ - auditing = EffectiveCpdAvailableAuditsDatatable.new(self)
5
+ - if auditing.present?
6
+ .mt-4
7
+ %p You have been selected for audit:
8
+ = render_datatable(auditing, simple: true)
9
+
10
+ - audited = EffectiveCpdCompletedAuditsDatatable.new(self)
11
+ - if audited.present?
12
+ .mt-4
13
+ %p You have completed these past audits:
14
+ = render_datatable(audited, simple: true)
15
+
16
+ - available = EffectiveCpdAvailableCyclesDatatable.new(self)
17
+ - if available.present?
18
+ .mt-4
19
+ %p Please submit a CPD statement for the following available #{cpd_cycles_label}:
20
+ = render_datatable(available, simple: true)
21
+
22
+ - completed = EffectiveCpdCompletedStatementsDatatable.new(self)
23
+ - if completed.present?
24
+ .mt-4
25
+ %p You have completed these past statements:
26
+ = render_datatable(completed, simple: true)
27
+
28
+ - # Auditor / Audit reviewer datatables (2)
29
+ - reviewing = EffectiveCpdAvailableAuditReviewsDatatable.new(self)
30
+ - if reviewing.present?
31
+ .mt-4
32
+ %p You have been selected to assess the following audits:
33
+ = render_datatable(reviewing, simple: true)
34
+
35
+ - reviewed = EffectiveCpdCompletedAuditReviewsDatatable.new(self)
36
+ - if reviewed.present?
37
+ .mt-4
38
+ %p You have completed these past audit assessments:
39
+ = render_datatable(reviewed, simple: true)
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.3.3'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_cpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-17 00:00:00.000000000 Z
11
+ date: 2022-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -261,6 +261,7 @@ files:
261
261
  - app/views/admin/cpd_cycles/_form_cpd_special_rules.html.haml
262
262
  - app/views/admin/cpd_special_rules/_form.html.haml
263
263
  - app/views/admin/cpd_statements/_cpd_statement.html.haml
264
+ - app/views/effective/cpd/_dashboard.html.haml
264
265
  - app/views/effective/cpd_audit_level_questions/_cpd_audit_level_question.html.haml
265
266
  - app/views/effective/cpd_audit_responses/_cpd_audit_response.html.haml
266
267
  - app/views/effective/cpd_audit_responses/_fields.html.haml