phptest-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Phptest-users] Help with java and PHP timer for PHPTest


From: TW-2
Subject: Re: [Phptest-users] Help with java and PHP timer for PHPTest
Date: Fri, 17 Jan 2003 08:46:17 -0700

 I got it to work.

Here it is:

./include/ functions.js file ----

function display(){
rtime=etime-ctime;
if (rtime>60)
m=parseInt(rtime/60);
else{
m=0;
}
s=parseInt(rtime-m*60);
if(s<10)
s="0"+s
window.status="Time Remaining :  "+m+":"+s
window.setTimeout("checktime()",1000)
}

function settimes(){
alert("You have 12 minutes")
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
etime=hours*3600+mins*60+secs;
etime+=10;  //You can change this value  according to how much time you wish
to set the timer. Where time is in secs (720 = 12 mins * 60 secs/min). Max
time is 60 mins (3600secs)
checktime();
}

function checktime(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
ctime=hours*3600+mins*60+secs
if(ctime>=etime){
expired();
}
else
display();
}

function expired(){
alert("Time expired");
document.test.submit();

}

---------------------------------------------------------------

Then in test.php you have to make the following adjustments:

find the line:
----
if (isset($submit)) {
        $test->grade($questions);
----

and change to this:

----

if (isset($submit) || isset($test1)) {
        $test->grade($questions);
----

farther down you need to comment out:

echo "<input type=\"submit\"  name=\"submit\"
value=\"{$strings['BUTTON_SUBMIT']}\" />\n";

and add the following in it's place:

echo "<input type=\"hidden\" name=\"test1\" value=\"test1\" />\n";

You will also need to add the onload() function to your own header.inc.php
file for test.php, in my case I made a special header file for only the
test.php file.

I have added custom header files and other stuff for the test but this is
the bulk of what you need. My situation is that I have heavily customized
PHPTest to suit my needs so this may or may not work for you, use at your
own risk! I will help where I can in case I forgot something....


Cheers!

TW


----- Original Message -----
From: "Brandon Tallent" <address@hidden>
To: "general phptest discussion" <address@hidden>
Sent: Friday, January 17, 2003 7:39 AM
Subject: Re: [Phptest-users] Help with java and PHP timer for PHPTest


> I couldn't figure out how to do that either.  That's
> why the timer is broken right now :)
>
> Brandon
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]