Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Auto trigger finish course when student pass the quiz or used up retake attempts
- This topic has 25 replies, 2 voices, and was last updated 5 years ago by logan.
-
AuthorPosts
-
April 16, 2019 at 10:34 am #204788squallhajimeSpectatorDear 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.April 16, 2019 at 12:50 pm #204830loganMemberHello, 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.April 16, 2019 at 3:55 pm #204867squallhajimeSpectatorok, please advise to set Auto trigger Finish Course once the retake is used up. Thanks.April 17, 2019 at 11:37 am #205018loganMemberHello, 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(); });April 18, 2019 at 2:53 am #205112squallhajimeSpectatorThis reply has been marked as private.April 18, 2019 at 8:30 am #205153loganMemberHello, 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/39961d601deafe23d137383d8b603475April 18, 2019 at 5:22 pm #205249squallhajimeSpectatorThis reply has been marked as private.April 19, 2019 at 11:19 am #205367loganMemberThis reply has been marked as private.April 19, 2019 at 3:35 pm #205402squallhajimeSpectatorHello 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. We need to students able to go back view the units videos, unless they have finished the course.April 19, 2019 at 3:37 pm #205403squallhajimeSpectatorThis reply has been marked as private.April 20, 2019 at 3:15 am #205438squallhajimeSpectatorThis reply has been marked as private.April 20, 2019 at 10:54 am #205497loganMemberHello, Remove the above codes and give me some time to restructure the code. Shared url is not working.https://ufile.io/n3s9bh5fApril 20, 2019 at 3:29 pm #205520squallhajimeSpectatorThis reply has been marked as private.April 20, 2019 at 3:38 pm #205525squallhajimeSpectatorIf 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.April 20, 2019 at 5:03 pm #205536squallhajimeSpectatorThis reply has been marked as private.
-
AuthorPosts
- The topic ‘Auto trigger finish course when student pass the quiz or used up retake attempts’ is closed to new replies.