JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 26th, 2002, 02:15 AM
steven_wong steven_wong is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 9 steven_wong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
javascript timer in php quiz

i have seen many quiz system using javascipt to show user how long they take the quiz.

i just imagine is it possible implement it in php since variable in javascript not in $, just the name, how to pass it to php script like quiz, so after they take quiz page said:

congratulation, it's only takes 1 minute and 23 second .

i have search in manual on how to do that using time(),
$timestart=time();

code ....

$timeend=time();

$used_time=$timestart-$timeend;
$used_time=date('m:s',$used_time);

but by echo $used_time it just give me strange result, even i take long time or shor time only result not far range between 01:23-01:35.

how to track time use by user to complete quiz , is it done by php or javascript ? like http://www.ewebquiz.com/ which is written in asp.

any hint are appreciate

thanks,

Reply With Quote
  #2  
Old August 26th, 2002, 07:42 AM
SilkySmooth's Avatar
SilkySmooth SilkySmooth is offline
Newbie :P
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2001
Location: In the PHP Engine :-)
Posts: 2,880 SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 32 m 23 sec
Reputation Power: 15
Hi,

The code you have found should work, the problem is how you implement that code into your system, simply putting it all into one page will not work because PHP is server side, so the page is called, the code is processed and the results sent back to the browser, try implementing it in the following way:

PHP Code:
 $timestart=time(); 


Now get the user to fill out the quiz etc and send the results to a second page, include in the form a hidden value like so

PHP Code:
<INPUT TYPE="HIDDEN" NAME="timestart" VALUE="<?echo $timestart;?>"


Then in the page that checks the data of the quiz put the following code:

PHP Code:
 $timeend=time();

$used_time=$timestart-$timeend;
$used_time=date('m:s',$used_time); 


That should give you a more accurate reading.

HTH
__________________
---------------------
-- SilkySmooth --
---------------------
Proxy | Little Directory

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > javascript timer in php quiz


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT