Can I get a simple php code to measure how many words per minute someone can type?

Reply

Join Date: Mar 2009
Posts: 3
Reputation: qinazaza is an unknown quantity at this point 
Solved Threads: 0
qinazaza qinazaza is offline Offline
Newbie Poster

Can I get a simple php code to measure how many words per minute someone can type?

 
0
  #1
Mar 20th, 2009
I just need a basic php code so that I can edit it. Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Can I get a simple php code to measure how many words per minute someone can type?

 
0
  #2
Mar 20th, 2009
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,821
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 117
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

Re: Can I get a simple php code to measure how many words per minute someone can type?

 
0
  #3
Mar 20th, 2009
Yes you can get , I guess next question would be how to make it work ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,444
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 135
cwarn23's Avatar
cwarn23 cwarn23 is online now Online
Nearly a Posting Virtuoso

Re: Can I get a simple php code to measure how many words per minute someone can type?

 
0
  #4
Mar 20th, 2009
Although it is possible, you will find that the typing speed php calculates will be slower than the real typing speed due to page loading and submitting time. For this reason you should deduct about 1 second from the overall time if the page has no graphics.
As for how to make it work, I would suggest placing in a hidden field the time the page was loaded then when the page is submitted, that time that was recorded can be compared to the current time to work out how long it took. Then do number of characters they typed devided by 3. Then do time it took devided by the previous result (the devide by 3 result). Then do 1 devided by the result. Really simple stuff but as I mentioned, an online typing test will not be 100% accurate due to page loading time and the time for submitting the results. Also note that when timing typing speed, one word normally = 3 characters.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 509
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Can I get a simple php code to measure how many words per minute someone can type?

 
0
  #5
Mar 20th, 2009
Originally Posted by qinazaza View Post
I just need a basic php code so that I can edit it. Thanks.
If it's simple, why can't you write it? And if you can't write it, what makes you think you can edit it?
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,444
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 135
cwarn23's Avatar
cwarn23 cwarn23 is online now Online
Nearly a Posting Virtuoso

Re: Can I get a simple php code to measure how many words per minute someone can type?

 
0
  #6
Mar 21st, 2009
Originally Posted by Ezzaral View Post
If it's simple, why can't you write it? And if you can't write it, what makes you think you can edit it?
Well if you would like an example the following is a script which will do the job.
  1. <?
  2. error_reporting(E_ALL ^ E_NOTICE);
  3. $time=date('G-i-s-u'); //nj
  4. echo 'You may test yourself by typing in the below field and clicking submit. Timer immediately after the page loads.<br>';
  5. if (isset($_POST['typetext'])) {
  6. $time_end=explode('-',$time);
  7. $time_start=explode('-',$_POST['timestart']);
  8. $time_start[0]=bcmul($time_start[0],'3600000000');
  9. $time_start[1]=bcmul($time_start[1],'60000000');
  10. $time_start[2]=$time_start[2]*1000000;
  11. $start_time=bcadd(bcadd($time_start[0],$time_start[1]),bcadd($time_start[2],$time_start[3]));
  12. $time_end[0]=bcmul($time_end[0],'3600000000');
  13. $time_end[1]=bcmul($time_end[1],'60000000');
  14. $time_end[2]=$time_end[2]*1000000;
  15. $end_time=bcadd(bcadd($time_end[0],$time_end[1]),bcadd($time_end[2],$time_end[3]));
  16. $totaltime=bcsub($end_time,$start_time);
  17.  
  18. //above calculates the total time with great accuracy
  19. $totaltime=bcdiv($totaltime,1000000);
  20. if ($_SERVER['SERVER_NAME']!=='localhost') { $totaltime-=1000000; }
  21. if (strlen($_POST['typetext'])) {
  22. $chars=strlen($_POST['typetext']);
  23. $chars/=3;
  24. $subtime=60/$totaltime;
  25. $result=$totaltime/$chars;
  26. $result=$subtime/$result;
  27. }
  28. echo 'Your typing speed is: '.round($result,2).' words per minute.<br>';
  29. } else { unset($time); }
  30. ?>
  31. <form method='post' style='margin:0px; padding:0px;'>
  32. <input type='hidden' value='<? echo date('G-i-s-u'); ?>' name='timestart'>
  33. <textarea name='typetext' style='width:50%; height:75px;'></textarea>
  34. <input type='submit' value='submit'>
  35. </form><br>
  36. Note that the more you type the more accurate the test will be.
Also with the above script, the more you type the more accurate the test will be and you can type anything into the text box for the test.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 524
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: Can I get a simple php code to measure how many words per minute someone can type?

 
0
  #7
Mar 22nd, 2009
PHP would not be the best way to do this, not only due to the fact that page load times need to be taken into consideration (as already mentioned) but also because alot of the typing speed tests also take into account accuracy of the words typed. The code by cwarn23 above will count how many characters/words have been typed into a textbox and how long it took (roughly) but this would not stop you typing gibberish or 'a a a a a a a '....etc into the box.

You would really need something client-side (JavaScript maybe if it must be a web app) and a preset paragraph(s) to be typed. The script would then need to analyze the text as it is typed to make sure the words are input correctly, and if they are not then to make this count against the user. While this could be done in PHP, it is not going to be the simplest or easiest solution.

This is not a matter of 'basic code'.
Last edited by Will Gresham; Mar 22nd, 2009 at 1:38 am.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC