Last active
August 10, 2020 21:01
-
-
Save rohit-skywalker/f2edd47a94818ff9e68cfcecfc50b1b7 to your computer and use it in GitHub Desktop.
FINISH ASSIGNMENT TO MARK UNIT COMPLETE
This file contains 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_unit_mark_complete','wplms_assignments_force_unit_complete1234',99,3); | |
function wplms_assignments_force_unit_complete1234($mark_unit_html,$unit_id,$course_id){ | |
$flag=0; | |
$assignment_locking = vibe_get_option('assignment_locking'); | |
if(isset($assignment_locking) && $assignment_locking){ | |
$unit_assignments = get_post_meta($unit_id,'vibe_assignment',false); | |
if(empty($unit_assignments)) | |
return $mark_unit_html; | |
if(is_Array($unit_assignments) && is_array($unit_assignments[0])) | |
$unit_assignments = vibe_sanitize($unit_assignments); | |
if(isset($unit_assignments) && is_array($unit_assignments)) | |
foreach($unit_assignments as $unit_assignment){ | |
if(is_numeric($unit_assignment)){ | |
$user_id = get_current_user_id(); | |
$assignment_complete = get_post_meta($unit_assignment,$user_id,true); | |
if(isset($assignment_complete) && $assignment_complete !=''){ | |
$flag=1; | |
}else{ | |
$flag=0; | |
break; | |
} | |
}//end-if | |
}//end-for | |
} | |
if(!$flag){ | |
return '<a>'.__('FINISH ASSIGNMENT TO MARK UNIT COMPLETE','vibe').'</a>'; | |
} | |
return '<a href="#" id="mark-complete" data-unit="'.$unit_id.'" class="unit_button">Mark this Unit Complete</a>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment