effective_cpd 1.6.4 → 1.7.0
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 +4 -4
- data/README.md +20 -4
- data/app/models/concerns/effective_cpd_statement.rb +15 -0
- data/app/models/effective/cpd_rule.rb +9 -2
- data/app/models/effective/cpd_statement_activity.rb +2 -1
- data/app/views/admin/users/_form_cpd_targets.html.haml +5 -6
- data/app/views/effective/cpd_statements/_agreement_fields.html.haml +6 -0
- data/app/views/effective/cpd_statements/_agreements.html.haml +2 -19
- data/app/views/effective/cpd_statements/agreements.html.haml +1 -6
- data/config/locales/effective_cpd.en.yml +4 -0
- data/lib/effective_cpd/version.rb +1 -1
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 94c7c2fc57c5109c37e1ae0216f297eebb6556210e96db897e6592cd357b49e7
         | 
| 4 | 
            +
              data.tar.gz: 2561bc3bae5ca830c72ad9b3499b0e303db66fa5121c685b2d15fb3a5743da85
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 750ffcaba4258184debafb988238cbe47774b19a74a494656d600dff4234fc1e94d057040f177f9c07348e81ad2f32258abe52f76b4d4e3a53fa163562586d97
         | 
| 7 | 
            +
              data.tar.gz: 6571b2816b5616a2fd00928d3ebf142cf7ada391eccd5b7bfa9ca18e5ecc1708ba2d3728e5a67fe046b21879158d04ed2b45a5a3352faaae5dbcbfcc2bf28453
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            Continuing professional development.
         | 
| 4 4 |  | 
| 5 | 
            -
            An admin creates a set of categories,  | 
| 5 | 
            +
            An admin creates a set of categories, activities and rules.  User enters number of hours or work done to have a scored statement. Audits.
         | 
| 6 6 |  | 
| 7 7 | 
             
            Works with action_text for content bodies, and active_storage for file uploads.
         | 
| 8 8 |  | 
| @@ -93,7 +93,7 @@ Use the following datatables to display to your user their statements and audits | |
| 93 93 | 
             
                = render_datatable(reviewed, simple: true)
         | 
| 94 94 | 
             
            ```
         | 
| 95 95 |  | 
| 96 | 
            -
            On the Admin::Users#edit | 
| 96 | 
            +
            On the `Admin::Users#edit`, you can use the following datatables as well:
         | 
| 97 97 |  | 
| 98 98 | 
             
            ```haml
         | 
| 99 99 | 
             
            %h2 CPD Statements
         | 
| @@ -138,7 +138,7 @@ Once all these 3 areas have been configured, users can submit statements and aud | |
| 138 138 |  | 
| 139 139 | 
             
            You can specify the required score in the CPD Cycle.
         | 
| 140 140 |  | 
| 141 | 
            -
            You can also  | 
| 141 | 
            +
            You can also programmatically do it. Add the following to your user class.
         | 
| 142 142 |  | 
| 143 143 | 
             
            ```
         | 
| 144 144 | 
             
            # This is an ActiveRecord concern to add the has_many :cpd_statements
         | 
| @@ -167,6 +167,22 @@ def cpd_statement_required_score(cpd_statement) | |
| 167 167 | 
             
            end
         | 
| 168 168 | 
             
            ```
         | 
| 169 169 |  | 
| 170 | 
            +
            ## Custom Score Rounding
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            In your `effective_cpd_statement` model you can override the `#round_amount` method to perform
         | 
| 173 | 
            +
            specific rounding on the score that will be applied to `amount` and `amount2`.
         | 
| 174 | 
            +
             | 
| 175 | 
            +
            Example:
         | 
| 176 | 
            +
             | 
| 177 | 
            +
            ```ruby
         | 
| 178 | 
            +
              # Rounding to the nearest 0.5
         | 
| 179 | 
            +
              def round_amount(amount)
         | 
| 180 | 
            +
                return 0 if amount.blank?
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                (amount * 2.0).round / 2.0
         | 
| 183 | 
            +
              end
         | 
| 184 | 
            +
            ```
         | 
| 185 | 
            +
             | 
| 170 186 | 
             
            ## Rake Tasks
         | 
| 171 187 |  | 
| 172 188 | 
             
            You can use
         | 
| @@ -181,7 +197,7 @@ All authorization checks are handled via the effective_resources gem found in th | |
| 181 197 |  | 
| 182 198 | 
             
            ## Permissions
         | 
| 183 199 |  | 
| 184 | 
            -
            The permissions you actually want to define are as follows (using  | 
| 200 | 
            +
            The permissions you actually want to define are as follows (using CanCanCan):
         | 
| 185 201 |  | 
| 186 202 | 
             
            ```ruby
         | 
| 187 203 | 
             
            # Regular signed up user. Guest users not supported.
         | 
| @@ -33,6 +33,7 @@ module EffectiveCpdStatement | |
| 33 33 | 
             
                log_changes(except: :wizard_steps) if respond_to?(:log_changes)
         | 
| 34 34 |  | 
| 35 35 | 
             
                has_many_attached :files
         | 
| 36 | 
            +
                has_many_purgable :files
         | 
| 36 37 |  | 
| 37 38 | 
             
                attr_accessor :current_user
         | 
| 38 39 | 
             
                attr_accessor :current_step
         | 
| @@ -151,4 +152,18 @@ module EffectiveCpdStatement | |
| 151 152 | 
             
                  cpd_statement_activities.each { |activity| scores[activity.cpd_category_id] += activity.score.to_d }
         | 
| 152 153 | 
             
                end
         | 
| 153 154 | 
             
              end
         | 
| 155 | 
            +
             | 
| 156 | 
            +
              #
         | 
| 157 | 
            +
              # This method is used in CpdScore#score so it can be overridden to provide a
         | 
| 158 | 
            +
              # custom round score calculation.
         | 
| 159 | 
            +
              # Any model that is a statement can override this method to provide a custom
         | 
| 160 | 
            +
              # round score calculation.
         | 
| 161 | 
            +
              #
         | 
| 162 | 
            +
              # @param [Decimal] amount
         | 
| 163 | 
            +
              #
         | 
| 164 | 
            +
              # @return [Decimal] rounded decimal
         | 
| 165 | 
            +
              #
         | 
| 166 | 
            +
              def round_amount(amount)
         | 
| 167 | 
            +
                return amount
         | 
| 168 | 
            +
              end
         | 
| 154 169 | 
             
            end
         | 
| @@ -13,7 +13,7 @@ module Effective | |
| 13 13 | 
             
                  log_changes(to: :cpd_cycle)
         | 
| 14 14 | 
             
                end
         | 
| 15 15 |  | 
| 16 | 
            -
                # Only permit the words amount, amount2 and any  | 
| 16 | 
            +
                # Only permit the words amount, amount2 and any character 0-9 + - / * . ( )
         | 
| 17 17 | 
             
                INVALID_FORMULA_CHARS = /[^0-9\+\-\.\/\*\(\)]/
         | 
| 18 18 |  | 
| 19 19 | 
             
                effective_resource do
         | 
| @@ -111,7 +111,14 @@ module Effective | |
| 111 111 |  | 
| 112 112 | 
             
                  return cpd_statement_activity.carry_over if cpd_statement_activity.is_carry_over?
         | 
| 113 113 |  | 
| 114 | 
            -
                   | 
| 114 | 
            +
                  # Statements can override the #round_amount method to perform their own
         | 
| 115 | 
            +
                  # calculations.  For example, a statement may round to the nearest 0.5 or
         | 
| 116 | 
            +
                  # to the nearest 0.25 or to the nearest 0.1.
         | 
| 117 | 
            +
                  statement = cpd_statement_activity.cpd_statement
         | 
| 118 | 
            +
                  amount = statement.round_amount(cpd_statement_activity.amount)
         | 
| 119 | 
            +
                  amount2 = statement.round_amount(cpd_statement_activity.amount2)
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  eval_equation(amount: amount, amount2: amount2)
         | 
| 115 122 | 
             
                end
         | 
| 116 123 |  | 
| 117 124 | 
             
                private
         | 
| @@ -4,7 +4,7 @@ | |
| 4 4 | 
             
              %p
         | 
| 5 5 | 
             
                #{cpd_targets_label} set the requirements checked when submitting a #{cpd_statement_label}
         | 
| 6 6 |  | 
| 7 | 
            -
              %table.table
         | 
| 7 | 
            +
              %table.table.table-striped.table-hover.table-sm
         | 
| 8 8 | 
             
                %thead
         | 
| 9 9 | 
             
                  %th= cpd_cycle_label
         | 
| 10 10 | 
             
                  %th Default Requirements
         | 
| @@ -29,11 +29,10 @@ | |
| 29 29 | 
             
                    %tr
         | 
| 30 30 | 
             
                      %td= link_to(cpd_cycle, effective_cpd.edit_admin_cpd_cycle_path(cpd_cycle), target: '_blank')
         | 
| 31 31 | 
             
                      %td
         | 
| 32 | 
            -
                         | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
                          = collection.find { |value| value.last == default_required_to_submit }.first.downcase
         | 
| 32 | 
            +
                        = pluralize(default_target, cpd_credit_label.downcase)
         | 
| 33 | 
            +
                        = default_required_to_submit ? 'required' : 'targeted'
         | 
| 34 | 
            +
                        and
         | 
| 35 | 
            +
                        = collection.find { |value| value.last == default_required_to_submit }.first.downcase
         | 
| 37 36 |  | 
| 38 37 | 
             
                      %td
         | 
| 39 38 | 
             
                        .row
         | 
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            %h2 Agreements
         | 
| 2 | 
            +
            = f.check_box :confirm_read, label: "Yes, I have read the above content and agreements"
         | 
| 3 | 
            +
            = f.check_box :confirm_factual, label: "Yes, I declare all provided information to be factual and complete"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            %h2 Resume
         | 
| 6 | 
            +
            = f.file_field :files, label: 'Attach resume', hint: "Please attach your resume or other #{cpd_name_label} related documents"
         | 
| @@ -1,20 +1,3 @@ | |
| 1 1 | 
             
            = card('Agreements') do
         | 
| 2 | 
            -
               | 
| 3 | 
            -
                 | 
| 4 | 
            -
                  %tr
         | 
| 5 | 
            -
                    %th Read all contents and agreements
         | 
| 6 | 
            -
                    %td= cpd_statement.confirm_read ? 'Yes' : 'No'
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  %tr
         | 
| 9 | 
            -
                    %th Declared all information factual
         | 
| 10 | 
            -
                    %td= cpd_statement.confirm_factual ? 'Yes' : 'No'
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  %tr
         | 
| 13 | 
            -
                    %th Attachments
         | 
| 14 | 
            -
                    %td
         | 
| 15 | 
            -
                      - if cpd_statement.files.blank?
         | 
| 16 | 
            -
                        None
         | 
| 17 | 
            -
                      - else
         | 
| 18 | 
            -
                        %ul
         | 
| 19 | 
            -
                          - cpd_statement.files.each do |file|
         | 
| 20 | 
            -
                            = link_to(file.filename, url_for(file), target: '_blank')
         | 
| 2 | 
            +
              = effective_table_with(cpd_statement) do |f|
         | 
| 3 | 
            +
                = render('effective/cpd_statements/agreement_fields', f: f)
         | 
| @@ -10,11 +10,6 @@ | |
| 10 10 | 
             
              = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
         | 
| 11 11 | 
             
                = f.hidden_field :current_step
         | 
| 12 12 |  | 
| 13 | 
            -
                 | 
| 14 | 
            -
                = f.check_box :confirm_read, label: "Yes, I have read the above content and agreements"
         | 
| 15 | 
            -
                = f.check_box :confirm_factual, label: "Yes, I declare all provided information to be factual and complete"
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                %h2 Resume
         | 
| 18 | 
            -
                = f.file_field :files, label: 'Attach resume', hint: "Please attach your resume or other #{cpd_name_label} related documents"
         | 
| 13 | 
            +
                = render('effective/cpd_statements/agreement_fields', f: f)
         | 
| 19 14 |  | 
| 20 15 | 
             
                = f.submit 'Save and Continue', center: true
         | 
| @@ -20,6 +20,7 @@ en: | |
| 20 20 | 
             
                  effective/cpd_statement_activity: 'CPD Statement Activity'
         | 
| 21 21 | 
             
                  effective/cpd_category: 'CPD Category'
         | 
| 22 22 | 
             
                  effective/cpd_target: 'CPD Target'
         | 
| 23 | 
            +
                  effective/cpd_rule: 'CPD Rule'
         | 
| 23 24 |  | 
| 24 25 | 
             
                attributes:
         | 
| 25 26 | 
             
                  # Application namespace
         | 
| @@ -37,3 +38,6 @@ en: | |
| 37 38 | 
             
                  # Effective namespace
         | 
| 38 39 | 
             
                  effective/cpd_statement_activity:
         | 
| 39 40 | 
             
                    cpd_cycle: 'CPD Period'
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  effective/cpd_rule:
         | 
| 43 | 
            +
                    cpd_cycle: 'CPD Period'
         | 
    
        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: 1. | 
| 4 | 
            +
              version: 1.7.0
         | 
| 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: 2023- | 
| 11 | 
            +
            date: 2023-07-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -441,6 +441,7 @@ files: | |
| 441 441 | 
             
            - app/views/effective/cpd_statements/_activities_edit.html.haml
         | 
| 442 442 | 
             
            - app/views/effective/cpd_statements/_activities_new.html.haml
         | 
| 443 443 | 
             
            - app/views/effective/cpd_statements/_activities_table.html.haml
         | 
| 444 | 
            +
            - app/views/effective/cpd_statements/_agreement_fields.html.haml
         | 
| 444 445 | 
             
            - app/views/effective/cpd_statements/_agreements.html.haml
         | 
| 445 446 | 
             
            - app/views/effective/cpd_statements/_cpd_statement.html.haml
         | 
| 446 447 | 
             
            - app/views/effective/cpd_statements/_layout.html.haml
         | 
| @@ -482,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 482 483 | 
             
                - !ruby/object:Gem::Version
         | 
| 483 484 | 
             
                  version: '0'
         | 
| 484 485 | 
             
            requirements: []
         | 
| 485 | 
            -
            rubygems_version: 3. | 
| 486 | 
            +
            rubygems_version: 3.4.10
         | 
| 486 487 | 
             
            signing_key:
         | 
| 487 488 | 
             
            specification_version: 4
         | 
| 488 489 | 
             
            summary: Continuing professional development and audits rails engine
         |