Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jeff Balicki
/
st_joseph
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
647db71c
authored
2023-04-02 21:53:41 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
mark comp time
Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent
5db9e236
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
wp-content/themes/crlg/css/course-admin.css
wp-content/themes/crlg/inc/learn_mark_as_complete.php
wp-content/themes/crlg/css/course-admin.css
View file @
647db71
.dataTables_wrapper
.dataTables_length
select
{
width
:
50px
!important
;
}
table
>
tbody
tr
>
td
:last-child
{
width
:
50px
!important
;
}
/*# sourceMappingURL=course-admin.css.map */
\ No newline at end of file
...
...
wp-content/themes/crlg/inc/learn_mark_as_complete.php
View file @
647db71
...
...
@@ -37,19 +37,22 @@ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'Lear
if
(
(
!
empty
(
$course_id
)
)
&&
(
get_post_type
(
$course_id
)
===
learndash_get_post_type_slug
(
'course'
)
)
)
{
$users
=
learndash_get_course_users_access_from_meta
(
$course_id
);
echo
'<table
id="markcomplete" width="100%"> <thead><tr><th>Enrolment Date</th><th>Email</th><th>First Name</th><th>Last Name</th><th>
Online</th><th>Mark Complete</th></tr></thead>'
;
foreach
(
$users
as
$user
){
$user_info
=
get_userdata
(
$user
);
$course_status
=
learndash_course_status
(
$course_id
,
$user
);
echo
'<table
style="table-layout:fixed;" id="markcomplete" width="100%"> <thead><tr><th>Enrolment Date</th><th>User Account</th><th>Email</th><th>First Name</th><th>Last Name</th><th>Last
Online</th><th>Mark Complete</th></tr></thead>'
;
foreach
(
$users
as
$user
_id
){
$user_info
=
get_userdata
(
$user
_id
);
$course_status
=
learndash_course_status
(
$course_id
,
$user
_id
);
if
(
$course_status
!=
"Completed"
){
$course_enrolled_since
=
ld_course_access_from
(
$course_id
,
$user
);
$course_enrolled_since
=
ld_course_access_from
(
$course_id
,
$user
_id
);
$course_enrolled_since
=
learndash_adjust_date_time_display
(
$course_enrolled_since
,
'Y-m-d H:i:s'
);
$online
=
"
Offline
"
;
if
(
is_user_online
(
$user
)){
$online
=
""
;
if
(
is_user_online
(
$user
_id
)){
$online
=
"Online"
;
}
else
{
$online
=
user_last_online
(
$user_id
);
}
echo
'<tr><td>'
.
$course_enrolled_since
.
'</td><td>'
.
$user_info
->
user_email
.
'</td><td>'
.
$user_info
->
first_name
.
'</td><td>'
.
$user_info
->
last_name
.
'</td><td>'
.
$online
.
'</td><td><button class="mark_as_complete components-button is-primary" data-user-id="'
.
$user
.
'" data-course-id="'
.
$course_id
.
'" >Mark Complete</button></td></tr>'
;
echo
'<tr><td>'
.
$course_enrolled_since
.
'</td><td> <a href="'
.
get_edit_user_link
(
$user_id
)
.
'">'
.
$user_info
->
user_login
.
'
</a> </td><td><a href="mailto:'
.
$user_info
->
user_email
.
'">'
.
$user_info
->
user_email
.
'</a></td><td>'
.
$user_info
->
first_name
.
'</td><td>'
.
$user_info
->
last_name
.
'</td><td>'
.
$online
.
'</td><td ><button class="mark_as_complete components-button is-primary" data-user-id="'
.
$user_id
.
'" data-course-id="'
.
$course_id
.
'" >Mark Complete</button></td></tr>'
;
}
}
echo
"</table>"
;
...
...
@@ -136,7 +139,6 @@ function course_admin_script() {
//Update user online status
add_action
(
'init'
,
'users_status_init'
);
add_action
(
'admin_init'
,
'users_status_init'
);
function
users_status_init
(){
$logged_in_users
=
get_transient
(
'users_status'
);
//Get the active users from the transient.
$user
=
wp_get_current_user
();
//Get the current user's data
...
...
@@ -148,7 +150,7 @@ function users_status_init(){
'username'
=>
$user
->
user_login
,
'last'
=>
time
(),
);
set_transient
(
'users_status'
,
$logged_in_users
,
900
);
//Set this transient to expire 15 minutes after it is created.
set_transient
(
'users_status'
,
$logged_in_users
,
0
);
}
}
...
...
@@ -161,10 +163,11 @@ function is_user_online($id){
//Check when a user was last online.
function
user_last_online
(
$id
){
$logged_in_users
=
get_transient
(
'users_status'
);
//Get the active users from the transient.
//Determine if the user has ever been logged in (and return their last active date if so).
if
(
isset
(
$logged_in_users
[
$id
][
'last'
])
){
return
$logged_in_users
[
$id
][
'last'
];
$date
=
new
DateTime
(
'@'
.
$logged_in_users
[
$id
][
'last'
]);
$date
->
setTimezone
(
new
DateTimeZone
(
'America/Toronto'
));
return
$date
->
format
(
'Y-m-d H:i:s'
);
}
else
{
return
false
;
}
...
...
Please
register
or
sign in
to post a comment