Remove retake button if user have passed the quiz or 100% in quiz

Please try adding the given code in wplms-customizer.php file in wplms customizer plugin :

add_filter('wplms_quiz_retake_count','check_retakes',10,4);
function check_retakes($retakes,$quiz_id,$course,$user_id){
  $user_marks=get_post_meta($quiz_id,$user_id,true);
  $quiz_passing_marks=get_post_meta($quiz_id,'vibe_quiz_passing_score',true);
  if($user_marks >= $quiz_passing_marks)
    return 0;
  else
    return $retakes;
}

Remove Retakes if user achieves 100% in quiz :

 

add_filter('wplms_quiz_retake_count','check_retakes',10,4);
function check_retakes($retakes,$quiz_id,$course,$user_id){  
$user_marks=get_post_meta($quiz_id,$user_id,true); 
$questions = bp_course_get_quiz_questions($quiz_id,$user_id);
 $total = array_reduce($questions['marks'],function($carry,$item){ $carry +=$item; return $carry;});   
if($user_marks >= $total)    return 0;  
else    return $retakes;
}

Was this article helpful?

Related Articles

Leave A Comment?