Jump to content
xisto Community
doctor

How To Create An Online Timed Test With PHP? Can we do a online test with a counter(from 20 second) php for a php-n

Recommended Posts

Is there anyone got a online timed test script?Or anyone knows how to create this script?I wait your answers and all php programmers.

Hi, interesting script you propose, i saw sometime ago something like that, but i dont remember if it was in php, i think it not be difficult to develop, so i will do it in my spare time in a few hours.

Best regards,
Edited by TavoxPeru (see edit history)

Share this post


Link to post
Share on other sites

You can do it with php and if you want you also could add an javascript real time, so you want to know how it works ? Well, one way is to make it with sessions, say you have 10 pages of questions.. so you start a sessions and set the start time when the user clicks start and always check the value and set the finish time and get the period of the time. Simple maths :D Also, you save the answers in the super global $_SERVER; and check them after the test is done or whatever. There might be different ways to do it, saving to a database or files as temporary data.. I would use sessions, but if the user does not have cookies enabled - he might have some problems.. :P

Share this post


Link to post
Share on other sites

You can do it with php and if you want you also could add an javascript real time, so you want to know how it works ? Well, one way is to make it with sessions, say you have 10 pages of questions.. so you start a sessions and set the start time when the user clicks start and always check the value and set the finish time and get the period of the time. Simple maths :D Also, you save the answers in the super global $_SERVER; and check them after the test is done or whatever. There might be different ways to do it, saving to a database or files as temporary data.. I would use sessions, but if the user does not have cookies enabled - he might have some problems.. :P

As I mentioned in database part is there anyone got this script?Is there anyone possible to write this script?
I want to explain my problem again.I made a php-nuke website.I have so many users.My users wanted a online timed(counts from 20 seconds)test(multiple choices).(like who wants to be a millionaire).I made the login and register system.But I have problems in test page stage.Users will be send questions to our database.And admin will control these questions.He will save it to our database or delete it from our database.And users will be race in a day only five times.And also they must be answer the questions in 20 seconds.There will be shown a counter in the question page that counts from 20 second.Also unregistered users can not be reach the test page by anyway.Or if they try this the page must be redirect him to register page.Only registered users can answer these questions.I think it will be possible by Session_start() and session_register and session_destroy codes or by setcookie.I have little time to this because of my university education.But I think you will help me.I search all internet pages but I couldn't find any useful scripts about this online timed test.But I will have more time in the summer holiday.Is it impossible?I think impossible is nothing!Can we put time script by javascript?But how can we connect it with our database?I mean that out of time there will be a page shown that echo like this "Sorry you answered false.Please restart our test...." or answered in 20 seconds "Congratulations.Please click to next question".
Also istatistics of other users must be shown in the page.Also after all true answers the users score must be increase.And after all wrongs the score must be decrease.(I did all of this with Delphi but i can not put it on my website.)
So,I wait your ideas or helps or scripts.
Regards;

Share this post


Link to post
Share on other sites

Hi, i just start this project in my spare time i have today, you can see it Here thanks to Xisto.com.

It is not finished yet, but for a start is ok. First of all, you must register to access the trivia script, so, when you click in the above link you access the registration process, complete the form and if the data is ok the script will send you your access data to the email you give. This email includes an activation link that you must click to activate your account and after that you can login, if you dont do it you cannot access the trivia script.

The trivia script will present user-defined trivia questions along with choices and determine whether or not the visitor entered the correct answer. Features randomized question and choice order along with 100% templates. All the question, choices and answers are stored in a simple text file.

So, as you can see, this is not the best solution, in the next version i will use a database to store the questions, choices and answers as other information, and also implement the 20 seconds counter.

Best regards,

Share this post


Link to post
Share on other sites

Well, my new version is partially finished, i just implement the database because i have a qUestion related with the time counter, tell me, the 20 seconds counter must be for all questions or for each question????best regards,

Share this post


Link to post
Share on other sites

Well, my new version is partially finished, i just implement the database because i have a qUestion related with the time counter, tell me, the 20 seconds counter must be for all questions or for each question????
best regards,

the 20 seconds counter must be for each questions!

Share this post


Link to post
Share on other sites

the 20 seconds counter must be for each questions!

Ok, and a test how many question should include???? to be practical i will include only 5 questions for test, and because it will be a test, i will not do any type of validation.

best regards,

Share this post


Link to post
Share on other sites

Ok, and a test how many question should include???? to be practical i will include only 5 questions for test, and because it will be a test, i will not do any type of validation.
best regards,

How can I get the script from you?
I did what you said but ı can't get.
Regards.

Share this post


Link to post
Share on other sites

How can I get the script from you? I did what you said but ı can't get.
Regards.

Yes, sorry for that, right now i'm very busy with a lot of work and in a few hours i will try to upload a new version with some changes. Well, i just upload the new version, it works but i have some trouble with date's checking, also im not finished yet the 20s time counter, i think im in the correct way.

When i finish i will post all the code.

best regards,
Edited by TavoxPeru (see edit history)

Share this post


Link to post
Share on other sites

Yes, sorry for that, right now i'm very busy with a lot of work and in a few hours i will try to upload a new version with some changes. Well, i just upload the new version, it works but i have some trouble with date's checking, also im not finished yet the 20s time counter, i think im in the correct way.
When i finish i will post all the code.

best regards,

Thank u very much for your interestings about my question.

Share this post


Link to post
Share on other sites

Thank u very much for your interestings about my question.

You're welcome, BTW after a few days without coding -too much work :-)- i just correct the trouble with the dates checking and will continue with the rest of the problem. So, i hope that i will finish it this weekend.

best regards,

Share this post


Link to post
Share on other sites

Well, after some days i return to this script -i'm very busy with a lot of work- so, i just upload the new version, it works but i have some trouble with the 20s time counter, the problem is that the form.submit() function doesnt work when the time is over.

Here's the problematic code:

$formoutput = "<form name=\"form\" method=\"POST\" action=\"".$_SERVER["PHP_SELF"]."\"><input type=\"hidden\" name=\"question\" value=\"" . $TheQuestion . "\">";$formoutput .= "Time Left: <input type=\"text\" name=\"seconds\" size=\"3\"><br /><br />\n" ."<script type=\"text/javascript\">\n" ."var myTime = 20;\n" ."function countDown() { \n" ."\tdocument.form.seconds.value = myTime; \n" ."\tif (myTime == 0) { \n" ."\t\t// http://forums.xisto.com/no_longer_exists/; ."\t\t//clearTimeout(timer1);\n" ."\t\t//document.form.submit()\n" ."\t\tlocation.href ='" . $_SERVER["PHP_SELF"]. "';\n" ."\t}\n" . "\telse if (myTime > 0) { \n" ."\t\tmyTime--; \n" ."\t\tsetTimeout(\"countDown()\",1000); \n" ."\t}\n" ."}\n\n" ."countDown();\n" ."</script>"; $formoutput .= $choiceoutput;$formoutput .= "<br><input type=\"submit\" value=\"Answer\" name=\"submit\"></form>";

Best regards,

Share this post


Link to post
Share on other sites

I saw this question in the PHP section and though the first answer should be no you can not use PHP to create a timed event for such a script. PHP is server side and only reacts when the server is accessed. The browser (client side is always open) so the only way to write a time dependant script would be with JavaScript. So technically you can not create a PHP script for something like a clock or a counter that counts down. That would be best achieved by using JaavaScript or JScript. Of course you can user PHP to manage the database or flat file to store questions and things like that but using PHP alone will not do the job.

Share this post


Link to post
Share on other sites

So your trivia questionsmust be answered within 20 sec.At page YY:Ask question + register start time-Make sure a JS refreshes after 20 sec to page XX.-And make sure answers are posted to page XX.Page XX checks for an correct answer AND checks if the registered start time in php is within the 20 sec (JS can be easily disabled and needs double checking)

Edited by MS2 (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.