Jump to content

how to do QUIZ???


~*tie*~

Recommended Posts

Do you already have the database of questions? If so, what are the fields in the database? Ideally each question would have an ID and the answer in the database, along with whatever question text or anything else. If you want to only display a few questions per page, you will need to keep track of which page you are on. Each page will need to be a large form that contains all of the questions and answers, and you can have a hidden form element that keeps track of the page number. When you get the list of questions out of the database, you can use the SQL LIMIT clause to only get the 5, or however many, questions you need for that page.As far as keeping track of the answers goes, it will probably be best to save all of the answers in the session until they finish the quiz, and then save all of the results to the database. That way you don't wind up with unfinished results in the database.How much do you have so far? What do you need help with? Are you also keeping track of the students in the database, do they have user accounts for the quiz, or are they anonymous?

Link to comment
Share on other sites

yup..i do have the database question.there's 7 fields(qID-auto increment,question,optionA,optionB,optionC,optionD,answer).i sort of undrstand what u mean,but since i'm a newbie..i really don know how to do it. any example of coding will be really helpful..so far, i have the question table, student details table, mark table...after they do those question, the mark will be stored in the mark table cause after that if they wanna review their performance they can do so.

Link to comment
Share on other sites

i think i'm done wif the displaying the question.i will be display 5 question each quiz.now the problem is....how to do the comparing?if the answer they choose is right...add score..if not...do nothingthen the score tht scored...add into table 'mark' for tht particular studnt.

Link to comment
Share on other sites

Do you want to save each answer in the database, or just the final scores? It would be easier to save just the score, but if you saved the results for each question then the students could review their answers or you could set up reports on which questions get missed the most. If all you want to do is save the final score, you could set up the table with the scores to have the student id, a date and time, and a score.If you have a MySQL database, you can start with the code on this page as an example. Read the page for info on how it works.http://www.php.net/manual/en/function.mysql-fetch-assoc.phpYou can modify the code on that page to add the limit of 5 per page and the code to read the last answers and update the session with the score. In order to read which answer they chose you need to understand how to process a form in PHP. There is a sticky thread in this forum that talks about how to process forms, and there is a tutorial on the w3schools site that goes over it as well. The only other part is using the session, you can get example code for doing that here:http://www.php.net/manual/en/function.session-start.php

Link to comment
Share on other sites

i had go tru all you expalaination but still got no clue on wht suppose to be donei juz want the final score to be stored in the database n i already have the db wif these fields->studentid,score,date.here is an example i got from intrnet

elseif ($submit) {	$score = 0;	$total = mysql_num_rows($display);		while ($result = mysql_fetch_array($display)) 						{					$answer = $result["answer"];			$q = $result["q"];					if ($$q == $answer) 		{		$score++; 		}		}		echo "<p align=center><b>You scored $score out of $total</b></p>";	echo "<p>";		if   ($score == $total) {	echo "Congratulations! You got every question right!";	}	elseif ($score/$total < 0.34) {	echo "Oh dear. Not the best score, but don't worry, it's only a quiz.";	}	elseif ($score/$total > 0.67) {	echo "Well done! You certainly know your stuff.";	}	else {	echo "Not bad - but there were a few that caught you out!";	}echo "</p>";

there's no session include n so as i still don u/stand bout session thingy..will this cding be reliable? :)

Link to comment
Share on other sites

justsomeguy...thx for all ur help b4 thisi manage to do the quiz and the mark gained will be popup in a small window.now...how do i insert the mark into tht particular student who do the quiz??there will be table called quiz score where the mark shud be inserted here.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...