How to evaluate marks correct answer and wrong answer on mcq after user’s input in php ??
http://qwizard.in/exam.php?id=2
every time user’s able to see new questions random wise..
“i m already stored correct answer and wrong answer on database..
i m not able to gives points on correct answer on wrong answer..
Do you want to make the radio button checked? Like: when user comes at: http://qwizard.in/exam.php?id=2 and he will be able to see the correct answer? Please confirm. If you want to work like this?
what is other ways i can do it ?? without using radio button..
yes users will be see his/her correct answer and points systems ..
in which other ways i can run play quiz instead of radio button ??
yes users needs to see correct answer and his/her points after each time answering with questions..
For displaying the correct answer to the users, you have to check the IP address and made the if else to display the answers.
sir user will register on it then he will play quiz.. i m able to display the questions.. not able to display correct answer if user’s gives wrong answer.. how i do this ??
2nd query is how i show here points system also ??
Ok, You have to run the Ajax while pressing the next button, which will check answer, if it is correct then count the points and move to next question. If the answer is wrong then, it will check the answer and return with the correct answer from the Ajax call. Hope it will help you.
sir can u give me some demo code or example for this ?? so it will helpful for me .. i m new on coding ..
Ok, I am making a code for you. Please wait.
Firstly, you have to include the
<script src=”https://code.jquery.com/jquery-1.12.0.min.js”></script> before </head>
Then, replace your main content of the page with the below code:
<div id=”content”>
<ul>
<li>
Each year World Red Cross and Red Crescent Day is celebrated on</li>
<input type=’radio’ name=ans class=’er’ value=’1’>June 8<br>
<input type=’radio’ name=ans class=’er’ value=’2’>May 8
</li>
</ul>
<span class=’button’ id=’btnsbmt’>NEXT</span>
<div id=”resultarea” style=”color:#ff0000”></div>
<script type=”text/javascript”>
jQuery(’#btnsbmt’).click(function(){
var getValue = jQuery(’input[name=ans]:checked’).val();
var request = jQuery.ajax({
url: ”ajax.php”,
data: {userAnswer : getValue},
dataType: ”html”,
success: function(data){
jQuery(”#resultarea”).text(data);
}
});
});
</script>
</div>
After that, you have to create a new file ajax.php and place it on the same server. Add the below code in that and enjoy:
<?php
echo $userAnswer = $_REQUEST[’userAnswer’]; //get value from the ajax to validate with the database
/**
Compare the $userAnswer value with the database and do the required thing.
You can return the required values from here.
*/
?>
This is the demo example. You can exapnd using the above example and make the new pages using ajax.