Last active
January 30, 2018 06:26
-
-
Save MrVibe/6053135b0d5b86d1936f96a6e5a2f54d to your computer and use it in GitHub Desktop.
Assignment completion check in Courses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wplms_finish_course_check',function($flag,$course_curriculum){ | |
$user_id = get_current_user_id(); | |
global $post; | |
if($post->post_type != 'course'){return $flag;} | |
$course_id = $post->ID; | |
global $wpdb; | |
$members_assignment_marks = $wpdb->get_results( $wpdb->prepare("SELECT meta_value as marks,post_id as assignment_id FROM {$wpdb->postmeta} where meta_key=%d AND post_id IN (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='vibe_assignment_course' AND meta_value = %d)",$user_id,$course_id), ARRAY_A); | |
if(isset($members_assignment_marks) && is_array($members_assignment_marks) && count($members_assignment_marks)){ | |
foreach($members_assignment_marks as $members_assignment_mark){ | |
//Check if include in Course evaluation is Switched "on" for assignment | |
$include_in_course = get_post_meta($members_assignment_mark['assignment_id'],'vibe_assignment_evaluation',true); | |
if(vibe_validate($include_in_course) && !empty($members_assignment_mark['marks'])){ | |
return $members_assignment_mark['assignment_id']; | |
} | |
} | |
} | |
return $flag; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment