|
-
Mar 31st, 2009, 02:41 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Time start, time end ....
Okay this is probably more complex than it needs to be.
I need to take the time someone starts a test and the time the person finishes a test. I then need to subtract time start from time end and arrive at a weighting to subtract from the overall test score.
For example
20 questions each worth 200 points, minus time in seconds weighting.
Really have no idea on this one
-
Mar 31st, 2009, 03:51 PM
#2
Re: Time start, time end ....
you could use sessions. the only problem is, if the user doesn't do anything (load a new page) for 20 minutes (by default), the session will expire. so, if that happens, you could tell them the text expired. if you can make sure that not every question is on one page, then you could do it fine.
this could be the page you have the first question on (meaning the page the test starts).
PHP Code:
<?php //this needs to be at the beginning of every page that will use a session (every page of the test) session_start(); if(!isset($_SESSION['start_test'])) $_SESSION['start_test'] = time(); ?> <h1>question 1</h1> how big is a refrigerator? <br /> .....
then, when they're on the 20th question, you can make them click a finishing button which would bring them to this page:
PHP Code:
<?php //every page! session_start(); $_SESSION['end_time'] = time(); $time_taken = $_SESSION['end_time'] - $_SESSION['start_time']; ?> <h1>you took <?php echo round($time_taken / 60); ?> minutes.</h1>
you can then weight the answers however you like.
you can also use sessions to store the user's answers to every question (assuming your test will span multiple pages), and then check them all at the end instead of per page. and, if an answer isn't set for a page, you could redirect. for example, if the user tries to load question 5 but doesn't have a start time defined (meaning he didn't start the test) or doesn't have the answer to question 4 defined (didn't answer question 4), then you could redirect to question 4 (if the start time is defined, that is), or to the beginning of the test.
hope that makes sense. ask questions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|