Maximum retake in one day

Home Forums Chit Chat WPLMS customizations Maximum retake in one day

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #180895
    fokusdisain
    Spectator
    Dear WPLMS dev, Is it possible to set maximum retake course/quiz per day?   Thanks
    #182248
    MrVibe
    Keymaster
    If you ask me it is possible, the answer is always yes. Turns out this one is easy :   add_filter('bp_course_fetch_user_quiz_retake_count',function($retake_count,$quiz_id,$user_id){ global $wpdb; $retakes_in_oneday = $wpdb->get_var($wpdb->prepare( " SELECT count(activity.content) FROM {$bp->activity->table_name} AS activity WHERE   activity.component  = 'course' AND   activity.type   = 'retake_quiz' AND   user_id = %d AND   ( item_id = %d OR secondary_item_id = %d ) AND date >= now() - INTERVAL 1 DAY ORDER BY date_recorded DESC " ,$user_id,$quiz_id,$quiz_id)); if(!empty($retakes_in_oneday)){ //user already attempted quiz once in last 1 day. return 0; } return $retake_count; });
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Maximum retake in one day’ is closed to new replies.