Show time spent by student on course admin

Please add this code in your wp-content/plugins/wplms-customizer/wplms-customizer.php file :

 

add_action('wplms_user_course_admin_member','custom_wplms_user_course_admin_member',10,2);
 
function custom_wplms_user_course_admin_member($student_id,$course_id){
global $bp,$wpdb;
 
$start_time = $wpdb->get_var($wpdb->prepare("SELECT date_recorded FROM {$bp->activity->table_name} WHERE type ='start_course' AND item_id=%d AND component='course' AND user_id=%d ORDER BY id DESC LIMIT 1", $course_id,$student_id));
 
 
if(!empty($start_time ))
echo '<span style="display:block">Time Spent : '. human_time_diff(strtotime($start_time),strtotime(current_time( 'timestamp' ))).'</span>';
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *