effective_learndash 0.1.0 → 0.1.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: '0970ec691c0993f6c77e5131eba3da9ed11ef1c74a5cd00f0cdba5373cf1f5b4'
4
- data.tar.gz: dd0229161ba6030e9711202259063af16e506ec6d029647d43a112b4ac4f8150
3
+ metadata.gz: 81bcba4c739ea9bac4b39489414f6cefbaff0530deb01af45e18960072057476
4
+ data.tar.gz: 461b4243fa49f7d9cc4a5aba4f2be46d991648328c42a8d81f7cadb193d21031
5
5
  SHA512:
6
- metadata.gz: a6ff74e9f0842c69d6f69886a8a7ef86b1196bbfd83e803afdd58e075c8ac99371a4b125d22b67e136268b4b5d4ac6718371b3ff6db936abddcb123ac3d8b28a
7
- data.tar.gz: e742085fcf413769c5936203091663b95d704a98d4b26b3778d77668f62d7ec79a53c52ffade1e9cf0d4cf56941ab83797d67a3efac1905ae30755f416958ff2
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.
@@ -1,3 +1,3 @@
1
1
  module EffectiveLearndash
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.3'.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.1.0
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-25 00:00:00.000000000 Z
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