Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Problem with hide results code and hide retake quiz button after passing quiz
- This topic has 22 replies, 3 voices, and was last updated 4 years, 6 months ago by logan.
-
AuthorPosts
-
September 27, 2019 at 2:05 pm #228037dianaw84SpectatorLogan 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 muchSeptember 28, 2019 at 11:02 am #228109loganMemberHello, 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.September 28, 2019 at 1:32 pm #228125dianaw84SpectatorThis reply has been marked as private.September 30, 2019 at 7:03 am #228194loganMemberThis reply has been marked as private.September 30, 2019 at 2:57 pm #228268dianaw84SpectatorI'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.October 1, 2019 at 2:35 pm #228425Anshuman SahuKeymasterplease 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);October 1, 2019 at 3:57 pm #228440dianaw84SpectatorHi, 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 youOctober 3, 2019 at 1:48 pm #228675Anshuman SahuKeymasterOkay fixed it at your end . please check .October 3, 2019 at 2:56 pm #228694dianaw84SpectatorThank 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/peer4gOctober 3, 2019 at 2:57 pm #228695dianaw84SpectatorThis reply has been marked as private.October 3, 2019 at 3:02 pm #228697dianaw84SpectatorThis reply has been marked as private.October 4, 2019 at 2:16 pm #228872Anshuman SahuKeymasterOk 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 .October 4, 2019 at 3:36 pm #228891dianaw84SpectatorOk 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 youOctober 7, 2019 at 12:17 pm #229111loganMemberHello, 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.October 11, 2019 at 2:48 pm #229796dianaw84SpectatorYes, I checked it always with user account but the issue reappears. -
AuthorPosts
- The topic ‘Problem with hide results code and hide retake quiz button after passing quiz’ is closed to new replies.