effective_learndash 0.1.0 → 0.1.3
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 +3 -0
- data/app/datatables/effective_learndash_enrollments_datatable.rb +30 -0
- data/app/models/effective/learndash_enrollment.rb +8 -0
- data/app/models/effective/learndash_user.rb +6 -0
- data/app/views/effective/learndash/_dashboard.html.haml +31 -0
- data/lib/effective_learndash/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81bcba4c739ea9bac4b39489414f6cefbaff0530deb01af45e18960072057476
|
4
|
+
data.tar.gz: 461b4243fa49f7d9cc4a5aba4f2be46d991648328c42a8d81f7cadb193d21031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf9e1c610922fd5a50d9217ca3edd65861599a21e68d6ccfacbe1ffe47276e0612645b691c92955fac10dbf03c2b30c6a0cf4051cf7616edf5bde243673e7ad4
|
7
|
+
data.tar.gz: 30913570908343e2eb323a4a73fd646a3751db4916073e857abd16069d26f156d233149fe381a0d53b79bc63a45c61ce93dc9985598638a6fe5a3e2a6a190e40
|
data/README.md
CHANGED
@@ -71,6 +71,9 @@ All authorization checks are handled via the effective_resources gem found in th
|
|
71
71
|
The permissions you actually want to define are as follows (using CanCan):
|
72
72
|
|
73
73
|
```ruby
|
74
|
+
can(:show, Effective::LearndashUser) { |lduser| lduser.owner_id == user.id }
|
75
|
+
can(:index, Effective::LearndashEnrollment)
|
76
|
+
|
74
77
|
if user.admin?
|
75
78
|
can :admin, :effective_learndash
|
76
79
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Dashboard LearndashUsers
|
2
|
+
class EffectiveLearndashEnrollmentsDatatable < Effective::Datatable
|
3
|
+
datatable do
|
4
|
+
col :learndash_course
|
5
|
+
col :progress_status
|
6
|
+
|
7
|
+
col :last_step, visible: false
|
8
|
+
col :steps_completed, visible: false
|
9
|
+
col :steps_total, visible: false
|
10
|
+
|
11
|
+
col :date_started, as: :date
|
12
|
+
col :date_completed, as: :date
|
13
|
+
|
14
|
+
actions_col(show: false) do |enrollment|
|
15
|
+
if enrollment.not_started?
|
16
|
+
dropdown_link_to('Start', EffectiveLearndash.learndash_url, target: '_blank')
|
17
|
+
elsif enrollment.in_progress?
|
18
|
+
dropdown_link_to('Continue', EffectiveLearndash.learndash_url, target: '_blank')
|
19
|
+
else
|
20
|
+
dropdown_link_to('Show', EffectiveLearndash.learndash_url, target: '_blank')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
collection do
|
27
|
+
Effective::LearndashEnrollment.deep.where(learndash_user: current_user.learndash_user)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -46,6 +46,14 @@ module Effective
|
|
46
46
|
persisted? ? "#{learndash_user} #{learndash_course}" : 'learndash enrollment'
|
47
47
|
end
|
48
48
|
|
49
|
+
def not_started?
|
50
|
+
progress_status == 'not-started'
|
51
|
+
end
|
52
|
+
|
53
|
+
def in_progress?
|
54
|
+
progress_status == 'in-progress'
|
55
|
+
end
|
56
|
+
|
49
57
|
def completed?
|
50
58
|
progress_status == 'completed'
|
51
59
|
end
|
@@ -44,6 +44,12 @@ module Effective
|
|
44
44
|
owner&.to_s || username.presence || 'learndash user'
|
45
45
|
end
|
46
46
|
|
47
|
+
def check_and_refresh!
|
48
|
+
return if last_synced_at.present? && (Time.zone.now - last_synced_at) < 10
|
49
|
+
return if learndash_enrollments.none? { |enrollment| !enrollment.completed? }
|
50
|
+
refresh!
|
51
|
+
end
|
52
|
+
|
47
53
|
def refresh!
|
48
54
|
assign_api_course_enrollments
|
49
55
|
save!
|
@@ -0,0 +1,31 @@
|
|
1
|
+
- learndash_user = current_user.try(:learndash_user)
|
2
|
+
- authorized = learndash_user && EffectiveResources.authorized?(self, :show, learndash_user)
|
3
|
+
|
4
|
+
%h2 Learndash Courses
|
5
|
+
|
6
|
+
- if learndash_user.blank?
|
7
|
+
%p You do not have a Learndash account.
|
8
|
+
|
9
|
+
- if learndash_user.present?
|
10
|
+
%p
|
11
|
+
= succeed('.') do
|
12
|
+
You have an existing account on
|
13
|
+
= link_to('Learndash', EffectiveLearndash.learndash_url, target: '_blank')
|
14
|
+
|
15
|
+
- if learndash_user.present? && authorized
|
16
|
+
- learndash_user.check_and_refresh!
|
17
|
+
|
18
|
+
%p Please sign into Learndash with the following credentials:
|
19
|
+
|
20
|
+
%ul
|
21
|
+
%li Email: #{learndash_user.email}
|
22
|
+
%li Username: #{learndash_user.username}
|
23
|
+
%li Password: #{learndash_user.password}
|
24
|
+
|
25
|
+
- if learndash_user.learndash_enrollments.present?
|
26
|
+
%p You are enrolled in #{pluralize(learndash_user.learndash_enrollments.length, 'course')}.
|
27
|
+
|
28
|
+
- datatable = EffectiveResources.best('EffectiveLearndashEnrollmentsDatatable').new(self)
|
29
|
+
= render_datatable(datatable, simple: true)
|
30
|
+
- else
|
31
|
+
You are not enrolled in any Learndash courses.
|
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.1.
|
4
|
+
version: 0.1.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-03-
|
11
|
+
date: 2022-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- app/datatables/admin/effective_learndash_courses_datatable.rb
|
186
186
|
- app/datatables/admin/effective_learndash_enrollments_datatable.rb
|
187
187
|
- app/datatables/admin/effective_learndash_users_datatable.rb
|
188
|
+
- app/datatables/effective_learndash_enrollments_datatable.rb
|
188
189
|
- app/helpers/effective_learndash_helper.rb
|
189
190
|
- app/models/concerns/effective_learndash_owner.rb
|
190
191
|
- app/models/effective/learndash_api.rb
|
@@ -196,6 +197,7 @@ files:
|
|
196
197
|
- app/views/admin/learndash_owners/_form.html.haml
|
197
198
|
- app/views/admin/learndash_users/_form.html.haml
|
198
199
|
- app/views/admin/learndash_users/_learndash_user.html.haml
|
200
|
+
- app/views/effective/learndash/_dashboard.html.haml
|
199
201
|
- config/effective_learndash.rb
|
200
202
|
- config/routes.rb
|
201
203
|
- db/migrate/01_create_effective_learndash.rb.erb
|