effective_learndash 0.5.2 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 103df8a3518f06fe9afa329c85eb3f47dda27a3ef01c8218c906b16f521723e6
4
- data.tar.gz: ed6e70df974e0d7d8fff36b6ae570d81c1ec4589c984ceee507fa4f4aa1351e4
3
+ metadata.gz: bbd7d00a9c8c0dd7715549afd145caf8f920a442ab76b6653e5606f1911abe4b
4
+ data.tar.gz: 583bfa80479b118ef76b83bb3c55566fdfc4124a5d9390b20de20202f06606e7
5
5
  SHA512:
6
- metadata.gz: ceba9cfb798598e0b6b2d1917bb792307bb174ab8e476d284dbaf7cd7e6a61a34ac1c8b122de719d9e2af59a14f53b99343e170a90f6c2e6da2525f09a13cd09
7
- data.tar.gz: 415ba6c5929423c5ad028603dadbb63a81e8b721e41a4f734c098475022eb72425ab9364de18a736d540cc8a2d6f82f7bf4ec4d55668861d9838e808a37eda5b
6
+ metadata.gz: 4b50cdb0c0621f8096fd69ca90a0ca83319164949f9254219b04b7334f7238f4dffb8ccd914f559ff01dd7fb4d1cd6799c05a7b1b8441d78fbdd676fe32ee9c8
7
+ data.tar.gz: a57c4396de6504918637c50afd9591ce77636680b8e658a40feceac09da92c0ce9b5e45d97f28e6ddbc582b20ab763e83ffd9963c977313bc6703566ff99bcd2
@@ -19,6 +19,7 @@ module Admin
19
19
  col :learndash_course
20
20
 
21
21
  col :progress_status
22
+ col :admin_completed, visible: false
22
23
 
23
24
  col :last_step, visible: false
24
25
  col :steps_completed, visible: false
@@ -9,9 +9,7 @@ class EffectiveLearndashAvailableCoursesDatatable < Effective::Datatable
9
9
  end
10
10
 
11
11
  actions_col show: false do |learndash_course|
12
- if current_user.learndash_enrollment(course: learndash_course).present?
13
- 'Registered. Please access from the home dashboard or applicant wizard.'
14
- elsif learndash_course.can_register?
12
+ if learndash_course.can_register?
15
13
  dropdown_link_to('Register', effective_learndash.new_learndash_course_course_registration_path(learndash_course))
16
14
  end
17
15
  end
@@ -8,12 +8,11 @@ module Effective
8
8
 
9
9
  log_changes(to: :learndash_course, except: [:last_synced_at]) if respond_to?(:log_changes)
10
10
 
11
- # Only admin can mark finished
12
- # Finished is treated as an admin override for completed?
13
- PROGRESS_STATUSES = ['not-started', 'in-progress', 'completed', 'finished']
11
+ PROGRESS_STATUSES = ['not-started', 'in-progress', 'completed']
14
12
 
15
13
  effective_resource do
16
14
  last_synced_at :string
15
+ admin_completed :boolean
17
16
 
18
17
  # Wordpress
19
18
  progress_status :string
@@ -28,7 +27,7 @@ module Effective
28
27
  timestamps
29
28
  end
30
29
 
31
- scope :completed, -> { where(progress_status: ['completed', 'finished']) }
30
+ scope :completed, -> { where(progress_status: 'completed').or(where(admin_completed: true)) }
32
31
  scope :in_progress, -> { where(progress_status: 'in-progress') }
33
32
  scope :not_started, -> { where(progress_status: 'not-started') }
34
33
 
@@ -63,35 +62,27 @@ module Effective
63
62
  progress_status == 'in-progress'
64
63
  end
65
64
 
66
- # Admin override to completed
67
- def finished?
68
- progress_status == 'finished'
69
- end
70
-
71
65
  # Checked to see if the course is done throughout
72
66
  def completed?
73
- progress_status == 'completed' || finished?
67
+ progress_status == 'completed' || admin_completed?
74
68
  end
75
69
 
76
70
  def completed_on
77
- date_completed || (created_at if finished?)
71
+ date_completed
78
72
  end
79
73
 
80
- def mark_as_finished!
81
- update!(progress_status: 'finished')
82
- end
74
+ # This is an admin action only
75
+ def mark_as_completed!
76
+ self.date_started ||= Time.zone.now
77
+ self.date_completed ||= Time.zone.now
83
78
 
84
- # Guess old status
85
- def unfinish!
86
- if date_completed.present?
87
- assign_attributes(progress_status: 'completed')
88
- elsif date_started.present?
89
- assign_attributes(progress_status: 'in-progress')
90
- else
91
- assign_attributes(progress_status: 'not-started')
92
- end
79
+ update!(progress_status: 'completed', admin_completed: true)
80
+ end
93
81
 
94
- save!
82
+ # This is an admin action only
83
+ def uncomplete!
84
+ assign_attributes(date_started: nil, date_completed: nil, progress_status: nil, admin_completed: false)
85
+ refresh!
95
86
  end
96
87
 
97
88
  def refresh!(force: false)
@@ -113,11 +104,19 @@ module Effective
113
104
  last_step: data[:last_step],
114
105
  steps_completed: data[:steps_completed],
115
106
  steps_total: data[:steps_total],
116
- date_started: Time.use_zone('UTC') { Time.zone.parse(data[:date_started]) },
117
- date_completed: (Time.use_zone('UTC') { Time.zone.parse(data[:date_completed]) } if data[:date_completed].present?)
118
107
  )
119
108
 
120
- assign_attributes(progress_status: data[:progress_status]) unless finished?
109
+ if (date = data[:date_started]).present?
110
+ assign_attributes(date_started: Time.use_zone('UTC') { Time.zone.parse(date) })
111
+ end
112
+
113
+ if (date = data[:date_completed]).present?
114
+ assign_attributes(date_completed: Time.use_zone('UTC') { Time.zone.parse(date) })
115
+ end
116
+
117
+ unless completed?
118
+ assign_attributes(progress_status: data[:progress_status])
119
+ end
121
120
 
122
121
  true
123
122
  end
@@ -8,7 +8,7 @@
8
8
  %p Click the New button from the below table to enroll a user into this course.
9
9
  %p Enrolling a user here will enroll them on the LearnDash site.
10
10
  %p Alternately, if this course is available for registration, the enrollment will be created upon registration purchase.
11
- %p Marking the course finished will allow them to proceed without completing the course on the Learndash LMS.
11
+ %p Marking the course completed here will allow them to proceed without completing the course on the Learndash LMS.
12
12
 
13
13
  - datatable = Admin::EffectiveLearndashEnrollmentsDatatable.new(learndash_course: learndash_course)
14
14
  = render_datatable(datatable, inline: true)
@@ -21,6 +21,6 @@
21
21
  = tab 'Wizard' do
22
22
  = render '/admin/learndash_courses/form_course_registration_content', learndash_course: learndash_course
23
23
 
24
- - if learndash_course.respond_to?(:log_changes_datatable)
24
+ - if learndash_course.respond_to?(:logs_datatable)
25
25
  = tab "Logs" do
26
- = render_inline_datatable(learndash_course.log_changes_datatable)
26
+ = render_inline_datatable(learndash_course.log_s_datatable)
@@ -24,7 +24,7 @@
24
24
  %p
25
25
  Click the New button from the below table to manually enroll this user into a new course.
26
26
  %br
27
- %small.text-muted Marking the course finished will allow them to proceed without completing the course on the Learndash LMS.
27
+ %small.text-muted Marking the course completed here will allow them to proceed without completing the course on the Learndash LMS.
28
28
 
29
29
  - datatable = Admin::EffectiveLearndashEnrollmentsDatatable.new(learndash_user: learndash_user)
30
30
  = render_datatable(datatable, inline: true)
@@ -33,5 +33,6 @@
33
33
  - available = EffectiveResources.best('EffectiveLearndashAvailableCoursesDatatable').new(self)
34
34
 
35
35
  - if available.present? && authorized_registration
36
- %p The following courses are available for registration:
37
- = render_datatable(available, simple: true)
36
+ .mt-4
37
+ %p The following courses are available for registration:
38
+ = render_datatable(available, simple: true)
data/config/routes.rb CHANGED
@@ -23,8 +23,8 @@ EffectiveLearndash::Engine.routes.draw do
23
23
 
24
24
  resources :learndash_enrollments, only: [:index, :new, :create, :update] do
25
25
  post :refresh, on: :member
26
- post :mark_as_finished, on: :member
27
- post :unfinish, on: :member
26
+ post :mark_as_completed, on: :member
27
+ post :uncomplete, on: :member
28
28
  end
29
29
 
30
30
  resources :learndash_courses, only: [:index, :edit, :update] do
@@ -48,6 +48,7 @@ class CreateEffectiveLearndash < ActiveRecord::Migration[6.0]
48
48
  t.integer :learndash_user_id
49
49
 
50
50
  t.datetime :last_synced_at
51
+ t.boolean :admin_completed, default: false
51
52
 
52
53
  # Wordpress
53
54
  t.string :progress_status
@@ -1,3 +1,3 @@
1
1
  module EffectiveLearndash
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_learndash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.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-10-23 00:00:00.000000000 Z
11
+ date: 2023-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails