Time spent plugin

Home Forums Legacy Support Support queries How-to & Troubleshooting Time spent plugin

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #376876
    Khorus8
    Spectator
    Hello, Is it possible to create a function for the student can't finish a course if he spend less than X hours in a course ?
    #376916
    Veronica
    Moderator
    hi yes we can try that with custom code like if the course has duration of 6 hours and user has spend 5hours then it won't be able to complete the course
    #376991
    Khorus8
    Spectator
    Yahou this would be perfect ! With a message giving reason to the student and the time it's remain to spend in course ? 🤩 I would like to buy this custum code
    #377055
    Veronica
    Moderator
    yes possible need to check code will update you
    #378337
    Khorus8
    Spectator
    Hello Veronica, any news ? Thanks
    #378471
    Veronica
    Moderator
    hi check this code:
    add_filter('bp_get_course_check_course_complete_stop',function($bool,$course_id,$user_id){
    
    	global $bp,$wpdb;
           	
        $course_date = $wpdb->get_var($wpdb->prepare( "
                        SELECT activity.date_recorded FROM {$bp->activity->table_name} AS activity
                        WHERE     activity.component     = 'course'
                        AND     activity.type     = 'start_course'
                        AND     user_id = %d
                        AND     item_id = %d
                        ORDER BY date_recorded DESC LIMIT 0,1
                    " ,$user_id,$course_id));
        if(!empty($course_date)){
        	$course_duration_parameter = apply_filters('vibe_course_duration_parameter',86400,$course_id);
            $duration  = get_post_meta($course_id,'vibe_duration',true);
            $duration = $course_duration_parameter*$duration;
            if(!empty($duration)){
            	$time_passed = time() - $course_date;
            	if($time_passed < $duration){
            		return array('status'=>0,'message'=>_x('Atleast stay for '.tofriendlytime($time_passed < $duration)));
            	}
            }
        }
    	return $bool;
    },10,3);
    #378502
    Khorus8
    Spectator
    thanks ! Have you test it ? Where do I have to put this code ?
    #378569
    Veronica
    Moderator
    hi you need to put the code in wplms-customizer.php in wp-admin>>plugins>>plugin editor
Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Time spent plugin’ is closed to new replies.