Problem with hide results code and hide retake quiz button after passing quiz

Home Forums Legacy Support Support queries How-to & Troubleshooting Problem with hide results code and hide retake quiz button after passing quiz

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #228037
    dianaw84
    Spectator
    Logan I think you have answer to the wrong topic. You closed the ticket "https://wplms.io/support/forums/topic/dont-show-results-if-test-is-not-passed/" but you answered to the ticket https://wplms.io/support/forums/topic/block-quiz-until-units-are-incompleted/#post-227993 About "Don't show results if test is not passed" you gave me this code, to hide results at all (also for who passed quiz):

    add_filter('wplms_hide_quiz_result_details',function($flag,$quiz_id){

    return 1;

    },10,2);
    2. Add this script in your wp-admin -> wplms -> footer -> google anaylitics script :

    jQuery(document).ready(function(){ jQuery('body').find('.quiz_results_popup').attr('href',(jQuery('.quiz_results_popup').attr('href')+'&force')); jQuery('.unit_content').on('unit_traverse',function(){ jQuery('body').find('.quiz_results_popup').attr('href',(jQuery('.quiz_results_popup').attr('href')+'&force')); }); });

    and it works. But now after adding this code, the code to hide "retake quiz" button if student has passed quiz written in this topic (closed) https://wplms.io/support/forums/topic/disable-test-retake-if-passed/ doesn't work anymore. In a nutshell, I need to hide results at all and to hide retake quiz for who are passed quiz. Could you help me? I don't understand why the code to hide retake quiz button for student that has passed quiz doesn't work anymore. Thank you very much
    #228109
    logan
    Member
    Hello, don't use these codes. you need to use the above code(no. 1) only. second code is something else, that does not have to be applied in your plugin. share the credentials i will share a video that the above code works fine for quiz results.
    #228125
    dianaw84
    Spectator
    This reply has been marked as private.
    #228194
    logan
    Member
    This reply has been marked as private.
    #228268
    dianaw84
    Spectator
    I'm sorry if I made you angry. But maybe I didn't explain myself well: my problem was just not to show the results at all anymore, both for those who passed the test and those who did not pass it. You gave me a code that works; in fact the results are no longer shown, only the scores appear and this is fine. But I asked about 2 weeks ago (when my client had not yet told me he wanted to hide the results for everyone) in this topic https://wplms.io/support/forums/topic/disable-test-retake-if-passed/ how to do to disable test retake if test is passed. Also this code worked. But when I added your code to not show results anymore, the code to disable test retake if test is passed seems to not work anymore, in fact appears again the button, as show in this screenshot, where I've set 3/3 as passing score https://prnt.sc/pcxtf2. I know there have been so many changes of idea, but if it were for me I would have chosen to show the results and that's it, but unfortunately my client decided not to show them anymore and so that's why I had to send so many tickets where I asked for things different. Sorry again for all, I hope you'll understand. it was not my intention to annoy you or make you angry.
    #228425
    Anshuman Sahu
    Keymaster
      please try adding this given code in your wplms-customizer.php file in wplms customizer plugin :     add_filter('bp_course_fetch_user_quiz_retake_count',function ($retake_count,$quiz_id,$user_id){   $passing_score = get_post_meta($quiz_id,'vibe_quiz_passing_score',true);   if(isset($passing_score) && is_numeric($passing_score)){     $user_id = get_current_user_id();     $score = get_post_meta($quiz_id,$user_id,true);     if($score > $passing_score){         return get_post_meta($quiz_id,'vibe_quiz_retakes',true);     }   }   return $retake_count; },10,3);
    #228440
    dianaw84
    Spectator
    Hi, thank you, I added this code to <span style="color: #1d1c1d; font-family: Slack-Lato, appleLogo, sans-serif; font-size: 15px; font-variant-ligatures: common-ligatures;">wplms-customizer.php</span>. It's correct when a user doesn't pass quiz that results are not shown (only score) but if a user pass results are showed and appears "retake quiz". I don't want to show "retake quiz" button if user passed quiz. And hide results for everyone (I want to show only score). I used this code for disable retake quiz, it worked but now no more add_filter('wplms_quiz_retakes_left','wplms_passed_quiz_retakes',10,2); function wplms_passed_quiz_retakes($remaining_retakes,$quiz_id){ $passing_score = get_post_meta($quiz_id,'vibe_quiz_passing_score',true); if(isset($passing_score) && is_numeric($passing_score)){ $user_id = get_current_user_id(); $score = get_post_meta($quiz_id,$user_id,true); if($score > $passing_score){ return 0; } } return $remaining_retakes; } Sorry for all, I don't know what happened... Thank you
    #228675
    Anshuman Sahu
    Keymaster
    Okay fixed it at your end . please check .
    #228694
    dianaw84
    Spectator
    Thank you for your help, I tried on a test course but unfortunately if test is passed and I click on "result button", retake quiz button appears again. Check the screenshot https://prnt.sc/peer4g
    #228695
    dianaw84
    Spectator
    This reply has been marked as private.
    #228697
    dianaw84
    Spectator
    This reply has been marked as private.
    #228872
    Anshuman Sahu
    Keymaster
    Ok spotted the issue . Always set the passing mark 1 value lesser than actual. 

    Example: in a quiz, if you want to set 15 marks as passing marks then you would need to set 14 as passing marks.

    Our problem is changing this logic is that there are many users who have set their passing scores according to the above logic and if we change it then they might need to update all of their quizzes.

      so you need to set passing marks to be 2 instead of 3 .  
    #228891
    dianaw84
    Spectator
    Ok it seems as you say. But it's a problem, because if a student reaches the minimum score to pass the quiz, he will can retake quiz, but I need it not to happen (for example: my quiz have as maximum marks 30, passing marks 18, if a student reaches 18, he passes quiz, but retake quiz button appears anyway). Also setting passing score one mark less doesn't resolve the problem. I need to solve this problem...please help me...thank you  
    #229111
    logan
    Member
    Hello, note that you are not testing this with admin credentials. admin can access this unlimited time. you need to check this with a user account.
    #229796
    dianaw84
    Spectator
    Yes, I checked it always with user account but the issue reappears.
Viewing 15 posts - 1 through 15 (of 23 total)
  • The topic ‘Problem with hide results code and hide retake quiz button after passing quiz’ is closed to new replies.