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>';
}

 

Was this article helpful?

Related Articles

2 Comments

  1. learner4life

    Hi, is it possible to modify this code to get a sense of time spent in minutes and/or hours? Even though my course duration is in days, they are primarily video lectures so I want to get a sense of actually how much time are students spending time watching videos. And days/weeks become too vague for that.

  2. Shibon

    Hi
    Is it possible to find the approximate time spent by user for studying course

Leave A Comment?