Hello, I followed this tutorial
https://wplms.io/support/knowledge-base/remove-retake-button-if-user-have-passed-the-quiz/
It works with version 4?
I would like to hideCourse Retakes if the result of the quiz is higher than a 75 percentage of correct answer and I tried to put this code in my customizer plugin:
add_filter('wplms_quiz_retake_count','remove_retake_button_if_user_passed_the_quiz',10,4);
function remove_retake_button_if_user_passed_the_quiz($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;});
$total_passed= $total/100*75;
if(empty($total))
return $retakes;
if($user_marks >= $total_passed) {
?>
<style> .course_retake > a{
display:none !important;} </style>
<?php
return 0;
}
else
return $retakes;
}
Thank you for any suggestion, Marco