DataTable mark_as_complete
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
3 changed files
with
16 additions
and
7 deletions
wp-content/themes/crlg/css/course-admin.css
0 → 100644
| ... | @@ -37,18 +37,15 @@ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'Lear | ... | @@ -37,18 +37,15 @@ if ( ( class_exists( 'LearnDash_Settings_Metabox' ) ) && ( ! class_exists( 'Lear |
| 37 | 37 | ||
| 38 | if ( ( ! empty( $course_id ) ) && ( get_post_type( $course_id ) === learndash_get_post_type_slug( 'course' ) ) ) { | 38 | if ( ( ! empty( $course_id ) ) && ( get_post_type( $course_id ) === learndash_get_post_type_slug( 'course' ) ) ) { |
| 39 | $users = learndash_get_course_users_access_from_meta( $course_id ); | 39 | $users = learndash_get_course_users_access_from_meta( $course_id ); |
| 40 | echo '<table width="100%"><tr><th>Username</th><th>Email</th><th>First Name</th><th>Last Name</th><th>Mark Complete</th><tr>'; | 40 | echo '<table id="markcomplete" width="100%"> <thead><tr><th>Enrolment Date</th><th>Email</th><th>First Name</th><th>Last Name</th><th>Mark Complete</th></tr></thead>'; |
| 41 | foreach($users as $user){ | 41 | foreach($users as $user){ |
| 42 | $user_info = get_userdata($user); | 42 | $user_info = get_userdata($user); |
| 43 | $course_status = learndash_course_status( $course_id ,$user); | 43 | $course_status = learndash_course_status( $course_id ,$user); |
| 44 | |||
| 45 | echo '<tr><td>'. $user_info->user_login .'</td><td>'. $user_info->user_email .'</td><td>'.$user_info->first_name.'</td><td>'.$user_info->last_name.'</td><td>'; | ||
| 46 | if( $course_status != "Completed" ){ | 44 | if( $course_status != "Completed" ){ |
| 47 | echo '<button class="mark_as_complete" data-user-id="'.$user.'" data-course-id="'.$course_id.'" >Mark Complete</button>'; | 45 | $course_enrolled_since = ld_course_access_from( $course_id, $user ); |
| 48 | }else{ | 46 | $course_enrolled_since = learndash_adjust_date_time_display( $course_enrolled_since, 'Y-m-d H:i:s' ); |
| 49 | echo 'Completed'; | 47 | 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><button class="mark_as_complete components-button is-primary" data-user-id="'.$user.'" data-course-id="'.$course_id.'" >Mark Complete</button></td></tr>'; |
| 50 | } | 48 | } |
| 51 | echo '</td></tr>'; | ||
| 52 | } | 49 | } |
| 53 | echo "</table>"; | 50 | echo "</table>"; |
| 54 | echo""; | 51 | echo""; |
| ... | @@ -122,5 +119,11 @@ add_action( 'admin_print_scripts-post.php', 'course_admin_script', 11 ); | ... | @@ -122,5 +119,11 @@ add_action( 'admin_print_scripts-post.php', 'course_admin_script', 11 ); |
| 122 | function course_admin_script() { | 119 | function course_admin_script() { |
| 123 | global $post_type; | 120 | global $post_type; |
| 124 | if( 'sfwd-courses' == $post_type ) | 121 | if( 'sfwd-courses' == $post_type ) |
| 122 | |||
| 123 | wp_enqueue_style( 'course-dataTables-styles', '//cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css' ); | ||
| 124 | wp_enqueue_script( 'course-dataTables-script', '//cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js' ); | ||
| 125 | wp_enqueue_script( 'course-admin-script', get_stylesheet_directory_uri() . '/js/course-admin.js' ); | 125 | wp_enqueue_script( 'course-admin-script', get_stylesheet_directory_uri() . '/js/course-admin.js' ); |
| 126 | wp_enqueue_style( 'course-admin-styles', get_stylesheet_directory_uri() . '/css/course-admin.css' ); | ||
| 127 | |||
| 128 | |||
| 126 | } | 129 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | 1 | ||
| 2 | jQuery(document).ready(function($) { | 2 | jQuery(document).ready(function($) { |
| 3 | 3 | ||
| 4 | |||
| 5 | var table = new DataTable('#markcomplete'); | ||
| 6 | |||
| 4 | $(document).on('click','.mark_as_complete', function() { | 7 | $(document).on('click','.mark_as_complete', function() { |
| 5 | 8 | ||
| 6 | var button = $(this); | 9 | var button = $(this); | ... | ... |
-
Please register or sign in to post a comment