Certification and evaluation of course based on the final quiz

Please add the given code in your wplms-customizer.php file in wplms-customizer plugin :

add_filter('wplms_course_student_marks','student_marks',999,3);

function student_marks($student_marks,$id,$user_id){

    $curriculum=bp_course_get_curriculum_units($id);
    if(get_post_type($curriculum[(count($curriculum)-1)]) == 'quiz'){
        $student_marks=get_post_meta($curriculum[(count($curriculum)-1)],$user_id,true);
    }
    return $student_marks;     
}
add_filter('wplms_course_maximum_marks','total_marks',999,3);
function total_marks($total_marks,$id,$user_id){

    $curriculum=bp_course_get_curriculum_units($id);//vibe_sanitize(get_post_meta($id,'vibe_course_curriculum',false));
           
    if(is_numeric($curriculum[(count($curriculum)-1)])){
        if(get_post_type($curriculum[(count($curriculum)-1)]) == 'quiz'){
            $questions = vibe_sanitize(get_post_meta($curriculum[(count($curriculum)-1)],'quiz_questions'.$user_id,false));
            if(!isset($questions) || !is_array($questions))
            $questions = vibe_sanitize(get_post_meta($c,'vibe_quiz_questions',false));
            $total_marks = array_sum($questions['marks']);
        }
    }
    return $total_marks;
}

 

Was this article helpful?

Leave A Comment?