Auto trigger finish course when student pass the quiz or used up retake attempts

Home Forums Legacy Support Support queries How-to & Troubleshooting Auto trigger finish course when student pass the quiz or used up retake attempts

Viewing 15 posts - 1 through 15 (of 26 total)
  • Author
    Posts
  • #204788
    squallhajime
    Spectator
    Dear Support, I set to pass the quiz, each student has to score at least 30 marks, and set to receive the certificate, each student has to score at least 80%. Each student has 10 retake attempt for their quiz. How can i set Auto trigger Finish Course when student scored at least 80% (receive certificate), if not it will Auto trigger Finish Course when the student used up all their retake attempts. I saw this but i think some modification needed: https://wplms.io/support/knowledge-base/auto-trigger-finish-course-when-user-passes-quiz/ Please advise. Thanks.
    #204830
    logan
    Member
    Hello, Well that code was based on the quiz marks which we have at that moment . But we do not have course marks at that moment so we could not check whether user has 80% marks or not ,therefore we cannot trigger auto finish course here . But we can check the retakes and can trigger auto finish course . Please tell if you need code to check left retakes and trigger auto finish course.
    #204867
    squallhajime
    Spectator
    ok, please advise to set Auto trigger Finish Course once the retake is used up. Thanks.
    #205018
    logan
    Member
      Hello, Please paste this snippets in your wp-admin > plugins > editor > wplms-customizer plugin > wplms-customizer.php  add_action('wp_footer',function ($quiz_id,$marks,$user_id){     ?>     <script>     function check_quiz_marks(){       var qid = jQuery('.course_timeline ul li.active a').data('unit');       jQuery.ajax({           type: "POST",           url: ajaxurl,           dataType: 'json',           data: { action: 'check_quiz_marks',                    security: $('#hash').val(),                   quiz_id:qid,                 },           cache: false,           success: function (json) {             console.log(json);             if(json && json.status){               var value= parseInt($('.course_progressbar').attr('data-value'));               if(value >= 100){                 $('input[name="submit_course"]').trigger('click');               }else{                    $('input[name="submit_course"]').addClass('hide');               }             }           }       });     }     jQuery(document).ready(function($){       $('.unit_content').on('unit_traverse',function(){         check_quiz_marks();         console.log('unit_content');       });       $('.course_progressbar').on('increment',function(){         check_quiz_marks();         console.log('course_progressbar');       });       console.log('ahava me');         check_quiz_marks();     });     </script>     <?php        },10); add_action('wp_ajax_check_quiz_marks',function (){   $quiz_id= $_POST['quiz_id'];   if ( !isset($_POST['security']) || !wp_verify_nonce($_POST['security'],'security') || !is_numeric($quiz_id)){      _e('Security check Failed. Contact Administrator.','vibe');      die();   }   $user_id  = get_current_user_id();   $course = get_post_meta($quiz_id,'vibe_quiz_course',true);   $retakes=apply_filters('wplms_quiz_retake_count',get_post_meta($quiz_id,'vibe_quiz_retakes',true),$quiz_id,$course,$user_id);              if(function_exists('bp_course_fetch_user_quiz_retake_count') && bp_is_active('activity')){          $retake_count = bp_course_fetch_user_quiz_retake_count($quiz_id,$user_id);     if(!empty($retakes) && $retakes > $retake_count){       $retake_count = $retakes - intval($retake_count);     }else{       $retake_count = 0;     }   }      $retake_count = intval($retake_count);   if(!empty($retake_count )){     echo json_encode(array(         'status' => 0,       ));   }else{     echo json_encode(array(         'status' => 1,       ));   }   die(); });
    #205112
    squallhajime
    Spectator
    This reply has been marked as private.
    #205153
    logan
    Member
    Hello, I have updated the code there was a fatal error while i did copy/paste from local to here. Copy code from here: https://gist.github.com/madhvendras84/39961d601deafe23d137383d8b603475
    #205249
    squallhajime
    Spectator
    This reply has been marked as private.
    #205367
    logan
    Member
    This reply has been marked as private.
    #205402
    squallhajime
    Spectator
    Hello support, Basically, after applying your code, students are not able to go back and watch their unit video after they attempt the quiz. It will keep redirect them to below page, when click on previous unit or click on the units. 2019-04-19-23-50-56 We need to students able to go back view the units videos, unless they have finished the course.
    #205403
    squallhajime
    Spectator
    This reply has been marked as private.
    #205438
    squallhajime
    Spectator
    This reply has been marked as private.
    #205497
    logan
    Member
    Hello, Remove the above codes and give me some time to restructure the code. Shared url is not working.https://ufile.io/n3s9bh5f
    #205520
    squallhajime
    Spectator
    This reply has been marked as private.
    #205525
    squallhajime
    Spectator
    If the above link is still not wrong, please suggest a place where i can upload the file and you can download it! This is wasting alot of time.
    #205536
    squallhajime
    Spectator
    This reply has been marked as private.
Viewing 15 posts - 1 through 15 (of 26 total)
  • The topic ‘Auto trigger finish course when student pass the quiz or used up retake attempts’ is closed to new replies.