effective_cpd 0.4.0 → 0.4.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
  SHA256:
3
- metadata.gz: f290e98f25e51c9ebc4497830cd628ac7921a01c2a2be09b1a335af28bc6c003
4
- data.tar.gz: fe7d20bb2bbdada0b0a30f53801ad877f51e5a01d8d56d3af4b225c820ec402e
3
+ metadata.gz: 7a4a0dc542b4aab7be7e662920d7d9c8c01b365debd9ba594bb6ffe92f4f3ccc
4
+ data.tar.gz: cd1039d075de6ca26ee36fc38c5790599e1d6761aa1fe0e5fc9791e4294709cb
5
5
  SHA512:
6
- metadata.gz: b7bbf3b41e25cdd4b5ebe86d0f186c531450e614ef454367a08623f6868aa93e9ba5e37f35e7ad7f867a04e04f6a8c458acec9dd69cf2e98aca6329a1d21580e
7
- data.tar.gz: 4050c510065598ca04809542bd50a16e54e93c9284610dc610693a06212cd9c897ef40e39508cc5f14e0d2f2e1239492bb42deb71fe257a3a51aadd8a7276843
6
+ metadata.gz: 9fb17b6984b76cc262edf4f85f898dd1b09e3338b388e178edb12068bc8eede3501b6314186a97fa28ecfbc81380df81d6316865321fe93ccf5d068ecbf7b5dd
7
+ data.tar.gz: 0c514c94d8ff831ebdbd7431d00bd07e7f7b452721c0cbb17958381ace13e2e5426c3c8c73ba797d47e4c8c7fc2d69ad23061ff28d01da4c471ecfbc54cded6d
@@ -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,17 @@ 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.class.respond_to?(:effective_cpd_cpd_cycle?)
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.class.respond_to?(:effective_cpd_cpd_cycle?)
39
+ cpd_statement(cpd_cycle: cpd_cycle) || cpd_statements.build(cpd_cycle: cpd_cycle)
40
+ end
41
+
29
42
  module ClassMethods
30
43
  def effective_cpd_user?; true; end
31
44
  end
@@ -66,6 +66,10 @@ module Effective
66
66
  end
67
67
  end
68
68
 
69
+ def self.effective_cpd_cpd_cycle?
70
+ true
71
+ end
72
+
69
73
  def self.latest_cycle
70
74
  order(id: :desc).first
71
75
  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
@@ -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
 
@@ -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.4.0'
2
+ VERSION = '0.4.3'
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.4.0
4
+ version: 0.4.3
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-08-24 00:00:00.000000000 Z
11
+ date: 2022-09-09 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